From 6de3871dc3f017f8ebb2ee43d8c6b26964a3fc4c Mon Sep 17 00:00:00 2001 From: Jerome Ju Date: Thu, 9 Feb 2023 02:51:02 +0000 Subject: [PATCH] wip --- pkg/reconciler/taskrun/taskrun_test.go | 5 -- test/embed_test.go | 115 ------------------------- 2 files changed, 120 deletions(-) delete mode 100644 test/embed_test.go diff --git a/pkg/reconciler/taskrun/taskrun_test.go b/pkg/reconciler/taskrun/taskrun_test.go index ca3f656d6ed..ded6aae533e 100644 --- a/pkg/reconciler/taskrun/taskrun_test.go +++ b/pkg/reconciler/taskrun/taskrun_test.go @@ -70,7 +70,6 @@ import ( "knative.dev/pkg/controller" "knative.dev/pkg/kmeta" "knative.dev/pkg/logging" - "knative.dev/pkg/ptr" pkgreconciler "knative.dev/pkg/reconciler" "knative.dev/pkg/system" @@ -313,10 +312,6 @@ var ( EmptyDir: &corev1.EmptyDirVolumeSource{}, }, } - - gitResourceSecurityContext = &corev1.SecurityContext{ - RunAsUser: ptr.Int64(0), - } ) const fakeVersion string = "unknown" diff --git a/test/embed_test.go b/test/embed_test.go deleted file mode 100644 index 24d9dc8cf44..00000000000 --- a/test/embed_test.go +++ /dev/null @@ -1,115 +0,0 @@ -//go:build e2e -// +build e2e - -/* -Copyright 2019 The Tekton Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package test - -import ( - "context" - "fmt" - "strings" - "testing" - - "github.com/tektoncd/pipeline/test/parse" - - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - knativetest "knative.dev/pkg/test" - "knative.dev/pkg/test/helpers" -) - -const ( - // TODO(#127) Currently not reliable to retrieve this output - taskOutput = "do you want to build a snowman" -) - -// TestTaskRun_EmbeddedResource is an integration test that will verify a very simple "hello world" TaskRun can be -// executed with an embedded resource spec. -func TestTaskRun_EmbeddedResource(t *testing.T) { - ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) - defer cancel() - c, namespace := setup(ctx, t) - t.Parallel() - - knativetest.CleanupOnInterrupt(func() { tearDown(ctx, t, c, namespace) }, t.Logf) - defer tearDown(ctx, t, c, namespace) - - embedTaskName := helpers.ObjectNameForTest(t) - embedTaskRunName := helpers.ObjectNameForTest(t) - - t.Logf("Creating Task and TaskRun in namespace %s", namespace) - if _, err := c.V1beta1TaskClient.Create(ctx, getEmbeddedTask(t, embedTaskName, namespace, []string{"/bin/sh", "-c", fmt.Sprintf("echo %s", taskOutput)}), metav1.CreateOptions{}); err != nil { - t.Fatalf("Failed to create Task `%s`: %s", embedTaskName, err) - } - if _, err := c.V1beta1TaskRunClient.Create(ctx, getEmbeddedTaskRun(t, embedTaskRunName, namespace, embedTaskName), metav1.CreateOptions{}); err != nil { - t.Fatalf("Failed to create TaskRun `%s`: %s", embedTaskRunName, err) - } - - t.Logf("Waiting for TaskRun %s in namespace %s to complete", embedTaskRunName, namespace) - if err := WaitForTaskRunState(ctx, c, embedTaskRunName, TaskRunSucceed(embedTaskRunName), "TaskRunSuccess", v1beta1Version); err != nil { - t.Errorf("Error waiting for TaskRun %s to finish: %s", embedTaskRunName, err) - } - - // TODO(#127) Currently we have no reliable access to logs from the TaskRun so we'll assume successful - // completion of the TaskRun means the TaskRun did what it was intended. -} - -func getEmbeddedTask(t *testing.T, taskName, namespace string, args []string) *v1beta1.Task { - t.Helper() - var argsForYaml []string - for _, s := range args { - argsForYaml = append(argsForYaml, fmt.Sprintf("'%s'", s)) - } - return parse.MustParseV1beta1Task(t, fmt.Sprintf(` -metadata: - name: %s - namespace: %s -spec: - resources: - inputs: - - name: docs - type: git - steps: - - image: ubuntu - command: ['/bin/bash'] - args: ['-c', 'cat /workspace/docs/LICENSE'] - - image: busybox - command: %s -`, taskName, namespace, fmt.Sprintf("[%s]", strings.Join(argsForYaml, ", ")))) -} - -func getEmbeddedTaskRun(t *testing.T, trName, namespace, taskName string) *v1beta1.TaskRun { - t.Helper() - return parse.MustParseV1beta1TaskRun(t, fmt.Sprintf(` -metadata: - name: %s - namespace: %s -spec: - resources: - inputs: - - name: docs - resourceSpec: - type: git - params: - - name: URL - value: https://github.com/knative/docs - taskRef: - name: %s -`, trName, namespace, taskName)) -}