diff --git a/cmd/loadTests.go b/cmd/loadTests.go index 311c335e5..557d92842 100644 --- a/cmd/loadTests.go +++ b/cmd/loadTests.go @@ -6,6 +6,7 @@ import ( "flag" "fmt" "os" + "regexp" "runtime" "strconv" "strings" @@ -18,10 +19,12 @@ import ( metricsConstants "github.com/redhat-appstudio-qe/perf-monitoring/api/pkg/constants" "github.com/redhat-appstudio-qe/perf-monitoring/api/pkg/metrics" appstudioApi "github.com/redhat-appstudio/application-api/api/v1alpha1" + buildservice "github.com/redhat-appstudio/build-service/api/v1alpha1" "github.com/redhat-appstudio/e2e-tests/pkg/constants" "github.com/redhat-appstudio/e2e-tests/pkg/framework" "github.com/redhat-appstudio/e2e-tests/pkg/utils" loadtestUtils "github.com/redhat-appstudio/e2e-tests/pkg/utils/loadtests" + "github.com/redhat-appstudio/e2e-tests/pkg/utils/tekton" integrationv1beta1 "github.com/redhat-appstudio/integration-service/api/v1beta1" "github.com/spf13/cobra" pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" @@ -32,6 +35,7 @@ import ( k8swait "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" "knative.dev/pkg/apis" + rclient "sigs.k8s.io/controller-runtime/pkg/client" ) type UserAppsCompsMap struct { @@ -220,6 +224,9 @@ func (u *UserAppsCompsMap) GetIntegrationTestScenarios(userName, appName string) var ( componentRepoUrl string = "https://github.com/devfile-samples/devfile-sample-code-with-quarkus" componentsCount int = 1 + componentRepoRevision string = "main" + componentRepoTemplate bool + quayRepo string = "redhat-user-workloads-stage" usernamePrefix string = "testuser" numberOfUsers int testScenarioGitURL string = "https://github.com/konflux-ci/integration-examples.git" @@ -241,6 +248,7 @@ var ( enableProgressBars bool pushGatewayURI string = "" jobName string = "" + buildPipelineSelectorBundle string = "" ) var ( @@ -323,6 +331,9 @@ type LogData struct { BinaryDetails string `json:"binaryDetails"` ComponentRepoUrl string `json:"componentRepoUrl"` ComponentsCount int `json:"componentsCount"` + ComponentRepoRevision string `json:"componentRepoRevision"` + ComponentRepoTemplate bool `json:"componentRepoTemplate"` + QuayRepo string `json:"quayRepo"` NumberOfThreads int `json:"threads"` NumberOfUsersPerThread int `json:"usersPerThread"` NumberOfUsers int `json:"totalUsers"` @@ -451,6 +462,9 @@ func ExecuteLoadTest() { func init() { rootCmd.Flags().StringVar(&componentRepoUrl, "component-repo", componentRepoUrl, "the component repo URL to be used") rootCmd.Flags().IntVar(&componentsCount, "components-count", componentsCount, "number of components to create per application") + rootCmd.Flags().StringVar(&componentRepoRevision, "component-repo-revision", componentRepoRevision, "the component repo revision, git branch") + rootCmd.Flags().BoolVarP(&componentRepoTemplate, "component-repo-template", "e", false, "if you want to use per-user branch based on provided branch for PaC testing") + rootCmd.Flags().StringVar(&quayRepo, "quay-repo", quayRepo, "the target quay repo for PaC templated image pushes") rootCmd.Flags().StringVar(&usernamePrefix, "username", usernamePrefix, "the prefix used for usersignup names") rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "if 'debug' traces should be displayed in the console") rootCmd.Flags().BoolVarP(&stage, "stage", "s", false, "is you want to run the test on stage") @@ -472,6 +486,7 @@ func init() { rootCmd.Flags().BoolVar(&enableProgressBars, "enable-progress-bars", false, "if you want to enable progress bars") rootCmd.Flags().StringVar(&pushGatewayURI, "pushgateway-url", pushGatewayURI, "PushGateway url (needs to be set if metrics are enabled)") rootCmd.Flags().StringVar(&jobName, "job-name", jobName, "Job Name to track Metrics (needs to be set if metrics are enabled)") + rootCmd.Flags().StringVar(&buildPipelineSelectorBundle, "build-pipeline-selector-bundle", buildPipelineSelectorBundle, "BuildPipelineSelector bundle to use when testing with build-definition PR") } func logError(errCode int, message string) { @@ -590,6 +605,9 @@ func setup(cmd *cobra.Command, args []string) { BinaryDetails: binaryDetails, ComponentRepoUrl: componentRepoUrl, ComponentsCount: componentsCount, + ComponentRepoRevision: componentRepoRevision, + ComponentRepoTemplate: componentRepoTemplate, + QuayRepo: quayRepo, NumberOfThreads: threadCount, NumberOfUsersPerThread: numberOfUsers, NumberOfUsers: overallCount, @@ -969,10 +987,13 @@ func StageCleanup(journeyContexts []*JourneyContext) { klog.V(5).Infof("StageCleanup start") defer klog.V(5).Infof("StageCleanup end") + var err error + var framework *framework.Framework + for _, journeyCtx := range journeyContexts { for _, username := range journeyCtx.userAppsCompsMap.GetUserNames() { - framework := journeyCtx.userAppsCompsMap.GetUserFramework(username) - err := framework.AsKubeDeveloper.HasController.DeleteAllApplicationsInASpecificNamespace(framework.UserNamespace, 5*time.Minute) + framework = journeyCtx.userAppsCompsMap.GetUserFramework(username) + err = framework.AsKubeDeveloper.HasController.DeleteAllApplicationsInASpecificNamespace(framework.UserNamespace, 5*time.Minute) if err != nil { klog.Errorf("while deleting resources for username: %s, got error: %v\n", username, err) } @@ -981,6 +1002,11 @@ func StageCleanup(journeyContexts []*JourneyContext) { if err != nil { klog.Errorf("while deleting component detection queries for username: %s, got error: %v\n", username, err) } + + err = deleteAllBuildPipelineSelectors(framework, time.Minute) + if err != nil { + klog.Errorf("while deleting build pipeline selectors for user: %s, got error: %v\n", username, err) + } } } } @@ -1025,6 +1051,70 @@ func increaseBar(bar *uiprogress.Bar, mutex *sync.Mutex) { } } +func listAllBuildPipelineSelectors(f *framework.Framework) (*buildservice.BuildPipelineSelectorList, error) { + list := &buildservice.BuildPipelineSelectorList{} + err := f.AsKubeDeveloper.HasController.KubeRest().List(context.Background(), list, &rclient.ListOptions{Namespace: f.UserNamespace}) + klog.V(5).Infof("listAllBuildPipelineSelectors namespace: %s, len: %d, err: %v", f.UserNamespace, len(list.Items), err) + return list, err +} + +func deleteAllBuildPipelineSelectors(f *framework.Framework, timeout time.Duration) error { + klog.V(5).Infof("deleteAllBuildPipelineSelectors start namespace: %s", f.UserNamespace) + defer klog.V(5).Infof("deleteAllBuildPipelineSelectors end") + + list, err := listAllBuildPipelineSelectors(f) + if err != nil { + return fmt.Errorf("error listing build pipeline selectors from %s: %v", f.UserNamespace, err) + } + + for _, bps := range list.Items { + toDelete := bps + err = f.AsKubeDeveloper.HasController.KubeRest().Delete(context.Background(), &toDelete) + if err != nil { + return fmt.Errorf("error deleting build pipeline selector %s from %s: %v", bps.Name, f.UserNamespace, err) + } + } + + return utils.WaitUntil(func() (done bool, err error) { + list, err := listAllBuildPipelineSelectors(f) + if err != nil { + return false, nil + } + return len(list.Items) == 0, nil + }, timeout) +} + +func createBuildPipelineSelector(f *framework.Framework, bundle *string) error { + klog.V(5).Infof("createBuildPipelineSelector start bundle: %s, namespace: %s", *bundle, f.UserNamespace) + defer klog.V(5).Infof("createBuildPipelineSelector end") + + var err error + + err = deleteAllBuildPipelineSelectors(f, time.Minute) + if err != nil { + klog.Errorf("error deleting build pipeline selectors from %s: %v\n", f.UserNamespace, err) + } + + bps := &buildservice.BuildPipelineSelector{ + ObjectMeta: metav1.ObjectMeta{ + Name: "build-pipeline-selector", + Namespace: f.UserNamespace, + }, + Spec: buildservice.BuildPipelineSelectorSpec{Selectors: []buildservice.PipelineSelector{ + { + Name: "all-pipelines", + PipelineRef: *tekton.NewBundleResolverPipelineRef("docker-build", *bundle), + }, + }}, + } + err = f.AsKubeAdmin.CommonController.KubeRest().Create(context.TODO(), bps) + if err != nil { + return fmt.Errorf("error creating build pipeline selector in %s with bundle %s: %v", f.UserNamespace, *bundle, err) + } + + return nil +} + func tryNewFramework(username string, user loadtestUtils.User, timeout time.Duration) (*framework.Framework, error) { ch := make(chan *framework.Framework) var fw *framework.Framework @@ -1178,8 +1268,7 @@ func (h *ConcreteHandlerResources) Handle(ctx *JourneyContext) { } // Handle Component Detection Query Creation - cdqName := fmt.Sprintf("%s-cdq-%s", username, util.GenerateRandomString(5)) - blnOK, cdq := h.handleCDQCreation(ctx, framework, username, usernamespace, applicationName, cdqName) + blnOK, cdq := h.handleCDQCreation(ctx, framework, username, usernamespace) if !blnOK { // If CDQ creation failed, continue with the next user continue @@ -1215,12 +1304,7 @@ func (h *ConcreteHandlerResources) handleApplicationCreation(ctx *JourneyContext return false } - ApplicationCreationTimeSumPerThread[ctx.ThreadIndex] += applicationCreationTime MetricsWrapper(MetricsController, metricsConstants.CollectorApplications, metricsConstants.MetricTypeGuage, metricsConstants.MetricApplicationCreationTimeGauge, applicationCreationTime.Seconds()) - if applicationCreationTime > ApplicationCreationTimeMaxPerThread[ctx.ThreadIndex] { - ApplicationCreationTimeMaxPerThread[ctx.ThreadIndex] = applicationCreationTime - } - return h.validateApplicationCreation(ctx, framework, applicationName, username, usernamespace, applicationCreationTime) } @@ -1343,7 +1427,13 @@ func handleApplicationSuccess(ctx *JourneyContext, username, applicationName str SuccessfulApplicationCreationsPerThread[ctx.ThreadIndex] += 1 MetricsWrapper(MetricsController, metricsConstants.CollectorApplications, metricsConstants.MetricTypeCounter, metricsConstants.MetricSuccessfulApplicationCreationCounter) increaseBar(ctx.ApplicationsBar, applicationsBarMutex) - ctx.userAppsCompsMap.AddApplication(username, applicationName) + + // Transform applicationActualCreationTimeInSeconds from float64 to time.Duration + applicationActualCreationTimeInSecondsToDuration := time.Duration(applicationActualCreationTimeInSeconds * float64(time.Second)) + ApplicationCreationTimeSumPerThread[ctx.ThreadIndex] += applicationActualCreationTimeInSecondsToDuration + if applicationActualCreationTimeInSecondsToDuration > ApplicationCreationTimeMaxPerThread[ctx.ThreadIndex] { + ApplicationCreationTimeMaxPerThread[ctx.ThreadIndex] = applicationActualCreationTimeInSecondsToDuration + } } func handleApplicationFailure(ctx *JourneyContext, applicationName string, username string, err error, conditionError error) { @@ -1378,12 +1468,7 @@ func (h *ConcreteHandlerResources) handleIntegrationTestScenarioCreation(ctx *Jo return false } - ItsCreationTimeSumPerThread[ctx.ThreadIndex] += itsCreationTime MetricsWrapper(MetricsController, metricsConstants.CollectorIntegrationTestsSC, metricsConstants.MetricTypeGuage, metricsConstants.MetricIntegrationTestSenarioCreationTimeGauge, itsCreationTime.Seconds()) - if itsCreationTime > ItsCreationTimeMaxPerThread[ctx.ThreadIndex] { - ItsCreationTimeMaxPerThread[ctx.ThreadIndex] = itsCreationTime - } - return h.validateIntegrationTestScenarioCreation(ctx, framework, itsName, applicationName, username, usernamespace, itsCreationTime) } @@ -1454,7 +1539,13 @@ func handleItsSuccess(ctx *JourneyContext, itsName, username string, application SuccessfulItsCreationsPerThread[ctx.ThreadIndex] += 1 MetricsWrapper(MetricsController, metricsConstants.CollectorIntegrationTestsSC, metricsConstants.MetricTypeCounter, metricsConstants.MetricSuccessfulIntegrationTestSenarioCreationCounter) increaseBar(ctx.ItsBar, itsBarMutex) - ctx.userAppsCompsMap.AddIntegrationTestScenario(username, applicationName, itsName) + + // Transform itsActualCreationTimeInSeconds from float64 to time.Duration + itsActualCreationTimeInSecondsToDuration := time.Duration(itsActualCreationTimeInSeconds * float64(time.Second)) + ItsCreationTimeSumPerThread[ctx.ThreadIndex] += itsActualCreationTimeInSecondsToDuration + if itsActualCreationTimeInSecondsToDuration > ItsCreationTimeMaxPerThread[ctx.ThreadIndex] { + ItsCreationTimeMaxPerThread[ctx.ThreadIndex] = itsActualCreationTimeInSecondsToDuration + } } func handleItsFailure(ctx *JourneyContext, applicationName string, err, conditionError error) { @@ -1469,23 +1560,31 @@ func handleItsFailure(ctx *JourneyContext, applicationName string, err, conditio increaseBar(ctx.ItsBar, itsBarMutex) } -func (h *ConcreteHandlerResources) handleCDQCreation(ctx *JourneyContext, framework *framework.Framework, username, usernamespace, applicationName, cdqName string) (bool, *appstudioApi.ComponentDetectionQuery) { - klog.V(5).Infof("handleCDQCreation start username: %s, usernamespace: %s, applicationName: %s", username, usernamespace, applicationName) - defer klog.V(5).Infof("handleCDQCreation end username: %s, usernamespace: %s, applicationName: %s", username, usernamespace, applicationName) +func (h *ConcreteHandlerResources) handleCDQCreation(ctx *JourneyContext, framework *framework.Framework, username, usernamespace string) (bool, *appstudioApi.ComponentDetectionQuery) { + err, componentRepoRevisionFinal := handleRepoTemplating(ctx, framework, username, usernamespace) + if err != nil { + logError(30, fmt.Sprintf("Unable to template repository for user %s: %v", username, err)) + //FailedCDQCreationsPerThread[ctx.ThreadIndex] += 1 + //MetricsWrapper(MetricsController, metricsConstants.CollectorCDQ, metricsConstants.MetricTypeCounter, metricsConstants.MetricFailedCDQCreationCounter) + increaseBar(ctx.CDQsBar, cdqsBarMutex) + return false, nil + } + ApplicationName := fmt.Sprintf("%s-app", username) + ComponentDetectionQueryName := fmt.Sprintf("%s-cdq", username) startTimeForCDQ := time.Now() - cdq, err := framework.AsKubeDeveloper.HasController.CreateComponentDetectionQueryWithTimeout(cdqName, usernamespace, componentRepoUrl, "", "", "", false, 60*time.Minute) + cdq, err := framework.AsKubeDeveloper.HasController.CreateComponentDetectionQueryWithTimeout(ComponentDetectionQueryName, usernamespace, componentRepoUrl, componentRepoRevisionFinal, "", "", false, 60*time.Minute) cdqCreationTime := time.Since(startTimeForCDQ) if err != nil { - logError(9, fmt.Sprintf("Unable to create ComponentDetectionQuery %s: %v", cdqName, err)) + logError(9, fmt.Sprintf("Unable to create ComponentDetectionQuery %s: %v", ComponentDetectionQueryName, err)) FailedCDQCreationsPerThread[ctx.ThreadIndex] += 1 MetricsWrapper(MetricsController, metricsConstants.CollectorCDQ, metricsConstants.MetricTypeCounter, metricsConstants.MetricFailedCDQCreationCounter) increaseBar(ctx.CDQsBar, cdqsBarMutex) return false, nil } - if cdq.Name != cdqName { - logError(10, fmt.Sprintf("Actual cdq name (%s) does not match expected (%s): %v", cdq.Name, cdqName, err)) + if cdq.Name != ComponentDetectionQueryName { + logError(10, fmt.Sprintf("Actual cdq name (%s) does not match expected (%s): %v", cdq.Name, ComponentDetectionQueryName, err)) FailedCDQCreationsPerThread[ctx.ThreadIndex] += 1 MetricsWrapper(MetricsController, metricsConstants.CollectorCDQ, metricsConstants.MetricTypeCounter, metricsConstants.MetricFailedCDQCreationCounter) increaseBar(ctx.CDQsBar, cdqsBarMutex) @@ -1499,16 +1598,77 @@ func (h *ConcreteHandlerResources) handleCDQCreation(ctx *JourneyContext, framew return false, nil } - CDQCreationTimeSumPerThread[ctx.ThreadIndex] += cdqCreationTime MetricsWrapper(MetricsController, metricsConstants.CollectorCDQ, metricsConstants.MetricTypeGuage, metricsConstants.MetricCDQCreationTimeGauge, cdqCreationTime.Seconds()) - if cdqCreationTime > CDQCreationTimeMaxPerThread[ctx.ThreadIndex] { - CDQCreationTimeMaxPerThread[ctx.ThreadIndex] = cdqCreationTime + return h.validateCDQ(ctx, framework, ComponentDetectionQueryName, ApplicationName, username, usernamespace, cdqCreationTime) +} + +func handleRepoTemplating(ctx *JourneyContext, framework *framework.Framework, username, usernamespace string) (error, string) { + // Usual case, no repo templating takes place + if ! componentRepoTemplate { + return nil, componentRepoRevision + } + + // PaC testing, let's template repo and return branch name + var branchName string + var componentRepoName string + var err error + var exists bool + + // Parse just repo name out of url + regex := regexp.MustCompile(`/([^/]+)/?$`) + match := regex.FindStringSubmatch(componentRepoUrl) + if match != nil { + componentRepoName = match[1] + } else { + return fmt.Errorf("Failed to parse repo name out of url %s", componentRepoUrl), "" + } + + // Cleanup if it already exists + branchName = username + exists, err = framework.AsKubeAdmin.CommonController.Github.ExistsRef(componentRepoName, branchName) + if err != nil { + return err, "" + } + if exists { + klog.Errorf("Branch %s already exists, deleting it", branchName) + err := framework.AsKubeAdmin.CommonController.Github.DeleteRef(componentRepoName, branchName) + if err != nil { + return err, "" + } + } + + // Create branch + err = framework.AsKubeAdmin.CommonController.Github.CreateRef(componentRepoName, componentRepoRevision, "", branchName) + if err != nil { + return err, "" } - return h.validateCDQCreation(ctx, framework, cdqName, applicationName, username, usernamespace, cdqCreationTime) + // Template files we care about + fileList := []string{".tekton/multi-platform-test-pull-request.yaml", ".tekton/multi-platform-test-push.yaml"} + for _, file := range fileList { + fileResponse, err := framework.AsKubeAdmin.CommonController.Github.GetFile(componentRepoName, file, branchName) + if err != nil { + return err, "" + } + + fileContent, err2 := fileResponse.GetContent() + if err2 != nil { + return err2, "" + } + + fileContentNew := strings.ReplaceAll(fileContent, "NAMESPACE", usernamespace) + fileContentNew = strings.ReplaceAll(fileContentNew, "QUAY_REPO", quayRepo) + + _, err3 := framework.AsKubeAdmin.CommonController.Github.UpdateFile(componentRepoName, file, fileContentNew, branchName, *fileResponse.SHA) + if err3 != nil { + return err3, "" + } + } + + return nil, branchName } -func (h *ConcreteHandlerResources) validateCDQCreation(ctx *JourneyContext, framework *framework.Framework, cdqName, applicationName, username, usernamespace string, cdqCreationTime time.Duration) (bool, *appstudioApi.ComponentDetectionQuery) { +func (h *ConcreteHandlerResources) validateCDQ(ctx *JourneyContext, framework *framework.Framework, cdqName, ApplicationName, username, usernamespace string, cdqCreationTime time.Duration) (bool, *appstudioApi.ComponentDetectionQuery) { cdqValidationInterval := time.Second * 20 cdqValidationTimeout := time.Minute * 30 var conditionError error @@ -1549,7 +1709,7 @@ func (h *ConcreteHandlerResources) validateCDQCreation(ctx *JourneyContext, fram }, cdqValidationInterval, cdqValidationTimeout) if err != nil || conditionError != nil { - handleCdqFailure(ctx, applicationName, err, conditionError) + handleCdqFailure(ctx, ApplicationName, err, conditionError) return false, nil } return true, cdq @@ -1561,6 +1721,13 @@ func handleCdqSuccess(ctx *JourneyContext, cdqName string, cdqActualCreationTime SuccessfulCDQCreationsPerThread[ctx.ThreadIndex] += 1 MetricsWrapper(MetricsController, metricsConstants.CollectorCDQ, metricsConstants.MetricTypeCounter, metricsConstants.MetricSuccessfulCDQCreationCounter) increaseBar(ctx.CDQsBar, cdqsBarMutex) + + // Transform cdqActualCreationTimeInSeconds from float64 to time.Duration + cdqActualCreationTimeInSecondsToDuration := time.Duration(cdqActualCreationTimeInSeconds * float64(time.Second)) + CDQCreationTimeSumPerThread[ctx.ThreadIndex] += cdqActualCreationTimeInSecondsToDuration + if cdqActualCreationTimeInSecondsToDuration > CDQCreationTimeMaxPerThread[ctx.ThreadIndex] { + CDQCreationTimeMaxPerThread[ctx.ThreadIndex] = cdqActualCreationTimeInSecondsToDuration + } } func handleCdqFailure(ctx *JourneyContext, applicationName string, err, conditionError error) { @@ -1624,18 +1791,7 @@ func (h *ConcreteHandlerResources) handleComponentCreation(ctx *JourneyContext, increaseBar(ctx.ComponentsBar, componentsBarMutex) return false } - - ComponentCreationTimeSumPerThread[ctx.ThreadIndex] += componentCreationTime MetricsWrapper(MetricsController, metricsConstants.CollectorComponents, metricsConstants.MetricTypeGuage, metricsConstants.MetricComponentCreationTimeGauge, componentCreationTime.Seconds()) - if componentCreationTime > ComponentCreationTimeMaxPerThread[ctx.ThreadIndex] { - ComponentCreationTimeMaxPerThread[ctx.ThreadIndex] = componentCreationTime - } - - validated := h.validateComponent(ctx, framework, component.Name, applicationName, username, usernamespace, componentCreationTime) - if !validated { - logError(30, fmt.Sprintf("Validation of component name (%s) failed with: %v", component.Name, err)) - return false - } } ctx.ChPipelines <- username @@ -1698,7 +1854,14 @@ func handleComponentSuccess(ctx *JourneyContext, username, applicationName, comp SuccessfulComponentCreationsPerThread[ctx.ThreadIndex] += 1 MetricsWrapper(MetricsController, metricsConstants.CollectorComponents, metricsConstants.MetricTypeCounter, metricsConstants.MetricSuccessfulComponentCreationCounter) increaseBar(ctx.ComponentsBar, componentsBarMutex) - ctx.userAppsCompsMap.AddComponent(username, applicationName, componentName) + ctx.ChPipelines <- username + + // Transform componentActualCreationTimeInSeconds from float64 to time.Duration + componentActualCreationTimeInSecondsToDuration := time.Duration(componentActualCreationTimeInSeconds * float64(time.Second)) + ComponentCreationTimeSumPerThread[ctx.ThreadIndex] += componentActualCreationTimeInSecondsToDuration + if componentActualCreationTimeInSecondsToDuration > ComponentCreationTimeMaxPerThread[ctx.ThreadIndex] { + ComponentCreationTimeMaxPerThread[ctx.ThreadIndex] = componentActualCreationTimeInSecondsToDuration + } } func handleComponentFailure(ctx *JourneyContext, applicationName string, err, conditionError error) { @@ -2127,7 +2290,6 @@ func (h *ConcreteHandlerDeployments) validateDeploymentCreation(ctx *JourneyCont err := k8swait.PollUntilContextTimeout(context.Background(), deploymentCreatedRetryInterval, deploymentCreatedTimeout, false, func(ctx context.Context) (done bool, err error) { _, err = framework.AsKubeDeveloper.CommonController.GetDeployment(componentName, usernamespace) if err != nil { - klog.Infof("Unable getting deployment - %v", err) time.Sleep(time.Millisecond * time.Duration(rand.IntnRange(10, 200))) return false, nil } diff --git a/pkg/clients/github/git.go b/pkg/clients/github/git.go index d8cbc9641..ef36f2393 100644 --- a/pkg/clients/github/git.go +++ b/pkg/clients/github/git.go @@ -6,9 +6,8 @@ import ( "strings" "time" - . "github.com/onsi/gomega" - "github.com/google/go-github/v44/github" + "github.com/redhat-appstudio/e2e-tests/pkg/utils" ) func (g *Github) DeleteRef(repository, branchName string) error { @@ -39,12 +38,19 @@ func (g *Github) CreateRef(repository, baseBranchName, sha, newBranchName string if err != nil { return fmt.Errorf("error when creating a new branch '%s' for the repo '%s': %+v", newBranchName, repository, err) } - Eventually(func(gomega Gomega) { + err = utils.WaitUntilWithInterval(func() (done bool, err error) { exist, err := g.ExistsRef(repository, newBranchName) - gomega.Expect((err)).NotTo(HaveOccurred()) - gomega.Expect(exist).To(BeTrue()) - - }, 2*time.Minute, 2*time.Second).Should(Succeed()) //Wait for the branch to actually exist + if err != nil { + return false, err + } + if exist && err == nil { + return exist, err + } + return false, nil + }, 2*time.Second, 2*time.Minute) //Wait for the branch to actually exist + if err != nil { + return fmt.Errorf("Failed waiting for repo being done: %+v", err) + } return nil } diff --git a/tests/load-tests/ci-scripts/collect-results.sh b/tests/load-tests/ci-scripts/collect-results.sh index f33538952..8070cfc04 100755 --- a/tests/load-tests/ci-scripts/collect-results.sh +++ b/tests/load-tests/ci-scripts/collect-results.sh @@ -23,6 +23,7 @@ find "$output_dir" -type f -name '*.pprof' -exec cp -vf {} "${ARTIFACT_DIR}" \; pipelineruns_json=$ARTIFACT_DIR/pipelineruns.json taskruns_json=$ARTIFACT_DIR/taskruns.json pods_json=$ARTIFACT_DIR/pods.json +buildpipelineselectors_json=$ARTIFACT_DIR/buildpipelineselectors.json application_timestamps=$ARTIFACT_DIR/applications.appstudio.redhat.com_timestamps application_timestamps_csv=${application_timestamps}.csv @@ -182,6 +183,9 @@ jq -r ".items[] | .spec.nodeName" "$pods_json" | sort | uniq -c | sed -e 's,\s\+ echo "Node;Pods" >"$task_pods_distribution_csv" jq -r '.items[] | select(.metadata.labels."appstudio.openshift.io/application" != null).spec.nodeName' "$pods_json" | sort | uniq -c | sed -e 's,\s\+\([0-9]\+\)\s\+\(.*\),\2;\1,g' >>"$task_pods_distribution_csv" +## Record BuildPipelineSelectors +oc get BuildPipelineSelectors -A -o json >"$buildpipelineselectors_json" + ## Tekton Artifact Performance Analysis tapa_dir=./tapa.git diff --git a/tests/load-tests/ci-scripts/setup-cluster.sh b/tests/load-tests/ci-scripts/setup-cluster.sh index 9f40a48cc..d4e737aca 100755 --- a/tests/load-tests/ci-scripts/setup-cluster.sh +++ b/tests/load-tests/ci-scripts/setup-cluster.sh @@ -58,10 +58,15 @@ if [ "${TEKTON_PERF_ENABLE_CPU_PROFILING:-}" == "true" ] || [ "${TEKTON_PERF_ENA oc patch -n tekton-results cm tekton-results-config-observability --type=json -p='[{"op": "add", "path": "/data/profiling.enable", "value": "true"}]' fi +## Patch Build Service github secret +echo "Patching Build Service github token" +oc patch -n build-service secret pipelines-as-code-secret --type=json -p='[{"op": "add", "path": "/data/password", "value": "'"$(cat /usr/local/ci-secrets/redhat-appstudio-load-test/github-token | tr -d "\n" | base64 -w0)"'"}]' +oc rollout restart deployment -n build-service +oc rollout status deployment -n build-service -w + ## Patch HAS github secret echo "Patching HAS github tokens" -oc patch -n application-service secret has-github-token --type=json -p='[{"op": "add", "path": "/data/tokens", "value": "'"$(base64 -w0