From cd0ff7d57209d26d0f1e2f5bc0669e46828923a1 Mon Sep 17 00:00:00 2001 From: Jorge Romero Date: Thu, 22 Jun 2023 12:54:33 +0200 Subject: [PATCH 01/72] Refactor and add new feature to improve automatic tests of the QS --- tests/Makefile | 4 +- tests/quickstarter-test.sh | 115 ++++--- tests/quickstarter/bitbucket.go | 1 + tests/quickstarter/quickstarter_test.go | 348 +++++++++++++--------- tests/quickstarter/steps.go | 21 +- tests/scripts/free-unused-resources.sh | 18 +- tests/scripts/print-sonar-scan-run.sh | 10 +- tests/scripts/upload-file-to-bitbucket.sh | 60 +++- tests/utils/constants.go | 7 - tests/utils/environment.go | 10 + tests/utils/filter-quickstarters.go | 55 ++++ tests/utils/openshift-client.go | 15 +- tests/utils/project_names.go | 15 + 13 files changed, 444 insertions(+), 235 deletions(-) delete mode 100644 tests/utils/constants.go create mode 100644 tests/utils/environment.go create mode 100644 tests/utils/filter-quickstarters.go create mode 100644 tests/utils/project_names.go diff --git a/tests/Makefile b/tests/Makefile index 56fa45058..5c2fc9677 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -9,6 +9,7 @@ QS := ods-quickstarters/... ### By default we do not parallelize tests PARALLEL := 1 +PROJECT := unitt ## Full test of existing ODS core installation. Caution: Creates UNITT project and ODSVERIFY project. test: smoketest verify test-create-projects @@ -35,12 +36,13 @@ test-create-projects: ## Run quickstarter tests within existing ODS installation. Depends on UNITT project. test-quickstarter: - @(./quickstarter-test.sh $(QS) $(PARALLEL)) + @(./quickstarter-test.sh $(PROJECT) $(QS) $(PARALLEL)) .PHONY: test-quickstarter ## Install tools required for tests. prep-tools: which go-junit-report || go get github.com/jstemmer/go-junit-report + which golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.50.0 .PHONY: prep-tools ## Lint diff --git a/tests/quickstarter-test.sh b/tests/quickstarter-test.sh index ff78c1db4..716686c30 100755 --- a/tests/quickstarter-test.sh +++ b/tests/quickstarter-test.sh @@ -7,58 +7,83 @@ THIS_SCRIPT="$(basename $0)" # By default we run all quickstarter tests, otherwise just the quickstarter # passed as the first argument to this script. -QUICKSTARTER=${1-"ods-quickstarters/..."} -PARALLEL=${2-"1"} +BITBUCKET_TEST_PROJECT="unitt" +QUICKSTARTER="ods-quickstarters/..." +PARALLEL="1" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ODS_CORE_DIR=${SCRIPT_DIR%/*} -if ! oc whoami &> /dev/null; then - echo "${THIS_SCRIPT}: You need to login to OpenShift to run the tests" - echo "${THIS_SCRIPT}: Returning with exit code 1" - exit 1 -fi +function check_already_logged_in_openshift(){ + if ! oc whoami &> /dev/null; then + echo "${THIS_SCRIPT}: You need to login to OpenShift to run the tests" + echo "${THIS_SCRIPT}: Returning with exit code 1" + exit 1 + fi +} -if [ -f test-quickstarter-results.txt ]; then - rm test-quickstarter-results.txt -fi +function cleanup_workspace(){ + if [ -f test-quickstarter-results.txt ]; then + rm test-quickstarter-results.txt + fi +} -BITBUCKET_TEST_PROJECT="unitt" -echo "Setup Bitbucket test project ${BITBUCKET_TEST_PROJECT} ..." -BITBUCKET_URL=$(${ODS_CORE_DIR}/scripts/get-config-param.sh BITBUCKET_URL) -CD_USER_ID=$(${ODS_CORE_DIR}/scripts/get-config-param.sh CD_USER_ID) -CD_USER_PWD_B64=$(${ODS_CORE_DIR}/scripts/get-config-param.sh CD_USER_PWD_B64) -./scripts/setup-bitbucket-test-project.sh \ - --bitbucket=${BITBUCKET_URL} \ - --user=${CD_USER_ID} \ - --password=$(base64 -d - <<< ${CD_USER_PWD_B64}) \ - --project=${BITBUCKET_TEST_PROJECT} - -echo " " -echo "${THIS_SCRIPT}: Cleaning a little bit the host machine to not suffer from limitated resources... " -echo " " -if [ -f ./scripts/free-unused-resources.sh ]; then - chmod +x ./scripts/free-unused-resources.sh - ./scripts/free-unused-resources.sh || true -else - echo "Not found script ./scripts/free-unused-resources.sh " -fi +function run_test(){ + echo " " + echo "${THIS_SCRIPT}: Running tests (${QUICKSTARTER}). Output will take a while to arrive ..." + echo " " + + + # Should fix error " panic: test timed out after " + echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER}" + go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER} ${BITBUCKET_TEST_PROJECT} | tee test-quickstarter-results.txt 2>&1 + + exitcode="${PIPESTATUS[0]}" + + if [ -f test-quickstarter-results.txt ]; then + go-junit-report < test-quickstarter-results.txt > test-quickstarter-report.xml + fi + + echo " " + echo " " + echo "${THIS_SCRIPT}: Returning with exit code ${exitcode}" + echo " " + echo " " + exit $exitcode +} -echo " " -echo "${THIS_SCRIPT}: Running tests (${QUICKSTARTER}). Output will take a while to arrive ..." -echo " " -# Should fix error " panic: test timed out after " -echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER}" -go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER} | tee test-quickstarter-results.txt 2>&1 -exitcode="${PIPESTATUS[0]}" -if [ -f test-quickstarter-results.txt ]; then - go-junit-report < test-quickstarter-results.txt > test-quickstarter-report.xml +function usage { + printf "Run quickstarters tests.\n\n" + printf "\t-h |--help\t\tPrint usage\n" + printf "\t-p |--project\t\tBitbucket project (* mandatory)\n" + printf "\t-pa|--parallel\t\tNumber of test executed in parallel\n" + printf "\t-q |--quickstarter\tQuickStarter to test or Quickstarter folder (default:ods-quickstarters/...)\n" +} + +while [[ "$#" -gt 0 ]]; do + case $1 in + + -h|--help) usage; exit 0;; + + -pa|--parallel) PARALLEL="$2"; shift;; + -pa=*|--parallel=*) PARALLEL="${1#*=}";; + + -q|--quickstarter) QUICKSTARTER="$2"; shift;; + -q=*|--quickstarter=*) QUICKSTARTER="${1#*=}";; + + -p|--project) BITBUCKET_TEST_PROJECT="$2"; shift;; + -p=*|--project=*) BITBUCKET_TEST_PROJECT="${1#*=}";; + + *) echo_error "Unknown parameter passed: $1"; exit 1;; +esac; shift; done + +if [ -z "${BITBUCKET_TEST_PROJECT}" ]; then + echo "--project is mandatory" + usage + exit 1 fi -echo " " -echo " " -echo "${THIS_SCRIPT}: Returning with exit code ${exitcode}" -echo " " -echo " " -exit $exitcode +check_already_logged_in_openshift +cleanup_workspace +run_test \ No newline at end of file diff --git a/tests/quickstarter/bitbucket.go b/tests/quickstarter/bitbucket.go index c962ba236..642478689 100644 --- a/tests/quickstarter/bitbucket.go +++ b/tests/quickstarter/bitbucket.go @@ -20,6 +20,7 @@ func recreateBitbucketRepo(config map[string]string, project string, repo string fmt.Sprintf("--password=%s", password), fmt.Sprintf("--project=%s", project), fmt.Sprintf("--repository=%s", repo), + "--insecure", }, []string{}) if err != nil { diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 2e7e72872..2581b30aa 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -28,7 +28,9 @@ func TestQuickstarter(t *testing.T) { var quickstarterPaths []string odsCoreRootPath := "../.." - target := os.Args[len(os.Args)-1] + project := os.Args[len(os.Args)-1] + utils.Set_project_name(project) + target := os.Args[len(os.Args)-2] if strings.HasPrefix(target, ".") || strings.HasPrefix(target, "/") { if strings.HasSuffix(target, "...") { quickstarterPaths = collectTestableQuickstarters( @@ -51,12 +53,17 @@ func TestQuickstarter(t *testing.T) { quickstarterPaths = []string{fmt.Sprintf("%s/../%s", odsCoreRootPath, target)} } } + dir, err := os.Getwd() + if err != nil { + fmt.Println("Error:", err) + return + } + quickstarterPaths = utils.RemoveExcludedQuickstarters(t, dir, quickstarterPaths) config, err := utils.ReadConfiguration() if err != nil { t.Fatal(err) } - cdUserPassword, err := b64.StdEncoding.DecodeString(config["CD_USER_PWD_B64"]) if err != nil { t.Fatalf("Error decoding cd_user password: %s", err) } @@ -76,9 +83,6 @@ func TestQuickstarter(t *testing.T) { fmt.Printf("Running tests for quickstarter %s\n", quickstarterName) fmt.Printf("\n\n") - freeUnusedResources(t) - restartAtlassianSuiteIfLicenseExpiresInLessThan(t) - // Run each quickstarter test in a subtest to avoid exiting early // when t.Fatal is used. t.Run(quickstarterName, func(t *testing.T) { @@ -103,166 +107,227 @@ func TestQuickstarter(t *testing.T) { ) repoName := fmt.Sprintf("%s-%s", strings.ToLower(utils.PROJECT_NAME), step.ComponentID) + tmplData := templateData(config, step.ComponentID, "") if step.Type == "upload" { - if len(step.UploadParams.Filename) == 0 { - step.UploadParams.Filename = filepath.Base(step.UploadParams.File) - } - stdout, stderr, err := utils.RunScriptFromBaseDir("tests/scripts/upload-file-to-bitbucket.sh", []string{ - fmt.Sprintf("--bitbucket=%s", config["BITBUCKET_URL"]), - fmt.Sprintf("--user=%s", config["CD_USER_ID"]), - fmt.Sprintf("--password=%s", cdUserPassword), - fmt.Sprintf("--project=%s", utils.PROJECT_NAME), - fmt.Sprintf("--repository=%s", repoName), - fmt.Sprintf("--file=%s/%s", testdataPath, step.UploadParams.File), - fmt.Sprintf("--filename=%s", step.UploadParams.Filename), - }, []string{}) - - if err != nil { - t.Fatalf( - "Execution of `upload-file-to-bitbucket.sh` failed: \nStdOut: %s\nStdErr: %s\nErr: %s\n", - stdout, - stderr, - err) - } else { - fmt.Printf("Uploaded file %s to %s\n", step.UploadParams.File, config["BITBUCKET_URL"]) - } + executeStepUpload(t, step, testdataPath, tmplData, repoName, config) + continue + } + + if step.Type == "run" { + executeStepRun(t, step, testdataPath) continue } - var request utils.RequestBuild - var pipelineName string - var jenkinsfile string - var verify *TestStepVerify - tmplData := templateData(config, step.ComponentID, "") if step.Type == "provision" { - // cleanup and create bb resources for this test - err = recreateBitbucketRepo(config, utils.PROJECT_NAME, repoName) - if err != nil { - t.Fatal(err) - } - err = deleteOpenShiftResources(utils.PROJECT_NAME, step.ComponentID, utils.PROJECT_NAME_DEV) - if err != nil { - t.Fatal(err) - } - branch := config["ODS_GIT_REF"] - if len(step.ProvisionParams.Branch) > 0 { - branch = renderTemplate(t, step.ProvisionParams.Branch, tmplData) - } - agentImageTag := config["ODS_IMAGE_TAG"] - if len(step.ProvisionParams.AgentImageTag) > 0 { - agentImageTag = renderTemplate(t, step.ProvisionParams.AgentImageTag, tmplData) - } - sharedLibraryRef := agentImageTag - if len(step.ProvisionParams.SharedLibraryRef) > 0 { - sharedLibraryRef = renderTemplate(t, step.ProvisionParams.SharedLibraryRef, tmplData) - } - env := []utils.EnvPair{ - { - Name: "ODS_NAMESPACE", - Value: config["ODS_NAMESPACE"], - }, - { - Name: "ODS_GIT_REF", - Value: config["ODS_GIT_REF"], - }, - { - Name: "ODS_IMAGE_TAG", - Value: config["ODS_IMAGE_TAG"], - }, - { - Name: "ODS_BITBUCKET_PROJECT", - Value: config["ODS_BITBUCKET_PROJECT"], - }, - { - Name: "AGENT_IMAGE_TAG", - Value: agentImageTag, - }, - { - Name: "SHARED_LIBRARY_REF", - Value: sharedLibraryRef, - }, - { - Name: "PROJECT_ID", - Value: utils.PROJECT_NAME, - }, - { - Name: "COMPONENT_ID", - Value: step.ComponentID, - }, - { - Name: "GIT_URL_HTTP", - Value: fmt.Sprintf("%s/%s/%s.git", config["REPO_BASE"], utils.PROJECT_NAME, repoName), - }, - } - request = utils.RequestBuild{ - Repository: quickstarterRepo, - Branch: branch, - Project: config["ODS_BITBUCKET_PROJECT"], - Env: append(env, step.ProvisionParams.Env...), - } - // If quickstarter is overwritten, use that value. Otherwise - // we use the quickstarter under test. - if len(step.ProvisionParams.Quickstarter) > 0 { - jenkinsfile = fmt.Sprintf("%s/Jenkinsfile", step.ProvisionParams.Quickstarter) - } else { - jenkinsfile = fmt.Sprintf("%s/Jenkinsfile", quickstarterName) - } - pipelineName = step.ProvisionParams.Pipeline - verify = step.ProvisionParams.Verify - } else if step.Type == "build" { - branch := "master" - if len(step.BuildParams.Branch) > 0 { - branch = renderTemplate(t, step.BuildParams.Branch, tmplData) - } - request = utils.RequestBuild{ - Repository: repoName, - Branch: branch, - Project: utils.PROJECT_NAME, - Env: step.BuildParams.Env, - } - jenkinsfile = "Jenkinsfile" - pipelineName = step.BuildParams.Pipeline - verify = step.BuildParams.Verify + executeProvision(t, step, testdataPath, tmplData, repoName, quickstarterRepo, quickstarterName, config) + continue } - buildName, err := utils.RunJenkinsPipeline(jenkinsfile, request, pipelineName) - if err != nil { - t.Fatal(err) + + if step.Type == "build" { + executeBuild(t, step, testdataPath, tmplData, repoName, config) + continue } - verifyPipelineRun(t, step, verify, testdataPath, repoName, buildName, config) + t.Fatal("Unknown step") + } + + fmt.Printf("\n\n\n\n") + fmt.Printf("========== End test for Quickstarter %s\n", quickstarterName) + fmt.Printf("\n\n") }) + + } + +} + +func executeProvision(t *testing.T, step TestStep, testdataPath string, tmplData TemplateData, repoName string, quickstarterRepo string, quickstarterName string, config map[string]string) { + // cleanup and create bb resources for this test + err := recreateBitbucketRepo(config, utils.PROJECT_NAME, repoName) + if err != nil { + t.Fatal(err) + } + err = deleteOpenShiftResources(utils.PROJECT_NAME, step.ComponentID, utils.PROJECT_NAME_DEV) + if err != nil { + t.Fatal(err) + } + branch := config["ODS_GIT_REF"] + if len(step.ProvisionParams.Branch) > 0 { + branch = renderTemplate(t, step.ProvisionParams.Branch, tmplData) + } + agentImageTag := config["ODS_IMAGE_TAG"] + if len(step.ProvisionParams.AgentImageTag) > 0 { + agentImageTag = renderTemplate(t, step.ProvisionParams.AgentImageTag, tmplData) + } + sharedLibraryRef := agentImageTag + if len(step.ProvisionParams.SharedLibraryRef) > 0 { + sharedLibraryRef = renderTemplate(t, step.ProvisionParams.SharedLibraryRef, tmplData) + } + env := []utils.EnvPair{ + { + Name: "ODS_NAMESPACE", + Value: config["ODS_NAMESPACE"], + }, + { + Name: "ODS_GIT_REF", + Value: config["ODS_GIT_REF"], + }, + { + Name: "ODS_IMAGE_TAG", + Value: config["ODS_IMAGE_TAG"], + }, + { + Name: "ODS_BITBUCKET_PROJECT", + Value: config["ODS_BITBUCKET_PROJECT"], + }, + { + Name: "AGENT_IMAGE_TAG", + Value: agentImageTag, + }, + { + Name: "SHARED_LIBRARY_REF", + Value: sharedLibraryRef, + }, + { + Name: "PROJECT_ID", + Value: utils.PROJECT_NAME, + }, + { + Name: "COMPONENT_ID", + Value: step.ComponentID, + }, + { + Name: "GIT_URL_HTTP", + Value: fmt.Sprintf("%s/%s/%s.git", config["REPO_BASE"], utils.PROJECT_NAME, repoName), + }, + } + request := utils.RequestBuild{ + Repository: quickstarterRepo, + Branch: branch, + Project: config["ODS_BITBUCKET_PROJECT"], + Env: append(env, step.ProvisionParams.Env...), } + + t.Cleanup(func() { + err = deleteOpenShiftResources(utils.PROJECT_NAME, step.ComponentID, utils.PROJECT_NAME_DEV) + }) + + // If quickstarter is overwritten, use that value. Otherwise + // we use the quickstarter under test. + var jenkinsfile string + if len(step.ProvisionParams.Quickstarter) > 0 { + jenkinsfile = fmt.Sprintf("%s/Jenkinsfile", step.ProvisionParams.Quickstarter) + } else { + jenkinsfile = fmt.Sprintf("%s/Jenkinsfile", quickstarterName) + } + pipelineName := step.ProvisionParams.Pipeline + verify := step.ProvisionParams.Verify + + buildName, err := utils.RunJenkinsPipeline(jenkinsfile, request, pipelineName) + if err != nil { + t.Fatal(err) + } + verifyPipelineRun(t, step, verify, testdataPath, repoName, buildName, config) +} + +func executeBuild(t *testing.T, step TestStep, testdataPath string, tmplData TemplateData, repoName string, config map[string]string) { + branch := "master" + if len(step.BuildParams.Branch) > 0 { + branch = renderTemplate(t, step.BuildParams.Branch, tmplData) + } + request := utils.RequestBuild{ + Repository: repoName, + Branch: branch, + Project: utils.PROJECT_NAME, + Env: step.BuildParams.Env, + } + jenkinsfile := "Jenkinsfile" + pipelineName := step.BuildParams.Pipeline + verify := step.BuildParams.Verify + + buildName, err := utils.RunJenkinsPipeline(jenkinsfile, request, pipelineName) + if err != nil { + t.Fatal(err) + } + verifyPipelineRun(t, step, verify, testdataPath, repoName, buildName, config) } -func freeUnusedResources(t *testing.T) { +func executeStepUpload(t *testing.T, step TestStep, testdataPath string, tmplData TemplateData, repoName string, config map[string]string) { + if step.UploadParams == nil || len(step.UploadParams.File) == 0 { + t.Fatalf("Missing upload parameters.") + } + if len(step.UploadParams.Filename) == 0 { + step.UploadParams.Filename = filepath.Base(step.UploadParams.File) + } + cdUserPassword, err := b64.StdEncoding.DecodeString(config["CD_USER_PWD_B64"]) + if err != nil { + t.Fatalf("Execution of `upload-file-to-bitbucket.sh` failed: \nErr: %s\n", err) + } - // Run cleanup operations to ensure we always have enough resources. - stdout, stderr, err := utils.RunScriptFromBaseDir( - "tests/scripts/free-unused-resources.sh", - []string{}, []string{}, - ) + fileToUpload := fmt.Sprintf("%s/%s", testdataPath, step.UploadParams.File) + if step.UploadParams.Render { + fmt.Printf("Rendering template to upload") + tmpl, err := template.ParseFiles(fileToUpload) + if err != nil { + fmt.Errorf("Failed to load file to upload: %w", err) + return + } + outputFile, err := os.Create(fileToUpload) + if err != nil { + fmt.Errorf("Error creating output file: %w", err) + return + } + defer outputFile.Close() + fmt.Printf("Execute render") + err = tmpl.Execute(outputFile, tmplData) + if err != nil { + fmt.Errorf("Failed to render file: %w", err) + return + } + } + + stdout, stderr, err := utils.RunScriptFromBaseDir("tests/scripts/upload-file-to-bitbucket.sh", []string{ + fmt.Sprintf("--bitbucket=%s", config["BITBUCKET_URL"]), + fmt.Sprintf("--user=%s", config["CD_USER_ID"]), + fmt.Sprintf("--password=%s", cdUserPassword), + fmt.Sprintf("--project=%s", utils.PROJECT_NAME), + fmt.Sprintf("--repository=%s", repoName), + fmt.Sprintf("--file=%s", fileToUpload), + fmt.Sprintf("--filename=%s", step.UploadParams.Filename), + }, []string{}) + fmt.Printf("%s", stdout) if err != nil { - t.Fatalf("Error cleaning up : \nStdOut: %s\nStdErr: %s\nErr: %s\n", stdout, stderr, err) + t.Fatalf( + "Execution of `upload-file-to-bitbucket.sh` failed: \nStdOut: %s\nStdErr: %s\nErr: %s\n", + stdout, + stderr, + err) } else { - fmt.Printf("Cleaned cluster state.\n") + fmt.Printf("Uploaded file %s to %s\n", step.UploadParams.File, config["BITBUCKET_URL"]) } } -func restartAtlassianSuiteIfLicenseExpiresInLessThan(t *testing.T) { +func executeStepRun(t *testing.T, step TestStep, testdataPath string) { + if step.RunParams == nil || len(step.RunParams.File) == 0 { + t.Fatalf("Missing run parameters, not defined script file.") + } - // Run cleanup operations to ensure we always have enough resources. - stdout, stderr, err := utils.RunScriptFromBaseDir( - "ods-devenv/scripts/restart-atlassian-suite-if-license-expires-in-less-than.sh", - []string{"--hours-left", "2"}, []string{}, - ) + fmt.Printf("Executing script: %s\n", step.RunParams.File) + step.RunParams.File = fmt.Sprintf("%s/%s", testdataPath, step.RunParams.File) + stdout, stderr, err := utils.RunCommand(step.RunParams.File, []string{}, []string{}) + fmt.Printf("%s", stdout) if err != nil { - t.Fatalf("Error cleaning up : \nStdOut: %s\nStdErr: %s\nErr: %s\n", stdout, stderr, err) + t.Fatalf( + "Execution of script:%s failed: \nStdOut: %s\nStdErr: %s\nErr: %s\n", + step.RunParams.File, + stdout, + stderr, + err) } else { - fmt.Printf("Checked if needed to restart atlassian suite.\n") + fmt.Printf("Executed script: %s\n", step.RunParams.File) } } @@ -295,6 +360,7 @@ func templateData(config map[string]string, componentID string, buildName string buildParts := strings.Split(buildName, "-") buildNumber = buildParts[len(buildParts)-1] } + aquaEnabled, _ := strconv.ParseBool(config["AQUA_ENABLED"]) return TemplateData{ ProjectID: utils.PROJECT_NAME, ComponentID: componentID, @@ -304,6 +370,8 @@ func templateData(config map[string]string, componentID string, buildName string OdsBitbucketProject: config["ODS_BITBUCKET_PROJECT"], SanitizedOdsGitRef: sanitizedOdsGitRef, BuildNumber: buildNumber, + SonarQualityProfile: utils.GetEnv("SONAR_QUALITY_PROFILE", "Sonar way"), + AquaEnabled: aquaEnabled, } } diff --git a/tests/quickstarter/steps.go b/tests/quickstarter/steps.go index 55e118f92..ae441cd81 100644 --- a/tests/quickstarter/steps.go +++ b/tests/quickstarter/steps.go @@ -34,6 +34,14 @@ type TestStep struct { BuildParams *TestStepBuildParams `json:"buildParams"` // Parameters for "upload" step type UploadParams *TestStepUploadParams `json:"uploadParams"` + // Parameters for "run" step type + RunParams *TestStepRunParams `json:"runParams"` +} + +// TestStepUploadParams defines the parameters for the "provision" step type. +type TestStepRunParams struct { + // File to execute relative to "testdata" directory + File string `json:"file"` } // TestStepUploadParams defines the parameters for the "provision" step type. @@ -42,6 +50,8 @@ type TestStepUploadParams struct { File string `json:"file"` // Name of the uploaded file in the repository. Defaults to just the filename of +File+. Filename string `json:"filename"` + // In case this is a template file that we want to render. + Render bool `json:"render"` } // TestStepProvisionParams defines the parameters for the "provision" step type. @@ -105,9 +115,8 @@ type TestStepVerify struct { // TemplateData holds template parameters. Those will be applied to all // values defined in the steps, as they are treated as Go templates. // For example, Jenkins run attachments can be defined like this: -// -// runAttachments: -// - SCRR-{{.ProjectID}}-{{.ComponentID}}.docx, and then the +// runAttachments: +// - SCRR-{{.ProjectID}}-{{.ComponentID}}.docx, and then the type TemplateData struct { // Project ID (the prefix of the *-cd, *-dev and *-test namespaces). ProjectID string @@ -126,6 +135,10 @@ type TemplateData struct { SanitizedOdsGitRef string // Jenkins Build number BuildNumber string + // Name of the Sonar Quality Profile + SonarQualityProfile string + // Is enable Aqua + AquaEnabled bool } // readSteps reads "steps.yml" in given folder. @@ -149,7 +162,7 @@ func readSteps(folder string) (*TestSteps, error) { } // A poor man's workaround for missing enums in Go. There are better ways // to do it, but nothing as simple as this. - allowedTypes := map[string]bool{"provision": true, "build": true, "upload": true} + allowedTypes := map[string]bool{"provision": true, "build": true, "upload": true, "run": true} for i, step := range s.Steps { if _, ok := allowedTypes[step.Type]; !ok { allowed := []string{} diff --git a/tests/scripts/free-unused-resources.sh b/tests/scripts/free-unused-resources.sh index 83890c00c..4fdd24ac9 100755 --- a/tests/scripts/free-unused-resources.sh +++ b/tests/scripts/free-unused-resources.sh @@ -2,8 +2,6 @@ echo " " -ME=$(basename $0) - function clean_containers { echo "Removing docker containers no more used... " if docker ps -a | grep -q 'Exited .* ago' ; then @@ -29,7 +27,6 @@ function clean_tests { } function clean_odsverify { - echo "Cleaning projects ODS__VERIFY... " if [ "true" == "$CLEAN_ODS_VERIFY" ]; then echo "Removing ODS VERIFY projects..." oc projects | grep '^\s*odsverify.*' | while read -r line; do @@ -44,14 +41,14 @@ function clean_odsverify { } function clean_images { - echo "Cleaning OC images" echo "oc adm prune images --keep-tag-revisions=1 --keep-younger-than=30m --confirm" oc adm prune images --keep-tag-revisions=1 --keep-younger-than=30m --confirm || true } function usage { + ME=$(basename $0) echo " " - echo "usage: ${ME} [--odsVerify] [--omitTests] [--omitTestsProject tes22]" + echo "usage: ${ME} [--odsVerify] [--omitTestsProject tes22]" echo " " } @@ -62,7 +59,6 @@ function echo_error() { OMIT_TESTS_PROJECT=none CLEAN_ODS_VERIFY="false" -CLEAN_TESTS="false" while [[ "$#" -gt 0 ]]; do case $1 in @@ -75,19 +71,11 @@ while [[ "$#" -gt 0 ]]; do --omitTestsProject) OMIT_TESTS_PROJECT="$2"; echo "Tests to omit: $OMIT_TESTS_PROJECT"; shift;; - --cleanTests) CLEAN_TESTS="true";; - *) echo_error "Unknown parameter passed: $1"; exit 1;; esac; shift; done clean_containers -if [ "true" == "${CLEAN_TESTS}" ]; then - clean_tests -else - echo " " - echo "${ME}: INFO: Not cleaning tests" - echo " " -fi +clean_tests clean_odsverify clean_images diff --git a/tests/scripts/print-sonar-scan-run.sh b/tests/scripts/print-sonar-scan-run.sh index da64b53ca..a76b46373 100755 --- a/tests/scripts/print-sonar-scan-run.sh +++ b/tests/scripts/print-sonar-scan-run.sh @@ -2,4 +2,12 @@ set -eu set -o pipefail -curl -sS --insecure -u $1: $2/api/navigation/component?componentKey=$3 | jq 'del(.analysisDate)' | jq 'del(.version)' | jq 'del(.id)' | jq 'del(.qualityProfiles[].key)' | jq 'del(.qualityGate.key)' | jq 'del (.extensions[] | select(.))' +curl -sS --insecure -u $1: $2/api/navigation/component?component=$3 | \ +jq 'del(.analysisDate)' | \ +jq 'del(.version)' | \ +jq 'del(.id)' | \ +jq 'del(.qualityProfiles[].key)' | \ +jq 'del(.qualityGate.key)' | \ +jq 'del(.extensions[] | select(.))' | \ +jq 'del(.qualityProfiles[] | select(.language == "xml"))' | \ +jq 'del(.organization)' diff --git a/tests/scripts/upload-file-to-bitbucket.sh b/tests/scripts/upload-file-to-bitbucket.sh index c5166685c..80d344a99 100755 --- a/tests/scripts/upload-file-to-bitbucket.sh +++ b/tests/scripts/upload-file-to-bitbucket.sh @@ -76,24 +76,56 @@ while [[ "$#" -gt 0 ]]; do *) echo_error "Unknown parameter passed: $1"; exit 1;; esac; shift; done -lastCommit=$(curl --insecure -sS \ - -u "${BITBUCKET_USER}:${BITBUCKET_PWD}" \ - "${BITBUCKET_URL}/rest/api/latest/projects/${BITBUCKET_PROJECT}/repos/${REPOSITORY}/commits" | jq .values[0].id | sed 's|\"||g') - -echo "last commit: ${lastCommit}" - httpCode=$(curl --insecure -sS \ -u "${BITBUCKET_USER}:${BITBUCKET_PWD}" \ - -X PUT \ - -F branch=$BRANCH \ - -F sourceCommitId=$lastCommit \ - -F "comment=ods test" \ - -F "content=@${FILE}" \ - -F filename=blob \ + -X GET \ "${BITBUCKET_URL}/rest/api/latest/projects/${BITBUCKET_PROJECT}/repos/${REPOSITORY}/browse/${REPO_FILE}" \ + -o /dev/null \ -w "%{http_code}") if [ $httpCode != "200" ]; then - echo "An error occured during update of ${BITBUCKET_URL}/rest/api/latest/projects/${BITBUCKET_PROJECT}/repos/${REPOSITORY}/browse/${REPO_FILE} - error:$httpCode" - exit 1 + echo "New file added to Bitbucket" + httpCode=$(curl --insecure -sS \ + -u "${BITBUCKET_USER}:${BITBUCKET_PWD}" \ + -X PUT \ + -F branch=$BRANCH \ + -F "comment=ods test" \ + -F "content=@${FILE}" \ + -F filename=blob \ + "${BITBUCKET_URL}/rest/api/latest/projects/${BITBUCKET_PROJECT}/repos/${REPOSITORY}/browse/${REPO_FILE}" \ + -o /dev/null \ + -w "%{http_code}") + + if [ $httpCode != "200" ]; then + echo "An error occured during creation of ${BITBUCKET_URL}/rest/api/latest/projects/${BITBUCKET_PROJECT}/repos/${REPOSITORY}/browse/${REPO_FILE} - error:$httpCode" + exit 1 + fi + +else + echo "File update" + + lastCommit=$(curl --insecure -sS \ + -u "${BITBUCKET_USER}:${BITBUCKET_PWD}" \ + "${BITBUCKET_URL}/rest/api/latest/projects/${BITBUCKET_PROJECT}/repos/${REPOSITORY}/commits" | jq .values[0].id | sed 's|\"||g') + + echo "last commit: ${lastCommit}" + + httpCode=$(curl --insecure -sS \ + -u "${BITBUCKET_USER}:${BITBUCKET_PWD}" \ + -X PUT \ + -F branch=$BRANCH \ + -F sourceCommitId=$lastCommit \ + -F "comment=ods test" \ + -F "content=@${FILE}" \ + -F filename=blob \ + "${BITBUCKET_URL}/rest/api/latest/projects/${BITBUCKET_PROJECT}/repos/${REPOSITORY}/browse/${REPO_FILE}" \ + -o /dev/null \ + -w "%{http_code}") + + if [ $httpCode != "200" ] && [ $httpCode != "409"]; then + echo "An error occured during update of ${BITBUCKET_URL}/rest/api/latest/projects/${BITBUCKET_PROJECT}/repos/${REPOSITORY}/browse/${REPO_FILE} - error:$httpCode" + exit 1 + fi fi + + diff --git a/tests/utils/constants.go b/tests/utils/constants.go deleted file mode 100644 index 53b4be03d..000000000 --- a/tests/utils/constants.go +++ /dev/null @@ -1,7 +0,0 @@ -package utils - -const PROJECT_NAME = "unitt" -const PROJECT_ENV_VAR = "PROJECT_ID=" + PROJECT_NAME -const PROJECT_NAME_CD = "unitt-cd" -const PROJECT_NAME_DEV = "unitt-dev" -const PROJECT_NAME_TEST = "unitt-test" diff --git a/tests/utils/environment.go b/tests/utils/environment.go new file mode 100644 index 000000000..282a61311 --- /dev/null +++ b/tests/utils/environment.go @@ -0,0 +1,10 @@ +package utils + +import "os" + +func GetEnv(key, fallback string) string { + if value, ok := os.LookupEnv(key); ok { + return value + } + return fallback +} diff --git a/tests/utils/filter-quickstarters.go b/tests/utils/filter-quickstarters.go new file mode 100644 index 000000000..5eee50e47 --- /dev/null +++ b/tests/utils/filter-quickstarters.go @@ -0,0 +1,55 @@ +package utils + +import ( + "bufio" + "fmt" + "os" + "strings" + "testing" +) + +func RemoveExcludedQuickstarters(t *testing.T, dir string, quickstarterPaths []string) []string { + var quickstarterPathsFiltered []string + var exclusionList []string + + var filePath string = fmt.Sprintf("%s/../%s", dir, "quickStartersExclusionList.txt") + fmt.Printf("\n\nLooking for file quickStartersExclusionList.txt ... %s\n", filePath) + + _, err := os.Stat(filePath) + + if os.IsNotExist(err) { + fmt.Printf("File %s does not exist, The list of Quickstarters is not filtered.\n", filePath) + return quickstarterPaths + } + + file, err := os.Open(filePath) + if err != nil { + fmt.Println(err) + t.Fatal(err) + } + defer file.Close() + + scanner := bufio.NewScanner(file) + for scanner.Scan() { + exclusionList = append(exclusionList, scanner.Text()) + } + + fmt.Printf("\n\nQuickStarters that will be excluded...\n%s", exclusionList) + + for _, quickstarterPath := range quickstarterPaths { + if sliceContainsString(exclusionList, quickstarterPath) == -1 { + quickstarterPathsFiltered = append(quickstarterPathsFiltered, quickstarterPath) + } + } + + return quickstarterPathsFiltered +} + +func sliceContainsString(slice []string, str string) int { + for pos, s := range slice { + if strings.Contains(str, s) { + return pos + } + } + return -1 +} diff --git a/tests/utils/openshift-client.go b/tests/utils/openshift-client.go index dbe02e49e..ca7dcae4e 100644 --- a/tests/utils/openshift-client.go +++ b/tests/utils/openshift-client.go @@ -3,19 +3,18 @@ package utils import ( "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" - "os" - "path/filepath" ) func GetOCClient() (*rest.Config, error) { - home, err := os.UserHomeDir() - if err != nil { - return nil, err - } - config, err := clientcmd.BuildConfigFromFlags("", filepath.Join(home, ".kube", "config")) + + kubeCfg := clientcmd.NewNonInteractiveDeferredLoadingClientConfig( + clientcmd.NewDefaultClientConfigLoadingRules(), + &clientcmd.ConfigOverrides{}, + ) + restCfg, err := kubeCfg.ClientConfig() if err != nil { return nil, err } - return config, nil + return restCfg, nil } diff --git a/tests/utils/project_names.go b/tests/utils/project_names.go new file mode 100644 index 000000000..38d2574f6 --- /dev/null +++ b/tests/utils/project_names.go @@ -0,0 +1,15 @@ +package utils + +var PROJECT_NAME = "unitt" +var PROJECT_ENV_VAR = "PROJECT_ID=" + PROJECT_NAME +var PROJECT_NAME_CD = PROJECT_NAME + "-cd" +var PROJECT_NAME_DEV = PROJECT_NAME + "-dev" +var PROJECT_NAME_TEST = PROJECT_NAME + "-test" + +func Set_project_name(project string) { + PROJECT_NAME = project + PROJECT_ENV_VAR = "PROJECT_ID=" + PROJECT_NAME + PROJECT_NAME_CD = PROJECT_NAME + "-cd" + PROJECT_NAME_DEV = PROJECT_NAME + "-dev" + PROJECT_NAME_TEST = PROJECT_NAME + "-test" +} From 554c0c55f6c62507d7d250a10fa5c099810e8682 Mon Sep 17 00:00:00 2001 From: Jorge Romero Date: Wed, 28 Jun 2023 16:13:14 +0200 Subject: [PATCH 02/72] Change the way we get the token to interact with jenkins --- tests/scripts/get-artifact-from-jenkins-run.sh | 2 +- tests/scripts/print-jenkins-log.sh | 2 +- tests/scripts/print-jenkins-unittest-results.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/scripts/get-artifact-from-jenkins-run.sh b/tests/scripts/get-artifact-from-jenkins-run.sh index a06539211..9444aceaf 100755 --- a/tests/scripts/get-artifact-from-jenkins-run.sh +++ b/tests/scripts/get-artifact-from-jenkins-run.sh @@ -8,7 +8,7 @@ BUILD_URL=$(oc get -n ${PROJECT} build ${BUILD_NAME} -o jsonpath='{.metadata.ann echo $BUILD_URL ARTIFACT_URL=$BUILD_URL/artifact/artifacts/$3 echo "grabbing artifact from $ARTIFACT_URL - and storing in /tmp" -TOKEN=$(oc -n ${PROJECT} get sa/jenkins --template='{{range .secrets}}{{ .name }} {{end}}' | xargs -n 1 oc -n ${PROJECT} get secret --template='{{ if .data.token }}{{ .data.token }}{{end}}' | head -n 1 | base64 -d -) +TOKEN=$(oc whoami --show-token) httpCode=$(curl --insecure -sS ${ARTIFACT_URL} --header "Authorization: Bearer ${TOKEN}" -o /tmp/$3 -w "%{http_code}") echo "response: $httpCode" if [ ! "${httpCode}" == "200" ]; then diff --git a/tests/scripts/print-jenkins-log.sh b/tests/scripts/print-jenkins-log.sh index 3da6d75bc..17f5e2ff8 100755 --- a/tests/scripts/print-jenkins-log.sh +++ b/tests/scripts/print-jenkins-log.sh @@ -26,7 +26,7 @@ if [ "OC_ERROR" == "${LOG_URL}" ]; then OC_ERROR="true" TOKEN="OC_ERROR" else - TOKEN=$(oc -n ${PROJECT} get sa/jenkins --template='{{range .secrets}}{{ .name }} {{end}}' | xargs -n 1 oc -n ${PROJECT} get secret --template='{{ if .data.token }}{{ .data.token }}{{end}}' | head -n 1 | base64 -d -) + TOKEN=$(oc whoami --show-token) fi if [ -f ${JENKINS_LOG_FILE} ]; then diff --git a/tests/scripts/print-jenkins-unittest-results.sh b/tests/scripts/print-jenkins-unittest-results.sh index fdb2370a2..f4a1d890c 100755 --- a/tests/scripts/print-jenkins-unittest-results.sh +++ b/tests/scripts/print-jenkins-unittest-results.sh @@ -7,6 +7,6 @@ BUILD_NAME=$2 BUILD_URL=$(oc get -n "${PROJECT}" build "${BUILD_NAME}" -o jsonpath='{.metadata.annotations.openshift\.io/jenkins-build-uri}') echo "Using $BUILD_URL/testReport calculated from ${BUILD_NAME}" -TOKEN=$(oc -n "${PROJECT}" get sa/jenkins --template='{{range .secrets}}{{ .name }} {{end}}' | xargs -n 1 oc -n "${PROJECT}" get secret --template='{{ if .data.token }}{{ .data.token }}{{end}}' | head -n 1 | base64 -d -) +TOKEN=$(oc whoami --show-token) curl --insecure -sS "${BUILD_URL}/testReport" --location --header "Authorization: Bearer ${TOKEN}" From ff63fc0fad50ee7e9a49dee298e1d95098227fbc Mon Sep 17 00:00:00 2001 From: "zxBCN Romero,Jorge (IT EDS) EXTERNAL" Date: Fri, 30 Jun 2023 13:50:44 +0200 Subject: [PATCH 03/72] Replace ods-env configuration with enviroment variables --- tests/utils/ods-env.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/utils/ods-env.go b/tests/utils/ods-env.go index ca7405c16..d5ca9a0b2 100644 --- a/tests/utils/ods-env.go +++ b/tests/utils/ods-env.go @@ -29,5 +29,10 @@ func ReadConfiguration() (map[string]string, error) { } } + for _, e := range os.Environ() { + parts := strings.SplitN(e, "=", 2) + values[parts[0]] = parts[1] + } + return values, nil } From 3d08e97770127fb5185f73beb699260c9a2d4e9f Mon Sep 17 00:00:00 2001 From: "zxBCN Romero,Jorge (IT EDS) EXTERNAL" Date: Fri, 30 Jun 2023 13:50:52 +0200 Subject: [PATCH 04/72] remove dead code --- tests/quickstarter/quickstarter_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 2581b30aa..60fddc0a6 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -64,9 +64,6 @@ func TestQuickstarter(t *testing.T) { if err != nil { t.Fatal(err) } - if err != nil { - t.Fatalf("Error decoding cd_user password: %s", err) - } fmt.Printf("\n\nRunning test steps found in the following directories:\n") for _, quickstarterPath := range quickstarterPaths { From 2fac3b32b903b90a18dce67c6338ff500dd67603 Mon Sep 17 00:00:00 2001 From: "zxBCN Romero,Jorge (IT EDS) EXTERNAL" Date: Tue, 4 Jul 2023 14:14:16 +0200 Subject: [PATCH 05/72] Fix linting error --- tests/quickstarter/quickstarter_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 60fddc0a6..0e980e739 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -268,20 +268,19 @@ func executeStepUpload(t *testing.T, step TestStep, testdataPath string, tmplDat fmt.Printf("Rendering template to upload") tmpl, err := template.ParseFiles(fileToUpload) if err != nil { - fmt.Errorf("Failed to load file to upload: %w", err) - return + t.Fatalf("Failed to load file to upload: \nErr: %s\n", err) + } outputFile, err := os.Create(fileToUpload) if err != nil { - fmt.Errorf("Error creating output file: %w", err) - return + t.Fatalf("Error creating output file: \nErr: %s\n", err) + } defer outputFile.Close() fmt.Printf("Execute render") err = tmpl.Execute(outputFile, tmplData) if err != nil { - fmt.Errorf("Failed to render file: %w", err) - return + t.Fatalf("Failed to render file: \nErr: %s\n", err) } } From 619b8ce0c0262d4bb26fadd037e7443313955d86 Mon Sep 17 00:00:00 2001 From: "zxBCN Romero,Jorge (IT EDS) EXTERNAL" Date: Tue, 4 Jul 2023 14:14:52 +0200 Subject: [PATCH 06/72] Improve quickstater-test.sh adding log file processing --- tests/Makefile | 2 +- tests/quickstarter-test.sh | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 5c2fc9677..2dc681b46 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -36,7 +36,7 @@ test-create-projects: ## Run quickstarter tests within existing ODS installation. Depends on UNITT project. test-quickstarter: - @(./quickstarter-test.sh $(PROJECT) $(QS) $(PARALLEL)) + @(./quickstarter-test.sh -p $(PROJECT) -q $(QS) -pa $(PARALLEL)) .PHONY: test-quickstarter ## Install tools required for tests. diff --git a/tests/quickstarter-test.sh b/tests/quickstarter-test.sh index 716686c30..11d06f9ff 100755 --- a/tests/quickstarter-test.sh +++ b/tests/quickstarter-test.sh @@ -28,6 +28,22 @@ function cleanup_workspace(){ fi } +function generate_results(){ + echo "Process results" + cd $ODS_CORE_DIR/tests + if [ -f test-quickstarter-results.txt ]; then + go-junit-report < test-quickstarter-results.txt > test-quickstarter-report.xml + cat -v test-quickstarter-results.txt > test-output + go-junit-report < test-output > test-quickstarter-report.xml + csplit -z test-quickstarter-results.txt '/=== CONT/' {*} + rm xx00 + for file in xx*; do + newName=$(grep -oP -m 1 'TestQuickstarter/\K\w+.*' $file) + mv $file $newName.txt + done + fi +} + function run_test(){ echo " " echo "${THIS_SCRIPT}: Running tests (${QUICKSTARTER}). Output will take a while to arrive ..." @@ -40,15 +56,14 @@ function run_test(){ exitcode="${PIPESTATUS[0]}" - if [ -f test-quickstarter-results.txt ]; then - go-junit-report < test-quickstarter-results.txt > test-quickstarter-report.xml - fi - echo " " echo " " echo "${THIS_SCRIPT}: Returning with exit code ${exitcode}" echo " " echo " " + + generate_results + exit $exitcode } @@ -86,4 +101,4 @@ fi check_already_logged_in_openshift cleanup_workspace -run_test \ No newline at end of file +run_test From b2d849fc2ff3591cebb40386bd360a4a4e0d8623 Mon Sep 17 00:00:00 2001 From: "zxBCN Romero,Jorge (IT EDS) EXTERNAL" Date: Fri, 7 Jul 2023 09:16:00 +0200 Subject: [PATCH 07/72] Unify golden files verification --- tests/quickstarter-test.sh | 4 ++-- tests/quickstarter/golden-files.go | 28 +++++++++++++++++++++++++ tests/quickstarter/quickstarter_test.go | 6 ++++-- tests/quickstarter/sonarqube.go | 21 ------------------- 4 files changed, 34 insertions(+), 25 deletions(-) create mode 100644 tests/quickstarter/golden-files.go diff --git a/tests/quickstarter-test.sh b/tests/quickstarter-test.sh index 11d06f9ff..b099021de 100755 --- a/tests/quickstarter-test.sh +++ b/tests/quickstarter-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -eu +set -u set -o pipefail export CGO_ENABLED=0 @@ -53,7 +53,7 @@ function run_test(){ # Should fix error " panic: test timed out after " echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER}" go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER} ${BITBUCKET_TEST_PROJECT} | tee test-quickstarter-results.txt 2>&1 - + exitcode="${PIPESTATUS[0]}" echo " " diff --git a/tests/quickstarter/golden-files.go b/tests/quickstarter/golden-files.go new file mode 100644 index 000000000..7e0e14f07 --- /dev/null +++ b/tests/quickstarter/golden-files.go @@ -0,0 +1,28 @@ +package quickstarter + +import ( + "bytes" + "fmt" + "html/template" + + "github.com/google/go-cmp/cmp" +) + +func verifyGoldenFile(componentID string, wantFile string, gotFile string, tmplData TemplateData) error { + + var want bytes.Buffer + tmpl, err := template.ParseFiles(wantFile) + if err != nil { + return fmt.Errorf("Failed to load golden file to verify State: %w", err) + } + err = tmpl.Execute(&want, tmplData) + if err != nil { + return fmt.Errorf("Failed to render file to verify State: %w", err) + } + + if diff := cmp.Diff(want.String(), gotFile); diff != "" { + return fmt.Errorf("State mismatch for %s (-want +got):\n%s", componentID, diff) + } + + return nil +} diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 0e980e739..9037653b9 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -388,9 +388,11 @@ func verifyPipelineRun(t *testing.T, step TestStep, verify *TestStepVerify, test t.Fatal(err) } fmt.Printf("%s pipeline run for %s returned:\n%s", step.Type, step.ComponentID, stages) - err = utils.VerifyJenkinsStages( + err = verifyGoldenFile( + step.ComponentID, fmt.Sprintf("%s/%s", testdataPath, verify.JenkinsStages), stages, + tmplData, ) if err != nil { t.Fatal(err) @@ -403,7 +405,7 @@ func verifyPipelineRun(t *testing.T, step TestStep, verify *TestStepVerify, test if err != nil { t.Fatal(err) } - err = verifySonarScan( + err = verifyGoldenFile( step.ComponentID, fmt.Sprintf("%s/%s", testdataPath, verify.SonarScan), sonarscan, diff --git a/tests/quickstarter/sonarqube.go b/tests/quickstarter/sonarqube.go index 52a8d4e89..fc184b07a 100644 --- a/tests/quickstarter/sonarqube.go +++ b/tests/quickstarter/sonarqube.go @@ -1,12 +1,9 @@ package quickstarter import ( - "bytes" b64 "encoding/base64" "fmt" - "html/template" - "github.com/google/go-cmp/cmp" "github.com/opendevstack/ods-core/tests/utils" ) @@ -34,21 +31,3 @@ func retrieveSonarScan(projectKey string, config map[string]string) (string, err return stdout, nil } - -func verifySonarScan(componentID string, wantScanFile string, gotScan string, tmplData TemplateData) error { - var wantScan bytes.Buffer - tmpl, err := template.ParseFiles(wantScanFile) - if err != nil { - return fmt.Errorf("Failed to load golden file to verify Sonar scan: %w", err) - } - err = tmpl.Execute(&wantScan, tmplData) - if err != nil { - return fmt.Errorf("Failed to render file to verify Sonar scan: %w", err) - } - - if diff := cmp.Diff(wantScan.String(), gotScan); diff != "" { - return fmt.Errorf("Sonar scan mismatch for %s (-want +got):\n%s", componentID, diff) - } - - return nil -} From c6be933f662f0edfdb33c791e7d3e0e869b34087 Mon Sep 17 00:00:00 2001 From: brais <26645694+braisvq1996@users.noreply.github.com> Date: Tue, 28 Nov 2023 18:09:24 +0100 Subject: [PATCH 08/72] match Shared library to branch used instead of agent tag --- tests/quickstarter/quickstarter_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 9037653b9..eafb2ac8c 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -157,7 +157,7 @@ func executeProvision(t *testing.T, step TestStep, testdataPath string, tmplData if len(step.ProvisionParams.AgentImageTag) > 0 { agentImageTag = renderTemplate(t, step.ProvisionParams.AgentImageTag, tmplData) } - sharedLibraryRef := agentImageTag + sharedLibraryRef := branch if len(step.ProvisionParams.SharedLibraryRef) > 0 { sharedLibraryRef = renderTemplate(t, step.ProvisionParams.SharedLibraryRef, tmplData) } From 431969d6c48bf7bc12ff253f4f1c4d0096245f98 Mon Sep 17 00:00:00 2001 From: brais <26645694+braisvq1996@users.noreply.github.com> Date: Tue, 28 Nov 2023 18:19:36 +0100 Subject: [PATCH 09/72] restore config --- tests/quickstarter/quickstarter_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index eafb2ac8c..9037653b9 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -157,7 +157,7 @@ func executeProvision(t *testing.T, step TestStep, testdataPath string, tmplData if len(step.ProvisionParams.AgentImageTag) > 0 { agentImageTag = renderTemplate(t, step.ProvisionParams.AgentImageTag, tmplData) } - sharedLibraryRef := branch + sharedLibraryRef := agentImageTag if len(step.ProvisionParams.SharedLibraryRef) > 0 { sharedLibraryRef = renderTemplate(t, step.ProvisionParams.SharedLibraryRef, tmplData) } From 407e7f911ccf2e77f76f9d78a44ca1654d03dc44 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 20 May 2024 17:36:08 +0200 Subject: [PATCH 10/72] private qs test --- tests/quickstarter-test.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/quickstarter-test.sh b/tests/quickstarter-test.sh index b099021de..24846cce2 100755 --- a/tests/quickstarter-test.sh +++ b/tests/quickstarter-test.sh @@ -8,7 +8,8 @@ THIS_SCRIPT="$(basename $0)" # By default we run all quickstarter tests, otherwise just the quickstarter # passed as the first argument to this script. BITBUCKET_TEST_PROJECT="unitt" -QUICKSTARTER="ods-quickstarters/..." +## QUICKSTARTER="ods-quickstarters/..." +QUICKSTARTER="ods-boehringer-quickstarters/..." PARALLEL="1" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -51,8 +52,12 @@ function run_test(){ # Should fix error " panic: test timed out after " - echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER}" - go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER} ${BITBUCKET_TEST_PROJECT} | tee test-quickstarter-results.txt 2>&1 + ## echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER}" + ## go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER} ${BITBUCKET_TEST_PROJECT} | tee test-quickstarter-results.txt 2>&1 + + # For Private QS + echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} bitbucket-dev.biscrum.com/projects/ODS4/ods-boehringer-quickstarters -args ${QUICKSTARTER}" + go test -v -count=1 -timeout 30h -parallel ${PARALLEL} bitbucket-dev.biscrum.com/projects/ODS4/ods-boehringer-quickstarters -args ${QUICKSTARTER} ${BITBUCKET_TEST_PROJECT} | tee test-quickstarter-results.txt 2>&1 exitcode="${PIPESTATUS[0]}" From e2ebc7d6d2893b56878e4ae516ca22f647ce4272 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 23 May 2024 12:17:04 +0200 Subject: [PATCH 11/72] revert --- tests/quickstarter-test.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/quickstarter-test.sh b/tests/quickstarter-test.sh index 24846cce2..0426326b1 100755 --- a/tests/quickstarter-test.sh +++ b/tests/quickstarter-test.sh @@ -8,8 +8,8 @@ THIS_SCRIPT="$(basename $0)" # By default we run all quickstarter tests, otherwise just the quickstarter # passed as the first argument to this script. BITBUCKET_TEST_PROJECT="unitt" -## QUICKSTARTER="ods-quickstarters/..." -QUICKSTARTER="ods-boehringer-quickstarters/..." +QUICKSTARTER="ods-quickstarters/..." +## QUICKSTARTER="ods-boehringer-quickstarters/..." PARALLEL="1" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -52,12 +52,8 @@ function run_test(){ # Should fix error " panic: test timed out after " - ## echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER}" - ## go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER} ${BITBUCKET_TEST_PROJECT} | tee test-quickstarter-results.txt 2>&1 - - # For Private QS - echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} bitbucket-dev.biscrum.com/projects/ODS4/ods-boehringer-quickstarters -args ${QUICKSTARTER}" - go test -v -count=1 -timeout 30h -parallel ${PARALLEL} bitbucket-dev.biscrum.com/projects/ODS4/ods-boehringer-quickstarters -args ${QUICKSTARTER} ${BITBUCKET_TEST_PROJECT} | tee test-quickstarter-results.txt 2>&1 + echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER}" + go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER} ${BITBUCKET_TEST_PROJECT} | tee test-quickstarter-results.txt 2>&1 exitcode="${PIPESTATUS[0]}" From 03bccdfcd868e7b115d845ee6c70a36ed71bd8c3 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 27 May 2024 17:16:13 +0200 Subject: [PATCH 12/72] private qs test 2 --- tests/quickstarter-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/quickstarter-test.sh b/tests/quickstarter-test.sh index 0426326b1..89ace78c2 100755 --- a/tests/quickstarter-test.sh +++ b/tests/quickstarter-test.sh @@ -8,7 +8,7 @@ THIS_SCRIPT="$(basename $0)" # By default we run all quickstarter tests, otherwise just the quickstarter # passed as the first argument to this script. BITBUCKET_TEST_PROJECT="unitt" -QUICKSTARTER="ods-quickstarters/..." +## QUICKSTARTER="ods-quickstarters/..." ## QUICKSTARTER="ods-boehringer-quickstarters/..." PARALLEL="1" From 95fb2e65ee9db38804767285a2bc123bb56df268 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Wed, 29 May 2024 14:09:59 +0200 Subject: [PATCH 13/72] golden test --- tests/quickstarter-test.sh | 14 +++++++++----- tests/quickstarter/quickstarter_test.go | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/quickstarter-test.sh b/tests/quickstarter-test.sh index 89ace78c2..900c150d3 100755 --- a/tests/quickstarter-test.sh +++ b/tests/quickstarter-test.sh @@ -8,8 +8,8 @@ THIS_SCRIPT="$(basename $0)" # By default we run all quickstarter tests, otherwise just the quickstarter # passed as the first argument to this script. BITBUCKET_TEST_PROJECT="unitt" -## QUICKSTARTER="ods-quickstarters/..." -## QUICKSTARTER="ods-boehringer-quickstarters/..." +QUICKSTARTER_FOLDER="ods-quickstarters/..." +QUICKSTARTER="" PARALLEL="1" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -52,8 +52,8 @@ function run_test(){ # Should fix error " panic: test timed out after " - echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER}" - go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER} ${BITBUCKET_TEST_PROJECT} | tee test-quickstarter-results.txt 2>&1 + echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${BITBUCKET_TEST_PROJECT} ${QUICKSTARTER_FOLDER} ${QUICKSTARTER}" + # go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER} ${BITBUCKET_TEST_PROJECT} | tee test-quickstarter-results.txt 2>&1 exitcode="${PIPESTATUS[0]}" @@ -74,7 +74,8 @@ function usage { printf "\t-h |--help\t\tPrint usage\n" printf "\t-p |--project\t\tBitbucket project (* mandatory)\n" printf "\t-pa|--parallel\t\tNumber of test executed in parallel\n" - printf "\t-q |--quickstarter\tQuickStarter to test or Quickstarter folder (default:ods-quickstarters/...)\n" + printf "\t-qf |--quickstarterfolder\tQuickstarter folder (default:ods-quickstarters/...)\n" + printf "\t-q |--quickstarter\tQuickStarter to test\n" } while [[ "$#" -gt 0 ]]; do @@ -88,6 +89,9 @@ while [[ "$#" -gt 0 ]]; do -q|--quickstarter) QUICKSTARTER="$2"; shift;; -q=*|--quickstarter=*) QUICKSTARTER="${1#*=}";; + -qf|--quickstarterfolder) QUICKSTARTER_FOLDER="$2"; shift;; + -qf=*|--quickstarterfolder=*) QUICKSTARTER_FOLDER="${1#*=}";; + -p|--project) BITBUCKET_TEST_PROJECT="$2"; shift;; -p=*|--project=*) BITBUCKET_TEST_PROJECT="${1#*=}";; diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 9037653b9..2d2e06426 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -31,6 +31,7 @@ func TestQuickstarter(t *testing.T) { project := os.Args[len(os.Args)-1] utils.Set_project_name(project) target := os.Args[len(os.Args)-2] + fmt.Sprintf(target) if strings.HasPrefix(target, ".") || strings.HasPrefix(target, "/") { if strings.HasSuffix(target, "...") { quickstarterPaths = collectTestableQuickstarters( From 1ebbde7949f996bea218fbd84643bf87c245d077 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Wed, 29 May 2024 18:22:30 +0200 Subject: [PATCH 14/72] golden test --- tests/quickstarter-test.sh | 2 +- tests/quickstarter/quickstarter_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/quickstarter-test.sh b/tests/quickstarter-test.sh index 900c150d3..caf20a217 100755 --- a/tests/quickstarter-test.sh +++ b/tests/quickstarter-test.sh @@ -53,7 +53,7 @@ function run_test(){ # Should fix error " panic: test timed out after " echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${BITBUCKET_TEST_PROJECT} ${QUICKSTARTER_FOLDER} ${QUICKSTARTER}" - # go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER} ${BITBUCKET_TEST_PROJECT} | tee test-quickstarter-results.txt 2>&1 + go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${BITBUCKET_TEST_PROJECT} ${QUICKSTARTER_FOLDER} ${QUICKSTARTER} | tee test-quickstarter-results.txt 2>&1 exitcode="${PIPESTATUS[0]}" diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 2d2e06426..dc2a76e34 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -24,6 +24,9 @@ import ( // folder - otherwise a folder next to "ods-core" is assumed, by default // "ods-quickstarters". If the argument ends with "...", all directories with a // "testdata" directory are tested, otherwise only the given folder is run. + +// Comment by Srita +// Adding new parameter quickstarterfolder to paramterarize the hardcoded value "ods-quickstarters" func TestQuickstarter(t *testing.T) { var quickstarterPaths []string @@ -32,6 +35,8 @@ func TestQuickstarter(t *testing.T) { utils.Set_project_name(project) target := os.Args[len(os.Args)-2] fmt.Sprintf(target) + quickstarterfolder := os.Args[len(os.Args)-3] + fmt.Sprintf(quickstarterfolder) if strings.HasPrefix(target, ".") || strings.HasPrefix(target, "/") { if strings.HasSuffix(target, "...") { quickstarterPaths = collectTestableQuickstarters( From 35a21a4027524ad21f96f09e2d2705d37ec66fcb Mon Sep 17 00:00:00 2001 From: bandyopa Date: Wed, 29 May 2024 18:35:05 +0200 Subject: [PATCH 15/72] golden test --- tests/quickstarter/quickstarter_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index dc2a76e34..d0b130b2a 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -34,9 +34,9 @@ func TestQuickstarter(t *testing.T) { project := os.Args[len(os.Args)-1] utils.Set_project_name(project) target := os.Args[len(os.Args)-2] - fmt.Sprintf(target) + fmt.Printf("Target: ", target) quickstarterfolder := os.Args[len(os.Args)-3] - fmt.Sprintf(quickstarterfolder) + fmt.Printf("QSFolder: ", quickstarterfolder) if strings.HasPrefix(target, ".") || strings.HasPrefix(target, "/") { if strings.HasSuffix(target, "...") { quickstarterPaths = collectTestableQuickstarters( From bf85fa562629d4f61df783218b21099818967fe4 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Wed, 29 May 2024 18:40:01 +0200 Subject: [PATCH 16/72] golden test --- tests/quickstarter/quickstarter_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index d0b130b2a..309973847 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -34,9 +34,9 @@ func TestQuickstarter(t *testing.T) { project := os.Args[len(os.Args)-1] utils.Set_project_name(project) target := os.Args[len(os.Args)-2] - fmt.Printf("Target: ", target) + fmt.Printf("Target: %s", target) quickstarterfolder := os.Args[len(os.Args)-3] - fmt.Printf("QSFolder: ", quickstarterfolder) + fmt.Printf("QSFolder: %s", quickstarterfolder) if strings.HasPrefix(target, ".") || strings.HasPrefix(target, "/") { if strings.HasSuffix(target, "...") { quickstarterPaths = collectTestableQuickstarters( From d491a3ece3aef4e1ad60f99e236da9ec13f426f4 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Wed, 29 May 2024 18:43:45 +0200 Subject: [PATCH 17/72] golden test --- tests/quickstarter/quickstarter_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 309973847..3ac245875 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -32,9 +32,10 @@ func TestQuickstarter(t *testing.T) { var quickstarterPaths []string odsCoreRootPath := "../.." project := os.Args[len(os.Args)-1] + fmt.Printf("Project: %s\n", project) utils.Set_project_name(project) target := os.Args[len(os.Args)-2] - fmt.Printf("Target: %s", target) + fmt.Printf("Target: %s\n", target) quickstarterfolder := os.Args[len(os.Args)-3] fmt.Printf("QSFolder: %s", quickstarterfolder) if strings.HasPrefix(target, ".") || strings.HasPrefix(target, "/") { From 0d1f2cdd5cc487e04d04f78341cf90d866f77e22 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 30 May 2024 16:15:52 +0200 Subject: [PATCH 18/72] golden test --- tests/quickstarter/quickstarter_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 3ac245875..dec967dde 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -25,19 +25,19 @@ import ( // "ods-quickstarters". If the argument ends with "...", all directories with a // "testdata" directory are tested, otherwise only the given folder is run. -// Comment by Srita -// Adding new parameter quickstarterfolder to paramterarize the hardcoded value "ods-quickstarters" +// Adding new parameter quickstarter to parameterize the hardcoded value "ods-quickstarters" func TestQuickstarter(t *testing.T) { var quickstarterPaths []string odsCoreRootPath := "../.." - project := os.Args[len(os.Args)-1] - fmt.Printf("Project: %s\n", project) + quickstarter := os.Args[len(os.Args)-1] + fmt.Printf("QSFolder: %s", quickstarter) utils.Set_project_name(project) target := os.Args[len(os.Args)-2] fmt.Printf("Target: %s\n", target) - quickstarterfolder := os.Args[len(os.Args)-3] - fmt.Printf("QSFolder: %s", quickstarterfolder) + project := os.Args[len(os.Args)-3] + fmt.Printf("Project: %s\n", project) + if strings.HasPrefix(target, ".") || strings.HasPrefix(target, "/") { if strings.HasSuffix(target, "...") { quickstarterPaths = collectTestableQuickstarters( From 52162e5b6f6d10afab1c489e69ed069e0feb4c04 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 30 May 2024 16:18:32 +0200 Subject: [PATCH 19/72] golden test --- tests/quickstarter/quickstarter_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index dec967dde..c54045125 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -32,11 +32,11 @@ func TestQuickstarter(t *testing.T) { odsCoreRootPath := "../.." quickstarter := os.Args[len(os.Args)-1] fmt.Printf("QSFolder: %s", quickstarter) - utils.Set_project_name(project) target := os.Args[len(os.Args)-2] fmt.Printf("Target: %s\n", target) project := os.Args[len(os.Args)-3] fmt.Printf("Project: %s\n", project) + utils.Set_project_name(project) if strings.HasPrefix(target, ".") || strings.HasPrefix(target, "/") { if strings.HasSuffix(target, "...") { From 7d93e2a1faf587fb88cb00314ea7ce9531b9c7d6 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 30 May 2024 17:23:45 +0200 Subject: [PATCH 20/72] golden test --- tests/quickstarter/quickstarter_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index c54045125..495199ca0 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -30,11 +30,11 @@ func TestQuickstarter(t *testing.T) { var quickstarterPaths []string odsCoreRootPath := "../.." - quickstarter := os.Args[len(os.Args)-1] - fmt.Printf("QSFolder: %s", quickstarter) - target := os.Args[len(os.Args)-2] + quickstarter := os.Args[len(os.Args)] + fmt.Printf("QS: %s\n", quickstarter) + target := os.Args[len(os.Args)-1] fmt.Printf("Target: %s\n", target) - project := os.Args[len(os.Args)-3] + project := os.Args[len(os.Args)-2] fmt.Printf("Project: %s\n", project) utils.Set_project_name(project) From 1b20197c3e3c37c27c3a33386b8d74b6fefbf076 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 30 May 2024 20:26:13 +0200 Subject: [PATCH 21/72] golden test --- tests/quickstarter/quickstarter_test.go | 31 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 495199ca0..807c21b78 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -30,11 +30,11 @@ func TestQuickstarter(t *testing.T) { var quickstarterPaths []string odsCoreRootPath := "../.." - quickstarter := os.Args[len(os.Args)] + quickstarter := os.Args[len(os.Args)-1] fmt.Printf("QS: %s\n", quickstarter) - target := os.Args[len(os.Args)-1] + target := os.Args[len(os.Args)-2] fmt.Printf("Target: %s\n", target) - project := os.Args[len(os.Args)-2] + project := os.Args[len(os.Args)-3] fmt.Printf("Project: %s\n", project) utils.Set_project_name(project) @@ -46,12 +46,33 @@ func TestQuickstarter(t *testing.T) { } else { quickstarterPaths = append(quickstarterPaths, target) } + } else { + if quickstarter != "all" { + // quickstarter variable value not all = test only one quickstarter + quickstarterPaths = []string{fmt.Sprintf("%s/../%s/%s", odsCoreRootPath, strings.TrimSuffix(target, "/..."), quickstarter)} + } else { + // quickstarter variable value all = test all quickstarters + quickstarterPaths = collectTestableQuickstarters( + t, fmt.Sprintf("%s/../%s", odsCoreRootPath, strings.TrimSuffix(target, "/...")), + ) + } + } + + + /* if strings.HasPrefix(target, ".") || strings.HasPrefix(target, "/") { + if strings.HasSuffix(target, "...") { + quickstarterPaths = collectTestableQuickstarters( + t, strings.TrimSuffix(target, "/..."), + ) + } else { + quickstarterPaths = append(quickstarterPaths, target) + } } else { // No slash = quickstarter in ods-quickstarters // Ending with ... = all quickstarters in given folder // otherwise = exactly one quickstarter if !strings.Contains(target, "/") { - quickstarterPaths = []string{fmt.Sprintf("%s/../%s/%s", odsCoreRootPath, "ods-quickstarters", target)} + quickstarterPaths = []string{fmt.Sprintf("%s/../%s/%s", odsCoreRootPath, strings.TrimSuffix(target, "/..."), target)} } else if strings.HasSuffix(target, "...") { quickstarterPaths = collectTestableQuickstarters( t, fmt.Sprintf("%s/../%s", odsCoreRootPath, strings.TrimSuffix(target, "/...")), @@ -59,7 +80,7 @@ func TestQuickstarter(t *testing.T) { } else { quickstarterPaths = []string{fmt.Sprintf("%s/../%s", odsCoreRootPath, target)} } - } + } */ dir, err := os.Getwd() if err != nil { fmt.Println("Error:", err) From a29151aa3c9572fe6b510ac41ba5c2c0e021c2ca Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 30 May 2024 21:28:22 +0200 Subject: [PATCH 22/72] golden test --- tests/quickstarter/quickstarter_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 807c21b78..eefd99021 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -104,6 +104,17 @@ func TestQuickstarter(t *testing.T) { quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) quickstarterName := filepath.Base(quickstarterPath) + // check quickstarterPath content + files, err = FilePathWalkDir(quickstarterName) + if err != nil { + panic(err) + } + + for _, file := range files { + fmt.Println(file) + } + // + fmt.Printf("\n\n\n\n") fmt.Printf("Running tests for quickstarter %s\n", quickstarterName) fmt.Printf("\n\n") From 04348e2c157d0b0bc0f2ce7a5715841504d77863 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 30 May 2024 21:31:30 +0200 Subject: [PATCH 23/72] golden test --- tests/quickstarter/quickstarter_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index eefd99021..f4eba40b8 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -105,6 +105,7 @@ func TestQuickstarter(t *testing.T) { quickstarterName := filepath.Base(quickstarterPath) // check quickstarterPath content + var files []string files, err = FilePathWalkDir(quickstarterName) if err != nil { panic(err) @@ -114,7 +115,7 @@ func TestQuickstarter(t *testing.T) { fmt.Println(file) } // - + fmt.Printf("\n\n\n\n") fmt.Printf("Running tests for quickstarter %s\n", quickstarterName) fmt.Printf("\n\n") From 3f308e0288918492afcb76ca9b4d01e19953ddc4 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 30 May 2024 21:35:16 +0200 Subject: [PATCH 24/72] golden test --- tests/quickstarter/quickstarter_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index f4eba40b8..0fe19f281 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -114,6 +114,17 @@ func TestQuickstarter(t *testing.T) { for _, file := range files { fmt.Println(file) } + + func FilePathWalkDir(root string) ([]string, error) { + var files []string + err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { + if !info.IsDir() { + files = append(files, path) + } + return nil + }) + return files, err + } // fmt.Printf("\n\n\n\n") From b2da2aca25ea6784364a7c38ff827596a5f40cde Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 30 May 2024 21:38:32 +0200 Subject: [PATCH 25/72] golden test --- tests/quickstarter/quickstarter_test.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 0fe19f281..58b21a5ee 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -105,16 +105,7 @@ func TestQuickstarter(t *testing.T) { quickstarterName := filepath.Base(quickstarterPath) // check quickstarterPath content - var files []string - files, err = FilePathWalkDir(quickstarterName) - if err != nil { - panic(err) - } - - for _, file := range files { - fmt.Println(file) - } - + func FilePathWalkDir(root string) ([]string, error) { var files []string err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { @@ -125,6 +116,17 @@ func TestQuickstarter(t *testing.T) { }) return files, err } + + var files []string + files, err = FilePathWalkDir(quickstarterName) + if err != nil { + panic(err) + } + + for _, file := range files { + fmt.Println(file) + } + // fmt.Printf("\n\n\n\n") From b191d096a858943862e323047d246727d1d1a4a6 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 30 May 2024 21:43:46 +0200 Subject: [PATCH 26/72] golden test --- tests/quickstarter/quickstarter_test.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 58b21a5ee..92caf06af 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -106,19 +106,21 @@ func TestQuickstarter(t *testing.T) { // check quickstarterPath content - func FilePathWalkDir(root string) ([]string, error) { + func IOReadDir(root string) ([]string, error) { var files []string - err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { - if !info.IsDir() { - files = append(files, path) - } - return nil - }) - return files, err + fileInfo, err := ioutil.ReadDir(root) + if err != nil { + return files, err + } + + for _, file := range fileInfo { + files = append(files, file.Name()) + } + return files, nil } var files []string - files, err = FilePathWalkDir(quickstarterName) + files, err = IOReadDir(root) if err != nil { panic(err) } From afbe0da9cfac384df16f01abdc5fe60db26fc3b6 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 30 May 2024 21:47:41 +0200 Subject: [PATCH 27/72] golden test --- tests/quickstarter/quickstarter_test.go | 50 ++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 92caf06af..af435bc55 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -99,37 +99,37 @@ func TestQuickstarter(t *testing.T) { } fmt.Printf("\n\n") - for _, quickstarterPath := range quickstarterPaths { - testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) - quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) - quickstarterName := filepath.Base(quickstarterPath) - - // check quickstarterPath content - - func IOReadDir(root string) ([]string, error) { - var files []string - fileInfo, err := ioutil.ReadDir(root) - if err != nil { - return files, err - } + // check quickstarterPath content - for _, file := range fileInfo { - files = append(files, file.Name()) - } - return files, nil - } - + func IOReadDir(root string) ([]string, error) { var files []string - files, err = IOReadDir(root) + fileInfo, err := ioutil.ReadDir(root) if err != nil { - panic(err) + return files, err } - - for _, file := range files { - fmt.Println(file) + + for _, file := range fileInfo { + files = append(files, file.Name()) } + return files, nil + } + + var files []string + files, err = IOReadDir(quickstarterPath) + if err != nil { + panic(err) + } + + for _, file := range files { + fmt.Println(file) + } - // + // + + for _, quickstarterPath := range quickstarterPaths { + testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) + quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) + quickstarterName := filepath.Base(quickstarterPath) fmt.Printf("\n\n\n\n") fmt.Printf("Running tests for quickstarter %s\n", quickstarterName) From e7edae0dbb03db2369858c45859bbed3a99ec001 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 30 May 2024 21:51:15 +0200 Subject: [PATCH 28/72] golden test --- tests/quickstarter/quickstarter_test.go | 27 ------------------------- 1 file changed, 27 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index af435bc55..807c21b78 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -99,33 +99,6 @@ func TestQuickstarter(t *testing.T) { } fmt.Printf("\n\n") - // check quickstarterPath content - - func IOReadDir(root string) ([]string, error) { - var files []string - fileInfo, err := ioutil.ReadDir(root) - if err != nil { - return files, err - } - - for _, file := range fileInfo { - files = append(files, file.Name()) - } - return files, nil - } - - var files []string - files, err = IOReadDir(quickstarterPath) - if err != nil { - panic(err) - } - - for _, file := range files { - fmt.Println(file) - } - - // - for _, quickstarterPath := range quickstarterPaths { testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) From 9588f5077c7c47f17876796494cd66d5cc1256d1 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Fri, 31 May 2024 11:21:58 +0200 Subject: [PATCH 29/72] golden test --- tests/quickstarter/quickstarter_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 807c21b78..71f9f7a4f 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -49,7 +49,7 @@ func TestQuickstarter(t *testing.T) { } else { if quickstarter != "all" { // quickstarter variable value not all = test only one quickstarter - quickstarterPaths = []string{fmt.Sprintf("%s/../%s/%s", odsCoreRootPath, strings.TrimSuffix(target, "/..."), quickstarter)} + quickstarterPaths = []string{fmt.Sprintf("%s/../../%s/%s", odsCoreRootPath, strings.TrimSuffix(target, "/..."), quickstarter)} } else { // quickstarter variable value all = test all quickstarters quickstarterPaths = collectTestableQuickstarters( From 3bb9cd111c1cfba5b0b4a8f7737883b6febe74eb Mon Sep 17 00:00:00 2001 From: bandyopa Date: Fri, 31 May 2024 11:27:57 +0200 Subject: [PATCH 30/72] golden test --- tests/quickstarter/quickstarter_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 71f9f7a4f..835600ac1 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -49,7 +49,7 @@ func TestQuickstarter(t *testing.T) { } else { if quickstarter != "all" { // quickstarter variable value not all = test only one quickstarter - quickstarterPaths = []string{fmt.Sprintf("%s/../../%s/%s", odsCoreRootPath, strings.TrimSuffix(target, "/..."), quickstarter)} + quickstarterPaths = []string{fmt.Sprintf("%s/%s/%s", odsCoreRootPath, strings.TrimSuffix(target, "/..."), quickstarter)} } else { // quickstarter variable value all = test all quickstarters quickstarterPaths = collectTestableQuickstarters( From 77fda333c92a246bd55dd3865542378ffbb44136 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Fri, 31 May 2024 13:52:35 +0200 Subject: [PATCH 31/72] golden test --- tests/quickstarter/quickstarter_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 835600ac1..7c7c62959 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -49,7 +49,7 @@ func TestQuickstarter(t *testing.T) { } else { if quickstarter != "all" { // quickstarter variable value not all = test only one quickstarter - quickstarterPaths = []string{fmt.Sprintf("%s/%s/%s", odsCoreRootPath, strings.TrimSuffix(target, "/..."), quickstarter)} + quickstarterPaths = []string{fmt.Sprintf("%s/../%s/%s", odsCoreRootPath, strings.TrimSuffix(target, "/..."), quickstarter)} } else { // quickstarter variable value all = test all quickstarters quickstarterPaths = collectTestableQuickstarters( @@ -72,7 +72,7 @@ func TestQuickstarter(t *testing.T) { // Ending with ... = all quickstarters in given folder // otherwise = exactly one quickstarter if !strings.Contains(target, "/") { - quickstarterPaths = []string{fmt.Sprintf("%s/../%s/%s", odsCoreRootPath, strings.TrimSuffix(target, "/..."), target)} + quickstarterPaths = []string{fmt.Sprintf("%s/../%s/%s", odsCoreRootPath, "ods-quickstarters", target)} } else if strings.HasSuffix(target, "...") { quickstarterPaths = collectTestableQuickstarters( t, fmt.Sprintf("%s/../%s", odsCoreRootPath, strings.TrimSuffix(target, "/...")), From e178b9bbcfd7aa2557b70c7e4db2d8ff71dd87ff Mon Sep 17 00:00:00 2001 From: bandyopa Date: Fri, 31 May 2024 14:45:40 +0200 Subject: [PATCH 32/72] golden test --- tests/quickstarter/quickstarter_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 7c7c62959..0fcfef3d2 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -104,6 +104,9 @@ func TestQuickstarter(t *testing.T) { quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) quickstarterName := filepath.Base(quickstarterPath) + wd, _ := os.Getwd() + fmt.Println("Working Directory:", wd) + fmt.Printf("\n\n\n\n") fmt.Printf("Running tests for quickstarter %s\n", quickstarterName) fmt.Printf("\n\n") From 6d2567142e2b82a75a8c6a26011bfd05cacc3707 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Tue, 4 Jun 2024 16:56:26 +0200 Subject: [PATCH 33/72] golden test --- tests/quickstarter/quickstarter_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 0fcfef3d2..521f89e8a 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -100,13 +100,14 @@ func TestQuickstarter(t *testing.T) { fmt.Printf("\n\n") for _, quickstarterPath := range quickstarterPaths { - testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) - quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) - quickstarterName := filepath.Base(quickstarterPath) wd, _ := os.Getwd() fmt.Println("Working Directory:", wd) - + + testdataPath := fmt.Sprintf("%s/%s/testdata", wd, quickstarterPath) + quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) + quickstarterName := filepath.Base(quickstarterPath) + fmt.Printf("\n\n\n\n") fmt.Printf("Running tests for quickstarter %s\n", quickstarterName) fmt.Printf("\n\n") From 93b3b4c2d49af0361fdf3812f160c58fab475958 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Wed, 3 Jul 2024 18:11:51 +0200 Subject: [PATCH 34/72] golden test --- tests/quickstarter/quickstarter_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 521f89e8a..14a7e354f 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -108,6 +108,16 @@ func TestQuickstarter(t *testing.T) { quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) quickstarterName := filepath.Base(quickstarterPath) + files, err := ioutil.ReadDir(testdataPath) + if err != nil { + log.Fatal(err) + } + + for _, f := range files { + fmt.Println("Inside Loop") + fmt.Println(f.Name()) + } + fmt.Printf("\n\n\n\n") fmt.Printf("Running tests for quickstarter %s\n", quickstarterName) fmt.Printf("\n\n") From 6e07b3dcfaa3a9921bd7d01c4b5048085184479d Mon Sep 17 00:00:00 2001 From: bandyopa Date: Wed, 3 Jul 2024 18:20:12 +0200 Subject: [PATCH 35/72] golden test --- tests/quickstarter/quickstarter_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 14a7e354f..0e25ef503 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -12,6 +12,7 @@ import ( "strings" "testing" "text/template" + "log" "github.com/opendevstack/ods-core/tests/utils" ) From b070dd8a9d7611acf495aa73a34d9c74f40aa267 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Wed, 3 Jul 2024 18:25:03 +0200 Subject: [PATCH 36/72] golden test --- tests/quickstarter/quickstarter_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 0e25ef503..c1edcf617 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -105,11 +105,7 @@ func TestQuickstarter(t *testing.T) { wd, _ := os.Getwd() fmt.Println("Working Directory:", wd) - testdataPath := fmt.Sprintf("%s/%s/testdata", wd, quickstarterPath) - quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) - quickstarterName := filepath.Base(quickstarterPath) - - files, err := ioutil.ReadDir(testdataPath) + files, err := ioutil.ReadDir(wd) if err != nil { log.Fatal(err) } @@ -119,6 +115,10 @@ func TestQuickstarter(t *testing.T) { fmt.Println(f.Name()) } + testdataPath := fmt.Sprintf("%s/%s/testdata", wd, quickstarterPath) + quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) + quickstarterName := filepath.Base(quickstarterPath) + fmt.Printf("\n\n\n\n") fmt.Printf("Running tests for quickstarter %s\n", quickstarterName) fmt.Printf("\n\n") From e5aca74bb354e27976cf6ab4ade9f1f423609672 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Wed, 3 Jul 2024 18:29:47 +0200 Subject: [PATCH 37/72] golden test --- tests/quickstarter/quickstarter_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index c1edcf617..6dc5dbea5 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -105,17 +105,16 @@ func TestQuickstarter(t *testing.T) { wd, _ := os.Getwd() fmt.Println("Working Directory:", wd) - files, err := ioutil.ReadDir(wd) + files, err := ioutil.ReadDir(quickstarterPath) if err != nil { log.Fatal(err) } for _, f := range files { - fmt.Println("Inside Loop") fmt.Println(f.Name()) } - testdataPath := fmt.Sprintf("%s/%s/testdata", wd, quickstarterPath) + testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) quickstarterName := filepath.Base(quickstarterPath) From 417a4a91411f9cec70c156ca18c206d4d9022bf1 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 4 Jul 2024 09:37:06 +0200 Subject: [PATCH 38/72] golden test --- tests/quickstarter/quickstarter_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 6dc5dbea5..38f52fb9b 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -104,8 +104,9 @@ func TestQuickstarter(t *testing.T) { wd, _ := os.Getwd() fmt.Println("Working Directory:", wd) + fmt.Println("QS Directory:", "%s/../../../", wd) - files, err := ioutil.ReadDir(quickstarterPath) + files, err := ioutil.ReadDir("%s/../../../", wd) if err != nil { log.Fatal(err) } From 36fd3e82ecd7932dc0cacf265199d77783b68f72 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 4 Jul 2024 09:40:47 +0200 Subject: [PATCH 39/72] golden test --- tests/quickstarter/quickstarter_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 38f52fb9b..1a95e1d05 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -106,7 +106,9 @@ func TestQuickstarter(t *testing.T) { fmt.Println("Working Directory:", wd) fmt.Println("QS Directory:", "%s/../../../", wd) - files, err := ioutil.ReadDir("%s/../../../", wd) + testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) + + files, err := ioutil.ReadDir(testdataPath) if err != nil { log.Fatal(err) } @@ -114,8 +116,7 @@ func TestQuickstarter(t *testing.T) { for _, f := range files { fmt.Println(f.Name()) } - - testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) + quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) quickstarterName := filepath.Base(quickstarterPath) From 156fe7225afb5ad1b59c866c137acbe8b30937af Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 4 Jul 2024 09:43:56 +0200 Subject: [PATCH 40/72] golden test --- tests/quickstarter/quickstarter_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 1a95e1d05..dbafbb8ba 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -104,7 +104,6 @@ func TestQuickstarter(t *testing.T) { wd, _ := os.Getwd() fmt.Println("Working Directory:", wd) - fmt.Println("QS Directory:", "%s/../../../", wd) testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) From e05bc360020ac51695e314bd9f0c0c6d4f8eef83 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 4 Jul 2024 09:47:16 +0200 Subject: [PATCH 41/72] golden test --- tests/quickstarter/quickstarter_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index dbafbb8ba..2b7b23e48 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -104,6 +104,7 @@ func TestQuickstarter(t *testing.T) { wd, _ := os.Getwd() fmt.Println("Working Directory:", wd) + fmt.Println("QS Directory:", /tmp/workspace/qstestlauncher/Quickstarter-Golden-Test-Launcher/) testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) From c4a2018e870a087a15bdce6ebf88e1d06fb19dbe Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 4 Jul 2024 09:49:55 +0200 Subject: [PATCH 42/72] golden test --- tests/quickstarter/quickstarter_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 2b7b23e48..de4232722 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -104,7 +104,8 @@ func TestQuickstarter(t *testing.T) { wd, _ := os.Getwd() fmt.Println("Working Directory:", wd) - fmt.Println("QS Directory:", /tmp/workspace/qstestlauncher/Quickstarter-Golden-Test-Launcher/) + qs := /tmp/workspace/qstestlauncher/Quickstarter-Golden-Test-Launcher/ + fmt.Println("QS Directory:", qs) testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) From 690230707cd1e48c635bb818cb41d34f7576dfa6 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 4 Jul 2024 09:51:48 +0200 Subject: [PATCH 43/72] golden test --- tests/quickstarter/quickstarter_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index de4232722..ce279b117 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -104,7 +104,7 @@ func TestQuickstarter(t *testing.T) { wd, _ := os.Getwd() fmt.Println("Working Directory:", wd) - qs := /tmp/workspace/qstestlauncher/Quickstarter-Golden-Test-Launcher/ + qs := "/tmp/workspace/qstestlauncher/Quickstarter-Golden-Test-Launcher/" fmt.Println("QS Directory:", qs) testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) From 25ab230177caacca69e591751f26569f5fa282c6 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Thu, 4 Jul 2024 09:54:21 +0200 Subject: [PATCH 44/72] golden test --- tests/quickstarter/quickstarter_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index ce279b117..fd3fccff2 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -107,9 +107,7 @@ func TestQuickstarter(t *testing.T) { qs := "/tmp/workspace/qstestlauncher/Quickstarter-Golden-Test-Launcher/" fmt.Println("QS Directory:", qs) - testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) - - files, err := ioutil.ReadDir(testdataPath) + files, err := ioutil.ReadDir(qs) if err != nil { log.Fatal(err) } @@ -117,6 +115,8 @@ func TestQuickstarter(t *testing.T) { for _, f := range files { fmt.Println(f.Name()) } + + testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) quickstarterName := filepath.Base(quickstarterPath) From d7b2697b03eaca7f750f779115d59491d951e3a2 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Fri, 23 Aug 2024 14:13:59 +0200 Subject: [PATCH 45/72] golden test --- tests/Jenkinsfile | 162 ++++++++++++++++++++++++ tests/quickstarter/quickstarter_test.go | 4 +- 2 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 tests/Jenkinsfile diff --git a/tests/Jenkinsfile b/tests/Jenkinsfile new file mode 100644 index 000000000..c231e9147 --- /dev/null +++ b/tests/Jenkinsfile @@ -0,0 +1,162 @@ +properties([ + parameters([ + string( + name: 'Quickstarter', + defaultValue: 'all', + description: 'Enter the quickstarter name which is to be tested' + ), + string( + name: 'QuickstarterRepository', + defaultValue: 'ods-quickstarters', + description: 'Enter the repository name for the quickstarter which is to be tested' + ), + string( + name: 'quickstarterRef', + defaultValue: '4.x', + description: 'Enter the reference for the quickstarter (e.g., branch, tag, or commit)' + ), + string( + name: 'Project', + defaultValue: 'ods', + description: 'Enter the project name where the quickstarter in lower case will be provisioned' + ), + string( + name: 'ODS_URL', + defaultValue: 'https://github.com/opendevstack', + description: 'Enter the whole URL of the ODS files (https included)' + ), + text( + name: 'excludedQuickstarters', + defaultValue: '''inf-terraform-aws +inf-terraform-azure +ods-document-gen-svc +ods-provisioning-app +release-manager +ds-jupyter-lab +ds-rshiny''', + description: 'Enter the list of excluded quickstarters, one per line' + ) + ]), + disableConcurrentBuilds(), + buildDiscarder(logRotator(numToKeepStr: '10')), +]) + +// The project that we will use to test the quickstarters +def project = params.Project +// The Quickstarter to test +def quickstarter = params.Quickstarter +// Namespace fo the cd project +def odsNamespace = env.ODS_NAMESPACE ?: "$project-cd" +// projectID +def projectId = env.PROJECT_ID +// odsReference +def odsRef = params.quickstarterRef?:"master" +// QS repo +def QUICKSTARTER_REPO = params.QuickstarterRepository + +// URIS of the repositories used +def QUICK_STARTERS_URL = "${ODS_URL}/${QUICKSTARTER_REPO}.git" +def QUICK_STARTERS_BRANCH = "${quickstarterRef}" + +def ODS_CONFIGURATION_URL = "${ODS_URL}/ods-configuration.git" +def ODS_CONFIGURATION_BRANCH = "${quickstarterRef}" + +def ODS_CORE_URL = "${ODS_URL}/ods-core.git" +def ODS_CORE_BRANCH = "${quickstarterRef}" + +// List of QS that we want to exclude from the execution of the job. +def excludedQS = params.excludedQuickstarters?:'' + + +echo "QUICKSTARTER_REPO : ${QUICKSTARTER_REPO}" + +// Jenkins DeploymentConfig environment variables +def dockerRegistry +node { + dockerRegistry = env.DOCKER_REGISTRY +} + +// We need a golang version >= 17, so if we don't have one we need to build it. +// trigger pipeline + +def conts = containerTemplate( + name: 'jnlp', + image: "${dockerRegistry}/${odsNamespace}/jenkins-agent-golang:latest", + workingDir: '/tmp', + alwaysPullImage: true, + args: '' +) +def podLabel = "qs-tests" + +podTemplate( + label: podLabel, + cloud: 'openshift', + containers: [conts], + volumes: [], + serviceAccount: 'jenkins' +) { + node(podLabel) { + + stage('Init') { + currentBuild.description = "Testing QS" + + dir('ods-quickstarters'){ + git branch: "${QUICK_STARTERS_BRANCH}", + credentialsId: "${project}-cd-cd-user-with-password", + url: "${QUICK_STARTERS_URL}" + } + dir('ods-configuration'){ + //git branch: "${ODS_CONFIGURATION_BRANCH}", + git branch: "EDPQSTEST", // hardcoded for testing, remove before merging to github + credentialsId: "${project}-cd-cd-user-token", + url: "${ODS_CONFIGURATION_URL}" + } + + dir('ods-core'){ + git branch: "${ODS_CORE_BRANCH}", + credentialsId: "${project}-cd-cd-user-with-password", + url: "${ODS_CORE_URL}" + + // Write the file used to exclude Quickstarters in the tests + echo "Writing file quickStartersExclusionList.txt" + writeFile file: './tests/quickStartersExclusionList.txt', text: excludedQS + } + } + + stage('Test') { + echo "${WORKSPACE}" + + // If we select 'all' no one parameter will be provided, so it will try to test all the Quickstarters + // that have a test defined in the testdata folder. + def quickstarter_to_test = "" + quickstarter_to_test = "-q ${quickstarter}" + + echo "QUICKSTARTER TO TEST : ${quickstarter_to_test}" + echo "QUICKSTARTER REPO : ${QUICKSTARTER_REPO}" + echo "Project : ${project}" + + // In different environments SONAR_QUALITY_PROFILE can be different, with this env variable we provide + // the needed value + withEnv([ + "CGO_ENABLED=0", + "GOMODCACHE=${WORKSPACE}/.cache", + "SONAR_QUALITY_PROFILE=sonar way", + "ODS_GIT_REF=${odsRef}"]) { + sh """ + cd ods-core/tests + ls -lrta + ./quickstarter-test.sh -p ${project} -qf "${QUICKSTARTER_REPO}/..." ${quickstarter_to_test} || true + """ + } + + } + + stage('Get test results') { + archiveArtifacts artifacts: 'ods-core/tests/*.txt', followSymlinks: false + archiveArtifacts artifacts: 'ods-core/tests/test-quickstarter-report.xml', followSymlinks: false + junit(testResults:"ods-core/tests/test-quickstarter-report.xml", allowEmptyResults:true) + + } + } +} + diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index fd3fccff2..c75252d8f 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -104,13 +104,13 @@ func TestQuickstarter(t *testing.T) { wd, _ := os.Getwd() fmt.Println("Working Directory:", wd) - qs := "/tmp/workspace/qstestlauncher/Quickstarter-Golden-Test-Launcher/" + /*qs := "/tmp/workspace/qstestlauncher/Quickstarter-Golden-Test-Launcher/" fmt.Println("QS Directory:", qs) files, err := ioutil.ReadDir(qs) if err != nil { log.Fatal(err) - } + }*/ for _, f := range files { fmt.Println(f.Name()) From fa75db41a99285549ef54a8e3bab36f9287e2567 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Fri, 23 Aug 2024 14:23:27 +0200 Subject: [PATCH 46/72] golden test --- tests/quickstarter/quickstarter_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index c75252d8f..52da857b8 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -12,7 +12,6 @@ import ( "strings" "testing" "text/template" - "log" "github.com/opendevstack/ods-core/tests/utils" ) @@ -102,19 +101,19 @@ func TestQuickstarter(t *testing.T) { for _, quickstarterPath := range quickstarterPaths { - wd, _ := os.Getwd() + /*wd, _ := os.Getwd() fmt.Println("Working Directory:", wd) - /*qs := "/tmp/workspace/qstestlauncher/Quickstarter-Golden-Test-Launcher/" + qs := "/tmp/workspace/qstestlauncher/Quickstarter-Golden-Test-Launcher/" fmt.Println("QS Directory:", qs) files, err := ioutil.ReadDir(qs) if err != nil { log.Fatal(err) - }*/ + } for _, f := range files { fmt.Println(f.Name()) - } + }*/ testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) From 7dbb4e5a1b1ef99990284eb50c1d491bd8dfddc1 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 26 Aug 2024 08:42:49 +0200 Subject: [PATCH 47/72] golden test --- tests/Jenkinsfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/Jenkinsfile b/tests/Jenkinsfile index c231e9147..ab433e880 100644 --- a/tests/Jenkinsfile +++ b/tests/Jenkinsfile @@ -2,7 +2,8 @@ properties([ parameters([ string( name: 'Quickstarter', - defaultValue: 'all', + //defaultValue: 'all', + defaultValue: 'docker-plain', description: 'Enter the quickstarter name which is to be tested' ), string( @@ -12,17 +13,20 @@ properties([ ), string( name: 'quickstarterRef', - defaultValue: '4.x', + //defaultValue: '4.x', + defaultValue: 'feature/quickstarter-golden-test', description: 'Enter the reference for the quickstarter (e.g., branch, tag, or commit)' ), string( name: 'Project', - defaultValue: 'ods', + //defaultValue: 'ods', + defaultValue: 'edpqstest', description: 'Enter the project name where the quickstarter in lower case will be provisioned' ), string( name: 'ODS_URL', - defaultValue: 'https://github.com/opendevstack', + //defaultValue: 'https://github.com/opendevstack', + defaultValue: 'https://bitbucket-dev.biscrum.com/scm/ODS4', description: 'Enter the whole URL of the ODS files (https included)' ), text( @@ -100,7 +104,7 @@ podTemplate( stage('Init') { currentBuild.description = "Testing QS" - dir('ods-quickstarters'){ + dir("${QUICKSTARTER_REPO}"){ git branch: "${QUICK_STARTERS_BRANCH}", credentialsId: "${project}-cd-cd-user-with-password", url: "${QUICK_STARTERS_URL}" From 0fd4aef2606795ba31413eb48ced165739e34fa9 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 26 Aug 2024 08:46:47 +0200 Subject: [PATCH 48/72] remove commented code --- tests/quickstarter/quickstarter_test.go | 37 ------------------------- 1 file changed, 37 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 52da857b8..b74eec1f5 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -58,29 +58,6 @@ func TestQuickstarter(t *testing.T) { } } - - /* if strings.HasPrefix(target, ".") || strings.HasPrefix(target, "/") { - if strings.HasSuffix(target, "...") { - quickstarterPaths = collectTestableQuickstarters( - t, strings.TrimSuffix(target, "/..."), - ) - } else { - quickstarterPaths = append(quickstarterPaths, target) - } - } else { - // No slash = quickstarter in ods-quickstarters - // Ending with ... = all quickstarters in given folder - // otherwise = exactly one quickstarter - if !strings.Contains(target, "/") { - quickstarterPaths = []string{fmt.Sprintf("%s/../%s/%s", odsCoreRootPath, "ods-quickstarters", target)} - } else if strings.HasSuffix(target, "...") { - quickstarterPaths = collectTestableQuickstarters( - t, fmt.Sprintf("%s/../%s", odsCoreRootPath, strings.TrimSuffix(target, "/...")), - ) - } else { - quickstarterPaths = []string{fmt.Sprintf("%s/../%s", odsCoreRootPath, target)} - } - } */ dir, err := os.Getwd() if err != nil { fmt.Println("Error:", err) @@ -101,20 +78,6 @@ func TestQuickstarter(t *testing.T) { for _, quickstarterPath := range quickstarterPaths { - /*wd, _ := os.Getwd() - fmt.Println("Working Directory:", wd) - qs := "/tmp/workspace/qstestlauncher/Quickstarter-Golden-Test-Launcher/" - fmt.Println("QS Directory:", qs) - - files, err := ioutil.ReadDir(qs) - if err != nil { - log.Fatal(err) - } - - for _, f := range files { - fmt.Println(f.Name()) - }*/ - testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) From 71b2175eff4d015a1186f9e01b036effa5565d21 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 26 Aug 2024 10:06:37 +0200 Subject: [PATCH 49/72] fix parameters --- tests/Jenkinsfile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/Jenkinsfile b/tests/Jenkinsfile index ab433e880..e9383ae34 100644 --- a/tests/Jenkinsfile +++ b/tests/Jenkinsfile @@ -2,9 +2,8 @@ properties([ parameters([ string( name: 'Quickstarter', - //defaultValue: 'all', defaultValue: 'docker-plain', - description: 'Enter the quickstarter name which is to be tested' + description: 'Enter the quickstarter name which is to be tested. Use 'all' to test all the quickstarters together' ), string( name: 'QuickstarterRepository', @@ -13,22 +12,23 @@ properties([ ), string( name: 'quickstarterRef', - //defaultValue: '4.x', - defaultValue: 'feature/quickstarter-golden-test', + defaultValue: 'master', description: 'Enter the reference for the quickstarter (e.g., branch, tag, or commit)' ), string( name: 'Project', - //defaultValue: 'ods', - defaultValue: 'edpqstest', + defaultValue: 'ods', description: 'Enter the project name where the quickstarter in lower case will be provisioned' ), string( name: 'ODS_URL', - //defaultValue: 'https://github.com/opendevstack', - defaultValue: 'https://bitbucket-dev.biscrum.com/scm/ODS4', description: 'Enter the whole URL of the ODS files (https included)' ), + string( + name: 'JENKINS_AGENT_TAG', + defaultValue: 'latest', + description: 'Enter the tag for the jenkins golang agent' + ), text( name: 'excludedQuickstarters', defaultValue: '''inf-terraform-aws @@ -68,6 +68,8 @@ def ODS_CONFIGURATION_BRANCH = "${quickstarterRef}" def ODS_CORE_URL = "${ODS_URL}/ods-core.git" def ODS_CORE_BRANCH = "${quickstarterRef}" +def JENKINS_AGENT_TAG = "${JENKINS_AGENT_TAG}" + // List of QS that we want to exclude from the execution of the job. def excludedQS = params.excludedQuickstarters?:'' @@ -85,7 +87,7 @@ node { def conts = containerTemplate( name: 'jnlp', - image: "${dockerRegistry}/${odsNamespace}/jenkins-agent-golang:latest", + image: "${dockerRegistry}/${odsNamespace}/jenkins-agent-golang:"${JENKINS_AGENT_TAG}"", workingDir: '/tmp', alwaysPullImage: true, args: '' From f3c6740cbd6a75afa2d31372cf819aabf334fee3 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 26 Aug 2024 10:42:25 +0200 Subject: [PATCH 50/72] update go version to 1.22 --- tests/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/go.mod b/tests/go.mod index 6096438b9..b6b764d49 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -1,6 +1,6 @@ module github.com/opendevstack/ods-core/tests -go 1.13 +go 1.22 require ( github.com/ericchiang/pup v0.4.0 // indirect From 816435585a94da65ce5d04aa7e09d73a6360f2bd Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 2 Sep 2024 10:26:22 +0200 Subject: [PATCH 51/72] golden test --- tests/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/go.mod b/tests/go.mod index b6b764d49..f60d7d98d 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -1,6 +1,6 @@ module github.com/opendevstack/ods-core/tests -go 1.22 +go 1.23.0 require ( github.com/ericchiang/pup v0.4.0 // indirect From e03a0df3c8f3b9fe8c7760e378a28d707d367a92 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 2 Sep 2024 13:07:30 +0200 Subject: [PATCH 52/72] golden test --- tests/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/go.mod b/tests/go.mod index f60d7d98d..ec599356d 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -1,6 +1,6 @@ module github.com/opendevstack/ods-core/tests -go 1.23.0 +go 1.23 require ( github.com/ericchiang/pup v0.4.0 // indirect From faf2a3379ee569946d0f24bce805e84ae304e8ed Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 2 Sep 2024 13:23:10 +0200 Subject: [PATCH 53/72] revert go version --- tests/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/go.mod b/tests/go.mod index ec599356d..6096438b9 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -1,6 +1,6 @@ module github.com/opendevstack/ods-core/tests -go 1.23 +go 1.13 require ( github.com/ericchiang/pup v0.4.0 // indirect From 826a930c31b7d1708400c73d19ed0721e2ebb918 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 2 Sep 2024 13:43:26 +0200 Subject: [PATCH 54/72] golden test --- tests/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/go.mod b/tests/go.mod index 6096438b9..ec8f9361e 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -1,6 +1,6 @@ module github.com/opendevstack/ods-core/tests -go 1.13 +go 1.21 require ( github.com/ericchiang/pup v0.4.0 // indirect From ae228884414ba769bf03c42e14ad88abb5fd94bf Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 2 Sep 2024 13:51:49 +0200 Subject: [PATCH 55/72] golden test --- tests/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/go.mod b/tests/go.mod index ec8f9361e..ec599356d 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -1,6 +1,6 @@ module github.com/opendevstack/ods-core/tests -go 1.21 +go 1.23 require ( github.com/ericchiang/pup v0.4.0 // indirect From 14c3c6d870b2edcd4b8a73bb6524d52d4c73488f Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 2 Sep 2024 14:00:04 +0200 Subject: [PATCH 56/72] golden test --- tests/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/go.mod b/tests/go.mod index ec599356d..6096438b9 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -1,6 +1,6 @@ module github.com/opendevstack/ods-core/tests -go 1.23 +go 1.13 require ( github.com/ericchiang/pup v0.4.0 // indirect From 39f4fdc7109c57c53bd6e5ee54f44ae7b19132fd Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Mon, 2 Sep 2024 14:09:34 +0200 Subject: [PATCH 57/72] update golang to 1.23 and tidy packages --- tests/go.mod | 27 ++++++++++++++++----------- tests/go.sum | 27 --------------------------- 2 files changed, 16 insertions(+), 38 deletions(-) diff --git a/tests/go.mod b/tests/go.mod index 6096438b9..a3e6e205a 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -1,38 +1,43 @@ module github.com/opendevstack/ods-core/tests -go 1.13 +go 1.23 require ( - github.com/ericchiang/pup v0.4.0 // indirect - github.com/fatih/color v1.13.0 // indirect github.com/ghodss/yaml v1.0.0 + github.com/google/go-cmp v0.5.1 + github.com/jstemmer/go-junit-report v0.9.1 + github.com/openshift/api v0.0.0-20180801171038-322a19404e37 + github.com/openshift/client-go v3.9.0+incompatible + k8s.io/api v0.0.0-20190222213804-5cb15d344471 + k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628 + k8s.io/client-go v0.0.0-20190228174230-b40b2a5939e4 +) + +require ( github.com/gogo/protobuf v1.3.1 // indirect github.com/golang/protobuf v1.4.2 // indirect github.com/google/btree v1.0.0 // indirect - github.com/google/go-cmp v0.5.1 + github.com/google/gofuzz v1.0.0 // indirect github.com/googleapis/gnostic v0.4.0 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect github.com/imdario/mergo v0.3.8 // indirect github.com/json-iterator/go v1.1.8 // indirect - github.com/jstemmer/go-junit-report v0.9.1 github.com/kr/pretty v0.2.1 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect + github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect github.com/modern-go/reflect2 v1.0.1 // indirect - github.com/openshift/api v0.0.0-20180801171038-322a19404e37 - github.com/openshift/client-go v3.9.0+incompatible github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/spf13/pflag v1.0.5 // indirect golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 // indirect golang.org/x/net v0.0.0-20220524220425-1d687d428aca // indirect golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6 // indirect golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect + google.golang.org/appengine v1.4.0 // indirect + google.golang.org/protobuf v1.23.0 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect - k8s.io/api v0.0.0-20190222213804-5cb15d344471 - k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628 - k8s.io/client-go v0.0.0-20190228174230-b40b2a5939e4 k8s.io/klog v1.0.0 // indirect sigs.k8s.io/yaml v1.1.0 // indirect ) diff --git a/tests/go.sum b/tests/go.sum index 32a856f7b..e122315f2 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -3,16 +3,11 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/ericchiang/pup v0.4.0 h1:h9ahJXbHA3V8MFfAmasxi8DCx0Gu+aLAAEtb8Q3KCOo= -github.com/ericchiang/pup v0.4.0/go.mod h1:PpPzKkuAB7ypCQf9+wxC5MzaGaIDdgjtlpvc/0NaTJc= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -27,16 +22,12 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ github.com/google/gnostic v0.4.0 h1:9iS1H6UOaLpeNN1XLeRcR9qdtmGabUmQaBsrDONz6D4= github.com/google/gnostic v0.4.0/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/googleapis/gnostic v0.4.0 h1:BXDUo8p/DaxC+4FJY/SSx3gvnx9C1VdHNgaUkiEL5mk= -github.com/googleapis/gnostic v0.4.0/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/imdario/mergo v0.3.8 h1:CGgOkSJeqMRmt0D9XLWExdT4m4F1vd3FV3VPt+0VxkQ= @@ -52,12 +43,6 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -80,9 +65,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20220524220425-1d687d428aca h1:xTaFYiPROfpPhqrfTIDXj0ri1SpfueYT951s4bAuDO8= golang.org/x/net v0.0.0-20220524220425-1d687d428aca/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -90,24 +73,14 @@ golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6 h1:pE8b58s1HRDMi8RDc79m0H golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From d1146058bd992b30f5f51a061479b41301a4a350 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 2 Sep 2024 14:26:23 +0200 Subject: [PATCH 58/72] golden test --- tests/go.mod | 5 +---- tests/quickstarter/quickstarter_test.go | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/go.mod b/tests/go.mod index a3e6e205a..fddbad593 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -3,7 +3,7 @@ module github.com/opendevstack/ods-core/tests go 1.23 require ( - github.com/ghodss/yaml v1.0.0 + github.com/ghodss/yaml v1.0.0 github.com/google/go-cmp v0.5.1 github.com/jstemmer/go-junit-report v0.9.1 github.com/openshift/api v0.0.0-20180801171038-322a19404e37 @@ -11,9 +11,6 @@ require ( k8s.io/api v0.0.0-20190222213804-5cb15d344471 k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628 k8s.io/client-go v0.0.0-20190228174230-b40b2a5939e4 -) - -require ( github.com/gogo/protobuf v1.3.1 // indirect github.com/golang/protobuf v1.4.2 // indirect github.com/google/btree v1.0.0 // indirect diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index b74eec1f5..644e3bc45 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -69,6 +69,7 @@ func TestQuickstarter(t *testing.T) { if err != nil { t.Fatal(err) } + fmt.Printf("\nConfig:\n%s", config) fmt.Printf("\n\nRunning test steps found in the following directories:\n") for _, quickstarterPath := range quickstarterPaths { From d65fc861fd4b4d9f0956d0e485c83e4016bfa67a Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 2 Sep 2024 14:33:23 +0200 Subject: [PATCH 59/72] golden test --- tests/quickstarter/quickstarter_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 644e3bc45..507912abd 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -69,8 +69,7 @@ func TestQuickstarter(t *testing.T) { if err != nil { t.Fatal(err) } - fmt.Printf("\nConfig:\n%s", config) - + fmt.Printf("\n\nRunning test steps found in the following directories:\n") for _, quickstarterPath := range quickstarterPaths { fmt.Printf("- %s\n", quickstarterPath) @@ -149,6 +148,9 @@ func TestQuickstarter(t *testing.T) { func executeProvision(t *testing.T, step TestStep, testdataPath string, tmplData TemplateData, repoName string, quickstarterRepo string, quickstarterName string, config map[string]string) { // cleanup and create bb resources for this test + fmt.Printf("\n\n\nConfig:\n%s\n\n", config) + fmt.Printf("\n\n\nUtils.ProjectName:\n%s\n\n", utils.PROJECT_NAME) + fmt.Printf("\n\n\repoName:\n%s\n\n", repoName) err := recreateBitbucketRepo(config, utils.PROJECT_NAME, repoName) if err != nil { t.Fatal(err) From 9649326ffc76ace26bbfa74a01ab3b4254cdbcf9 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Mon, 2 Sep 2024 14:52:42 +0200 Subject: [PATCH 60/72] golden test --- tests/scripts/recreate-bitbucket-repo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/recreate-bitbucket-repo.sh b/tests/scripts/recreate-bitbucket-repo.sh index 9a4344e16..d5cd26512 100755 --- a/tests/scripts/recreate-bitbucket-repo.sh +++ b/tests/scripts/recreate-bitbucket-repo.sh @@ -80,7 +80,7 @@ if [ "${httpCode}" == "404" ]; then elif [ "${httpCode}" == "200" ]; then echo_info "Found project ${BITBUCKET_PROJECT} in Bitbucket." else - echo_error "Could not determine state of project ${BITBUCKET_PROJECT} on Bitbucket, got ${httpCode}." + echo_error "Could not determine state of project ${BITBUCKET_PROJECT} on Bitbucket with url ${BITBUCKET_URL}, got ${httpCode}." exit 1 fi From 440dbc5ee6b8518e5c7092b2e9ec806dcacb3be4 Mon Sep 17 00:00:00 2001 From: bandyopa Date: Tue, 3 Sep 2024 18:32:24 +0200 Subject: [PATCH 61/72] golden test --- tests/Jenkinsfile | 30 ++++++++++++++---------- tests/quickstarter/quickstarter_test.go | 3 --- tests/scripts/recreate-bitbucket-repo.sh | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/Jenkinsfile b/tests/Jenkinsfile index e9383ae34..18de52dfa 100644 --- a/tests/Jenkinsfile +++ b/tests/Jenkinsfile @@ -2,8 +2,7 @@ properties([ parameters([ string( name: 'Quickstarter', - defaultValue: 'docker-plain', - description: 'Enter the quickstarter name which is to be tested. Use 'all' to test all the quickstarters together' + description: 'Enter the quickstarter name which is to be tested. Use "all" to test all the quickstarters together' ), string( name: 'QuickstarterRepository', @@ -12,21 +11,30 @@ properties([ ), string( name: 'quickstarterRef', - defaultValue: 'master', + defaultValue: '4.x', description: 'Enter the reference for the quickstarter (e.g., branch, tag, or commit)' ), string( name: 'Project', + description: 'Enter the project name (in lower case) where the quickstarter will be provisioned' + ), + string( + name: 'ODS_NAMESPACE', defaultValue: 'ods', - description: 'Enter the project name where the quickstarter in lower case will be provisioned' + description: 'Enter the ods namespae to fetch the jenkins agent. Include "-cd" if the ODS Namespace is not ods as default' ), string( name: 'ODS_URL', + defaultValue: 'https://github.com/opendevstack', description: 'Enter the whole URL of the ODS files (https included)' ), string( name: 'JENKINS_AGENT_TAG', - defaultValue: 'latest', + defaultValue: '4.x', + description: 'Enter the tag for the jenkins golang agent' + ), + string( + name: 'SONAR_QUALITY_PROFILE', description: 'Enter the tag for the jenkins golang agent' ), text( @@ -50,9 +58,7 @@ def project = params.Project // The Quickstarter to test def quickstarter = params.Quickstarter // Namespace fo the cd project -def odsNamespace = env.ODS_NAMESPACE ?: "$project-cd" -// projectID -def projectId = env.PROJECT_ID +def odsNamespace = params.ODS_NAMESPACE // odsReference def odsRef = params.quickstarterRef?:"master" // QS repo @@ -69,6 +75,7 @@ def ODS_CORE_URL = "${ODS_URL}/ods-core.git" def ODS_CORE_BRANCH = "${quickstarterRef}" def JENKINS_AGENT_TAG = "${JENKINS_AGENT_TAG}" +def SONAR_QUALITY_PROFILE = "${SONAR_QUALITY_PROFILE}" // List of QS that we want to exclude from the execution of the job. def excludedQS = params.excludedQuickstarters?:'' @@ -87,7 +94,7 @@ node { def conts = containerTemplate( name: 'jnlp', - image: "${dockerRegistry}/${odsNamespace}/jenkins-agent-golang:"${JENKINS_AGENT_TAG}"", + image: "${dockerRegistry}/${odsNamespace}/jenkins-agent-golang:${JENKINS_AGENT_TAG}", workingDir: '/tmp', alwaysPullImage: true, args: '' @@ -112,8 +119,7 @@ podTemplate( url: "${QUICK_STARTERS_URL}" } dir('ods-configuration'){ - //git branch: "${ODS_CONFIGURATION_BRANCH}", - git branch: "EDPQSTEST", // hardcoded for testing, remove before merging to github + git branch: "${ODS_CONFIGURATION_BRANCH}", credentialsId: "${project}-cd-cd-user-token", url: "${ODS_CONFIGURATION_URL}" } @@ -146,7 +152,7 @@ podTemplate( withEnv([ "CGO_ENABLED=0", "GOMODCACHE=${WORKSPACE}/.cache", - "SONAR_QUALITY_PROFILE=sonar way", + "SONAR_QUALITY_PROFILE=${SONAR_QUALITY_PROFILE}", "ODS_GIT_REF=${odsRef}"]) { sh """ cd ods-core/tests diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index 507912abd..eb764aec5 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -148,9 +148,6 @@ func TestQuickstarter(t *testing.T) { func executeProvision(t *testing.T, step TestStep, testdataPath string, tmplData TemplateData, repoName string, quickstarterRepo string, quickstarterName string, config map[string]string) { // cleanup and create bb resources for this test - fmt.Printf("\n\n\nConfig:\n%s\n\n", config) - fmt.Printf("\n\n\nUtils.ProjectName:\n%s\n\n", utils.PROJECT_NAME) - fmt.Printf("\n\n\repoName:\n%s\n\n", repoName) err := recreateBitbucketRepo(config, utils.PROJECT_NAME, repoName) if err != nil { t.Fatal(err) diff --git a/tests/scripts/recreate-bitbucket-repo.sh b/tests/scripts/recreate-bitbucket-repo.sh index d5cd26512..9a4344e16 100755 --- a/tests/scripts/recreate-bitbucket-repo.sh +++ b/tests/scripts/recreate-bitbucket-repo.sh @@ -80,7 +80,7 @@ if [ "${httpCode}" == "404" ]; then elif [ "${httpCode}" == "200" ]; then echo_info "Found project ${BITBUCKET_PROJECT} in Bitbucket." else - echo_error "Could not determine state of project ${BITBUCKET_PROJECT} on Bitbucket with url ${BITBUCKET_URL}, got ${httpCode}." + echo_error "Could not determine state of project ${BITBUCKET_PROJECT} on Bitbucket, got ${httpCode}." exit 1 fi From 189ba87d81ca4e212662db40766fd408d70f82b4 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Mon, 16 Sep 2024 17:43:10 +0200 Subject: [PATCH 62/72] update github actions to go 1.23 --- .github/workflows/continuous-integration-workflow.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 8c14f3c4d..9db653166 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -165,10 +165,10 @@ jobs: name: Checkout repository uses: actions/checkout@v4.1.7 - - name: Setup Go 1.18 + name: Setup Go 1.23 uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version: 1.23 - name: Verify all Go files are formatted with gofmt working-directory: tests @@ -186,7 +186,7 @@ jobs: name: Verify all Go tests pass linting uses: golangci/golangci-lint-action@v6 with: - version: v1.49.0 + version: v1.60.1 working-directory: tests args: --timeout=10m - From 1c415a5ff733a0d13f9fbcd9b918a38759fcc34a Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Mon, 16 Sep 2024 17:46:03 +0200 Subject: [PATCH 63/72] fix format --- tests/quickstarter/quickstarter_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/quickstarter/quickstarter_test.go b/tests/quickstarter/quickstarter_test.go index eb764aec5..70ecccca3 100644 --- a/tests/quickstarter/quickstarter_test.go +++ b/tests/quickstarter/quickstarter_test.go @@ -69,7 +69,6 @@ func TestQuickstarter(t *testing.T) { if err != nil { t.Fatal(err) } - fmt.Printf("\n\nRunning test steps found in the following directories:\n") for _, quickstarterPath := range quickstarterPaths { fmt.Printf("- %s\n", quickstarterPath) @@ -79,7 +78,6 @@ func TestQuickstarter(t *testing.T) { for _, quickstarterPath := range quickstarterPaths { testdataPath := fmt.Sprintf("%s/testdata", quickstarterPath) - quickstarterRepo := filepath.Base(filepath.Dir(quickstarterPath)) quickstarterName := filepath.Base(quickstarterPath) From f035678cfe7119cf1d13743148cc746ce8c965c8 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Mon, 16 Sep 2024 17:47:29 +0200 Subject: [PATCH 64/72] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd841c73a..3d1e2ce5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Webhook Proxy maintenance ([#1298](https://github.com/opendevstack/ods-core/pull/1298)) - Update SonarQube to 10.x non LTS ([#1300](https://github.com/opendevstack/ods-core/issues/1300)) - Jenkins maintenance ([#1299](https://github.com/opendevstack/ods-core/pull/1299)) and update java version in Jenkins ([#1295](https://github.com/opendevstack/ods-core/issues/1295)) +- Update and fix golden tests ([#1233](https://github.com/opendevstack/ods-core/issues/1233)) ### Fixed From fadbefd93761ea9ad8a71e5f7398101a11333feb Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Mon, 16 Sep 2024 18:00:48 +0200 Subject: [PATCH 65/72] format golang files --- tests/quickstarter/steps.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/quickstarter/steps.go b/tests/quickstarter/steps.go index ae441cd81..8b809105b 100644 --- a/tests/quickstarter/steps.go +++ b/tests/quickstarter/steps.go @@ -115,8 +115,9 @@ type TestStepVerify struct { // TemplateData holds template parameters. Those will be applied to all // values defined in the steps, as they are treated as Go templates. // For example, Jenkins run attachments can be defined like this: -// runAttachments: -// - SCRR-{{.ProjectID}}-{{.ComponentID}}.docx, and then the +// +// runAttachments: +// - SCRR-{{.ProjectID}}-{{.ComponentID}}.docx, and then the type TemplateData struct { // Project ID (the prefix of the *-cd, *-dev and *-test namespaces). ProjectID string From 3d7ae16ea40ce7cae4d813e6f82ccfeead0415e2 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Mon, 16 Sep 2024 18:02:49 +0200 Subject: [PATCH 66/72] go mod tidy --- tests/go.mod | 11 ++++++++--- tests/go.sum | 39 +++++---------------------------------- 2 files changed, 13 insertions(+), 37 deletions(-) diff --git a/tests/go.mod b/tests/go.mod index f934f5a5e..cd179ed50 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -3,7 +3,7 @@ module github.com/opendevstack/ods-core/tests go 1.23 require ( - github.com/ghodss/yaml v1.0.0 + github.com/ghodss/yaml v1.0.0 github.com/google/go-cmp v0.5.1 github.com/jstemmer/go-junit-report v0.9.1 github.com/openshift/api v0.0.0-20180801171038-322a19404e37 @@ -11,6 +11,9 @@ require ( k8s.io/api v0.0.0-20190222213804-5cb15d344471 k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628 k8s.io/client-go v0.0.0-20190228174230-b40b2a5939e4 +) + +require ( github.com/gogo/protobuf v1.3.1 // indirect github.com/golang/protobuf v1.4.2 // indirect github.com/google/btree v1.0.0 // indirect @@ -25,9 +28,11 @@ require ( github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/spf13/pflag v1.0.5 // indirect golang.org/x/crypto v0.17.0 // indirect + golang.org/x/net v0.10.0 // indirect golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6 // indirect - golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect - golang.org/x/text v0.3.7 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect google.golang.org/appengine v1.4.0 // indirect google.golang.org/protobuf v1.23.0 // indirect diff --git a/tests/go.sum b/tests/go.sum index 998fe28d6..2ca0ca9ed 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -36,7 +36,7 @@ github.com/json-iterator/go v1.1.8 h1:QiWkFLKq0T7mpzwOTu6BzNDbfTE8OLrYhVKYMLF46O github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -61,47 +61,20 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6 h1:pE8b58s1HRDMi8RDc79m0HISf9D4TzseP40cEA6IGfs= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= @@ -109,8 +82,6 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= From b7dd84eac13cd9fe6bc2666dc7bd45aad9a60a37 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Wed, 25 Sep 2024 13:47:43 +0200 Subject: [PATCH 67/72] Jenkins Pipeline creation in makefile --- tests/Makefile | 18 ++++++-- tests/golden-test-pipeline.yml | 76 ++++++++++++++++++++++++++++++++ tests/jenkinsPipelineCreation.sh | 55 +++++++++++++++++++++++ 3 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 tests/golden-test-pipeline.yml create mode 100644 tests/jenkinsPipelineCreation.sh diff --git a/tests/Makefile b/tests/Makefile index 2dc681b46..d7c9ce5cc 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -7,9 +7,15 @@ MAKEFLAGS += --no-builtin-rules ### By default we test all quickstarters located in ods-quickstarters QS := ods-quickstarters/... +# Load environment variables from .env file +include ../../ods-configuration/ods-core.env +export $(shell sed 's/=.*//' ../../ods-configuration/ods-core.env) + ### By default we do not parallelize tests PARALLEL := 1 PROJECT := unitt +SONAR_PROFILE := "Sonar way" +QUICKSTARTER_REPOSITORY := ods-quickstarters ## Full test of existing ODS core installation. Caution: Creates UNITT project and ODSVERIFY project. test: smoketest verify test-create-projects @@ -34,7 +40,13 @@ test-create-projects: @(./create-projects-test.sh) .PHONY: test-create-projects -## Run quickstarter tests within existing ODS installation. Depends on UNITT project. +## Create Jenkins pipeline using REST API +jenkins-pipeline: + @(envsubst < jenkinsPipelineCreation.sh) + @(./jenkinsPipelineCreation.sh -p $(PROJECT) -q $(QUICKSTARTER_REPOSITORY) -s $(SONAR_PROFILE)) +.PHONY: jenkins-pipeline + +## Run quickstarter tests within existing ODS installation. Depends on UNITT project (default). test-quickstarter: @(./quickstarter-test.sh -p $(PROJECT) -q $(QS) -pa $(PARALLEL)) .PHONY: test-quickstarter @@ -42,14 +54,14 @@ test-quickstarter: ## Install tools required for tests. prep-tools: which go-junit-report || go get github.com/jstemmer/go-junit-report - which golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.50.0 + which golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.60.1 .PHONY: prep-tools ## Lint lint: echo "Checking code ..." golangci-lint --version - golangci-lint run --go=1.18 + golangci-lint run --go=1.23 .PHONY: lint ### HELP diff --git a/tests/golden-test-pipeline.yml b/tests/golden-test-pipeline.yml new file mode 100644 index 000000000..379b49392 --- /dev/null +++ b/tests/golden-test-pipeline.yml @@ -0,0 +1,76 @@ +apiVersion: template.openshift.io/v1 +kind: Template +parameters: + - name: PROJECT + displayName: Application + description: The name of the application project. + required: true + - name: ODS_GIT_REF + displayName: Git branch + description: The git branch to use for the pipeline. + required: true + - name: ODS_IMAGE_TAG + displayName: Agent tag + description: The tag for the jenkins golang agent. + required: true + - name: ODS_NAMESPACE + displayName: ODS namespace + description: The ods namespae to fetch the jenkins agent. Include "-cd" if the ODS Namespace is not ods as default + required: true + - name: BITBUCKET_URL + displayName: Bitbucket server URL + description: The Bitbucket server URL. + required: true + - name: ODS_BITBUCKET_PROJECT + displayName: ODS Bitbucket project + description: The ODS Bitbucket project. + required: true + - name: SONAR_QUALITY_PROFILE + displayName: SonarQube Quality Profile + description: SonarQube Quality Profile. + required: true + - name: QuickstarterRepository + displayName: Quickstarter repository + description: Quickstarter repository. + required: true +objects: + - apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + labels: + template: golden-test-pipeline + name: '${PROJECT}-golden-test' + spec: + failedBuildsHistoryLimit: 5 + runPolicy: Serial + source: + git: + ref: ${ODS_GIT_REF} + uri: '${BITBUCKET_URL}/${ODS_BITBUCKET_PROJECT}/ods-core.git' + sourceSecret: + name: cd-user-with-password + type: Git + strategy: + jenkinsPipelineStrategy: + env: + - name: Quickstarter + value: '' + - name: QuickstarterRepository + value: '${QuickstarterRepository}' + - name: quickstarterRef + value: '${ODS_GIT_REF}' + - name: Project + value: '${PROJECT}' + - name: ODS_NAMESPACE + value: '${ODS_NAMESPACE}' + - name: ODS_URL + value: '${BITBUCKET_URL}/${ODS_BITBUCKET_PROJECT}' + - name: JENKINS_AGENT_TAG + value: '${ODS_IMAGE_TAG}' + - name: SONAR_QUALITY_PROFILE + value: '${SONAR_QUALITY_PROFILE}' + - name: excludedQuickstarters + value: '' + jenkinsfilePath: Jenkinsfile + type: JenkinsPipeline + successfulBuildsHistoryLimit: 5 \ No newline at end of file diff --git a/tests/jenkinsPipelineCreation.sh b/tests/jenkinsPipelineCreation.sh new file mode 100644 index 000000000..9b254f8bf --- /dev/null +++ b/tests/jenkinsPipelineCreation.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -eux + +PROJECT="" +QuickstarterRepository="" +SONAR_QUALITY_PROFILE="" +ODS_GIT_REF="$ODS_GIT_REF" +BITBUCKET_URL="$BITBUCKET_URL" +ODS_NAMESPACE="$ODS_NAMESPACE" +ODS_IMAGE_TAG="$ODS_IMAGE_TAG" +ODS_BITBUCKET_PROJECT="$ODS_BITBUCKET_PROJECT" + +# Override ods configuration (optional) +while [[ "$#" > 0 ]]; do case $1 in + -g=*|--ods-git-ref=*) ODS_GIT_REF="${1#*=}";; + -g|--ods-git-ref) ODS_GIT_REF="$2"; shift;; + + -b=*|--bitbucket=*) BITBUCKET_URL="${1#*=}";; + -b|--bitbucket) BITBUCKET_URL="$2"; shift;; + + -n=*|--ods-namespace=*) ODS_NAMESPACE="${1#*=}";; + -n|--ods-namespace) ODS_NAMESPACE="$2"; shift;; + + -i=*|--ods-image-tag=*) ODS_IMAGE_TAG="${1#*=}";; + -i|--ods-image-tag) ODS_IMAGE_TAG="$2"; shift;; + + -m=*|--bitbucket-ods-project=*) ODS_BITBUCKET_PROJECT="${1#*=}";; + -m|--bitbucket-ods-project) ODS_BITBUCKET_PROJECT="$2"; shift;; + + -p=*|--project=*) PROJECT="${1#*=}";; + -p|--project) PROJECT="$2"; shift;; + + -q=*|--quickstarter-repository=*) QuickstarterRepository="${1#*=}";; + -q|--quickstarter-repository) QuickstarterRepository="$2"; shift;; + + -s=*|--sonar-quality-profile=*) SONAR_QUALITY_PROFILE="${1#*=}";; + -s|--sonar-quality-profile) SONAR_QUALITY_PROFILE="$2"; shift;; + + *) echo "Unknown parameter passed: $1"; exit 1;; +esac; shift; done + +# echo "create trigger secret" +# SECRET=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '') + +tailor --namespace=${PROJECT}-cd --non-interactive \ + apply \ + --param=ODS_GIT_REF=${ODS_GIT_REF} \ + --param=PROJECT=${PROJECT} \ + --param=BITBUCKET_URL=${BITBUCKET_URL} \ + --param=ODS_NAMESPACE=${ODS_NAMESPACE} \ + --param=ODS_IMAGE_TAG=${ODS_IMAGE_TAG} \ + --param=ODS_BITBUCKET_PROJECT=${ODS_BITBUCKET_PROJECT} \ + --param=SONAR_QUALITY_PROFILE="${SONAR_QUALITY_PROFILE}" \ + --param=QuickstarterRepository=${QuickstarterRepository} \ + --selector template=golden-test-pipeline From 51575f0515e355a1fd6a3c75a2ede104a60a3c79 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Wed, 25 Sep 2024 13:53:11 +0200 Subject: [PATCH 68/72] Fix git url --- tests/golden-test-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/golden-test-pipeline.yml b/tests/golden-test-pipeline.yml index 379b49392..0fea09ab5 100644 --- a/tests/golden-test-pipeline.yml +++ b/tests/golden-test-pipeline.yml @@ -46,7 +46,7 @@ objects: source: git: ref: ${ODS_GIT_REF} - uri: '${BITBUCKET_URL}/${ODS_BITBUCKET_PROJECT}/ods-core.git' + uri: '${BITBUCKET_URL}/scm/${ODS_BITBUCKET_PROJECT}/ods-core.git' sourceSecret: name: cd-user-with-password type: Git From 9293c247cd49c439853b24008a8e6875e16bd6c2 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Wed, 25 Sep 2024 13:58:48 +0200 Subject: [PATCH 69/72] fix test jenkisfile location --- tests/golden-test-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/golden-test-pipeline.yml b/tests/golden-test-pipeline.yml index 0fea09ab5..fee9fcd84 100644 --- a/tests/golden-test-pipeline.yml +++ b/tests/golden-test-pipeline.yml @@ -71,6 +71,6 @@ objects: value: '${SONAR_QUALITY_PROFILE}' - name: excludedQuickstarters value: '' - jenkinsfilePath: Jenkinsfile + jenkinsfilePath: tests/Jenkinsfile type: JenkinsPipeline successfulBuildsHistoryLimit: 5 \ No newline at end of file From 45bd474b5e90440e0da1fabaf74cc6d9b4c8076e Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Wed, 25 Sep 2024 14:44:39 +0200 Subject: [PATCH 70/72] fix git url --- tests/golden-test-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/golden-test-pipeline.yml b/tests/golden-test-pipeline.yml index fee9fcd84..e5ecd571f 100644 --- a/tests/golden-test-pipeline.yml +++ b/tests/golden-test-pipeline.yml @@ -64,7 +64,7 @@ objects: - name: ODS_NAMESPACE value: '${ODS_NAMESPACE}' - name: ODS_URL - value: '${BITBUCKET_URL}/${ODS_BITBUCKET_PROJECT}' + value: '${BITBUCKET_URL}/scm/${ODS_BITBUCKET_PROJECT}' - name: JENKINS_AGENT_TAG value: '${ODS_IMAGE_TAG}' - name: SONAR_QUALITY_PROFILE From 71fd5d76248008b9f7da21162ba3f8060725caa5 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Wed, 25 Sep 2024 14:44:50 +0200 Subject: [PATCH 71/72] use cd-user-with-password --- tests/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Jenkinsfile b/tests/Jenkinsfile index 18de52dfa..2d4c9175c 100644 --- a/tests/Jenkinsfile +++ b/tests/Jenkinsfile @@ -120,7 +120,7 @@ podTemplate( } dir('ods-configuration'){ git branch: "${ODS_CONFIGURATION_BRANCH}", - credentialsId: "${project}-cd-cd-user-token", + credentialsId: "${project}-cd-cd-user-with-password", url: "${ODS_CONFIGURATION_URL}" } From 28623c280dfb4a5efdd04d4ce9e25b25e1be8031 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Wed, 25 Sep 2024 15:03:31 +0200 Subject: [PATCH 72/72] add configurationRef parameter --- tests/Jenkinsfile | 9 ++++++++- tests/Makefile | 3 ++- tests/jenkinsPipelineCreation.sh | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/Jenkinsfile b/tests/Jenkinsfile index 2d4c9175c..743f0eefa 100644 --- a/tests/Jenkinsfile +++ b/tests/Jenkinsfile @@ -14,6 +14,11 @@ properties([ defaultValue: '4.x', description: 'Enter the reference for the quickstarter (e.g., branch, tag, or commit)' ), + string( + name: 'configurationRef', + defaultValue: 'master', + description: 'Enter the reference for the configuration (e.g., branch, tag, or commit)' + ), string( name: 'Project', description: 'Enter the project name (in lower case) where the quickstarter will be provisioned' @@ -61,6 +66,8 @@ def quickstarter = params.Quickstarter def odsNamespace = params.ODS_NAMESPACE // odsReference def odsRef = params.quickstarterRef?:"master" +// configurationReference +def confRef = params.configurationRef?:"master" // QS repo def QUICKSTARTER_REPO = params.QuickstarterRepository @@ -69,7 +76,7 @@ def QUICK_STARTERS_URL = "${ODS_URL}/${QUICKSTARTER_REPO}.git" def QUICK_STARTERS_BRANCH = "${quickstarterRef}" def ODS_CONFIGURATION_URL = "${ODS_URL}/ods-configuration.git" -def ODS_CONFIGURATION_BRANCH = "${quickstarterRef}" +def ODS_CONFIGURATION_BRANCH = "${confRef}" def ODS_CORE_URL = "${ODS_URL}/ods-core.git" def ODS_CORE_BRANCH = "${quickstarterRef}" diff --git a/tests/Makefile b/tests/Makefile index d7c9ce5cc..1188a83f5 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -16,6 +16,7 @@ PARALLEL := 1 PROJECT := unitt SONAR_PROFILE := "Sonar way" QUICKSTARTER_REPOSITORY := ods-quickstarters +configurationRef := master ## Full test of existing ODS core installation. Caution: Creates UNITT project and ODSVERIFY project. test: smoketest verify test-create-projects @@ -43,7 +44,7 @@ test-create-projects: ## Create Jenkins pipeline using REST API jenkins-pipeline: @(envsubst < jenkinsPipelineCreation.sh) - @(./jenkinsPipelineCreation.sh -p $(PROJECT) -q $(QUICKSTARTER_REPOSITORY) -s $(SONAR_PROFILE)) + @(./jenkinsPipelineCreation.sh -p $(PROJECT) -q $(QUICKSTARTER_REPOSITORY) -s $(SONAR_PROFILE) -c $(configurationRef)) .PHONY: jenkins-pipeline ## Run quickstarter tests within existing ODS installation. Depends on UNITT project (default). diff --git a/tests/jenkinsPipelineCreation.sh b/tests/jenkinsPipelineCreation.sh index 9b254f8bf..9938d1d40 100644 --- a/tests/jenkinsPipelineCreation.sh +++ b/tests/jenkinsPipelineCreation.sh @@ -3,6 +3,7 @@ set -eux PROJECT="" QuickstarterRepository="" +configurationRef="" SONAR_QUALITY_PROFILE="" ODS_GIT_REF="$ODS_GIT_REF" BITBUCKET_URL="$BITBUCKET_URL" @@ -15,6 +16,9 @@ while [[ "$#" > 0 ]]; do case $1 in -g=*|--ods-git-ref=*) ODS_GIT_REF="${1#*=}";; -g|--ods-git-ref) ODS_GIT_REF="$2"; shift;; + -c=*|--configurationRef=*) configurationRef="${1#*=}";; + -c|--configurationRef) configurationRef="$2"; shift;; + -b=*|--bitbucket=*) BITBUCKET_URL="${1#*=}";; -b|--bitbucket) BITBUCKET_URL="$2"; shift;; @@ -45,6 +49,7 @@ esac; shift; done tailor --namespace=${PROJECT}-cd --non-interactive \ apply \ --param=ODS_GIT_REF=${ODS_GIT_REF} \ + --param=configurationRef=${configurationRef} \ --param=PROJECT=${PROJECT} \ --param=BITBUCKET_URL=${BITBUCKET_URL} \ --param=ODS_NAMESPACE=${ODS_NAMESPACE} \