Repository: kubeflow/kfp-tekton (language: python)

Issue:
Upgrade tekton version to v0.20.0 for pipeline-loop
**Which issue is resolved by this Pull Request:** 
Resolves #
Upgrade tekton version to v0.20.0 to make consistency with other experiment projects
**Description of your changes:**

**Environment tested:**

* Python Version (use `python --version`):
* Tekton Version (use `tkn version`):
* Kubernetes Version (use `kubectl version`):
* OS (e.g. from `/etc/os-release`):

**Checklist:**
- [ ] The title for your pull request (PR) should follow our title convention. [Learn more about the pull request title convention used in this repository](https://github.com/kubeflow/pipelines/blob/master/CONTRIBUTING.md#pull-request-title-convention). 
<!--
   PR titles examples:
    * `fix(frontend): fixes empty page. Fixes #1234`
       Use `fix` to indicate that this PR fixes a bug.
    * `feat(backend): configurable service account. Fixes #1234, fixes #1235`
       Use `feat` to indicate that this PR adds a new feature. 
    * `chore: set up changelog generation tools`
       Use `chore` to indicate that this PR makes some changes that users don't need to know.
    * `test: fix CI failure. Part of #1234`
        Use `part of` to indicate that a PR is working on an issue, but shouldn't close the issue when merged.
-->
- [ ] Do you want this pull request (PR) cherry-picked into the current release branch?

    [Learn more about cherry-picking updates into the release branch](https://github.com/kubeflow/pipelines/blob/master/RELEASE.md#cherry-picking-pull-requests-to-release-branch).
<!--
    **(Recommended.)** Ask the PR approver to add the `cherrypick-approved` label to this PR. The release manager adds this PR to the release branch in a batch update before release.
-->



Discussion / hints:
Thanks @peng, for the PR.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubeflow/kfp-tekton/pull/502#issuecomment-800706817" title="Approved">fenglixa</a>*, *<a href="https://github.com/kubeflow/kfp-tekton/pull/502#" title="Author self-approved">vincent-pli</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubeflow%2Fkfp-tekton).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubeflow/kfp-tekton/blob/master/OWNERS)~~ [fenglixa]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Fix patch:
diff --git a/tekton-catalog/pipeline-loops/go.mod b/tekton-catalog/pipeline-loops/go.mod
index 8168ab6471..14ae692def 100644
--- a/tekton-catalog/pipeline-loops/go.mod
+++ b/tekton-catalog/pipeline-loops/go.mod
@@ -3,19 +3,15 @@ module github.com/kubeflow/kfp-tekton/tekton-catalog/pipeline-loops
 go 1.13
 
 require (
-	github.com/docker/cli v0.0.0-20200303162255-7d407207c304 // indirect
 	github.com/google/go-cmp v0.5.4
 	github.com/hashicorp/go-multierror v1.1.0
 	github.com/tektoncd/pipeline v0.20.0
-	go.opencensus.io v0.22.5
 	go.uber.org/zap v1.16.0
 	gomodules.xyz/jsonpatch/v2 v2.1.0
-	gotest.tools/v3 v3.0.2 // indirect
 	k8s.io/api v0.18.12
 	k8s.io/apimachinery v0.19.0
 	k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
 	knative.dev/pkg v0.0.0-20210107022335-51c72e24c179
-	knative.dev/test-infra v0.0.0-20200921012245-37f1a12adbd3 // indirect
 )
 
 // Knative deps


Test patch:
diff --git a/tekton-catalog/pipeline-loops/pkg/reconciler/pipelinelooprun/pipelinelooprun_test.go b/tekton-catalog/pipeline-loops/pkg/reconciler/pipelinelooprun/pipelinelooprun_test.go
index 9be3f9260f..bdc5c7c1cf 100644
--- a/tekton-catalog/pipeline-loops/pkg/reconciler/pipelinelooprun/pipelinelooprun_test.go
+++ b/tekton-catalog/pipeline-loops/pkg/reconciler/pipelinelooprun/pipelinelooprun_test.go
@@ -42,7 +42,7 @@ import (
 	ktesting "k8s.io/client-go/testing"
 	"k8s.io/client-go/tools/record"
 	"knative.dev/pkg/apis"
-	"knative.dev/pkg/configmap"
+	"knative.dev/pkg/configmap/informer"
 	"knative.dev/pkg/controller"
 	"knative.dev/pkg/logging"
 	"knative.dev/pkg/reconciler"
@@ -70,12 +70,6 @@ func requestCancel(run *v1alpha1.Run) *v1alpha1.Run {
 	return runWithCancelStatus
 }
 
-func allowRetry(tl *pipelineloopv1alpha1.PipelineLoop) *pipelineloopv1alpha1.PipelineLoop {
-	pipelineLoopWithRetries := tl.DeepCopy()
-	pipelineLoopWithRetries.Spec.Retries = 1
-	return pipelineLoopWithRetries
-}
-
 func running(tr *v1beta1.PipelineRun) *v1beta1.PipelineRun {
 	trWithStatus := tr.DeepCopy()
 	trWithStatus.Status.SetCondition(&apis.Condition{
@@ -138,7 +132,7 @@ func getPipelineLoopController(t *testing.T, d test.Data, pipelineloops []*pipel
 		}
 	}
 
-	configMapWatcher := configmap.NewInformedWatcher(c.Kube, system.GetNamespace())
+	configMapWatcher := informer.NewInformedWatcher(c.Kube, system.GetNamespace())
 	ctl := NewController(namespace)(ctx, configMapWatcher)
 
 	if la, ok := ctl.Reconciler.(reconciler.LeaderAware); ok {
@@ -1054,7 +1048,7 @@ func TestReconcilePipelineLoopRunFailures(t *testing.T) {
 		reason:       pipelineloopv1alpha1.PipelineLoopRunReasonFailedValidation,
 		wantEvents: []string{
 			"Normal Started ",
-			`Warning Failed Cannot determine number of iterations: The value of the iterate parameter "current-item" is not an array`,
+			`Warning Failed Cannot determine number of iterations: The value of the iterate parameter "current-item" can not transfer to array`,
 		},
 	}}
 
diff --git a/tekton-catalog/pipeline-loops/test/build_logs.go b/tekton-catalog/pipeline-loops/test/build_logs.go
deleted file mode 100644
index e2db2d4b9b..0000000000
--- a/tekton-catalog/pipeline-loops/test/build_logs.go
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
-Copyright 2019 The Knative 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"
-	"io/ioutil"
-	"strings"
-
-	corev1 "k8s.io/api/core/v1"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/client-go/kubernetes"
-	"knative.dev/pkg/test/logging"
-)
-
-// CollectPodLogs will get the logs for all containers in a Pod
-func CollectPodLogs(ctx context.Context, c *clients, podName, namespace string, logf logging.FormatLogger) {
-	logs, err := getContainersLogsFromPod(ctx, c.KubeClient.Kube, podName, namespace)
-	if err != nil {
-		logf("Could not get logs for pod %s: %s", podName, err)
-	}
-	logf("build logs %s", logs)
-}
-
-func getContainersLogsFromPod(ctx context.Context, c kubernetes.Interface, pod, namespace string) (string, error) {
-	p, err := c.CoreV1().Pods(namespace).Get(ctx, pod, metav1.GetOptions{})
-	if err != nil {
-		return "", err
-	}
-
-	sb := strings.Builder{}
-	for _, container := range p.Spec.Containers {
-		sb.WriteString(fmt.Sprintf("\n>>> Container %s:\n", container.Name))
-		logs, err := getContainerLogsFromPod(ctx, c, pod, container.Name, namespace)
-		if err != nil {
-			return "", err
-		}
-		sb.WriteString(logs)
-	}
-	return sb.String(), nil
-}
-
-func getContainerLogsFromPod(ctx context.Context, c kubernetes.Interface, pod, container, namespace string) (string, error) {
-	sb := strings.Builder{}
-	// Do not follow, which will block until the Pod terminates, and potentially deadlock the test.
-	// If done in the wrong order, this could actually block things and prevent the Pod from being
-	// deleted at all.
-	req := c.CoreV1().Pods(namespace).GetLogs(pod, &corev1.PodLogOptions{Follow: false, Container: container})
-	rc, err := req.Stream(ctx)
-	if err != nil {
-		return "", err
-	}
-	bs, err := ioutil.ReadAll(rc)
-	if err != nil {
-		return "", err
-	}
-	sb.Write(bs)
-	return sb.String(), nil
-}
diff --git a/tekton-catalog/pipeline-loops/test/clients.go b/tekton-catalog/pipeline-loops/test/clients.go
deleted file mode 100644
index 6ba546b856..0000000000
--- a/tekton-catalog/pipeline-loops/test/clients.go
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
-Copyright 2019 The Knative 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.
-*/
-
-/*
-Get access to client objects
-
-To initialize client objects you can use the setup function. It returns a clients struct
-that contains initialized clients for accessing:
-
-	- Kubernetes objects
-	- Pipelines (https://github.com/tektoncd/pipeline#pipeline)
-
-For example, to create a Pipeline
-
-	_, err = clients.PipelineClient.Pipelines.Create(test.Pipeline(namespaceName, pipelineName))
-
-And you can use the client to clean up resources created by your test
-
-	func tearDown(clients *test.Clients) {
-	    if clients != nil {
-	        clients.Delete([]string{routeName}, []string{configName})
-	    }
-	}
-
-*/
-package test
-
-import (
-	"testing"
-
-	"github.com/tektoncd/pipeline/pkg/client/clientset/versioned"
-	"github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1alpha1"
-	"github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1"
-	resourceversioned "github.com/tektoncd/pipeline/pkg/client/resource/clientset/versioned"
-	resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/client/resource/clientset/versioned/typed/resource/v1alpha1"
-	knativetest "knative.dev/pkg/test"
-)
-
-// clients holds instances of interfaces for making requests to the Pipeline controllers.
-type clients struct {
-	KubeClient *knativetest.KubeClient
-
-	PipelineClient         v1beta1.PipelineInterface
-	ClusterTaskClient      v1beta1.ClusterTaskInterface
-	TaskClient             v1beta1.TaskInterface
-	TaskRunClient          v1beta1.TaskRunInterface
-	PipelineRunClient      v1beta1.PipelineRunInterface
-	PipelineResourceClient resourcev1alpha1.PipelineResourceInterface
-	ConditionClient        v1alpha1.ConditionInterface
-	RunClient              v1alpha1.RunInterface
-}
-
-// newClients instantiates and returns several clientsets required for making requests to the
-// Pipeline cluster specified by the combination of clusterName and configPath. Clients can
-// make requests within namespace.
-func newClients(t *testing.T, configPath, clusterName, namespace string) *clients {
-	t.Helper()
-	var err error
-	c := &clients{}
-
-	c.KubeClient, err = knativetest.NewKubeClient(configPath, clusterName)
-	if err != nil {
-		t.Fatalf("failed to create kubeclient from config file at %s: %s", configPath, err)
-	}
-
-	cfg, err := knativetest.BuildClientConfig(configPath, clusterName)
-	if err != nil {
-		t.Fatalf("failed to create configuration obj from %s for cluster %s: %s", configPath, clusterName, err)
-	}
-
-	cs, err := versioned.NewForConfig(cfg)
-	if err != nil {
-		t.Fatalf("failed to create pipeline clientset from config file at %s: %s", configPath, err)
-	}
-	rcs, err := resourceversioned.NewForConfig(cfg)
-	if err != nil {
-		t.Fatalf("failed to create pipeline clientset from config file at %s: %s", configPath, err)
-	}
-	c.PipelineClient = cs.TektonV1beta1().Pipelines(namespace)
-	c.ClusterTaskClient = cs.TektonV1beta1().ClusterTasks()
-	c.TaskClient = cs.TektonV1beta1().Tasks(namespace)
-	c.TaskRunClient = cs.TektonV1beta1().TaskRuns(namespace)
-	c.PipelineRunClient = cs.TektonV1beta1().PipelineRuns(namespace)
-	c.PipelineResourceClient = rcs.TektonV1alpha1().PipelineResources(namespace)
-	c.ConditionClient = cs.TektonV1alpha1().Conditions(namespace)
-	c.RunClient = cs.TektonV1alpha1().Runs(namespace)
-	return c
-}
diff --git a/tekton-catalog/pipeline-loops/test/e2e-common.sh b/tekton-catalog/pipeline-loops/test/e2e-common.sh
deleted file mode 100755
index 511c4d1d57..0000000000
--- a/tekton-catalog/pipeline-loops/test/e2e-common.sh
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright 2019 The Knative 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.
-
-# Helper functions for E2E tests.
-
-source $(git rev-parse --show-toplevel)/vendor/github.com/tektoncd/plumbing/scripts/e2e-tests.sh
-
-function install_pipeline_crd() {
-  echo ">> Deploying Tekton Pipelines"
-  ko resolve -f config/ \
-      | sed -e 's%"level": "info"%"level": "debug"%' \
-      | sed -e 's%loglevel.controller: "info"%loglevel.controller: "debug"%' \
-      | sed -e 's%loglevel.webhook: "info"%loglevel.webhook: "debug"%' \
-      | kubectl apply -f - || fail_test "Build pipeline installation failed"
-  verify_pipeline_installation
-}
-
-# Install the Tekton pipeline crd based on the release number
-function install_pipeline_crd_version() {
-  echo ">> Deploying Tekton Pipelines of Version $1"
-  kubectl apply -f "https://github.com/tektoncd/pipeline/releases/download/$1/release.yaml" || fail_test "Build pipeline installation failed of Version $1"
-  verify_pipeline_installation
-}
-
-function verify_pipeline_installation() {
-  # Make sure that everything is cleaned up in the current namespace.
-  delete_pipeline_resources
-
-  # Wait for pods to be running in the namespaces we are deploying to
-  wait_until_pods_running tekton-pipelines || fail_test "Tekton Pipeline did not come up"
-}
-
-function uninstall_pipeline_crd() {
-  echo ">> Uninstalling Tekton Pipelines"
-  ko delete --ignore-not-found=true -f config/
-
-  # Make sure that everything is cleaned up in the current namespace.
-  delete_pipeline_resources
-}
-
-function uninstall_pipeline_crd_version() {
-  echo ">> Uninstalling Tekton Pipelines of version $1"
-  kubectl delete --ignore-not-found=true -f "https://github.com/tektoncd/pipeline/releases/download/$1/release.yaml"
-
-  # Make sure that everything is cleaned up in the current namespace.
-  delete_pipeline_resources
-}
-
-function delete_pipeline_resources() {
-  for res in conditions pipelineresources tasks clustertasks pipelines taskruns pipelineruns; do
-    kubectl delete --ignore-not-found=true ${res}.tekton.dev --all
-  done
-}
diff --git a/tekton-catalog/pipeline-loops/test/e2e-taskloops.sh b/tekton-catalog/pipeline-loops/test/e2e-taskloops.sh
deleted file mode 100755
index b61d9caf94..0000000000
--- a/tekton-catalog/pipeline-loops/test/e2e-taskloops.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright 2020 The Knative 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.
-
-# Helper functions for E2E tests.
-
-source $(git rev-parse --show-toplevel)/vendor/github.com/tektoncd/plumbing/scripts/e2e-tests.sh
-
-function install_pipelineloop_crd() {
-  echo ">> Deploying PipelineLoop custom task"
-  ko resolve -f config/ \
-      | sed -e 's%"level": "info"%"level": "debug"%' \
-      | sed -e 's%loglevel.controller: "info"%loglevel.controller: "debug"%' \
-      | sed -e 's%loglevel.webhook: "info"%loglevel.webhook: "debug"%' \
-      | kubectl apply -f - || fail_test "Build pipeline installation failed"
-  verify_pipelineloop_installation
-}
-
-function verify_pipelineloop_installation() {
-  # Make sure that everything is cleaned up in the current namespace.
-  delete_pipelineloop_resources
-
-  # Wait for pods to be running in the namespaces we are deploying to
-  wait_until_pods_running tekton-pipelines || fail_test "PipelineLoop controller or webhook did not come up"
-}
-
-function uninstall_pipelineloop_crd() {
-  echo ">> Uninstalling PipelineLoop custom task"
-  ko delete --ignore-not-found=true -f ${REPO_ROOT_DIR}/task-loops/config/
-
-  # Make sure that everything is cleaned up in the current namespace.
-  delete_pipelineloop_resources
-}
-
-function delete_pipelineloop_resources() {
-  # TODO: Runs should be cleaned up by e2e-common script in pipeline
-  for res in run; do
-    kubectl delete --ignore-not-found=true ${res}.tekton.dev --all
-  done
-  for res in pipelineloop; do
-    kubectl delete --ignore-not-found=true ${res}.custom.tekton.dev --all
-  done
-}
diff --git a/tekton-catalog/pipeline-loops/test/e2e-tests.sh b/tekton-catalog/pipeline-loops/test/e2e-tests.sh
deleted file mode 100755
index 7dc9b2981c..0000000000
--- a/tekton-catalog/pipeline-loops/test/e2e-tests.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright 2020 The Knative 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.
-
-# This script calls out to scripts in tektoncd/plumbing to setup a cluster
-# and deploy Tekton Pipelines to it for running integration tests.
-
-source $(git rev-parse --show-toplevel)/task-loops/test/e2e-common.sh
-source $(git rev-parse --show-toplevel)/task-loops/test/e2e-pipelineloops.sh
-
-# Script entry point.
-
-initialize $@
-
-# initialize function does a CD to REPO_ROOT_DIR so we have to CD back here.
-cd ${REPO_ROOT_DIR}/task-loops
-
-header "Setting up environment"
-
-install_pipeline_crd_version v0.18.0
-
-install_pipelineloop_crd
-
-failed=0
-
-# Run the integration tests
-header "Running Go e2e tests"
-go_test_e2e -timeout=20m ./test/... || failed=1
-
-(( failed )) && fail_test
-success
diff --git a/tekton-catalog/pipeline-loops/test/presubmit-tests.sh b/tekton-catalog/pipeline-loops/test/presubmit-tests.sh
deleted file mode 100755
index f8c07f4bfd..0000000000
--- a/tekton-catalog/pipeline-loops/test/presubmit-tests.sh
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright 2018 The Knative 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.
-
-# This script runs the presubmit tests; it is started by prow for each PR.
-# For convenience, it can also be executed manually.
-# Running the script without parameters, or with the --all-tests
-# flag, causes all tests to be executed, in the right order.
-# Use the flags --build-tests, --unit-tests and --integration-tests
-# to run a specific set of tests.
-
-# Markdown linting failures don't show up properly in Gubernator resulting
-# in a net-negative contributor experience.
-export DISABLE_MD_LINTING=1
-export TEST_FOLDER=$(pwd)
-export GO111MODULE=on
-
-source $(dirname $0)/../../vendor/github.com/tektoncd/plumbing/scripts/presubmit-tests.sh
-
-function pre_build_tests() {
-    pushd ${TEST_FOLDER}
-}
-
-function pre_unit_tests() {
-    pushd ${TEST_FOLDER}
-}
-
-function pre_integration_tests() {
-    pushd ${TEST_FOLDER}
-}
-
-function post_build_tests() {
-    popd
-}
-
-function post_unit_tests() {
-    popd
-}
-
-function post_integration_tests() {
-    popd
-}
-
-# June 28th 2019: work around https://github.com/tektoncd/plumbing/issues/44
-function unit_tests() {
-  local failed=0
-  echo "Using overridden unit_tests"
-  go test -v -race ./... || failed=1
-  echo "unit_tests returning $@"
-  return ${failed}
-}
-
-# We use the default build, unit and integration test runners.
-main $@
diff --git a/tekton-catalog/pipeline-loops/test/wait.go b/tekton-catalog/pipeline-loops/test/wait.go
deleted file mode 100644
index c6b6ddaa68..0000000000
--- a/tekton-catalog/pipeline-loops/test/wait.go
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
-Copyright 2019 The Knative 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.
-*/
-
-/*
-Poll Pipeline resources
-
-After creating Pipeline resources or making changes to them, you will need to
-wait for the system to realize those changes. You can use polling methods to
-check the resources reach the desired state.
-
-The WaitFor* functions use the kubernetes
-wait package (https://godoc.org/k8s.io/apimachinery/pkg/util/wait). To poll
-they use
-PollImmediate (https://godoc.org/k8s.io/apimachinery/pkg/util/wait#PollImmediate)
-and the return values of the function you provide behave the same as
-ConditionFunc (https://godoc.org/k8s.io/apimachinery/pkg/util/wait#ConditionFunc):
-a boolean to indicate if the function should stop or continue polling, and an
-error to indicate if there has been an error.
-
-
-For example, you can poll a TaskRun object to wait for it to have a Status.Condition:
-
-	err = WaitForTaskRunState(c, hwTaskRunName, func(tr *v1alpha1.TaskRun) (bool, error) {
-		if len(tr.Status.Conditions) > 0 {
-			return true, nil
-		}
-		return false, nil
-	}, "TaskRunHasCondition")
-
-*/
-package test
-
-import (
-	"context"
-	"fmt"
-	"strings"
-	"time"
-
-	"go.opencensus.io/trace"
-	appsv1 "k8s.io/api/apps/v1"
-	corev1 "k8s.io/api/core/v1"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/apimachinery/pkg/util/wait"
-	"knative.dev/pkg/apis"
-)
-
-const (
-	interval = 1 * time.Second
-	timeout  = 10 * time.Minute
-)
-
-// ConditionAccessorFn is a condition function used polling functions
-type ConditionAccessorFn func(ca apis.ConditionAccessor) (bool, error)
-
-func pollImmediateWithContext(ctx context.Context, fn func() (bool, error)) error {
-	return wait.PollImmediate(interval, timeout, func() (bool, error) {
-		select {
-		case <-ctx.Done():
-			return true, ctx.Err()
-		default:
-		}
-		return fn()
-	})
-}
-
-// WaitForTaskRunState polls the status of the TaskRun called name from client every
-// interval until inState returns `true` indicating it is done, returns an
-// error or timeout. desc will be used to name the metric that is emitted to
-// track how long it took for name to get into the state checked by inState.
-func WaitForTaskRunState(ctx context.Context, c *clients, name string, inState ConditionAccessorFn, desc string) error {
-	metricName := fmt.Sprintf("WaitForTaskRunState/%s/%s", name, desc)
-	_, span := trace.StartSpan(context.Background(), metricName)
-	defer span.End()
-
-	return pollImmediateWithContext(ctx, func() (bool, error) {
-		r, err := c.TaskRunClient.Get(ctx, name, metav1.GetOptions{})
-		if err != nil {
-			return true, err
-		}
-		return inState(&r.Status)
-	})
-}
-
-// WaitForDeploymentState polls the status of the Deployment called name
-// from client every interval until inState returns `true` indicating it is done,
-// returns an  error or timeout. desc will be used to name the metric that is emitted to
-// track how long it took for name to get into the state checked by inState.
-func WaitForDeploymentState(ctx context.Context, c *clients, name string, namespace string, inState func(d *appsv1.Deployment) (bool, error), desc string) error {
-	metricName := fmt.Sprintf("WaitForDeploymentState/%s/%s", name, desc)
-	_, span := trace.StartSpan(context.Background(), metricName)
-	defer span.End()
-
-	return pollImmediateWithContext(ctx, func() (bool, error) {
-		d, err := c.KubeClient.Kube.AppsV1().Deployments(namespace).Get(ctx, name, metav1.GetOptions{})
-		if err != nil {
-			return true, err
-		}
-		return inState(d)
-	})
-}
-
-// WaitForPodState polls the status of the Pod called name from client every
-// interval until inState returns `true` indicating it is done, returns an
-// error or timeout. desc will be used to name the metric that is emitted to
-// track how long it took for name to get into the state checked by inState.
-func WaitForPodState(ctx context.Context, c *clients, name string, namespace string, inState func(r *corev1.Pod) (bool, error), desc string) error {
-	metricName := fmt.Sprintf("WaitForPodState/%s/%s", name, desc)
-	_, span := trace.StartSpan(context.Background(), metricName)
-	defer span.End()
-
-	return pollImmediateWithContext(ctx, func() (bool, error) {
-		r, err := c.KubeClient.Kube.CoreV1().Pods(namespace).Get(ctx, name, metav1.GetOptions{})
-		if err != nil {
-			return true, err
-		}
-		return inState(r)
-	})
-}
-
-// WaitForPipelineRunState polls the status of the PipelineRun called name from client every
-// interval until inState returns `true` indicating it is done, returns an
-// error or timeout. desc will be used to name the metric that is emitted to
-// track how long it took for name to get into the state checked by inState.
-func WaitForPipelineRunState(ctx context.Context, c *clients, name string, polltimeout time.Duration, inState ConditionAccessorFn, desc string) error {
-	metricName := fmt.Sprintf("WaitForPipelineRunState/%s/%s", name, desc)
-	_, span := trace.StartSpan(context.Background(), metricName)
-	defer span.End()
-
-	ctx, cancel := context.WithTimeout(ctx, polltimeout)
-	defer cancel()
-	return pollImmediateWithContext(ctx, func() (bool, error) {
-		r, err := c.PipelineRunClient.Get(ctx, name, metav1.GetOptions{})
-		if err != nil {
-			return true, err
-		}
-		return inState(&r.Status)
-	})
-}
-
-// WaitForRunState polls the status of the Run called name from client every
-// interval until inState returns `true` indicating it is done, returns an
-// error or timeout. desc will be used to name the metric that is emitted to
-// track how long it took for name to get into the state checked by inState.
-func WaitForRunState(ctx context.Context, c *clients, name string, polltimeout time.Duration, inState ConditionAccessorFn, desc string) error {
-	metricName := fmt.Sprintf("WaitForRunState/%s/%s", name, desc)
-	_, span := trace.StartSpan(context.Background(), metricName)
-	defer span.End()
-
-	ctx, cancel := context.WithTimeout(ctx, polltimeout)
-	defer cancel()
-	return pollImmediateWithContext(ctx, func() (bool, error) {
-		r, err := c.RunClient.Get(ctx, name, metav1.GetOptions{})
-		if err != nil {
-			return true, err
-		}
-		return inState(&r.Status)
-	})
-}
-
-// WaitForServiceExternalIPState polls the status of the a k8s Service called name from client every
-// interval until an external ip is assigned indicating it is done, returns an
-// error or timeout. desc will be used to name the metric that is emitted to
-// track how long it took for name to get into the state checked by inState.
-func WaitForServiceExternalIPState(ctx context.Context, c *clients, namespace, name string, inState func(s *corev1.Service) (bool, error), desc string) error {
-	metricName := fmt.Sprintf("WaitForServiceExternalIPState/%s/%s", name, desc)
-	_, span := trace.StartSpan(context.Background(), metricName)
-	defer span.End()
-
-	return pollImmediateWithContext(ctx, func() (bool, error) {
-		r, err := c.KubeClient.Kube.CoreV1().Services(namespace).Get(ctx, name, metav1.GetOptions{})
-		if err != nil {
-			return true, err
-		}
-		return inState(r)
-	})
-}
-
-// Succeed provides a poll condition function that checks if the ConditionAccessor
-// resource has successfully completed or not.
-func Succeed(name string) ConditionAccessorFn {
-	return func(ca apis.ConditionAccessor) (bool, error) {
-		c := ca.GetCondition(apis.ConditionSucceeded)
-		if c != nil {
-			if c.Status == corev1.ConditionTrue {
-				return true, nil
-			} else if c.Status == corev1.ConditionFalse {
-				return true, fmt.Errorf("%q failed", name)
-			}
-		}
-		return false, nil
-	}
-}
-
-// Failed provides a poll condition function that checks if the ConditionAccessor
-// resource has failed or not.
-func Failed(name string) ConditionAccessorFn {
-	return func(ca apis.ConditionAccessor) (bool, error) {
-		c := ca.GetCondition(apis.ConditionSucceeded)
-		if c != nil {
-			if c.Status == corev1.ConditionTrue {
-				return true, fmt.Errorf("%q succeeded", name)
-			} else if c.Status == corev1.ConditionFalse {
-				return true, nil
-			}
-		}
-		return false, nil
-	}
-}
-
-// FailedWithReason provides a poll function that checks if the ConditionAccessor
-// resource has failed with the TimeoudOut reason
-func FailedWithReason(reason, name string) ConditionAccessorFn {
-	return func(ca apis.ConditionAccessor) (bool, error) {
-		c := ca.GetCondition(apis.ConditionSucceeded)
-		if c != nil {
-			if c.Status == corev1.ConditionFalse {
-				if c.Reason == reason {
-					return true, nil
-				}
-				return true, fmt.Errorf("%q completed with the wrong reason: %s (message: %s)", name, c.Reason, c.Message)
-			} else if c.Status == corev1.ConditionTrue {
-				return true, fmt.Errorf("%q completed successfully, should have been failed with reason %q", name, reason)
-			}
-		}
-		return false, nil
-	}
-}
-
-// FailedWithMessage provides a poll function that checks if the ConditionAccessor
-// resource has failed with the TimeoudOut reason
-func FailedWithMessage(message, name string) ConditionAccessorFn {
-	return func(ca apis.ConditionAccessor) (bool, error) {
-		c := ca.GetCondition(apis.ConditionSucceeded)
-		if c != nil {
-			if c.Status == corev1.ConditionFalse {
-				if strings.Contains(c.Message, message) {
-					return true, nil
-				}
-				return true, fmt.Errorf("%q completed with the wrong message: %s", name, c.Message)
-			} else if c.Status == corev1.ConditionTrue {
-				return true, fmt.Errorf("%q completed successfully, should have been failed with message %q", name, message)
-			}
-		}
-		return false, nil
-	}
-}
-
-// Running provides a poll condition function that checks if the ConditionAccessor
-// resource is currently running.
-func Running(name string) ConditionAccessorFn {
-	return func(ca apis.ConditionAccessor) (bool, error) {
-		c := ca.GetCondition(apis.ConditionSucceeded)
-		if c != nil {
-			if c.Status == corev1.ConditionTrue || c.Status == corev1.ConditionFalse {
-				return true, fmt.Errorf(`%q already finished`, name)
-			} else if c.Status == corev1.ConditionUnknown && (c.Reason == "Running" || c.Reason == "Pending") {
-				return true, nil
-			}
-		}
-		return false, nil
-	}
-}
-
-// TaskRunSucceed provides a poll condition function that checks if the TaskRun
-// has successfully completed.
-func TaskRunSucceed(name string) ConditionAccessorFn {
-	return Succeed(name)
-}
-
-// TaskRunFailed provides a poll condition function that checks if the TaskRun
-// has failed.
-func TaskRunFailed(name string) ConditionAccessorFn {
-	return Failed(name)
-}
-
-// PipelineRunSucceed provides a poll condition function that checks if the PipelineRun
-// has successfully completed.
-func PipelineRunSucceed(name string) ConditionAccessorFn {
-	return Succeed(name)
-}
-
-// PipelineRunFailed provides a poll condition function that checks if the PipelineRun
-// has failed.
-func PipelineRunFailed(name string) ConditionAccessorFn {
-	return Failed(name)
-}