@@ -15,6 +15,7 @@ import (
1515
1616 appstudioApi "github.com/konflux-ci/application-api/api/v1alpha1"
1717 integrationv1beta2 "github.com/konflux-ci/integration-service/api/v1beta2"
18+ intgteststat "github.com/konflux-ci/integration-service/pkg/integrationteststatus"
1819 "github.com/konflux-ci/operator-toolkit/metadata"
1920 . "github.com/onsi/ginkgo/v2"
2021 . "github.com/onsi/gomega"
@@ -33,7 +34,7 @@ var _ = framework.IntegrationServiceSuiteDescribe("Status Reporting of Integrati
3334 var snapshot * appstudioApi.Snapshot
3435 var component * appstudioApi.Component
3536 var pipelineRun , testPipelinerun , failedPipelineRun * tektonv1.PipelineRun
36- var integrationTestScenarioPass , integrationTestScenarioFail * integrationv1beta2.IntegrationTestScenario
37+ var integrationTestScenarioPass , integrationTestScenarioFail , integrationTestScenarioOptional * integrationv1beta2.IntegrationTestScenario
3738 var applicationName , componentName , componentBaseBranchName , pacBranchName , testNamespace string
3839 var mergeResult * github.PullRequestMergeResult
3940 var labels , annotations map [string ]string
@@ -69,6 +70,8 @@ var _ = framework.IntegrationServiceSuiteDescribe("Status Reporting of Integrati
6970 Expect (err ).ShouldNot (HaveOccurred ())
7071 integrationTestScenarioFail , err = f .AsKubeAdmin .IntegrationController .CreateIntegrationTestScenario ("" , applicationName , testNamespace , gitURL , revision , pathInRepoFail , "" , []string {})
7172 Expect (err ).ShouldNot (HaveOccurred ())
73+ integrationTestScenarioOptional , err = f .AsKubeAdmin .IntegrationController .CreateOptionalIntegrationTestScenario ("" , applicationName , testNamespace , gitURL , revision , pathInRepoFail , "" , []string {})
74+ Expect (err ).ShouldNot (HaveOccurred ())
7275
7376 Eventually (func () error {
7477 pipelineRun , err = f .AsKubeAdmin .HasController .GetComponentPipelineRunWithType (componentName , applicationName , testNamespace , "build" , "" , "" )
@@ -168,13 +171,19 @@ var _ = framework.IntegrationServiceSuiteDescribe("Status Reporting of Integrati
168171 Expect (err ).ToNot (HaveOccurred ())
169172 Expect (testPipelinerun .Labels [snapshotAnnotation ]).To (ContainSubstring (snapshot .Name ))
170173 Expect (testPipelinerun .Labels [scenarioAnnotation ]).To (ContainSubstring (integrationTestScenarioFail .Name ))
174+
175+ testPipelinerun , err = f .AsKubeDeveloper .IntegrationController .WaitForIntegrationPipelineToGetStarted (integrationTestScenarioOptional .Name , snapshot .Name , testNamespace )
176+ Expect (err ).ToNot (HaveOccurred ())
177+ Expect (testPipelinerun .Labels [snapshotAnnotation ]).To (ContainSubstring (snapshot .Name ))
178+ Expect (testPipelinerun .Labels [scenarioAnnotation ]).To (ContainSubstring (integrationTestScenarioOptional .Name ))
171179 })
172180 })
173181
174182 When ("Integration PipelineRuns are created" , func () {
175183 It ("should eventually complete successfully" , func () {
176184 Expect (f .AsKubeAdmin .IntegrationController .WaitForIntegrationPipelineToBeFinished (integrationTestScenarioPass , snapshot , testNamespace )).To (Succeed (), fmt .Sprintf ("Error when waiting for an integration pipelinerun for snapshot %s/%s to finish" , testNamespace , snapshot .GetName ()))
177185 Expect (f .AsKubeAdmin .IntegrationController .WaitForIntegrationPipelineToBeFinished (integrationTestScenarioFail , snapshot , testNamespace )).To (Succeed (), fmt .Sprintf ("Error when waiting for an integration pipelinerun for snapshot %s/%s to finish" , testNamespace , snapshot .GetName ()))
186+ Expect (f .AsKubeAdmin .IntegrationController .WaitForIntegrationPipelineToBeFinished (integrationTestScenarioOptional , snapshot , testNamespace )).To (Succeed (), fmt .Sprintf ("Error when waiting for an integration pipelinerun for snapshot %s/%s to finish" , testNamespace , snapshot .GetName ()))
178187 })
179188 })
180189
@@ -201,6 +210,29 @@ var _ = framework.IntegrationServiceSuiteDescribe("Status Reporting of Integrati
201210 Expect (f .AsKubeAdmin .CommonController .Github .GetCheckRunConclusion (integrationTestScenarioFail .Name , componentRepoNameForStatusReporting , prHeadSha , prNumber )).To (Equal (constants .CheckrunConclusionFailure ))
202211 })
203212
213+ It ("eventually leads to the status reported at Checks tab for the optional Integration PipelineRun" , func () {
214+ Expect (f .AsKubeAdmin .CommonController .Github .GetCheckRunConclusion (integrationTestScenarioOptional .Name , componentRepoNameForStatusReporting , prHeadSha , prNumber )).To (Equal (constants .CheckrunConclusionNeutral ))
215+ })
216+
217+ It ("checks if the optional Integration Test Scenario status is reported in the Snapshot" , func () {
218+ Eventually (func () error {
219+ snapshot , err = f .AsKubeAdmin .IntegrationController .GetSnapshot (snapshot .Name , "" , "" , testNamespace )
220+ Expect (err ).ShouldNot (HaveOccurred ())
221+
222+ statusDetail , err := f .AsKubeDeveloper .IntegrationController .GetIntegrationTestStatusDetailFromSnapshot (snapshot , integrationTestScenarioOptional .Name )
223+ Expect (err ).ToNot (HaveOccurred ())
224+
225+ if statusDetail .Status != intgteststat .IntegrationTestStatusTestFail {
226+ return fmt .Errorf ("test status doesn't have expected value %s" , intgteststat .IntegrationTestStatusTestFail )
227+ }
228+ return nil
229+ }, shortTimeout , constants .PipelineRunPollingInterval ).Should (Succeed ())
230+ })
231+
232+ It ("checks if the finalizer was removed from the optional Integration PipelineRun" , func () {
233+ Expect (f .AsKubeDeveloper .IntegrationController .WaitForFinalizerToGetRemovedFromIntegrationPipeline (integrationTestScenarioOptional , snapshot , testNamespace )).To (Succeed ())
234+ })
235+
204236 It ("merging the PR, expected to succeed " , func () {
205237 Eventually (func () error {
206238 mergeResult , err = f .AsKubeAdmin .CommonController .Github .MergePullRequest (componentRepoNameForStatusReporting , prNumber )
0 commit comments