mirror of https://github.com/knative/func.git
Remove gauron image references in code (#2647)
* remove gauron image references Signed-off-by: David Fridrich <fridrich.david19@gmail.com> * remove image Signed-off-by: David Fridrich <fridrich.david19@gmail.com> * remove gauron username Signed-off-by: David Fridrich <fridrich.david19@gmail.com> --------- Signed-off-by: David Fridrich <fridrich.david19@gmail.com>
This commit is contained in:
parent
7bf35e599c
commit
cd59f97595
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue