From cd59f9759566d202dccc8ec1a499c999a13865ab Mon Sep 17 00:00:00 2001 From: David Fridrich <49119790+gauron99@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:03:17 +0100 Subject: [PATCH] Remove gauron image references in code (#2647) * remove gauron image references Signed-off-by: David Fridrich * remove image Signed-off-by: David Fridrich * remove gauron username Signed-off-by: David Fridrich --------- Signed-off-by: David Fridrich --- cmd/deploy_test.go | 2 +- pkg/docker/runner_int_test.go | 89 ----------------------------------- 2 files changed, 1 insertion(+), 90 deletions(-) diff --git a/cmd/deploy_test.go b/cmd/deploy_test.go index 0e40175df..a78128cc4 100644 --- a/cmd/deploy_test.go +++ b/cmd/deploy_test.go @@ -842,7 +842,7 @@ func TestDeploy_ImageWithDigestErrors(t *testing.T) { func TestDeploy_ImageWithDigestDoesntPopulateBuild(t *testing.T) { root := FromTempDirectory(t) // image with digest (well almost, atleast in length and syntax) - const img = "docker.io/4141gauron3268@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + const img = "example.com/username@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" // Create a new Function in the temp directory _, err := fn.New().Init(fn.Function{Runtime: "go", Root: root}) if err != nil { diff --git a/pkg/docker/runner_int_test.go b/pkg/docker/runner_int_test.go index 2c9ac07b4..2132e0b82 100644 --- a/pkg/docker/runner_int_test.go +++ b/pkg/docker/runner_int_test.go @@ -24,9 +24,6 @@ import ( const displayEventImg = "gcr.io/knative-releases/knative.dev/eventing/cmd/event_display@sha256:610234e4319b767b187398085971d881956da660a4e0fab65a763e0f81881d82" -// public image from repo (author: github.com/gauron99) -const testImageWithDigest = "index.docker.io/4141gauron3268/teste-builder@sha256:4cf9eddf34f14cc274364a4ae60274301385d470de1fb91cbc6fec1227daa739" - func TestRun(t *testing.T) { root, cleanup := Mktemp(t) defer cleanup() @@ -101,92 +98,6 @@ func TestRun(t *testing.T) { } } -// TestRunDigested ensures that passing a digested image to the runner will deploy -// that image instead of the previously built one. This test is depended on the -// specific image since its verifying the function's output. -func TestRunDigested(t *testing.T) { - root, cleanup := Mktemp(t) - defer cleanup() - - ctx, cancel := context.WithTimeout(context.Background(), time.Minute*10) - t.Cleanup(cancel) - - // TODO: gauron99 - if image-digest-on-build is implemented, rework this - // to fit this schema -- build image (get digest) then run from temporary dir - // such that its .func stamp is not considered. All of this to remove the - // external pre-built container dependency - image := testImageWithDigest - prePullTestImages(t, image) - - f := fn.Function{Runtime: "go", Root: root, Registry: "docker.io/jdoe"} - - client := fn.New() - f, err := client.Init(f) - if err != nil { - t.Fatal(err) - } - - // prebuild default image - f, err = client.Build(ctx, f) - if err != nil { - t.Fatal(err) - } - - // simulate passing image from --image flag since client.Run just sets - // a timeout and simply calls runner.Run. - f.Build.Image = image - - // Run the function using a docker runner - var out, errOut bytes.Buffer - runner := docker.NewRunner(true, &out, &errOut) - j, err := runner.Run(ctx, f, fn.DefaultStartTimeout) - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { _ = j.Stop() }) - time.Sleep(time.Second * 5) - - var ( - id = "runner-my-id" - src = "runner-my-src" - typ = "runner-my-type" - ) - - event := cloudevents.NewEvent() - event.SetID(id) - event.SetSource(src) - event.SetType(typ) - - c, err := cloudevents.NewClientHTTP(cloudevents.WithTarget("http://localhost:" + j.Port)) - if err != nil { - t.Fatal(err) - } - - var httpErr *http.Result - res := c.Send(ctx, event) - if ok := errors.As(res, &httpErr); ok { - if httpErr.StatusCode < 200 || httpErr.StatusCode > 299 { - t.Fatal("non 2XX code") - } - } else { - t.Error("expected http.Result type") - } - time.Sleep(time.Second * 5) - - t.Log("out: ", out.String()) - t.Log("errOut: ", errOut.String()) - - outStr := out.String() - - if !(strings.Contains(outStr, id) && strings.Contains(outStr, src) && strings.Contains(outStr, typ)) { - t.Error("output doesn't contain invocation info") - } - - if !(strings.Contains(outStr, "testing the waters - serverside")) { - t.Error("output doesn't contain expected text") - } -} - func prePullTestImages(t *testing.T, img string) { t.Helper() c, _, err := docker.NewClient(dockerClient.DefaultDockerHost)