Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 888bca2

Browse files
committedNov 28, 2022
Add version argument to wait status function
1 parent 0bdfbfb commit 888bca2

36 files changed

+134
-149
lines changed
 

‎test/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ err = WaitForTaskRunState(c, hwTaskRunName, func(tr *v1alpha1.TaskRun) (bool, er
366366
return true, nil
367367
}
368368
return false, nil
369-
}, "TaskRunHasCondition")
369+
}, "TaskRunHasCondition", v1beta1Version)
370370
```
371371
372372
_[Metrics will be emitted](https://github.com/knative/pkg/tree/master/test#emit-metrics)

‎test/artifact_bucket_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ spec:
117117
t.Fatalf("Failed to create TaskRun `%s`: %s", createbuckettaskrun.Name, err)
118118
}
119119

120-
if err := WaitForTaskRunState(ctx, c, createbuckettaskrun.Name, TaskRunSucceed(createbuckettaskrun.Name), "TaskRunSuccess"); err != nil {
120+
if err := WaitForTaskRunState(ctx, c, createbuckettaskrun.Name, TaskRunSucceed(createbuckettaskrun.Name), "TaskRunSuccess", v1beta1Version); err != nil {
121121
t.Errorf("Error waiting for TaskRun %s to finish: %s", createbuckettaskrun.Name, err)
122122
}
123123

@@ -252,7 +252,7 @@ spec:
252252
}
253253

254254
// Verify status of PipelineRun (wait for it)
255-
if err := WaitForPipelineRunState(ctx, c, bucketTestPipelineRunName, timeout, PipelineRunSucceed(bucketTestPipelineRunName), "PipelineRunCompleted"); err != nil {
255+
if err := WaitForPipelineRunState(ctx, c, bucketTestPipelineRunName, timeout, PipelineRunSucceed(bucketTestPipelineRunName), "PipelineRunCompleted", v1beta1Version); err != nil {
256256
t.Errorf("Error waiting for PipelineRun %s to finish: %s", bucketTestPipelineRunName, err)
257257
t.Fatalf("PipelineRun execution failed")
258258
}
@@ -350,7 +350,7 @@ spec:
350350
t.Fatalf("Failed to create TaskRun `%s`: %s", deletelbuckettaskrun.Name, err)
351351
}
352352

353-
if err := WaitForTaskRunState(ctx, c, deletelbuckettaskrun.Name, TaskRunSucceed(deletelbuckettaskrun.Name), "TaskRunSuccess"); err != nil {
353+
if err := WaitForTaskRunState(ctx, c, deletelbuckettaskrun.Name, TaskRunSucceed(deletelbuckettaskrun.Name), "TaskRunSuccess", v1beta1Version); err != nil {
354354
t.Errorf("Error waiting for TaskRun %s to finish: %s", deletelbuckettaskrun.Name, err)
355355
}
356356
}

‎test/cancel_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ spec:
7777
}
7878

7979
t.Logf("Waiting for Pipelinerun %s in namespace %s to be started", pipelineRun.Name, namespace)
80-
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, Running(pipelineRun.Name), "PipelineRunRunning"); err != nil {
80+
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, Running(pipelineRun.Name), "PipelineRunRunning", v1beta1Version); err != nil {
8181
t.Fatalf("Error waiting for PipelineRun %s to be running: %s", pipelineRun.Name, err)
8282
}
8383

@@ -92,7 +92,7 @@ spec:
9292
wg.Add(1)
9393
go func(name string) {
9494
defer wg.Done()
95-
err := WaitForTaskRunState(ctx, c, name, Running(name), "TaskRunRunning")
95+
err := WaitForTaskRunState(ctx, c, name, Running(name), "TaskRunRunning", v1beta1Version)
9696
if err != nil {
9797
t.Errorf("Error waiting for TaskRun %s to be running: %v", name, err)
9898
}
@@ -121,7 +121,7 @@ spec:
121121
expectedReason := v1beta1.PipelineRunReasonCancelled.String()
122122
expectedCondition := FailedWithReason(expectedReason, pipelineRun.Name)
123123
t.Logf("Waiting for PipelineRun %s in namespace %s to be cancelled", pipelineRun.Name, namespace)
124-
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, expectedCondition, expectedReason); err != nil {
124+
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, expectedCondition, expectedReason, v1beta1Version); err != nil {
125125
t.Errorf("Error waiting for PipelineRun %q to finished: %s", pipelineRun.Name, err)
126126
}
127127

@@ -130,7 +130,7 @@ spec:
130130
wg.Add(1)
131131
go func(name string) {
132132
defer wg.Done()
133-
err := WaitForTaskRunState(ctx, c, name, FailedWithReason("TaskRunCancelled", name), "TaskRunCancelled")
133+
err := WaitForTaskRunState(ctx, c, name, FailedWithReason("TaskRunCancelled", name), "TaskRunCancelled", v1beta1Version)
134134
if err != nil {
135135
t.Errorf("Error waiting for TaskRun %s to be finished: %v", name, err)
136136
}

‎test/cluster_resource_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestClusterResource(t *testing.T) {
7878
}
7979

8080
// Verify status of TaskRun (wait for it)
81-
if err := WaitForTaskRunState(ctx, c, taskRunName, TaskRunSucceed(taskRunName), "TaskRunCompleted"); err != nil {
81+
if err := WaitForTaskRunState(ctx, c, taskRunName, TaskRunSucceed(taskRunName), "TaskRunCompleted", v1beta1Version); err != nil {
8282
t.Errorf("Error waiting for TaskRun %s to finish: %s", taskRunName, err)
8383
}
8484
}

‎test/conformance_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ spec:
128128
t.Fatalf("Failed to create TaskRun `%s`: %s", tc.tr.Name, err)
129129
}
130130

131-
if err := WaitForTaskRunState(ctx, c, tc.tr.Name, tc.fn(tc.tr.Name), "WaitTaskRunDone"); err != nil {
131+
if err := WaitForTaskRunState(ctx, c, tc.tr.Name, tc.fn(tc.tr.Name), "WaitTaskRunDone", v1beta1Version); err != nil {
132132
t.Errorf("Error waiting for TaskRun to finish: %s", err)
133133
return
134134
}

‎test/custom_task_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ spec:
129129
}
130130

131131
// Wait for the PipelineRun to start.
132-
if err := WaitForPipelineRunState(ctx, c, pipelineRunName, time.Minute, Running(pipelineRunName), "PipelineRunRunning"); err != nil {
132+
if err := WaitForPipelineRunState(ctx, c, pipelineRunName, time.Minute, Running(pipelineRunName), "PipelineRunRunning", v1beta1Version); err != nil {
133133
t.Fatalf("Waiting for PipelineRun to start running: %v", err)
134134
}
135135

@@ -208,7 +208,7 @@ spec:
208208
}
209209
}
210210
// Wait for the PipelineRun to become done/successful.
211-
if err := WaitForPipelineRunState(ctx, c, pipelineRunName, time.Minute, PipelineRunSucceed(pipelineRunName), "PipelineRunCompleted"); err != nil {
211+
if err := WaitForPipelineRunState(ctx, c, pipelineRunName, time.Minute, PipelineRunSucceed(pipelineRunName), "PipelineRunCompleted", v1beta1Version); err != nil {
212212
t.Fatalf("Waiting for PipelineRun to complete successfully: %v", err)
213213
}
214214

@@ -334,7 +334,7 @@ spec:
334334
}
335335

336336
t.Logf("Waiting for Pipelinerun %s in namespace %s to be started", pipelineRun.Name, namespace)
337-
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, Running(pipelineRun.Name), "PipelineRunRunning"); err != nil {
337+
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, Running(pipelineRun.Name), "PipelineRunRunning", v1beta1Version); err != nil {
338338
t.Fatalf("Error waiting for PipelineRun %s to be running: %s", pipelineRun.Name, err)
339339
}
340340

@@ -388,7 +388,7 @@ spec:
388388
}
389389

390390
t.Logf("Waiting for PipelineRun %s in namespace %s to be timed out", pipelineRun.Name, namespace)
391-
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, FailedWithReason(v1beta1.PipelineRunReasonTimedOut.String(), pipelineRun.Name), "PipelineRunTimedOut"); err != nil {
391+
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, FailedWithReason(v1beta1.PipelineRunReasonTimedOut.String(), pipelineRun.Name), "PipelineRunTimedOut", v1beta1Version); err != nil {
392392
t.Errorf("Error waiting for PipelineRun %s to finish: %s", pipelineRun.Name, err)
393393
}
394394

@@ -793,7 +793,7 @@ func TestWaitCustomTask_PipelineRun(t *testing.T) {
793793
}
794794

795795
// Wait for the PipelineRun to the desired state
796-
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, tc.prConditionAccessorFn(pipelineRun.Name), string(tc.wantPrCondition.Type)); err != nil {
796+
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, tc.prConditionAccessorFn(pipelineRun.Name), string(tc.wantPrCondition.Type), v1beta1Version); err != nil {
797797
t.Fatalf("Error waiting for PipelineRun %q to be running: %s", pipelineRun.Name, err)
798798
}
799799

‎test/dag_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ spec:
207207
t.Fatalf("Failed to create dag-pipeline-run PipelineRun: %s", err)
208208
}
209209
t.Logf("Waiting for DAG pipeline to complete")
210-
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, PipelineRunSucceed(pipelineRun.Name), "PipelineRunSuccess"); err != nil {
210+
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, PipelineRunSucceed(pipelineRun.Name), "PipelineRunSuccess", v1beta1Version); err != nil {
211211
t.Fatalf("Error waiting for PipelineRun to finish: %s", err)
212212
}
213213

‎test/duplicate_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ spec:
7070
go func(t *testing.T) {
7171
defer wg.Done()
7272

73-
if err := WaitForTaskRunState(ctx, c, taskrunName, TaskRunSucceed(taskrunName), "TaskRunDuplicatePodTaskRunFailed"); err != nil {
73+
if err := WaitForTaskRunState(ctx, c, taskrunName, TaskRunSucceed(taskrunName), "TaskRunDuplicatePodTaskRunFailed", v1beta1Version); err != nil {
7474
t.Errorf("Error waiting for TaskRun to finish: %s", err)
7575
return
7676
}

‎test/embed_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestTaskRun_EmbeddedResource(t *testing.T) {
6262
}
6363

6464
t.Logf("Waiting for TaskRun %s in namespace %s to complete", embedTaskRunName, namespace)
65-
if err := WaitForTaskRunState(ctx, c, embedTaskRunName, TaskRunSucceed(embedTaskRunName), "TaskRunSuccess"); err != nil {
65+
if err := WaitForTaskRunState(ctx, c, embedTaskRunName, TaskRunSucceed(embedTaskRunName), "TaskRunSuccess", v1beta1Version); err != nil {
6666
t.Errorf("Error waiting for TaskRun %s to finish: %s", embedTaskRunName, err)
6767
}
6868

‎test/entrypoint_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ spec:
6666
}
6767

6868
t.Logf("Waiting for TaskRun in namespace %s to finish successfully", namespace)
69-
if err := WaitForTaskRunState(ctx, c, epTaskRunName, TaskRunSucceed(epTaskRunName), "TaskRunSuccess"); err != nil {
69+
if err := WaitForTaskRunState(ctx, c, epTaskRunName, TaskRunSucceed(epTaskRunName), "TaskRunSuccess", v1beta1Version); err != nil {
7070
t.Errorf("Error waiting for TaskRun to finish successfully: %s", err)
7171
}
7272

‎test/examples_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,27 @@ func getCreatedTektonCRD(input []byte, kind string) (string, error) {
5151
}
5252

5353
func waitValidatePipelineRunDone(ctx context.Context, t *testing.T, c *clients, pipelineRunName string) {
54-
if err := WaitForPipelineRunState(ctx, c, pipelineRunName, timeout, Succeed(pipelineRunName), pipelineRunName); err != nil {
54+
if err := WaitForPipelineRunState(ctx, c, pipelineRunName, timeout, Succeed(pipelineRunName), pipelineRunName, v1beta1Version); err != nil {
5555
t.Fatalf("Failed waiting for pipeline run done: %v", err)
5656
}
5757
}
5858

5959
func waitValidateV1PipelineRunDone(ctx context.Context, t *testing.T, c *clients, pipelineRunName string) {
60-
if err := WaitForV1PipelineRunState(ctx, c, pipelineRunName, timeout, Succeed(pipelineRunName), pipelineRunName); err != nil {
60+
if err := WaitForPipelineRunState(ctx, c, pipelineRunName, timeout, Succeed(pipelineRunName), pipelineRunName, v1Version); err != nil {
6161
t.Fatalf("Failed waiting for V1 pipeline run done: %v", err)
6262
}
6363
}
6464

6565
func waitValidateTaskRunDone(ctx context.Context, t *testing.T, c *clients, taskRunName string) {
6666
// Per test basis
67-
if err := WaitForTaskRunState(ctx, c, taskRunName, Succeed(taskRunName), taskRunName); err != nil {
67+
if err := WaitForTaskRunState(ctx, c, taskRunName, Succeed(taskRunName), taskRunName, v1beta1Version); err != nil {
6868
t.Fatalf("Failed waiting for task run done: %v", err)
6969
}
7070
}
7171

7272
func waitValidateV1TaskRunDone(ctx context.Context, t *testing.T, c *clients, taskRunName string) {
7373
// Per test basis
74-
if err := WaitForV1TaskRunState(ctx, c, taskRunName, Succeed(taskRunName), taskRunName); err != nil {
74+
if err := WaitForTaskRunState(ctx, c, taskRunName, Succeed(taskRunName), taskRunName, v1Version); err != nil {
7575
t.Fatalf("Failed waiting for V1 task run done: %v", err)
7676
}
7777
}

‎test/git_checkout_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ spec:
155155
t.Fatalf("Failed to create PipelineRun %q: %s", gitTestPipelineRunName, err)
156156
}
157157

158-
if err := WaitForPipelineRunState(ctx, c, gitTestPipelineRunName, timeout, PipelineRunSucceed(gitTestPipelineRunName), "PipelineRunCompleted"); err != nil {
158+
if err := WaitForPipelineRunState(ctx, c, gitTestPipelineRunName, timeout, PipelineRunSucceed(gitTestPipelineRunName), "PipelineRunCompleted", v1beta1Version); err != nil {
159159
t.Errorf("Error waiting for PipelineRun %s to finish: %s", gitTestPipelineRunName, err)
160160
t.Fatalf("PipelineRun execution failed")
161161
}
@@ -238,7 +238,7 @@ spec:
238238
t.Fatalf("Failed to create PipelineRun %q: %s", gitTestPipelineRunName, err)
239239
}
240240

241-
if err := WaitForPipelineRunState(ctx, c, gitTestPipelineRunName, timeout, PipelineRunSucceed(gitTestPipelineRunName), "PipelineRunCompleted"); err != nil {
241+
if err := WaitForPipelineRunState(ctx, c, gitTestPipelineRunName, timeout, PipelineRunSucceed(gitTestPipelineRunName), "PipelineRunCompleted", v1beta1Version); err != nil {
242242
taskruns, err := c.V1beta1TaskRunClient.List(ctx, metav1.ListOptions{})
243243
if err != nil {
244244
t.Errorf("Error getting TaskRun list for PipelineRun %s %s", gitTestPipelineRunName, err)

‎test/helm_task_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestHelmDeployPipelineRun(t *testing.T) {
9898
}
9999

100100
// Verify status of PipelineRun (wait for it)
101-
if err := WaitForPipelineRunState(ctx, c, helmDeployPipelineRunName, timeout, PipelineRunSucceed(helmDeployPipelineRunName), "PipelineRunCompleted"); err != nil {
101+
if err := WaitForPipelineRunState(ctx, c, helmDeployPipelineRunName, timeout, PipelineRunSucceed(helmDeployPipelineRunName), "PipelineRunCompleted", v1beta1Version); err != nil {
102102
t.Errorf("Error waiting for PipelineRun %s to finish: %s", helmDeployPipelineRunName, err)
103103
t.Fatalf("PipelineRun execution failed; helm may or may not have been installed :(")
104104
}
@@ -357,7 +357,7 @@ spec:
357357
}
358358

359359
t.Logf("Waiting for TaskRun %s in namespace %s to complete", helmRemoveAllTaskRunName, namespace)
360-
if err := WaitForTaskRunState(ctx, c, helmRemoveAllTaskRunName, TaskRunSucceed(helmRemoveAllTaskRunName), "TaskRunSuccess"); err != nil {
360+
if err := WaitForTaskRunState(ctx, c, helmRemoveAllTaskRunName, TaskRunSucceed(helmRemoveAllTaskRunName), "TaskRunSuccess", v1beta1Version); err != nil {
361361
t.Logf("TaskRun %s failed to finish: %s", helmRemoveAllTaskRunName, err)
362362
}
363363
}

‎test/hermetic_taskrun_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestHermeticTaskRun(t *testing.T) {
6464
if _, err := c.V1beta1TaskRunClient.Create(ctx, regularTaskRun, metav1.CreateOptions{}); err != nil {
6565
t.Fatalf("Failed to create TaskRun `%s`: %s", regularTaskRunName, err)
6666
}
67-
if err := WaitForTaskRunState(ctx, c, regularTaskRunName, Succeed(regularTaskRunName), "TaskRunCompleted"); err != nil {
67+
if err := WaitForTaskRunState(ctx, c, regularTaskRunName, Succeed(regularTaskRunName), "TaskRunCompleted", v1beta1Version); err != nil {
6868
t.Errorf("Error waiting for TaskRun %s to finish: %s", regularTaskRunName, err)
6969
}
7070

@@ -76,7 +76,7 @@ func TestHermeticTaskRun(t *testing.T) {
7676
if _, err := c.V1beta1TaskRunClient.Create(ctx, hermeticTaskRun, metav1.CreateOptions{}); err != nil {
7777
t.Fatalf("Failed to create TaskRun `%s`: %s", regularTaskRun.Name, err)
7878
}
79-
if err := WaitForTaskRunState(ctx, c, hermeticTaskRunName, Failed(hermeticTaskRunName), "Failed"); err != nil {
79+
if err := WaitForTaskRunState(ctx, c, hermeticTaskRunName, Failed(hermeticTaskRunName), "Failed", v1beta1Version); err != nil {
8080
t.Errorf("Error waiting for TaskRun %s to fail: %s", hermeticTaskRunName, err)
8181
}
8282
})

‎test/ignore_step_error_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ spec:
7777
}
7878

7979
t.Logf("Waiting for PipelineRun in namespace %s to fail", namespace)
80-
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, FailedWithReason(pipelinerun.ReasonInvalidTaskResultReference, pipelineRun.Name), "InvalidTaskResultReference"); err != nil {
80+
if err := WaitForPipelineRunState(ctx, c, pipelineRun.Name, timeout, FailedWithReason(pipelinerun.ReasonInvalidTaskResultReference, pipelineRun.Name), "InvalidTaskResultReference", v1beta1Version); err != nil {
8181
t.Errorf("Error waiting for PipelineRun to fail: %s", err)
8282
}
8383

‎test/kaniko_task_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestKanikoTaskRun(t *testing.T) {
8484

8585
// Verify status of TaskRun (wait for it)
8686

87-
if err := WaitForTaskRunState(ctx, c, tr.Name, Succeed(tr.Name), "TaskRunCompleted"); err != nil {
87+
if err := WaitForTaskRunState(ctx, c, tr.Name, Succeed(tr.Name), "TaskRunCompleted", v1beta1Version); err != nil {
8888
t.Errorf("Error waiting for TaskRun %s to finish: %s", tr.Name, err)
8989
}
9090

0 commit comments

Comments
 (0)
Please sign in to comment.