1919import io .fabric8 .tekton .pipeline .v1beta1 .TaskRunBuilder ;
2020import io .fabric8 .tekton .pipeline .v1beta1 .TaskRunList ;
2121import io .fabric8 .tekton .pipeline .v1beta1 .TaskRunListBuilder ;
22- import java .io .IOException ;
2322import java .net .HttpURLConnection ;
2423import java .net .URL ;
25- import java .nio .charset .StandardCharsets ;
26- import org .apache .commons .io .IOUtils ;
2724import org .jenkinsci .plugins .workflow .cps .CpsFlowDefinition ;
2825import org .jenkinsci .plugins .workflow .job .WorkflowJob ;
2926import org .jenkinsci .plugins .workflow .job .WorkflowRun ;
3229import org .junit .Test ;
3330import org .junit .rules .RuleChain ;
3431import org .junit .rules .TestRule ;
35- import org .jvnet .hudson .test .ExtractResourceSCM ;
3632import org .jvnet .hudson .test .JenkinsRule ;
3733import org .waveywaves .jenkins .plugins .tekton .client .TektonUtils ;
3834import org .waveywaves .jenkins .plugins .tekton .client .ToolUtils ;
@@ -85,7 +81,7 @@ public void testScriptedPipelineWithFileInput_Task() throws Exception {
8581
8682 assertThat (kubernetesRule .getMockServer ().getRequestCount (), is (1 ));
8783
88- String log = jenkinsRule .getLog (b );
84+ String log = JenkinsRule .getLog (b );
8985 System .out .println (log );
9086
9187 assertThat (log , containsString ("Extracting: .tekton/task.yaml" ));
@@ -125,7 +121,7 @@ public void testDeclarativePipelineWithFileInput_Task() throws Exception {
125121
126122 assertThat (kubernetesRule .getMockServer ().getRequestCount (), is (1 ));
127123
128- String log = jenkinsRule .getLog (b );
124+ String log = JenkinsRule .getLog (b );
129125 System .out .println (log );
130126
131127 assertThat (log , containsString ("Extracting: .tekton/task.yaml" ));
@@ -169,7 +165,7 @@ public void testDeclarativePipelineWithYamlInput_Task() throws Exception {
169165
170166 assertThat (kubernetesRule .getMockServer ().getRequestCount (), is (1 ));
171167
172- String log = jenkinsRule .getLog (b );
168+ String log = JenkinsRule .getLog (b );
173169 System .out .println (log );
174170
175171 assertThat (log , containsString ("Extracting: .tekton/task.yaml" ));
@@ -258,7 +254,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun() throws Exception
258254 .addToItems (pod )
259255 .build ();
260256
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 " )
262258 .andReturn (HttpURLConnection .HTTP_OK , podList ).once ();
263259
264260 kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/test/pods/hello-world-pod" )
@@ -291,7 +287,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun() throws Exception
291287
292288 WorkflowRun b = jenkinsRule .assertBuildStatus (Result .SUCCESS , p .scheduleBuild2 (0 ).get ());
293289
294- String log = jenkinsRule .getLog (b );
290+ String log = JenkinsRule .getLog (b );
295291 System .out .println (log );
296292
297293 assertThat (log , containsString ("[Pipeline] tektonCreateRaw" ));
@@ -384,7 +380,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_DifferentNamespace(
384380 .addToItems (pod )
385381 .build ();
386382
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 " )
388384 .andReturn (HttpURLConnection .HTTP_OK , podList ).once ();
389385
390386 kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods/hello-world-pod" )
@@ -417,7 +413,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_DifferentNamespace(
417413
418414 WorkflowRun b = jenkinsRule .assertBuildStatus (Result .SUCCESS , p .scheduleBuild2 (0 ).get ());
419415
420- String log = jenkinsRule .getLog (b );
416+ String log = JenkinsRule .getLog (b );
421417 System .out .println (log );
422418
423419 assertThat (log , containsString ("[Pipeline] tektonCreateRaw" ));
@@ -516,7 +512,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_FailingContainer()
516512 .addToItems (pod )
517513 .build ();
518514
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 " )
520516 .andReturn (HttpURLConnection .HTTP_OK , podList ).once ();
521517
522518 kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods/hello-world-pod" )
@@ -549,7 +545,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_FailingContainer()
549545
550546 WorkflowRun b = jenkinsRule .assertBuildStatus (Result .FAILURE , p .scheduleBuild2 (0 ).get ());
551547
552- String log = jenkinsRule .getLog (b );
548+ String log = JenkinsRule .getLog (b );
553549 System .out .println (log );
554550
555551 assertThat (log , containsString ("[Pipeline] tektonCreateRaw" ));
@@ -643,7 +639,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_FailingPipelineRun(
643639 .addToItems (pod )
644640 .build ();
645641
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 " )
647643 .andReturn (HttpURLConnection .HTTP_OK , podList ).once ();
648644
649645 kubernetesRule .expect ().get ().withPath ("/api/v1/namespaces/tekton-pipelines/pods/hello-world-pod" )
@@ -676,7 +672,7 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_FailingPipelineRun(
676672
677673 WorkflowRun b = jenkinsRule .assertBuildStatus (Result .FAILURE , p .scheduleBuild2 (0 ).get ());
678674
679- String log = jenkinsRule .getLog (b );
675+ String log = JenkinsRule .getLog (b );
680676 System .out .println (log );
681677
682678 assertThat (log , containsString ("[Pipeline] tektonCreateRaw" ));
@@ -689,10 +685,6 @@ public void testDeclarativePipelineWithYamlInput_PipelineRun_FailingPipelineRun(
689685 assertThat (kubernetesRule .getMockServer ().getRequestCount (), is (9 ));
690686 }
691687
692- private String contents (String filename ) throws IOException {
693- return IOUtils .toString (this .getClass ().getResourceAsStream (filename ), StandardCharsets .UTF_8 .name ());
694- }
695-
696688 private OwnerReference ownerReference (String uid ) {
697689 return new OwnerReference ("" , false , false , "" , "" , uid );
698690 }
0 commit comments