Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(STONEINTG-1009): e2e tests for group snapshot #1461

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading