Skip to content

Commit

Permalink
feat(STONEINTG-1009): e2e tests for group snapshot
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Sztuka <jsztuka@redhat.com>
  • Loading branch information
jsztuka committed Nov 21, 2024
1 parent 766cb58 commit 79bf6f4
Show file tree
Hide file tree
Showing 5 changed files with 624 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/clients/has/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ func (h *HasController) GetAllPipelineRunsForApplication(applicationName, namesp
return nil, fmt.Errorf("no pipelinerun found for application %s", applicationName)
}

// GetAllGroupSnapshotsForApplication returns the groupSnapshots for a given application in the namespace
func (h *HasController) GetAllGroupSnapshotsForApplication(applicationName, namespace string) (*appservice.SnapshotList, error) {
snapshotLabels := map[string]string{"appstudio.openshift.io/application": applicationName, "test.appstudio.openshift.io/type": "group"}

list := &appservice.SnapshotList{}
err := h.KubeRest().List(context.Background(), list, &rclient.ListOptions{LabelSelector: labels.SelectorFromSet(snapshotLabels), Namespace: namespace})

if err != nil && !k8sErrors.IsNotFound(err) {
return nil, fmt.Errorf("error listing snapshots in %s namespace: %v", namespace, err)
}

if len(list.Items) > 0 {
return list, nil
}

return nil, fmt.Errorf("no snapshot found for application %s", applicationName)
}

// Set of options to retrigger pipelineRuns in CI to fight against flakynes
type RetryOptions struct {
// Indicate how many times a pipelineRun should be retriggered in case of flakines
Expand Down
27 changes: 27 additions & 0 deletions pkg/clients/integration/pipelineruns.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,30 @@ func (i *IntegrationController) WaitForBuildPipelineRunToGetAnnotated(testNamesp
return true, nil
})
}

// WaitForBuildPipelineToBeFinished wait for given build pipeline to finish.
// It exposes the error message from the failed task to the end user when the pipelineRun failed.
func (i *IntegrationController) WaitForBuildPipelineToBeFinished(testNamespace, applicationName, componentName string) error {
return wait.PollUntilContextTimeout(context.Background(), constants.PipelineRunPollingInterval, 15*time.Minute, true, func(ctx context.Context) (done bool, err error) {
pipelineRun, err := i.GetBuildPipelineRun(componentName, applicationName, testNamespace, false, "")
if err != nil {
GinkgoWriter.Println("Build pipelineRun has not been created yet for app %s/%s", testNamespace, applicationName)
return false, nil
}
for _, condition := range pipelineRun.Status.Conditions {
GinkgoWriter.Printf("PipelineRun %s reason: %s\n", pipelineRun.Name, condition.Reason)

if !pipelineRun.IsDone() {
return false, nil
}

if pipelineRun.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsTrue() {
return true, nil
} else {
logs, _ := tekton.GetFailedPipelineRunLogs(i.KubeRest(), i.KubeInterface(), pipelineRun)
return false, fmt.Errorf("%s", logs)
}
}
return false, nil
})
}
9 changes: 9 additions & 0 deletions tests/integration-service/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const (
componentRepoNameForGeneralIntegration = "konflux-test-integration"
componentRepoNameForIntegrationWithEnv = "konflux-test-integration-with-env"
componentRepoNameForStatusReporting = "konflux-test-integration-status-report"
multiComponentRepoNameForGroupSnapshot = "group-snapshot-multi-component"
multiComponentDefaultBranch = "main"
multiComponentGitRevision = "0d1835404efb8ab7bb1ab5b5b82cda1ebfda4b25"
multiRepoComponentGitRevision = "2e41cf5a68674503c86b6637de35eeedc2893794"
gitlabComponentRepoName = "hacbs-test-project-integration"
componentDefaultBranch = "main"
componentRevision = "34da5a8f51fba6a8b7ec75a727d3c72ebb5e1274"
Expand All @@ -35,6 +39,8 @@ const (

snapshotAnnotation = "appstudio.openshift.io/snapshot"
scenarioAnnotation = "test.appstudio.openshift.io/scenario"
groupSnapshotAnnotation = "test.appstudio.openshift.io/pr-group"
testGroupSnapshotAnnotation = "test.appstudio.openshift.io/group-test-info"
pipelinerunFinalizerByIntegrationService = "test.appstudio.openshift.io/pipelinerun"
snapshotRerunLabel = "test.appstudio.openshift.io/run"

Expand All @@ -45,6 +51,9 @@ var (
componentGitSourceURLForGeneralIntegration = fmt.Sprintf("https://github.com/%s/%s", utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe"), componentRepoNameForGeneralIntegration)
componentGitSourceURLForIntegrationWithEnv = fmt.Sprintf("https://github.com/%s/%s", utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe"), componentRepoNameForIntegrationWithEnv)
componentGitSourceURLForStatusReporting = fmt.Sprintf("https://github.com/%s/%s", utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe"), componentRepoNameForStatusReporting)
multiComponentGitSourceURLForGroupSnapshotA = fmt.Sprintf("https://github.com/%s/%s", utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe"), multiComponentRepoNameForGroupSnapshot)
multiComponentGitSourceURLForGroupSnapshotB = fmt.Sprintf("https://github.com/%s/%s", utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe"), multiComponentRepoNameForGroupSnapshot)
multiComponentContextDirs = []string{"go-component", "python-component"}
gitlabOrg = utils.GetEnv(constants.GITLAB_QE_ORG_ENV, constants.DefaultGitLabQEOrg)
gitlabProjectIDForStatusReporting = fmt.Sprintf("%s/%s", gitlabOrg, gitlabComponentRepoName)
gitlabComponentGitSourceURLForStatusReporting = fmt.Sprintf("https://gitlab.com/%s/%s", gitlabOrg, gitlabComponentRepoName)
Expand Down
Loading

0 comments on commit 79bf6f4

Please sign in to comment.