19
19
import io .fabric8 .tekton .pipeline .v1beta1 .TaskRunBuilder ;
20
20
import io .fabric8 .tekton .pipeline .v1beta1 .TaskRunList ;
21
21
import io .fabric8 .tekton .pipeline .v1beta1 .TaskRunListBuilder ;
22
- import java .io .IOException ;
23
22
import java .net .HttpURLConnection ;
24
23
import java .net .URL ;
25
- import java .nio .charset .StandardCharsets ;
26
- import org .apache .commons .io .IOUtils ;
27
24
import org .jenkinsci .plugins .workflow .cps .CpsFlowDefinition ;
28
25
import org .jenkinsci .plugins .workflow .job .WorkflowJob ;
29
26
import org .jenkinsci .plugins .workflow .job .WorkflowRun ;
32
29
import org .junit .Test ;
33
30
import org .junit .rules .RuleChain ;
34
31
import org .junit .rules .TestRule ;
35
- import org .jvnet .hudson .test .ExtractResourceSCM ;
36
32
import org .jvnet .hudson .test .JenkinsRule ;
37
33
import org .waveywaves .jenkins .plugins .tekton .client .TektonUtils ;
38
34
import org .waveywaves .jenkins .plugins .tekton .client .ToolUtils ;
@@ -85,7 +81,7 @@ public void testScriptedPipelineWithFileInput_Task() throws Exception {
85
81
86
82
assertThat (kubernetesRule .getMockServer ().getRequestCount (), is (1 ));
87
83
88
- String log = jenkinsRule .getLog (b );
84
+ String log = JenkinsRule .getLog (b );
89
85
System .out .println (log );
90
86
91
87
assertThat (log , containsString ("Extracting: .tekton/task.yaml" ));
@@ -125,7 +121,7 @@ public void testDeclarativePipelineWithFileInput_Task() throws Exception {
125
121
126
122
assertThat (kubernetesRule .getMockServer ().getRequestCount (), is (1 ));
127
123
128
- String log = jenkinsRule .getLog (b );
124
+ String log = JenkinsRule .getLog (b );
129
125
System .out .println (log );
130
126
131
127
assertThat (log , containsString ("Extracting: .tekton/task.yaml" ));
@@ -169,7 +165,7 @@ public void testDeclarativePipelineWithYamlInput_Task() throws Exception {
169
165
170
166
assertThat (kubernetesRule .getMockServer ().getRequestCount (), is (1 ));
171
167
172
- String log = jenkinsRule .getLog (b );
168
+ String log = JenkinsRule .getLog (b );
173
169
System .out .println (log );
174
170
175
171
assertThat (log , containsString ("Extracting: .tekton/task.yaml" ));
@@ -258,7 +254,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun() throws Exception
258
254
.addToItems (pod )
259
255
.build ();
260
256
261
- kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/test/pods" )
257
+ kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/test/pods?labelSelector=tekton.dev%2FtaskRun%3DtestTaskRun " )
262
258
.andReturn (HttpURLConnection .HTTP_OK , podList ).once ();
263
259
264
260
kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/test/pods/hello-world-pod" )
@@ -291,7 +287,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun() throws Exception
291
287
292
288
WorkflowRun b = jenkinsRule .assertBuildStatus (Result .SUCCESS , p .scheduleBuild2 (0 ).get ());
293
289
294
- String log = jenkinsRule .getLog (b );
290
+ String log = JenkinsRule .getLog (b );
295
291
System .out .println (log );
296
292
297
293
assertThat (log , containsString ("[Pipeline] tektonCreateRaw" ));
@@ -384,7 +380,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_DifferentNamespace(
384
380
.addToItems (pod )
385
381
.build ();
386
382
387
- kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods" )
383
+ kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods?labelSelector=tekton.dev%2FtaskRun%3DtestTaskRun " )
388
384
.andReturn (HttpURLConnection .HTTP_OK , podList ).once ();
389
385
390
386
kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods/hello-world-pod" )
@@ -417,7 +413,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_DifferentNamespace(
417
413
418
414
WorkflowRun b = jenkinsRule .assertBuildStatus (Result .SUCCESS , p .scheduleBuild2 (0 ).get ());
419
415
420
- String log = jenkinsRule .getLog (b );
416
+ String log = JenkinsRule .getLog (b );
421
417
System .out .println (log );
422
418
423
419
assertThat (log , containsString ("[Pipeline] tektonCreateRaw" ));
@@ -516,7 +512,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_FailingContainer()
516
512
.addToItems (pod )
517
513
.build ();
518
514
519
- kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods" )
515
+ kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods?labelSelector=tekton.dev%2FtaskRun%3DtestTaskRun " )
520
516
.andReturn (HttpURLConnection .HTTP_OK , podList ).once ();
521
517
522
518
kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods/hello-world-pod" )
@@ -549,7 +545,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_FailingContainer()
549
545
550
546
WorkflowRun b = jenkinsRule .assertBuildStatus (Result .FAILURE , p .scheduleBuild2 (0 ).get ());
551
547
552
- String log = jenkinsRule .getLog (b );
548
+ String log = JenkinsRule .getLog (b );
553
549
System .out .println (log );
554
550
555
551
assertThat (log , containsString ("[Pipeline] tektonCreateRaw" ));
@@ -643,7 +639,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_FailingPipelineRun(
643
639
.addToItems (pod )
644
640
.build ();
645
641
646
- kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods" )
642
+ kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods?labelSelector=tekton.dev%2FtaskRun%3DtestTaskRun " )
647
643
.andReturn (HttpURLConnection .HTTP_OK , podList ).once ();
648
644
649
645
kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods/hello-world-pod" )
@@ -676,7 +672,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_FailingPipelineRun(
676
672
677
673
WorkflowRun b = jenkinsRule .assertBuildStatus (Result .FAILURE , p .scheduleBuild2 (0 ).get ());
678
674
679
- String log = jenkinsRule .getLog (b );
675
+ String log = JenkinsRule .getLog (b );
680
676
System .out .println (log );
681
677
682
678
assertThat (log , containsString ("[Pipeline] tektonCreateRaw" ));
@@ -689,10 +685,6 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_FailingPipelineRun(
689
685
assertThat (kubernetesRule .getMockServer ().getRequestCount (), is (9 ));
690
686
}
691
687
692
- private String contents (String filename ) throws IOException {
693
- return IOUtils .toString (this .getClass ().getResourceAsStream (filename ), StandardCharsets .UTF_8 .name ());
694
- }
695
-
696
688
private OwnerReference ownerReference (String uid ) {
697
689
return new OwnerReference ("" , false , false , "" , "" , uid );
698
690
}
0 commit comments