Skip to content

Commit 77324c5

Browse files
committed
chore(stoneintg-1092): reinstate status reporting file
Signed-off-by: jcullina <[email protected]>
1 parent d062782 commit 77324c5

File tree

3 files changed

+197
-4
lines changed

3 files changed

+197
-4
lines changed

Diff for: tests/integration-service/const.go

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const (
5050
var (
5151
componentGitSourceURLForGeneralIntegration = fmt.Sprintf("https://github.com/%s/%s", utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe"), componentRepoNameForGeneralIntegration)
5252
componentGitSourceURLForIntegrationWithEnv = fmt.Sprintf("https://github.com/%s/%s", utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe"), componentRepoNameForIntegrationWithEnv)
53+
componentGitSourceURLForStatusReporting = fmt.Sprintf("https://github.com/%s/%s", utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe"), componentRepoNameForStatusReporting)
5354
multiComponentGitSourceURLForGroupSnapshot = fmt.Sprintf("https://github.com/%s/%s", utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe"), multiComponentRepoNameForGroupSnapshot)
5455
multiComponentContextDirs = []string{"go-component", "python-component"}
5556
gitlabOrg = utils.GetEnv(constants.GITLAB_QE_ORG_ENV, constants.DefaultGitLabQEOrg)

Diff for: tests/integration-service/group-snapshots-tests.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,16 @@ var _ = framework.IntegrationServiceSuiteDescribe("Creation of group snapshots f
5858

5959
applicationName = createApp(*f, testNamespace)
6060

61-
// Create base branches for multi-component definitions
61+
// The base branch or a ToBranch where all multi-component definitions will live
6262
multiComponentBaseBranchName = fmt.Sprintf("multi-repo-%s", util.GenerateRandomString(6))
6363
err = f.AsKubeAdmin.CommonController.Github.CreateRef(multiComponentRepoNameForGroupSnapshot, multiComponentDefaultBranch, multiComponentGitRevision, multiComponentBaseBranchName)
6464
Expect(err).ShouldNot(HaveOccurred())
6565

66+
// The base branch or ToBranch where different repo component definition will live
6667
err = f.AsKubeAdmin.CommonController.Github.CreateRef(componentRepoNameForGeneralIntegration, multiComponentDefaultBranch, multiRepoComponentGitRevision, multiComponentBaseBranchName)
6768
Expect(err).ShouldNot(HaveOccurred())
6869

69-
// PR Branch creation
70+
// Branch for creating pull request
7071
multiComponentPRBranchName = fmt.Sprintf("pr-branch-%s", util.GenerateRandomString(6))
7172

7273
// Create Integration Test Scenario
@@ -84,7 +85,7 @@ var _ = framework.IntegrationServiceSuiteDescribe("Creation of group snapshots f
8485
cleanup(*f, testNamespace, applicationName, componentNames[0], snapshot)
8586
}
8687

87-
// Cleanup branches created by PaC
88+
// Delete new branches created by PaC and a testing branch used as a component's base branch
8889
for _, pacBranchName := range pacBranchNames {
8990
err = f.AsKubeAdmin.CommonController.Github.DeleteRef(multiComponentRepoNameForGroupSnapshot, pacBranchName)
9091
if err != nil {
@@ -96,19 +97,25 @@ var _ = framework.IntegrationServiceSuiteDescribe("Creation of group snapshots f
9697
}
9798
}
9899

99-
// Cleanup base and PR branches
100+
// Delete the created base branch
100101
err = f.AsKubeAdmin.CommonController.Github.DeleteRef(multiComponentRepoNameForGroupSnapshot, multiComponentBaseBranchName)
101102
if err != nil {
102103
Expect(err.Error()).To(ContainSubstring(referenceDoesntExist))
103104
}
105+
106+
// Delete the created base branch for multi-repo
104107
err = f.AsKubeAdmin.CommonController.Github.DeleteRef(componentRepoNameForGeneralIntegration, multiComponentBaseBranchName)
105108
if err != nil {
106109
Expect(err.Error()).To(ContainSubstring(referenceDoesntExist))
107110
}
111+
112+
//Delete the created pr branch
108113
err = f.AsKubeAdmin.CommonController.Github.DeleteRef(multiComponentRepoNameForGroupSnapshot, multiComponentPRBranchName)
109114
if err != nil {
110115
Expect(err.Error()).To(ContainSubstring(referenceDoesntExist))
111116
}
117+
118+
//Delete the created pr branch for multi-repo
112119
err = f.AsKubeAdmin.CommonController.Github.DeleteRef(componentRepoNameForGeneralIntegration, multiComponentPRBranchName)
113120
if err != nil {
114121
Expect(err.Error()).To(ContainSubstring(referenceDoesntExist))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
package integration
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"time"
7+
8+
"github.com/konflux-ci/e2e-tests/pkg/clients/has"
9+
"github.com/konflux-ci/e2e-tests/pkg/constants"
10+
"github.com/konflux-ci/e2e-tests/pkg/framework"
11+
"github.com/konflux-ci/e2e-tests/pkg/utils"
12+
13+
appstudioApi "github.com/konflux-ci/application-api/api/v1alpha1"
14+
integrationv1beta2 "github.com/konflux-ci/integration-service/api/v1beta2"
15+
. "github.com/onsi/ginkgo/v2"
16+
. "github.com/onsi/gomega"
17+
pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
18+
)
19+
20+
var _ = framework.IntegrationServiceSuiteDescribe("Status Reporting of Integration tests", Label("integration-service", "github-status-reporting"), func() {
21+
defer GinkgoRecover()
22+
23+
var f *framework.Framework
24+
var err error
25+
26+
var prNumber int
27+
var timeout, interval time.Duration
28+
var prHeadSha string
29+
var snapshot *appstudioApi.Snapshot
30+
var component *appstudioApi.Component
31+
var pipelineRun, testPipelinerun *pipeline.PipelineRun
32+
var integrationTestScenarioPass, integrationTestScenarioFail *integrationv1beta2.IntegrationTestScenario
33+
var applicationName, componentName, componentBaseBranchName, pacBranchName, testNamespace string
34+
35+
AfterEach(framework.ReportFailure(&f))
36+
37+
Describe("with status reporting of Integration tests in CheckRuns", Ordered, func() {
38+
BeforeAll(func() {
39+
if os.Getenv(constants.SKIP_PAC_TESTS_ENV) == "true" {
40+
Skip("Skipping this test due to configuration issue with Spray proxy")
41+
}
42+
43+
f, err = framework.NewFramework(utils.GetGeneratedNamespace("stat-rep"))
44+
Expect(err).NotTo(HaveOccurred())
45+
testNamespace = f.UserNamespace
46+
47+
if utils.IsPrivateHostname(f.OpenshiftConsoleHost) {
48+
Skip("Using private cluster (not reachable from Github), skipping...")
49+
}
50+
51+
applicationName = createApp(*f, testNamespace)
52+
component, componentName, pacBranchName, componentBaseBranchName = createComponent(*f, testNamespace, applicationName, componentRepoNameForStatusReporting, componentGitSourceURLForStatusReporting)
53+
54+
integrationTestScenarioPass, err = f.AsKubeAdmin.IntegrationController.CreateIntegrationTestScenario("", applicationName, testNamespace, gitURL, revision, pathInRepoPass, []string{})
55+
Expect(err).ShouldNot(HaveOccurred())
56+
integrationTestScenarioFail, err = f.AsKubeAdmin.IntegrationController.CreateIntegrationTestScenario("", applicationName, testNamespace, gitURL, revision, pathInRepoFail, []string{})
57+
Expect(err).ShouldNot(HaveOccurred())
58+
})
59+
60+
AfterAll(func() {
61+
if !CurrentSpecReport().Failed() {
62+
cleanup(*f, testNamespace, applicationName, componentName, snapshot)
63+
}
64+
65+
// Delete new branches created by PaC and a testing branch used as a component's base branch
66+
err = f.AsKubeAdmin.CommonController.Github.DeleteRef(componentRepoNameForStatusReporting, pacBranchName)
67+
if err != nil {
68+
Expect(err.Error()).To(ContainSubstring(referenceDoesntExist))
69+
}
70+
err = f.AsKubeAdmin.CommonController.Github.DeleteRef(componentRepoNameForStatusReporting, componentBaseBranchName)
71+
if err != nil {
72+
Expect(err.Error()).To(ContainSubstring(referenceDoesntExist))
73+
}
74+
})
75+
76+
When("a new Component with specified custom branch is created", Label("custom-branch"), func() {
77+
It("triggers a Build PipelineRun", func() {
78+
timeout = time.Second * 600
79+
interval = time.Second * 1
80+
Eventually(func() error {
81+
pipelineRun, err = f.AsKubeAdmin.HasController.GetComponentPipelineRun(componentName, applicationName, testNamespace, "")
82+
if err != nil {
83+
GinkgoWriter.Printf("Build PipelineRun has not been created yet for the component %s/%s\n", testNamespace, componentName)
84+
return err
85+
}
86+
if !pipelineRun.HasStarted() {
87+
return fmt.Errorf("build pipelinerun %s/%s hasn't started yet", pipelineRun.GetNamespace(), pipelineRun.GetName())
88+
}
89+
return nil
90+
}, timeout, constants.PipelineRunPollingInterval).Should(Succeed(), fmt.Sprintf("timed out when waiting for the build PipelineRun to start for the component %s/%s", testNamespace, componentName))
91+
})
92+
93+
It("does not contain an annotation with a Snapshot Name", func() {
94+
Expect(pipelineRun.Annotations[snapshotAnnotation]).To(Equal(""))
95+
})
96+
97+
It("should lead to build PipelineRun finishing successfully", func() {
98+
Expect(f.AsKubeAdmin.HasController.WaitForComponentPipelineToBeFinished(component,
99+
"", f.AsKubeAdmin.TektonController, &has.RetryOptions{Retries: 2, Always: true}, pipelineRun)).To(Succeed())
100+
})
101+
102+
It("should have a related PaC init PR created", func() {
103+
timeout = time.Second * 300
104+
interval = time.Second * 1
105+
106+
Eventually(func() bool {
107+
prs, err := f.AsKubeAdmin.CommonController.Github.ListPullRequests(componentRepoNameForStatusReporting)
108+
Expect(err).ShouldNot(HaveOccurred())
109+
110+
for _, pr := range prs {
111+
if pr.Head.GetRef() == pacBranchName {
112+
prNumber = pr.GetNumber()
113+
prHeadSha = pr.Head.GetSHA()
114+
return true
115+
}
116+
}
117+
return false
118+
}, timeout, interval).Should(BeTrue(), fmt.Sprintf("timed out when waiting for init PaC PR (branch name '%s') to be created in %s repository", pacBranchName, componentRepoNameForStatusReporting))
119+
120+
// in case the first pipelineRun attempt has failed and was retried, we need to update the value of pipelineRun variable
121+
pipelineRun, err = f.AsKubeAdmin.HasController.GetComponentPipelineRun(componentName, applicationName, testNamespace, prHeadSha)
122+
Expect(err).ShouldNot(HaveOccurred())
123+
})
124+
125+
It("eventually leads to the build PipelineRun's status reported at Checks tab", func() {
126+
expectedCheckRunName := fmt.Sprintf("%s-%s", componentName, "on-pull-request")
127+
Expect(f.AsKubeAdmin.CommonController.Github.GetCheckRunConclusion(expectedCheckRunName, componentRepoNameForStatusReporting, prHeadSha, prNumber)).To(Equal(constants.CheckrunConclusionSuccess))
128+
})
129+
})
130+
131+
When("the PaC build pipelineRun run succeeded", func() {
132+
It("checks if the BuildPipelineRun have the annotation of chains signed", func() {
133+
Expect(f.AsKubeDeveloper.IntegrationController.WaitForBuildPipelineRunToGetAnnotated(testNamespace, applicationName, componentName, chainsSignedAnnotation)).To(Succeed())
134+
})
135+
136+
It("checks if the Snapshot is created", func() {
137+
snapshot, err = f.AsKubeDeveloper.IntegrationController.WaitForSnapshotToGetCreated("", "", componentName, testNamespace)
138+
Expect(err).ToNot(HaveOccurred())
139+
})
140+
141+
It("checks if the Build PipelineRun got annotated with Snapshot name", func() {
142+
Expect(f.AsKubeDeveloper.IntegrationController.WaitForBuildPipelineRunToGetAnnotated(testNamespace, applicationName, componentName, snapshotAnnotation)).To(Succeed())
143+
})
144+
})
145+
146+
When("the Snapshot was created", func() {
147+
It("should find both the related Integration PipelineRuns", func() {
148+
testPipelinerun, err = f.AsKubeDeveloper.IntegrationController.WaitForIntegrationPipelineToGetStarted(integrationTestScenarioPass.Name, snapshot.Name, testNamespace)
149+
Expect(err).ToNot(HaveOccurred())
150+
Expect(testPipelinerun.Labels[snapshotAnnotation]).To(ContainSubstring(snapshot.Name))
151+
Expect(testPipelinerun.Labels[scenarioAnnotation]).To(ContainSubstring(integrationTestScenarioPass.Name))
152+
153+
testPipelinerun, err = f.AsKubeDeveloper.IntegrationController.WaitForIntegrationPipelineToGetStarted(integrationTestScenarioFail.Name, snapshot.Name, testNamespace)
154+
Expect(err).ToNot(HaveOccurred())
155+
Expect(testPipelinerun.Labels[snapshotAnnotation]).To(ContainSubstring(snapshot.Name))
156+
Expect(testPipelinerun.Labels[scenarioAnnotation]).To(ContainSubstring(integrationTestScenarioFail.Name))
157+
})
158+
})
159+
160+
When("Integration PipelineRuns are created", func() {
161+
It("should eventually complete successfully", func() {
162+
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()))
163+
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()))
164+
})
165+
})
166+
167+
When("Integration PipelineRuns completes successfully", func() {
168+
It("should lead to Snapshot CR being marked as failed", FlakeAttempts(3), func() {
169+
// Snapshot marked as Failed because one of its Integration test failed (as expected)
170+
Eventually(func() bool {
171+
snapshot, err = f.AsKubeAdmin.IntegrationController.GetSnapshot("", pipelineRun.Name, "", testNamespace)
172+
return err == nil && !f.AsKubeAdmin.CommonController.HaveTestsSucceeded(snapshot)
173+
}, time.Minute*3, time.Second*5).Should(BeTrue(), fmt.Sprintf("Timed out waiting for Snapshot to be marked as failed %s/%s", snapshot.GetNamespace(), snapshot.GetName()))
174+
})
175+
176+
It("eventually leads to the status reported at Checks tab for the successful Integration PipelineRun", func() {
177+
Expect(f.AsKubeAdmin.CommonController.Github.GetCheckRunConclusion(integrationTestScenarioPass.Name, componentRepoNameForStatusReporting, prHeadSha, prNumber)).To(Equal(constants.CheckrunConclusionSuccess))
178+
})
179+
180+
It("eventually leads to the status reported at Checks tab for the failed Integration PipelineRun", func() {
181+
Expect(f.AsKubeAdmin.CommonController.Github.GetCheckRunConclusion(integrationTestScenarioFail.Name, componentRepoNameForStatusReporting, prHeadSha, prNumber)).To(Equal(constants.CheckrunConclusionFailure))
182+
})
183+
})
184+
})
185+
})

0 commit comments

Comments
 (0)