diff --git a/test/helm_task_test.go b/test/helm_task_test.go index 2fcc925228a..1e1c8411a76 100644 --- a/test/helm_task_test.go +++ b/test/helm_task_test.go @@ -41,10 +41,19 @@ var ( // TestHelmDeployPipelineRun is an integration test that will verify a pipeline build an image // and then using helm to deploy it func TestHelmDeployPipelineRun(t *testing.T) { - repo := ensureDockerRepo(t) + ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() + + repo, err := getDockerRepo("helmtasktest") + if err != nil { + // No KO_DOCKER_REPO set, this test cannot run, let's skip it + // We cannot use the sidecar registry (as it is today) because + // the kubelet won't pull images from an insecure registry + t.Skip("KO_DOCKER_REPO env variable is required") + } + c, namespace := setup(ctx, t) setupClusterBindingForHelm(ctx, c, t, namespace) diff --git a/test/kaniko_task_test.go b/test/kaniko_task_test.go index bc17c1a5650..5fe2a37c789 100644 --- a/test/kaniko_task_test.go +++ b/test/kaniko_task_test.go @@ -45,6 +45,11 @@ const ( // TestTaskRun is an integration test that will verify a TaskRun using kaniko func TestKanikoTaskRun(t *testing.T) { + var ( + namespace, repo string + c *clients + ) + ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -53,11 +58,16 @@ func TestKanikoTaskRun(t *testing.T) { t.Skip("Skip test as skipRootUserTests set to true") } - c, namespace := setup(ctx, t, withRegistry) + repo, err := getDockerRepo("kanikotasktest") + if err != nil { + // No KO_DOCKER_REPO set, use a sidecar registry instead + c, namespace = setup(ctx, t, withRegistry) + repo = fmt.Sprintf("registry.%s.svc.cluster.local:5000/kanikotasktest", namespace) + } else { + c, namespace = setup(ctx, t) + } t.Parallel() - repo := fmt.Sprintf("registry.%s:5000/kanikotasktest", namespace) - knativetest.CleanupOnInterrupt(func() { tearDown(ctx, t, c, namespace) }, t.Logf) defer tearDown(ctx, t, c, namespace) @@ -159,7 +169,7 @@ spec: } func getTask(t *testing.T, repo, namespace string) *v1beta1.Task { - return parse.MustParseTask(t, fmt.Sprintf(` + task := parse.MustParseTask(t, fmt.Sprintf(` metadata: name: %s namespace: %s @@ -177,16 +187,14 @@ spec: args: ['--dockerfile=/workspace/gitsource/integration/dockerfiles/Dockerfile_test_label', '--destination=%s', '--context=/workspace/gitsource', - '--oci-layout-path=/workspace/output/builtImage', - '--insecure', - '--insecure-pull', - '--insecure-registry=registry.%s:5000/'] + '--oci-layout-path=/workspace/output/builtImage'] securityContext: runAsUser: 0 sidecars: - name: registry image: %s -`, kanikoTaskName, namespace, getTestImage(kanikoImage), repo, namespace, getTestImage(registryImage))) +`, kanikoTaskName, namespace, getTestImage(kanikoImage), repo, getTestImage(registryImage))) + return task } func getTaskRun(t *testing.T, namespace string) *v1beta1.TaskRun { diff --git a/test/ko_test.go b/test/ko_test.go index 8fd393fd600..bd6315a38f1 100644 --- a/test/ko_test.go +++ b/test/ko_test.go @@ -22,26 +22,9 @@ import ( "errors" "fmt" "os" - "testing" ) -var ( - // Wether missing KO_DOCKER_REPO environment variable should be fatal or not - missingKoFatal = "true" -) - -func ensureDockerRepo(t *testing.T) string { - repo, err := getDockerRepo() - if err != nil { - if missingKoFatal == "false" { - t.Skip("KO_DOCKER_REPO env variable is required") - } - t.Fatal("KO_DOCKER_REPO env variable is required") - } - return repo -} - -func getDockerRepo() (string, error) { +func getDockerRepo(name string) (string, error) { // according to knative/test-infra readme (https://github.com/knative/test-infra/blob/13055d769cc5e1756e605fcb3bcc1c25376699f1/scripts/README.md) // the KO_DOCKER_REPO will be set with according to the project where the cluster is created // it is used here to dynamically get the docker registry to push the image to @@ -49,5 +32,5 @@ func getDockerRepo() (string, error) { if dockerRepo == "" { return "", errors.New("KO_DOCKER_REPO env variable is required") } - return fmt.Sprintf("%s/kanikotasktest", dockerRepo), nil + return fmt.Sprintf("%s/%s", dockerRepo, name), nil }