From 2d8f77007ea51250663c38c965eb836f6911be3a Mon Sep 17 00:00:00 2001 From: Jorge Romero Date: Wed, 17 Jun 2020 09:57:14 +0200 Subject: [PATCH 01/54] Initial state of FT_01_003, missing Step 3 of testcase --- build.gradle | 6 + readme.md | 45 +-- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 267 +++++++++++++++++- .../e2e/bitbucket/pages/RepositoryPage.groovy | 32 ++- .../jira/pages/CreateStoryIssuePage.groovy | 2 + .../groovy/org/ods/e2e/util/GitUtil.groovy | 88 ++++++ src/test/resources/application.properties | 4 +- 7 files changed, 403 insertions(+), 41 deletions(-) create mode 100644 src/test/groovy/org/ods/e2e/util/GitUtil.groovy diff --git a/build.gradle b/build.gradle index e719a25..33c19bc 100644 --- a/build.gradle +++ b/build.gradle @@ -37,6 +37,12 @@ dependencies { testCompile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion" testCompile "org.seleniumhq.selenium:htmlunit-driver:$htmlunitVersion" testCompile "org.seleniumhq.selenium:selenium-support:$seleniumVersion" + + // Use of git + compile "org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r" + testCompile "org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r" + testCompile "org.yaml:snakeyaml:1.26" + } webdriverBinaries { diff --git a/readme.md b/readme.md index db0786c..c970c30 100644 --- a/readme.md +++ b/readme.md @@ -1,16 +1,12 @@ -# Example Geb and Gradle Project - +# Automated test cases for ODS ## Description - -This is an example of incorporating Geb into a Gradle build. - +Suite of test cases for OpenDevStack and the Release Manager. The build is setup to work with Chrome, Chrome headless and html. Have a look at the `build.gradle` and the `src/test/resources/GebConfig.groovy` files. -It contains too the Firefox driver that it is not fully tested. +It contains too the Firefox driver that it is not fully tested as currently the provissioning app does not work with Firefox ## Usage - You need to set several environment variables in order to make this work, as it is intended to be used in a container / pod lately. | Variable | Value | @@ -19,30 +15,41 @@ You need to set several environment variables in order to make this work, as it | E2E_USER_EMAIL | email of the user (for Jira tools) | | E2E_USER_PASSWORD | user password | | JIRA_URL | Url of Jira instance related with the prov app | -| OPENSHIFT_PROJECT | project identifier for prov app | +| OPENSHIFT_PROJECT | project identifier for prov app in the preliminary tests | | OPENSHIFT_PUBLIC_HOST | host where we can locate the prov app | | OPENSHIFT_CLUSTER | URL of the Openshift Cluster | +| BITBUCKET_URL | Url of Bitbucket instance | +| SIMULATE | Specify (true or false) if we skip the creation of project, components, etc | The following commands will launch the tests with the individual browsers: - ./gradlew chromeTest - ./gradlew htmlunitTest - -To run with all, you can run: - - ./gradlew test +```shell script +# A test spec +$ ./gradlew chromeTest --tests "org.ods.e2e.ODSSpec" +# A specific test +$ ./gradlew chromeTest --tests "org.ods.e2e.ODSSpec.FT_01_003" +``` Replace `./gradlew` with `gradlew.bat` in the above examples if you're on Windows. -## Tests done - +## Tests being implemented ### Open Dev Stack ```ODSSpec.groovy``` - [x] FT_01_001 - Use the Provisioning app to create a project and add a Quickstarter. +- [ ] FT_01_002 - To provide evidences that a new boilerplate software updates can be easily added to ODS, and be available for use. +- [ ] FT_01_003 - IN PROGRESS - Orchestrate repositories and create LeVA Docs. +- [ ] FT_01_004 - Demonstrate that ODS infrastructure components are deployed and use the services for monitoring, backup and restoring. - [x] FT_01_005 - Prevent OpenDevStack to delete projects on Atlassian application. + +`JiraReleaseManagerSpec.groovy` +- [x] RT_02_001: Check the correctness of calculation – risk assessment without probability of occurrence +- [x] RT_04_001: Test if a C-CSD document can be created. Start creating an application, use Stories in Jira, amend the Documentation chapter issues and check the issue workflows +- [x] RT_06_001: Create Technical Specification Tasks in Jira, check their workflow. + +## Preliminary tests before doing the actual test cases ### Provisioning App -`ProvAppSpec.groovy` +`ProvAppSpec.groovy` - [x] Visit and login to the Provisioning App - [ ] IN PROGRESS - Create a project - [ ] IN PROGRESS - Add a quickstarter to a project *(Pending solve some issues with the Prov app)* @@ -53,10 +60,6 @@ Replace `./gradlew` with `gradlew.bat` in the above examples if you're on Window - [x] Visit the project summary Page - [x] Check for specify components -`JiraReleaseManagerSpec.groovy` -- [x] RT_02_001: Check the correctness of calculation – risk assessment without probability of occurrence -- [x] RT_04_001: Test if a C-CSD document can be created. Start creating an application, use Stories in Jira, amend the Documentation chapter issues and check the issue workflows -- [x] RT_06_001: Create Technical Specification Tasks in Jira, check their workflow. ### OpenShift `OpenShiftSpec.groovy` diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 6022290..7ed303f 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -3,6 +3,7 @@ package org.ods.e2e import org.ods.e2e.bitbucket.pages.DashboardPage import org.ods.e2e.bitbucket.pages.LoginPage import org.ods.e2e.bitbucket.pages.ProjectPage +import org.ods.e2e.bitbucket.pages.RepositoryPage import org.ods.e2e.jenkins.pages.JenkinsJobFolderPage import org.ods.e2e.openshift.pages.ConsoleProjectsPage import org.ods.e2e.openshift.pages.PodsPage @@ -10,6 +11,9 @@ import org.ods.e2e.provapp.pages.HomePage import org.ods.e2e.provapp.pages.ProvAppLoginPage import org.ods.e2e.provapp.pages.ProvisionPage import org.ods.e2e.util.BaseSpec +import org.ods.e2e.util.GitUtil +import org.yaml.snakeyaml.DumperOptions +import org.yaml.snakeyaml.Yaml class ODSSpec extends BaseSpec { @@ -26,8 +30,44 @@ class ODSSpec extends BaseSpec { ] ] ] + def releaseManagerComponent = [componentId: 'project-release-manager', quickStarter: ProvisionPage.quickstarters.releaseManager] + + def leVADocsTemplates = [ + 'CFTP-1.html.tmpl', + 'CFTP-3.html.tmpl', + 'CFTP-4.html.tmpl', + 'CFTP-5.html.tmpl', + 'CFTR-1.html.tmpl', + 'CFTR-3.html.tmpl', + 'CFTR-4.html.tmpl', + 'CFTR-5.html.tmpl', + 'CSD-1.html.tmpl', + 'CSD-3.html.tmpl', + 'CSD-4.html.tmpl', + 'CSD-5.html.tmpl', + 'DIL.html.tmpl', + 'DTP.html.tmpl', + 'DTR.html.tmpl', + 'footer.inc.html.tmpl', + 'header.inc.html.tmpl', + 'IVP.html.tmpl', + 'IVR.html.tmpl', + 'Overall-Cover.html.tmpl', + 'Overall-TIR-Cover.html.tmpl', + 'RA.html.tmpl', + 'SSDS-1.html.tmpl', + 'SSDS-3.html.tmpl', + 'SSDS-4.html.tmpl', + 'SSDS-5.html.tmpl', + 'TCP.html.tmpl', + 'TCR.html.tmpl', + 'TIP.html.tmpl', + 'TIR.html.tmpl', + 'TRC.html.tmpl', + ] def setup() { + // We will start with the provisioning app as the base url baseUrl = baseUrlProvisioningApp } @@ -36,32 +76,44 @@ class ODSSpec extends BaseSpec { def project = projects.default project.key = 'e2et3' - when: 'Visit Openshift' - baseUrl = baseUrlOpenshift + // STEP 2: Checkout / git clone the release manager repository and open metadata.yml + // Result: Repository cloned, metadata.yml is available + when: + def repositoryFolder = GitUtil.cloneRepository(projects.default.key, releaseManagerComponent.componentId) - and: 'and login in Openshift' - doOpenshiftLoginProcess() + and: + DumperOptions options = new DumperOptions() + options.setPrettyFlow(true) + options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK) + Yaml parser = new Yaml(options) - and: "Visit all project page" - to ConsoleProjectsPage + def metadataYml = parser.load(("$repositoryFolder/metadata.yml" as File).text) then: - waitFor { projectList } - def projects = findProjects(project.key) - assert projects - assert projects.contains(project.key + '-cd') + assert metadataYml - when: 'Visit pods page' - to PodsPage, project.key + '-cd' + // STEP 3: Add a new repository section into metadata.yml pointing to the component repository created earlier (see perreq.) – commit and push + // Result: New build of release manager in Jenkins visible, including a new build & deployment of your component. + when: + def metadataRepositories = metadataYml.getAt('repositories') + if (metadataRepositories == null) { + metadataYml.putAt('repositories', []) + metadataRepositories = metadataYml.getAt('repositories') + } + metadataRepositories.putAt(metadataRepositories.size, [id: 'a', name: 'aa', type: 'ods']) and: - def pods = getPods() + parser.dump(metadataYml, new FileWriter("$repositoryFolder/metadata.yml")) + and: + GitUtil.commitAddAll('New component added') then: - assert pods.find { pod -> pod.name.startsWith('jenkins') && pod.status == 'Running' } + false + } /** + * Test Objective: * The purpose of this test case is to present a level of evidences that the use of Provisioning Application, * in combination with Boilerplates and infrastructure elements like Jenkins, SonarQube and Nexus answer * the following specifications: @@ -74,6 +126,10 @@ class ODSSpec extends BaseSpec { * - to present evidences that Provisioning Application creates the Atlassian and Openshift components based on * boilerplate * - to present evidences the data of provision components are stored on the filesystem + * + * Prerequisites: + * Be logged in as Provisioning Application administrator, have an OpenShift project, have access to the + * console/terminal logs of Jenkins, Nexus and SonarQube and have administrator access to the Bitbucket repositories. */ def "FT_01_001"() { // STEP 1: Login to provisioning application with administrator privileges @@ -267,6 +323,189 @@ class ODSSpec extends BaseSpec { report("step 12 - build job of the component") } + /** + * Test Objective: + * The purpose of this test case is to demonstrate the functionality to orchestrate multiple repositories with the + * deployment, and * to automatically produce LeVA documentation. This test will use the Provisioning + * Application to create the necessary components in Atlassian and Openshift in a way it can demonstrate the entire + * test to answer the required functionalities: + * - to present evidences that ODS MRO orchestrates multiples repositories. + * - to present evidence that ODS MRO provide services to automate LeVA documentation generation. + * + * Prerrequisites + * Be logged in as Provisioning Application administrator, have a OpenShift project, have access to the console/terminal logs + * of Jenkins, Nexus and SonarQube and have administrator access to the Bitbucket repositories. FT_01_001 executed + * successfully. + * + */ + def "FT_01_003"() { + // STEP 1: Login to provisioning app – pick the created project and provision a new component based on the release-manager quickstarter + // Result: With your bitbucket project a new repository with the release manager is available + given: 'We login in the provision app' + def project = projects.default + project.components.add(releaseManagerComponent) + + and: + baseUrl = baseUrlProvisioningApp + + and: + to ProvAppLoginPage + doLoginProcess() + + expect: 'We are logged in the provisioning app' + at HomePage + + when: 'Click Provision link' + provisionLink.click() + + then: 'We visit the provisioning page' + at ProvisionPage + + when: + provisionOptionChooser.doSelectModifyProject() + projectModifyForm.doSelectProject(project.key) + + and: + projectModifyForm.doAddQuickStarter(releaseManagerComponent.quickStarter, releaseManagerComponent.componentId) + report('step 1: Quick starter to add') + + projectModifyForm.addQuickStarterButton.click() + + and: + if (!simulate) { + projectModifyForm.doStartProvision() + sleep(15000) + + waitFor { + $(".modal-dialog").css("display") != "hidden" + $("#resProject.alert-success") + $("#resButton").text() == "Close" + } + } + + then: 'Quickstarter was added' + simulate ? true : $("#resProject.alert-success") + report('step 1: Quick starter added') + + when: 'Visit Bitbucket' + baseUrl = baseUrlBitbucket + to LoginPage + + and: 'we do login' + doLogin() + + then: 'we are at the Dashboard' + at DashboardPage + + when: 'Visit project' + to ProjectPage, project.key + + then: 'We are in the project page' + currentUrl.endsWith("projects/${project.key}/") + report("step 1 - project in bitbucket") + + when: 'We visit one repository' + def repositories = getRepositoriesInfo() + + then: 'The repositories exits for the release manager' + assert repositories.findAll { repository -> + repository.name.toLowerCase() == (project.key + '-' + releaseManagerComponent.componentId).toLowerCase() + }.size() == 1 + + report("step 1 - release manager repository in bitbucket") + + // STEP 2: Checkout / git clone the release manager repository and open metadata.yml + // Result: Repository cloned, metadata.yml is available + when: + def repositoryFolder = GitUtil.cloneRepository(projects.default.key, releaseManagerComponent.componentId) + + and: + DumperOptions options = new DumperOptions() + options.setPrettyFlow(true) + options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK) + Yaml parser = new Yaml(options) + + def metadataYml = parser.load(("$repositoryFolder/metadata.yml" as File).text) + + then: + assert metadataYml + + // STEP 3: Add a new repository section into metadata.yml pointing to the component repository created earlier (see perreq.) – commit and push + // Result: New build of release manager in Jenkins visible, including a new build & deployment of your component. + when: 'Edit metadata.yml' + def metadataRepositories = metadataYml.getAt('repositories') + if (metadataRepositories == null) { + metadataYml.putAt('repositories', []) + metadataRepositories = metadataYml.getAt('repositories') + } + def component = project.components.first() + metadataRepositories.putAt(metadataRepositories.size, [ + id : component.componentId.toLowerCase(), + name: "$project.key-$component.componentId".toLowerCase(), type: 'ods']) + + and: 'Save metada.yml' + parser.dump(metadataYml, new FileWriter("$repositoryFolder/metadata.yml")) + + and: 'Commit the file' + GitUtil.commitAddAll('New component added') + + and: 'Push it to the repository' + GitUtil.push('origin') + + // TODO: Finalize when having a working QS + then: + true + + + // STEP 4: Go to bitbucket opendevstack project and locate ods-document-generation-templates + // Result: Repository is available and within document templates for LeVa can be found. + when: 'Visit project OPENDEVSTACK' + to ProjectPage, 'OPENDEVSTACK' + + then: 'We are in the project page' + currentUrl.endsWith("projects/OPENDEVSTACK/") + + when: 'Get repositories' + def odsRepositories = getRepositoriesInfo() + + then: 'Then ods-document-generation-templates exists' + assert odsRepositories.findAll { + repository -> repository.name.toLowerCase() == 'ods-document-generation-templates' + }.size() == 1 + + when: + to RepositoryPage, 'OPENDEVSTACK', 'ods-document-generation-templates', 'templates', [at: 'release/v1.0'] + + and: 'Get the existing files' + def templates = getFiles() + + then: 'exists all the files needed for the LeVADocs templates' + leVADocsTemplates.each { + leVAtemplate -> templates.contains(leVAtemplate) + } + report("step 4 - Repository is available and within document templates for LeVa can be found.") + + // STEP 5: Go to openshift – locate your project’s cd project (name-cd) and check for a running instance of Document generation service + // Result: Document Generation service pod is available + when: 'Visit Openshift' + baseUrl = baseUrlOpenshift + + and: 'and login in Openshift' + doOpenshiftLoginProcess() + + and: 'Visit pods page' + to PodsPage, project.key.toLowerCase() + '-cd' + sleep(5000) + + and: + def pods = getPods() + + then: + assert pods.find { pod -> pod.name.startsWith('docgen') && pod.status == 'Running' } + report("step 5 - Document Generation service pod is available") + + } + /** * The purpose of this test case is to demonstrate the functionality to prevent OpenDevStack * to delete projects on Atlassian application. diff --git a/src/test/groovy/org/ods/e2e/bitbucket/pages/RepositoryPage.groovy b/src/test/groovy/org/ods/e2e/bitbucket/pages/RepositoryPage.groovy index 2dfbd99..c2fd2d6 100644 --- a/src/test/groovy/org/ods/e2e/bitbucket/pages/RepositoryPage.groovy +++ b/src/test/groovy/org/ods/e2e/bitbucket/pages/RepositoryPage.groovy @@ -8,7 +8,7 @@ class RepositoryPage extends Page { static url = "/projects" - static at = { browser.currentUrl.contains("$project/repos/$repository/browse")} + static at = { browser.currentUrl.contains("$project/repos/$repository/browse") } /** * Adapt the url to get to the repository page @@ -16,12 +16,36 @@ class RepositoryPage extends Page { * @param args must contain 2 args, projectName and repositoryName */ String convertToPath(Object[] args) { - project = args[0].toString().toUpperCase() - repository = args[1] - args ? "/$project/repos/$repository/browse" : '' + def file = "" + def params = "" + args.eachWithIndex { Object entry, int i -> + if (i == 0) { + project = entry.toString().toUpperCase() + } else if (i == 1) { + repository = entry + } else { + if (entry instanceof String) { + file += file + "/$entry" + } else if (entry instanceof LinkedHashMap) { + entry.each { it -> + params += "$it.key=$it.value" + } + } + } + } + args ? "/$project/repos/$repository/browse$file?$params" : '' } static content = { commitsLink { $("#repository-nav-commits") } + fileRows { $("tr.file.file-row") } + } + + def getFiles() { + fileRows.collect { item -> + [name : item.$('td.item-name > a').text() , + description: item.$('td.message > a').text() + ] + } } } diff --git a/src/test/groovy/org/ods/e2e/jira/pages/CreateStoryIssuePage.groovy b/src/test/groovy/org/ods/e2e/jira/pages/CreateStoryIssuePage.groovy index c740ee9..52aa673 100644 --- a/src/test/groovy/org/ods/e2e/jira/pages/CreateStoryIssuePage.groovy +++ b/src/test/groovy/org/ods/e2e/jira/pages/CreateStoryIssuePage.groovy @@ -1,6 +1,7 @@ package org.ods.e2e.jira.pages import geb.Page +import org.ods.e2e.jira.modules.NavigationBarModule class CreateStoryIssuePage extends CreateIssuePage { static gampTopicFieldId = 'customfield_11903' @@ -33,6 +34,7 @@ class CreateStoryIssuePage extends CreateIssuePage { static at = { browser.currentUrl.contains('CreateIssue') && $("#issue-create-issue-type").text() == 'Story' } static content = { + navigationBar { module(NavigationBarModule) } gampTopicSelect { $("#$gampTopicFieldId") } reqAcceptanceCriteria { $("#$reqAcceptanceCriteriaFieldId") } funcSpecSummary { $("#$funcSpecSummaryFieldId") } diff --git a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy new file mode 100644 index 0000000..6031801 --- /dev/null +++ b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy @@ -0,0 +1,88 @@ +package org.ods.e2e.util + + +import org.eclipse.jgit.api.Git +import org.eclipse.jgit.transport.URIish +import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider + +import javax.net.ssl.X509TrustManager +import java.nio.file.Files +import java.security.cert.CertificateException +import java.security.cert.X509Certificate + +class TrustEverythingSSLTrustManager implements X509TrustManager { + + @Override + void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + + } + + @Override + void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + + } + + @Override + X509Certificate[] getAcceptedIssuers() { + return null + } +} + +class GitUtil { + static Properties applicationProperties = new SpecHelper().getApplicationProperties() + static baseUrlBitbucket = applicationProperties."config.atlassian.bitbucket.url" + static username = applicationProperties."config.atlassian.user.name" + static password = applicationProperties."config.atlassian.user.password" + + // Git repository used in the tests + static Git gitRepository + + /** + * Clone a repository in a temporary folder. + * it ignores the ssl certificate for wrong certificates. + * @param project the project key + * @param repository the repository + * @return the repository location + */ + static cloneRepository(project, repository) { + def gitUrl = baseUrlBitbucket.endsWith('/') ? baseUrlBitbucket : baseUrlBitbucket + '/' + def repositoryUrl = "${gitUrl}scm/$project/$project-${repository}.git".toLowerCase() + + File localPath = Files.createTempDirectory("${repository}-").toFile() + + gitRepository = Git.init().setDirectory(localPath).call() + def config = gitRepository.getRepository().getConfig() + config.setBoolean("http", null, "sslVerify", false) + config.save() + gitRepository.remoteAdd().setName('origin').setUri(new URIish(repositoryUrl)).call() + + gitRepository.pull() + .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password)) + .setRemote('origin') + .setRemoteBranchName('master') + .call() + + + return localPath + } + + /** + * Commit all modified files + * @param message The commit message + */ + static commitAddAll(message = 'new commit') { + gitRepository.commit().setMessage(message).setAll(true).call() + } + + /** + * Push commits to a repository + * @param remote The remote repository + * @return + */ + static push(remote = 'origin') { + gitRepository.push() + .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password)) + .setRemote(remote) + .call() + } +} diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 8f8c0ea..f52d25d 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -19,13 +19,13 @@ config.simulate=${SIMULATE} # Provisioning App config.provisioning-app.user.name=${E2E_USER_EMAIL} config.provisioning-app.user.password=${E2E_USER_PASSWORD} -config.provisioning.url=https://prov-app-dev.${OPENSHIFT_PUBLIC_HOST}/ +config.provisioning.url=https://2xstable-prov-app-prova-test.${OPENSHIFT_PUBLIC_HOST}/ # Atlassian config.atlassian.user.name=${E2E_USER_EMAIL} config.atlassian.user.password=${E2E_USER_PASSWORD} config.atlassian.jira.url=${JIRA_URL}/ -config.atlassian.bitbucket.url=${BITBUCKET_URL}/ +config.atlassian.bitbucket.url=${BITBUCKET_URL} ## Jenkins config.jenkins.user.name=${E2E_USER} From 4c2b7b1e987071da5b2c716275f5e7e56d17a9a3 Mon Sep 17 00:00:00 2001 From: Jorge Romero Date: Wed, 17 Jun 2020 16:15:24 +0200 Subject: [PATCH 02/54] Initial state of FT_01_002, steps 1..3 --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 150 ++++++++++++------ .../pages/ConsoleResourcesConfigMaps.groovy | 36 +++++ .../groovy/org/ods/e2e/util/GitUtil.groovy | 50 ++++-- 3 files changed, 180 insertions(+), 56 deletions(-) create mode 100644 src/test/groovy/org/ods/e2e/openshift/pages/ConsoleResourcesConfigMaps.groovy diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 7ed303f..74426cc 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -1,11 +1,13 @@ package org.ods.e2e + import org.ods.e2e.bitbucket.pages.DashboardPage import org.ods.e2e.bitbucket.pages.LoginPage import org.ods.e2e.bitbucket.pages.ProjectPage import org.ods.e2e.bitbucket.pages.RepositoryPage import org.ods.e2e.jenkins.pages.JenkinsJobFolderPage import org.ods.e2e.openshift.pages.ConsoleProjectsPage +import org.ods.e2e.openshift.pages.ConsoleResourcesConfigMaps import org.ods.e2e.openshift.pages.PodsPage import org.ods.e2e.provapp.pages.HomePage import org.ods.e2e.provapp.pages.ProvAppLoginPage @@ -17,6 +19,10 @@ import org.yaml.snakeyaml.Yaml class ODSSpec extends BaseSpec { + def static OPENDEVSTACK = 'OPENDEVSTACK' + def static E2E_TEST_BRANCH = 'e2e-test-branch' + def static E2E_TEST_FILE = 'e2e-tests.txt' + def projects = [ default: [ name : 'E2E Test Project', @@ -71,47 +77,6 @@ class ODSSpec extends BaseSpec { baseUrl = baseUrlProvisioningApp } - def "PLAY"() { - given: - def project = projects.default - project.key = 'e2et3' - - // STEP 2: Checkout / git clone the release manager repository and open metadata.yml - // Result: Repository cloned, metadata.yml is available - when: - def repositoryFolder = GitUtil.cloneRepository(projects.default.key, releaseManagerComponent.componentId) - - and: - DumperOptions options = new DumperOptions() - options.setPrettyFlow(true) - options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK) - Yaml parser = new Yaml(options) - - def metadataYml = parser.load(("$repositoryFolder/metadata.yml" as File).text) - - then: - assert metadataYml - - // STEP 3: Add a new repository section into metadata.yml pointing to the component repository created earlier (see perreq.) – commit and push - // Result: New build of release manager in Jenkins visible, including a new build & deployment of your component. - when: - def metadataRepositories = metadataYml.getAt('repositories') - if (metadataRepositories == null) { - metadataYml.putAt('repositories', []) - metadataRepositories = metadataYml.getAt('repositories') - } - metadataRepositories.putAt(metadataRepositories.size, [id: 'a', name: 'aa', type: 'ods']) - - and: - parser.dump(metadataYml, new FileWriter("$repositoryFolder/metadata.yml")) - - and: - GitUtil.commitAddAll('New component added') - then: - false - - } - /** * Test Objective: * The purpose of this test case is to present a level of evidences that the use of Provisioning Application, @@ -323,6 +288,99 @@ class ODSSpec extends BaseSpec { report("step 12 - build job of the component") } + /** + * Test Objective: To provide evidences that a new boilerplate software updates can be easily added to ODS, + * and be available for use. + * + * Prerequisites: Be logged in as Provisioning Application administrator, have a OpenShift project, have access + * to the console/terminal logs of Jenkins, Nexus and SonarQube and have administrator access to the Bitbucket + * repositories including the OpenDevStack one. + */ + def "FT_01_002"() { + // STEP 1: Go to Bitbucket ODS project – into repository ods-quickstarters + // Result: Project and repository available + given: + baseUrl = baseUrlBitbucket + + when: + to LoginPage + + and: 'we do login' + doLogin() + + then: 'we are at the Dashboard' + at DashboardPage + + when: 'Visit project' + to RepositoryPage, OPENDEVSTACK, 'ods-quickstarters' + + then: 'Project and repository available' + currentUrl.endsWith('OPENDEVSTACK/repos/ods-quickstarters/browse') + report('step 1 - Project and repository available') + + // STEP 2: Pick one quickstarter repository and create a branch from master – add, and commit a file into /files + // Result: Repository with master branch found, branch modified and committed/pushed + when: 'Checkout project' + def gitRepository = GitUtil.cloneRepository(OPENDEVSTACK, 'ods-quickstarters', false) + + and: 'Create a branch' + GitUtil.checkout(gitRepository, E2E_TEST_BRANCH, true) + + and: 'Add a file into /files' + def directory = gitRepository.repository.getWorkTree() + new File("$directory/fe-angular/files/$E2E_TEST_FILE").text = 'Testing file for FT_01_002' + + and: 'Commit and push file' + GitUtil.add(gitRepository, "fe-angular/files/$E2E_TEST_FILE") + GitUtil.commitAddAll(gitRepository, 'Added test file') + GitUtil.push(gitRepository) + + and: 'Visit bitbucket to grab evidences of adding files' + to RepositoryPage, OPENDEVSTACK, 'ods-quickstarters', 'fe-angular/files', [at: E2E_TEST_BRANCH] + + and: 'Get the existing files' + def files = getFiles() + + then: 'exists all the files needed for the LeVADocs templates' + files.find { file -> file.name == E2E_TEST_FILE } + report("step 2 - Repository with master branch found, branch modified and committed/pushed.") + + // STEP 3: Go to Openshift prov-test project and open available config maps + // Result: Configuration maps available – namely application.properties + when: 'Visit Openshift' + baseUrl = baseUrlOpenshift + + and: 'and login in Openshift' + doOpenshiftLoginProcess() + + and: 'Visit the config maps of the provisioning application' + to ConsoleResourcesConfigMaps, 'prov-test' + + and: 'Retrieve the configMaps' + def configMaps = getConfigMaps() + + then: + configMaps.findAll { configMap -> configMap.name == 'application.properties' }.size() == 1 + + + // STEP 4: In the application.properties config map copy the configuration lines from the quickstarter + // you pick from the step 2 + // Result: Existing Quickstarter / boilerplace configuration available + + // STEP 5: Replace the key with a name of your choice and add the branch identifier and Jenkins file path as + // documented in the application.properties – click save + // Result: Config map can be saved + + // STEP 6: From the console or thru OC cli - redeploy the provision application in prov-test + // Result: New deployment of provision app shown in console and new pod available + + // STEP 7: Login and pick modifiy existing project / and locate the new quickstarter + // Result: New quickstarter available in the list in provision application + + // STEP 8: Go to bitbucket, locate the new repository and locate the file added in step 2 + // Result: Repository and file available + } + /** * Test Objective: * The purpose of this test case is to demonstrate the functionality to orchestrate multiple repositories with the @@ -417,7 +475,7 @@ class ODSSpec extends BaseSpec { // STEP 2: Checkout / git clone the release manager repository and open metadata.yml // Result: Repository cloned, metadata.yml is available when: - def repositoryFolder = GitUtil.cloneRepository(projects.default.key, releaseManagerComponent.componentId) + def gitRepository = GitUtil.cloneRepository(projects.default.key, releaseManagerComponent.componentId) and: DumperOptions options = new DumperOptions() @@ -447,10 +505,10 @@ class ODSSpec extends BaseSpec { parser.dump(metadataYml, new FileWriter("$repositoryFolder/metadata.yml")) and: 'Commit the file' - GitUtil.commitAddAll('New component added') + GitUtil.commitAddAll(gitRepository, 'New component added') and: 'Push it to the repository' - GitUtil.push('origin') + GitUtil.push(gitRepository, 'origin') // TODO: Finalize when having a working QS then: @@ -460,7 +518,7 @@ class ODSSpec extends BaseSpec { // STEP 4: Go to bitbucket opendevstack project and locate ods-document-generation-templates // Result: Repository is available and within document templates for LeVa can be found. when: 'Visit project OPENDEVSTACK' - to ProjectPage, 'OPENDEVSTACK' + to ProjectPage, OPENDEVSTACK then: 'We are in the project page' currentUrl.endsWith("projects/OPENDEVSTACK/") @@ -474,7 +532,7 @@ class ODSSpec extends BaseSpec { }.size() == 1 when: - to RepositoryPage, 'OPENDEVSTACK', 'ods-document-generation-templates', 'templates', [at: 'release/v1.0'] + to RepositoryPage, OPENDEVSTACK, 'ods-document-generation-templates', 'templates', [at: 'release/v1.0'] and: 'Get the existing files' def templates = getFiles() diff --git a/src/test/groovy/org/ods/e2e/openshift/pages/ConsoleResourcesConfigMaps.groovy b/src/test/groovy/org/ods/e2e/openshift/pages/ConsoleResourcesConfigMaps.groovy new file mode 100644 index 0000000..903063c --- /dev/null +++ b/src/test/groovy/org/ods/e2e/openshift/pages/ConsoleResourcesConfigMaps.groovy @@ -0,0 +1,36 @@ +package org.ods.e2e.openshift.pages + +import geb.Page + +class ConsoleResourcesConfigMaps extends Page { + + def project + + static at = { browser.currentUrl.contains("/console/project/$project/browse/config-maps") } + + static content = { + configMapRows(wait: true, required: true) { $('table tr.ng-scope') } + } + + /** + * Adapt the url to get to the repository page + * https://openshift-url/console/project/PROJECT/browse/config-maps + * @param args must contain 1 args + * projectName - Name of the project + */ + String convertToPath(Object[] args) { + project = args[0] + args ? "/console/project/$project/browse/config-maps/" : '' + } + + /** + * Get the configmaps that exists in the project + * @return + */ + def getConfigMaps() { + configMapRows.collect { it -> + [name: it.find('td > a', 0).text(), + date: it.find('td > span', 0).text()] + } + } +} diff --git a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy index 6031801..14ee3b4 100644 --- a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy +++ b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy @@ -34,23 +34,25 @@ class GitUtil { static username = applicationProperties."config.atlassian.user.name" static password = applicationProperties."config.atlassian.user.password" - // Git repository used in the tests - static Git gitRepository - /** * Clone a repository in a temporary folder. * it ignores the ssl certificate for wrong certificates. * @param project the project key * @param repository the repository - * @return the repository location + * @return the repository */ - static cloneRepository(project, repository) { + static cloneRepository(project, repository, isODSComponentRepo = true) { def gitUrl = baseUrlBitbucket.endsWith('/') ? baseUrlBitbucket : baseUrlBitbucket + '/' - def repositoryUrl = "${gitUrl}scm/$project/$project-${repository}.git".toLowerCase() + def repositoryUrl + if (isODSComponentRepo) { + repositoryUrl = "${gitUrl}scm/$project/$project-${repository}.git".toLowerCase() + } else { + repositoryUrl = "${gitUrl}scm/$project/${repository}.git".toLowerCase() + } File localPath = Files.createTempDirectory("${repository}-").toFile() - gitRepository = Git.init().setDirectory(localPath).call() + def gitRepository = Git.init().setDirectory(localPath).call() def config = gitRepository.getRepository().getConfig() config.setBoolean("http", null, "sslVerify", false) config.save() @@ -63,26 +65,54 @@ class GitUtil { .call() - return localPath + return gitRepository } /** * Commit all modified files + * @param gitRepository The git repository * @param message The commit message */ - static commitAddAll(message = 'new commit') { + static commitAddAll(gitRepository, message = 'new commit') { gitRepository.commit().setMessage(message).setAll(true).call() } /** * Push commits to a repository + * @param gitRepository The git repository * @param remote The remote repository * @return */ - static push(remote = 'origin') { + static push(gitRepository, remote = 'origin') { gitRepository.push() .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password)) .setRemote(remote) .call() } + + /** + * Checkout an specific branch. + * @param gitRepository The git repository. + * @param branch The branch name. + * @param createBranch If you want to create the branch if it does not exists. + * @return + */ + static checkout(gitRepository, branch, createBranch = false) { + gitRepository.checkout() + .setName(branch) + .setCreateBranch(createBranch) + .call() + } + + /** + * Add files to the repository. + * @param gitRepository The repository. + * @param files The files. + */ + static add(gitRepository, files) { + gitRepository + .add() + .addFilepattern(files) + .call() + } } From 216d3f7248dd850bf695616bf3da22e9c2e22131 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Sun, 28 Jun 2020 23:33:53 +0200 Subject: [PATCH 03/54] FT_01_002 --- build.gradle | 4 + src/test/groovy/org/ods/e2e/ODSSpec.groovy | 128 +++++++++++++-- .../e2e/bitbucket/pages/RepositoryPage.groovy | 2 +- .../openshift/client/OpenShiftClient.groovy | 152 ++++++++++++++++++ src/test/resources/application.properties | 16 +- src/test/resources/k8stypes.properties | 1 + 6 files changed, 280 insertions(+), 23 deletions(-) create mode 100644 src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy create mode 100644 src/test/resources/k8stypes.properties diff --git a/build.gradle b/build.gradle index 33c19bc..d7aa4b9 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ ext { chromeDriverVersion = '83.0.4103.39' geckoDriverVersion = '0.26.0' htmlunitVersion = "2.36.0" + openshiftClientVersion = '9.0.0.Final' } repositories { @@ -43,6 +44,9 @@ dependencies { testCompile "org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r" testCompile "org.yaml:snakeyaml:1.26" + // Openshift client + implementation "com.openshift:openshift-restclient-java:$openshiftClientVersion" + } webdriverBinaries { diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 74426cc..57cda57 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -1,11 +1,11 @@ package org.ods.e2e - import org.ods.e2e.bitbucket.pages.DashboardPage import org.ods.e2e.bitbucket.pages.LoginPage import org.ods.e2e.bitbucket.pages.ProjectPage import org.ods.e2e.bitbucket.pages.RepositoryPage import org.ods.e2e.jenkins.pages.JenkinsJobFolderPage +import org.ods.e2e.openshift.client.OpenShiftClient import org.ods.e2e.openshift.pages.ConsoleProjectsPage import org.ods.e2e.openshift.pages.ConsoleResourcesConfigMaps import org.ods.e2e.openshift.pages.PodsPage @@ -22,6 +22,7 @@ class ODSSpec extends BaseSpec { def static OPENDEVSTACK = 'OPENDEVSTACK' def static E2E_TEST_BRANCH = 'e2e-test-branch' def static E2E_TEST_FILE = 'e2e-tests.txt' + def static E2E_TEST_QUICKSTARTER = 'E2ET3' def projects = [ default: [ @@ -301,6 +302,8 @@ class ODSSpec extends BaseSpec { // Result: Project and repository available given: baseUrl = baseUrlBitbucket + def openshiftProject = 'prov-test' + def openshiftApp = 'prov-app' when: to LoginPage @@ -321,6 +324,7 @@ class ODSSpec extends BaseSpec { // STEP 2: Pick one quickstarter repository and create a branch from master – add, and commit a file into /files // Result: Repository with master branch found, branch modified and committed/pushed when: 'Checkout project' + def quickstarter = 'fe-angular' def gitRepository = GitUtil.cloneRepository(OPENDEVSTACK, 'ods-quickstarters', false) and: 'Create a branch' @@ -328,21 +332,17 @@ class ODSSpec extends BaseSpec { and: 'Add a file into /files' def directory = gitRepository.repository.getWorkTree() - new File("$directory/fe-angular/files/$E2E_TEST_FILE").text = 'Testing file for FT_01_002' + def filesPath = "$quickstarter/files".toString() + def testFilePath = "$filesPath/$E2E_TEST_FILE" + new File("$directory/$testFilePath").text = 'Test file for FT_01_002' and: 'Commit and push file' - GitUtil.add(gitRepository, "fe-angular/files/$E2E_TEST_FILE") + GitUtil.add(gitRepository, testFilePath) GitUtil.commitAddAll(gitRepository, 'Added test file') GitUtil.push(gitRepository) - and: 'Visit bitbucket to grab evidences of adding files' - to RepositoryPage, OPENDEVSTACK, 'ods-quickstarters', 'fe-angular/files', [at: E2E_TEST_BRANCH] - - and: 'Get the existing files' - def files = getFiles() - - then: 'exists all the files needed for the LeVADocs templates' - files.find { file -> file.name == E2E_TEST_FILE } + then: 'Push successful if no exception' + true report("step 2 - Repository with master branch found, branch modified and committed/pushed.") // STEP 3: Go to Openshift prov-test project and open available config maps @@ -354,31 +354,131 @@ class ODSSpec extends BaseSpec { doOpenshiftLoginProcess() and: 'Visit the config maps of the provisioning application' - to ConsoleResourcesConfigMaps, 'prov-test' + to ConsoleResourcesConfigMaps, openshiftProject and: 'Retrieve the configMaps' def configMaps = getConfigMaps() then: configMaps.findAll { configMap -> configMap.name == 'application.properties' }.size() == 1 - + report("step 3 - Configuration maps available – namely application.properties") // STEP 4: In the application.properties config map copy the configuration lines from the quickstarter // you pick from the step 2 // Result: Existing Quickstarter / boilerplace configuration available + when: 'Read configMap' + def client = OpenShiftClient.connect(openshiftProject) + def configMap = client.getConfigMap('application.properties') + def configMapData = configMap.getData() + + and: 'Read the properties' + def propertyFile = configMapData.properties + def propertyBackup = propertyFile + def properties = new Properties() + properties.load(new StringReader(propertyFile)) + + and: 'Obtain existing properties' + def tmpProps = properties.findAll { + key, value -> + key.startsWith("jenkinspipeline.quickstarter.$quickstarter.") + } + + then: + !tmpProps.isEmpty() + report("step 4 - Existing Quickstarter / boilerplace configuration available") + // STEP 5: Replace the key with a name of your choice and add the branch identifier and Jenkins file path as // documented in the application.properties – click save // Result: Config map can be saved + when: 'Add quickstarter properties' + tmpProps = tmpProps.collectEntries { + key, value -> + def concreteProperty = key.substring("jenkinspipeline.quickstarter.$quickstarter.".length()) + def newKey = "jenkinspipeline.quickstarter.${E2E_TEST_QUICKSTARTER}.${concreteProperty}".toString() + [(newKey): value] + } + properties.putAll(tmpProps) + properties.setProperty("jenkinspipeline.quickstarter.${E2E_TEST_QUICKSTARTER}.branch".toString(), E2E_TEST_BRANCH) + properties.setProperty("jenkinspipeline.quickstarter.${E2E_TEST_QUICKSTARTER}.jenkinsfile".toString(), + "$E2E_TEST_QUICKSTARTER/Jenkinsfile".toString()) + + and: 'Update config map' + def sw = new StringWriter() + properties.store(sw, null) + propertyFile = sw.toString() + configMapData.properties = propertyFile + client.modifyConfigMap(configMap, configMapData) + + and: 'Save modified config map' + configMap = client.update(configMap) + + and: 'Retrieve the config map again' + configMapData = configMap.getData() + def newContent = configMapData.get('properties') + + then: 'We correctly retrieve the updated data' + newContent == propertyFile + report("step 5 - Config map can be saved") + // STEP 6: From the console or thru OC cli - redeploy the provision application in prov-test // Result: New deployment of provision app shown in console and new pod available - // STEP 7: Login and pick modifiy existing project / and locate the new quickstarter + when: 'Get deployments' + def lastVersion = client.getLastDeploymentVersion(openshiftApp) + + and: 'Redeploy the provisioning app' + client.deploy(openshiftApp) + + and: 'Wait for deployment' + def newVersion = client.waitForDeployment(openshiftApp, lastVersion) + + then: 'New deployment exists' + newVersion > lastVersion + report("step 6 - New deployment of provision app shown in console and new pod available.") + + // STEP 7: Login and pick modify existing project / and locate the new quickstarter // Result: New quickstarter available in the list in provision application + when: 'We are logged in the provissioning app' + baseUrl = baseUrlProvisioningApp + to ProvAppLoginPage + doLoginProcess() + + and: 'We are in the provisioning page' + def project = projects.default + to ProvisionPage + + and: 'We have selected modify project' + provisionOptionChooser.doSelectModifyProject() + + then: 'The new quickstarter available in the list' + projectModifyForm.getProjects().find { + entry -> entry.key == project.key + } + report("step 7 - New quickstarter available in the list in provision application.") + + // STEP 8: Go to bitbucket, locate the new repository and locate the file added in step 2 // Result: Repository and file available + + when: 'Visit bitbucket to grab evidences of adding files' + baseUrl = baseUrlBitbucket + to RepositoryPage, OPENDEVSTACK, 'ods-quickstarters', filesPath, [at: E2E_TEST_BRANCH] + + and: 'Get the existing files' + def files = getFiles() + + then: 'Test file exists' + files.find { file -> file.name == E2E_TEST_FILE } + report("step 8 - Repository and file available.") + + cleanup: 'Restore original contents of the config map' + configMapData.put('properties', propertyBackup) + client.modifyConfigMap(configMap, configMapData) + client.update(configMap) + } /** diff --git a/src/test/groovy/org/ods/e2e/bitbucket/pages/RepositoryPage.groovy b/src/test/groovy/org/ods/e2e/bitbucket/pages/RepositoryPage.groovy index c2fd2d6..68a0e94 100644 --- a/src/test/groovy/org/ods/e2e/bitbucket/pages/RepositoryPage.groovy +++ b/src/test/groovy/org/ods/e2e/bitbucket/pages/RepositoryPage.groovy @@ -25,7 +25,7 @@ class RepositoryPage extends Page { repository = entry } else { if (entry instanceof String) { - file += file + "/$entry" + file += "/$entry" } else if (entry instanceof LinkedHashMap) { entry.each { it -> params += "$it.key=$it.value" diff --git a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy new file mode 100644 index 0000000..522f679 --- /dev/null +++ b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy @@ -0,0 +1,152 @@ +package org.ods.e2e.openshift.client + + +import com.openshift.internal.util.JBossDmrExtentions +import com.openshift.restclient.ClientBuilder +import com.openshift.restclient.IClient +import com.openshift.restclient.IOpenShiftWatchListener +import com.openshift.restclient.ResourceKind +import com.openshift.restclient.capability.resources.IDeploymentTriggerable +import com.openshift.restclient.model.IConfigMap +import com.openshift.restclient.model.IDeploymentConfig +import com.openshift.restclient.model.IResource +import org.ods.e2e.util.SpecHelper + +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit + +class OpenShiftClient { + private static applicationProperties = new SpecHelper().getApplicationProperties() + private static builder = new ClientBuilder(applicationProperties['config.openshift.url']) + .withUserName(applicationProperties['config.openshift.user.name']) + .withPassword(applicationProperties['config.openshift.user.password']) + + private OpenShiftClient(client) { + this.client = client + } + + private final IClient client + private String project + + def static connect() { + return new OpenShiftClient(builder.build()) + } + + def static connect(project) { + return connect().project(project) + } + + def project(project) { + this.project = project + return this + } + + def getConfigMap(name) { + return getConfigMap(name, project) + } + + def getConfigMap(name, project) { + if (!name) { + throw new IllegalArgumentException('You must specify a name') + } + if (!project) { + throw new IllegalArgumentException('You must specify a project') + } + + return client. get(ResourceKind.CONFIG_MAP, name, project) + } + + def update(configMap) { + return client.update(configMap) + } + + def deploy(name) { + deploy(name, project) + } + + def deploy(name, project) { + def deployment = getDeploymentConfig(name, project) + def triggerable = deployment.getCapability(IDeploymentTriggerable.class) + triggerable.force = true + triggerable.latest = true + triggerable.trigger() + } + + def getLastDeploymentVersion(deploymentConfig) { + return getLastDeploymentVersion(deploymentConfig, project) + } + + def getLastDeploymentVersion(deploymentConfig, project) { + def deployment = getDeploymentConfig(deploymentConfig, project) + return deployment.latestVersionNumber + } + + def getDeploymentConfig(name) { + return getDeploymentConfig(name, project) + } + + def getDeploymentConfig(name, project) { + if (!name) { + throw new IllegalArgumentException('You must specify a DeploymentConfig name') + } + if (!project) { + throw new IllegalArgumentException('You must specify a project') + } + + return client. get(ResourceKind.DEPLOYMENT_CONFIG, name, project) + } + + def waitForDeployment(name, lastVersion) { + return waitForDeployment(name, lastVersion, project) + } + + def waitForDeployment(name, lastVersion, project) { + def listener = new IOpenShiftWatchListener.OpenShiftWatchListenerAdapter() { + private CountDownLatch latch = new CountDownLatch(1) + private int newVersion = 0 + private boolean deleted = false + + @Override + void received(IResource resource, IOpenShiftWatchListener.ChangeType change) { + def matcher = resource.name =~ /$name-(\d+)-.*/ + if (resource.kind == ResourceKind.POD && matcher.matches()) { + switch (change) { + case IOpenShiftWatchListener.ChangeType.ADDED: + newVersion = Integer.parseInt(matcher.group(1)) + break; + case IOpenShiftWatchListener.ChangeType.DELETED: + if (Integer.parseInt(matcher.group(1)) == lastVersion) { + deleted = true + } + break; + } + } + if (deleted && newVersion) { + latch.countDown() + } + } + + def await(timeout, timeUnit) { + return latch.await(timeout, timeUnit) + } + + def getNewVersion() { + return newVersion + } + } + def completed + def watcher = client.watch(project, listener, ResourceKind.POD) + try { + completed = listener.await(5, TimeUnit.MINUTES) + } finally { + watcher.stop() + } + return completed ? listener.getNewVersion() : 0 + } + + def modifyConfigMap(configMap, map) { + JBossDmrExtentions.set(configMap.getNode(), configMap.getPropertyKeys(), 'data', map) + return configMap + } + +} diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index f52d25d..5d0c1f9 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -17,25 +17,25 @@ config.project.key=${OPENSHIFT_PROJECT} config.simulate=${SIMULATE} # Provisioning App -config.provisioning-app.user.name=${E2E_USER_EMAIL} -config.provisioning-app.user.password=${E2E_USER_PASSWORD} +config.provisioning-app.user.name=${PROV_APP_USER} +config.provisioning-app.user.password=${PROV_APP_PASSWORD} config.provisioning.url=https://2xstable-prov-app-prova-test.${OPENSHIFT_PUBLIC_HOST}/ # Atlassian -config.atlassian.user.name=${E2E_USER_EMAIL} -config.atlassian.user.password=${E2E_USER_PASSWORD} +config.atlassian.user.name=${ATLASSIAN_USER} +config.atlassian.user.password=${ATLASSIAN_PASSWORD} config.atlassian.jira.url=${JIRA_URL}/ config.atlassian.bitbucket.url=${BITBUCKET_URL} ## Jenkins -config.jenkins.user.name=${E2E_USER} -config.jenkins.user.password=${E2E_USER_PASSWORD} +config.jenkins.user.name=${JENKINS_USER} +config.jenkins.user.password=${JENKINS_PASSWORD} config.jenkins.url=https://jenkins-${OPENSHIFT_PROJECT}-cd.${OPENSHIFT_PUBLIC_HOST}/ ### Openshift config.openshift.publichost=${OPENSHIFT_PUBLIC_HOST} -config.openshift.user.name=${E2E_USER} -config.openshift.user.password=${E2E_USER_PASSWORD} +config.openshift.user.name=${OPENSHIFT_USER} +config.openshift.user.password=${OPENSHIFT_PASSWORD} config.openshift.url=${OPENSHIFT_CLUSTER} ### Reports dir diff --git a/src/test/resources/k8stypes.properties b/src/test/resources/k8stypes.properties new file mode 100644 index 0000000..056b515 --- /dev/null +++ b/src/test/resources/k8stypes.properties @@ -0,0 +1 @@ +com.openshift.internal.restclient.model.deploy.DeploymentRequest=.DeploymentRequest \ No newline at end of file From a3ac6df1cafb7ef5a57523b3ae67137a21d45ce0 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 30 Jun 2020 13:27:51 +0200 Subject: [PATCH 04/54] Adapt some tests to changes in GitUtil --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index ac556c3..8f30fd1 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -735,7 +735,8 @@ class ODSSpec extends BaseSpec { // Result: Repository cloned, metadata.yml is available // ------------------------------------------------------------------------------------------------------------- when: - def repositoryFolder = GitUtil.cloneRepository(projects.default.key, releaseManagerComponent.componentId) + def gitRepository = GitUtil.cloneRepository(projects.default.key, releaseManagerComponent.componentId) + def repositoryFolder = gitRepository.repository.getWorkTree() and: DumperOptions options = new DumperOptions() @@ -780,10 +781,10 @@ class ODSSpec extends BaseSpec { parser.dump(metadataYml, new FileWriter("$repositoryFolder/metadata.yml")) and: 'Commit the file' - GitUtil.commitAddAll('New component added') + GitUtil.commitAddAll(gitRepository,'New component added') and: 'Push it to the repository' - GitUtil.push('origin') + GitUtil.push(gitRepository,'origin') // ------------------------------------------------------------------------------------------------------------- // 3.2 Trigger Jenkins build of the release manager. From 1b153703ab35428394ac726577e2e483fa1d6444 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 30 Jun 2020 13:28:36 +0200 Subject: [PATCH 05/54] Test scope for rest client --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c722b83..ee8fc9d 100644 --- a/build.gradle +++ b/build.gradle @@ -49,7 +49,7 @@ dependencies { testCompile "org.yaml:snakeyaml:1.26" // Openshift client - implementation "com.openshift:openshift-restclient-java:$openshiftClientVersion" + testImplementation "com.openshift:openshift-restclient-java:$openshiftClientVersion" } From 0d756c7c5efe0a58f68a18051941f64f6767bcc9 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 1 Jul 2020 13:55:32 +0200 Subject: [PATCH 06/54] Use an actual clone command and setup sslVerify at git user config level --- src/test/groovy/org/ods/e2e/util/GitUtil.groovy | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy index dcefbed..5b0045e 100644 --- a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy +++ b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy @@ -51,20 +51,11 @@ class GitUtil { } File localPath = Files.createTempDirectory("${repository}-").toFile() - - def gitRepository = Git.init().setDirectory(localPath).call() - def config = gitRepository.getRepository().getConfig() - config.setBoolean("http", null, "sslVerify", false) - config.save() - gitRepository.remoteAdd().setName('origin').setUri(new URIish(repositoryUrl)).call() - - gitRepository.pull() + def gitRepository = Git.cloneRepository() + .setDirectory(localPath) .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password)) - .setRemote('origin') - .setRemoteBranchName('master') - .call() - - + .setURI(new URIish(repositoryUrl)).call() + gitRepository.close() return gitRepository } From 8e0f870b671154b4ab47717586e28ab847a22cdc Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 1 Jul 2020 14:14:51 +0200 Subject: [PATCH 07/54] Fix cloneRepository --- src/test/groovy/org/ods/e2e/util/GitUtil.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy index 5b0045e..caa1ce2 100644 --- a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy +++ b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy @@ -54,7 +54,7 @@ class GitUtil { def gitRepository = Git.cloneRepository() .setDirectory(localPath) .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password)) - .setURI(new URIish(repositoryUrl)).call() + .setURI(repositoryUrl).call() gitRepository.close() return gitRepository } From 22d79da226b4e3b4a7ac882b9863c184e2bbfc67 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 1 Jul 2020 17:19:38 +0200 Subject: [PATCH 08/54] Specify initial branch for git clone --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 2 +- src/test/groovy/org/ods/e2e/util/GitUtil.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 8f30fd1..ea9c873 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -414,7 +414,7 @@ class ODSSpec extends BaseSpec { // Result: Repository with master branch found, branch modified and committed/pushed when: 'Checkout project' def quickstarter = 'fe-angular' - def gitRepository = GitUtil.cloneRepository(OPENDEVSTACK, 'ods-quickstarters', false) + def gitRepository = GitUtil.cloneRepository(OPENDEVSTACK, 'ods-quickstarters', 'feature/ods-devenv', false) and: 'Create a branch' GitUtil.checkout(gitRepository, E2E_TEST_BRANCH, true) diff --git a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy index caa1ce2..9725762 100644 --- a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy +++ b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy @@ -41,7 +41,7 @@ class GitUtil { * @param repository the repository * @return the repository */ - static cloneRepository(project, repository, isODSComponentRepo = true) { + static cloneRepository(project, repository, branch = null, isODSComponentRepo = true) { def gitUrl = baseUrlBitbucket.endsWith('/') ? baseUrlBitbucket : baseUrlBitbucket + '/' def repositoryUrl if (isODSComponentRepo) { From 54e21485c1c8bcab058b05cc72bfe6b5f9b4ccbf Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 1 Jul 2020 17:29:03 +0200 Subject: [PATCH 09/54] Fix specify initial branch --- src/test/groovy/org/ods/e2e/util/GitUtil.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy index 9725762..35dbc5b 100644 --- a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy +++ b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy @@ -54,7 +54,8 @@ class GitUtil { def gitRepository = Git.cloneRepository() .setDirectory(localPath) .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password)) - .setURI(repositoryUrl).call() + .setURI(repositoryUrl) + .setBranch(branch).call() gitRepository.close() return gitRepository } From 526ccfd64a4205c3a357cd557575b9d4fb765da4 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 1 Jul 2020 18:15:53 +0200 Subject: [PATCH 10/54] Set base bitbucket branch through environment variables --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 2 +- src/test/groovy/org/ods/e2e/util/BaseSpec.groovy | 5 +++++ src/test/resources/application.properties | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index ea9c873..3532a20 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -414,7 +414,7 @@ class ODSSpec extends BaseSpec { // Result: Repository with master branch found, branch modified and committed/pushed when: 'Checkout project' def quickstarter = 'fe-angular' - def gitRepository = GitUtil.cloneRepository(OPENDEVSTACK, 'ods-quickstarters', 'feature/ods-devenv', false) + def gitRepository = GitUtil.cloneRepository(OPENDEVSTACK, 'ods-quickstarters', baseBranchBitbucket, false) and: 'Create a branch' GitUtil.checkout(gitRepository, E2E_TEST_BRANCH, true) diff --git a/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy b/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy index 18ec02e..f3cf166 100644 --- a/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy +++ b/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy @@ -19,6 +19,7 @@ class BaseSpec extends GebReportingSpec { def baseUrlProvisioningApp def baseUrlJira def baseUrlBitbucket + def baseBranchBitbucket def baseUrlJenkins def baseUrlOpenshift def openshiftPublichost @@ -34,6 +35,10 @@ class BaseSpec extends GebReportingSpec { baseUrlProvisioningApp = removeLastSlash(applicationProperties."config.provisioning.url") baseUrlJira = removeLastSlash(applicationProperties."config.atlassian.jira.url") baseUrlBitbucket = removeLastSlash(applicationProperties."config.atlassian.bitbucket.url") + baseBranchBitbucket = applicationProperties."config.atlassian.bitbucket.branch" + if(!baseBranchBitbucket) { + baseBranchBitbucket = null + } baseUrlJenkins = removeLastSlash(applicationProperties."config.jenkins.url") baseUrlOpenshift = removeLastSlash(applicationProperties."config.openshift.url") simulate = applicationProperties."config.simulate".toUpperCase() == 'TRUE' diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 7a8dbab..a6e64c8 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -8,6 +8,7 @@ # OPENSHIFT_PUBLIC_HOST: Public host to access jenkins or the provisioning app # OPENSHIFT_CLUSTER: The OpenShift instance master instance. # BITBUCKET_URL: The url of Bitbucket +# BITBUCKET_BASE_BRANCH: The initial branch when cloning. HEAD if not specified. # JIRA_URL: The url of Jira # SIMULATE: Will help us during the develop of the test to simulate the creation of different artifacts # without creating them @@ -26,6 +27,7 @@ config.atlassian.user.name=${ATLASSIAN_USER} config.atlassian.user.password=${ATLASSIAN_PASSWORD} config.atlassian.jira.url=${JIRA_URL} config.atlassian.bitbucket.url=${BITBUCKET_URL} +config.atlassian.bitbucket.branch=${BITBUCKET_BASE_BRANCH} ## Jenkins config.jenkins.user.name=${JENKINS_USER} From b13b79ab868283e2a6be2162444f047349bc5b21 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 1 Jul 2020 18:49:37 +0200 Subject: [PATCH 11/54] Get provisioning app name and project from properties --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 12 +++++------- src/test/groovy/org/ods/e2e/util/BaseSpec.groovy | 4 ++++ src/test/resources/application.properties | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 3532a20..3bd1528 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -391,8 +391,6 @@ class ODSSpec extends BaseSpec { // Result: Project and repository available given: baseUrl = baseUrlBitbucket - def openshiftProject = 'prov-test' - def openshiftApp = 'prov-app' when: to LoginPage @@ -443,7 +441,7 @@ class ODSSpec extends BaseSpec { doOpenshiftLoginProcess() and: 'Visit the config maps of the provisioning application' - to ConsoleResourcesConfigMaps, openshiftProject + to ConsoleResourcesConfigMaps, provisioningAppProject and: 'Retrieve the configMaps' def configMaps = getConfigMaps() @@ -457,7 +455,7 @@ class ODSSpec extends BaseSpec { // Result: Existing Quickstarter / boilerplace configuration available when: 'Read configMap' - def client = OpenShiftClient.connect(openshiftProject) + def client = OpenShiftClient.connect(provisioningAppProject) def configMap = client.getConfigMap('application.properties') def configMapData = configMap.getData() @@ -515,13 +513,13 @@ class ODSSpec extends BaseSpec { // Result: New deployment of provision app shown in console and new pod available when: 'Get deployments' - def lastVersion = client.getLastDeploymentVersion(openshiftApp) + def lastVersion = client.getLastDeploymentVersion(provisioningAppName) and: 'Redeploy the provisioning app' - client.deploy(openshiftApp) + client.deploy(provisioningAppName) and: 'Wait for deployment' - def newVersion = client.waitForDeployment(openshiftApp, lastVersion) + def newVersion = client.waitForDeployment(provisioningAppName, lastVersion) then: 'New deployment exists' newVersion > lastVersion diff --git a/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy b/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy index f3cf166..cd290c3 100644 --- a/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy +++ b/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy @@ -17,6 +17,8 @@ class BaseSpec extends GebReportingSpec { static JavascriptExecutor js def baseUrlProvisioningApp + def provisioningAppProject + def provisioningAppName def baseUrlJira def baseUrlBitbucket def baseBranchBitbucket @@ -33,6 +35,8 @@ class BaseSpec extends GebReportingSpec { js = (JavascriptExecutor) driver openshiftPublichost = removeLastSlash(applicationProperties."config.openshift.publichost") baseUrlProvisioningApp = removeLastSlash(applicationProperties."config.provisioning.url") + provisioningAppName = applicationProperties."config.provisioning-app.name" + provisioningAppProject = applicationProperties."config.provisioning-app.project" baseUrlJira = removeLastSlash(applicationProperties."config.atlassian.jira.url") baseUrlBitbucket = removeLastSlash(applicationProperties."config.atlassian.bitbucket.url") baseBranchBitbucket = applicationProperties."config.atlassian.bitbucket.branch" diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index a6e64c8..dfcbda6 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -18,6 +18,8 @@ config.project.key=${OPENSHIFT_PROJECT} config.simulate=${SIMULATE} # Provisioning App +config.provisioning-app.name=${PROV_APP_NAME} +config.provisioning-app.project=${PROV_APP_PROJECT} config.provisioning-app.user.name=${PROV_APP_USER} config.provisioning-app.user.password=${PROV_APP_PASSWORD} config.provisioning.url=https://${PROV_APP_NAME}.${OPENSHIFT_PUBLIC_HOST} From 13d1563c20cf6d6b7e9143f6195e3adf354c2453 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 1 Jul 2020 19:13:37 +0200 Subject: [PATCH 12/54] Provisioning app name and deploy cfg name need not be the same --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 6 +++--- src/test/groovy/org/ods/e2e/util/BaseSpec.groovy | 4 ++-- src/test/resources/application.properties | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 3bd1528..d852738 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -513,13 +513,13 @@ class ODSSpec extends BaseSpec { // Result: New deployment of provision app shown in console and new pod available when: 'Get deployments' - def lastVersion = client.getLastDeploymentVersion(provisioningAppName) + def lastVersion = client.getLastDeploymentVersion(provisioningAppDeployCfg) and: 'Redeploy the provisioning app' - client.deploy(provisioningAppName) + client.deploy(provisioningAppDeployCfg) and: 'Wait for deployment' - def newVersion = client.waitForDeployment(provisioningAppName, lastVersion) + def newVersion = client.waitForDeployment(provisioningAppDeployCfg, lastVersion) then: 'New deployment exists' newVersion > lastVersion diff --git a/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy b/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy index cd290c3..6b06633 100644 --- a/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy +++ b/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy @@ -18,7 +18,7 @@ class BaseSpec extends GebReportingSpec { def baseUrlProvisioningApp def provisioningAppProject - def provisioningAppName + def provisioningAppDeployCfg def baseUrlJira def baseUrlBitbucket def baseBranchBitbucket @@ -35,7 +35,7 @@ class BaseSpec extends GebReportingSpec { js = (JavascriptExecutor) driver openshiftPublichost = removeLastSlash(applicationProperties."config.openshift.publichost") baseUrlProvisioningApp = removeLastSlash(applicationProperties."config.provisioning.url") - provisioningAppName = applicationProperties."config.provisioning-app.name" + provisioningAppDeployCfg = applicationProperties."config.provisioning-app.deployCfg" provisioningAppProject = applicationProperties."config.provisioning-app.project" baseUrlJira = removeLastSlash(applicationProperties."config.atlassian.jira.url") baseUrlBitbucket = removeLastSlash(applicationProperties."config.atlassian.bitbucket.url") diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index dfcbda6..e7b6bef 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -18,7 +18,7 @@ config.project.key=${OPENSHIFT_PROJECT} config.simulate=${SIMULATE} # Provisioning App -config.provisioning-app.name=${PROV_APP_NAME} +config.provisioning-app.deployCfg=${PROV_APP_DEPLOY_CFG} config.provisioning-app.project=${PROV_APP_PROJECT} config.provisioning-app.user.name=${PROV_APP_USER} config.provisioning-app.user.password=${PROV_APP_PASSWORD} From ab76fbbc7afa22b46e19896549a9c0882b0d8822 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Thu, 2 Jul 2020 10:09:13 +0200 Subject: [PATCH 13/54] Parameterize the name of the quickstarters configmap --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 4 ++-- src/test/groovy/org/ods/e2e/util/BaseSpec.groovy | 7 ++++++- src/test/resources/application.properties | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index d852738..9b4a92b 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -447,7 +447,7 @@ class ODSSpec extends BaseSpec { def configMaps = getConfigMaps() then: - configMaps.findAll { configMap -> configMap.name == 'application.properties' }.size() == 1 + configMaps.findAll { configMap -> configMap.name == quickstartersConfigMap }.size() == 1 report("step 3 - Configuration maps available – namely application.properties") // STEP 4: In the application.properties config map copy the configuration lines from the quickstarter @@ -456,7 +456,7 @@ class ODSSpec extends BaseSpec { when: 'Read configMap' def client = OpenShiftClient.connect(provisioningAppProject) - def configMap = client.getConfigMap('application.properties') + def configMap = client.getConfigMap(quickstartersConfigMap) def configMapData = configMap.getData() and: 'Read the properties' diff --git a/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy b/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy index 6b06633..5dc587b 100644 --- a/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy +++ b/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy @@ -27,6 +27,7 @@ class BaseSpec extends GebReportingSpec { def openshiftPublichost def simulate def extraLoginPage + def quickstartersConfigMap def setup() { driver.manage().window().setSize(new Dimension(1600, 1024)) @@ -40,7 +41,7 @@ class BaseSpec extends GebReportingSpec { baseUrlJira = removeLastSlash(applicationProperties."config.atlassian.jira.url") baseUrlBitbucket = removeLastSlash(applicationProperties."config.atlassian.bitbucket.url") baseBranchBitbucket = applicationProperties."config.atlassian.bitbucket.branch" - if(!baseBranchBitbucket) { + if (!baseBranchBitbucket) { baseBranchBitbucket = null } baseUrlJenkins = removeLastSlash(applicationProperties."config.jenkins.url") @@ -51,6 +52,10 @@ class BaseSpec extends GebReportingSpec { extraLoginPage = System.getenv("OCP_LOGIN_SELECTOR_PAGE")?.toUpperCase() == 'TRUE' ? true : false + quickstartersConfigMap = applicationProperties."config.openshift.quickstarters.configMap" + if (!quickstartersConfigMap) { + quickstartersConfigMap = 'quickstarters.properties' + } } def removeLastSlash(String str) { diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index e7b6bef..fd75ba7 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -41,6 +41,7 @@ config.openshift.publichost=${OPENSHIFT_PUBLIC_HOST} config.openshift.user.name=${OPENSHIFT_USER} config.openshift.user.password=${OPENSHIFT_PASSWORD} config.openshift.url=${OPENSHIFT_CLUSTER} +config.openshift.quickstarters.configMap=${QUICKSTARTERS_CONFIGMAP} ### Reports dir config.reports.dir=build/e2e-geb-reports From d5e0c00b26f5f84f9be238ddf15e013a835152d3 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Thu, 2 Jul 2020 15:12:31 +0200 Subject: [PATCH 14/54] Debug waiting for deployment --- .../org/ods/e2e/openshift/client/OpenShiftClient.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy index 522f679..2ceb6d5 100644 --- a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy +++ b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy @@ -12,6 +12,7 @@ import com.openshift.restclient.model.IDeploymentConfig import com.openshift.restclient.model.IResource import org.ods.e2e.util.SpecHelper +import java.sql.Timestamp import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit @@ -101,6 +102,7 @@ class OpenShiftClient { } def waitForDeployment(name, lastVersion, project) { + System.out.println(new Timestamp(System.currentTimeMillis())) def listener = new IOpenShiftWatchListener.OpenShiftWatchListenerAdapter() { private CountDownLatch latch = new CountDownLatch(1) private int newVersion = 0 @@ -121,7 +123,7 @@ class OpenShiftClient { break; } } - if (deleted && newVersion) { + if (deleted && newVersion > lastVersion) { latch.countDown() } } @@ -141,6 +143,7 @@ class OpenShiftClient { } finally { watcher.stop() } + System.out.println(new Timestamp(System.currentTimeMillis())) return completed ? listener.getNewVersion() : 0 } From bdd8f3d46f1835d47f3cb77d2be09406632d7583 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Mon, 6 Jul 2020 09:29:59 +0200 Subject: [PATCH 15/54] Fix waiting for deployment ready --- .../e2e/openshift/client/OpenShiftClient.groovy | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy index 2ceb6d5..c1fd873 100644 --- a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy +++ b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy @@ -107,23 +107,29 @@ class OpenShiftClient { private CountDownLatch latch = new CountDownLatch(1) private int newVersion = 0 private boolean deleted = false + private boolean ready = false @Override void received(IResource resource, IOpenShiftWatchListener.ChangeType change) { - def matcher = resource.name =~ /$name-(\d+)-.*/ - if (resource.kind == ResourceKind.POD && matcher.matches()) { + if (resource.kind == ResourceKind.POD && resource.getAnnotation('openshift.io/deployment-config.name') == name) { + def version = resource.getAnnotation('openshift.io/deployment-config.latest-version') switch (change) { case IOpenShiftWatchListener.ChangeType.ADDED: - newVersion = Integer.parseInt(matcher.group(1)) + newVersion = version + ready = resource.isReady() break; case IOpenShiftWatchListener.ChangeType.DELETED: - if (Integer.parseInt(matcher.group(1)) == lastVersion) { + if (version == lastVersion) { deleted = true } break; + case IOpenShiftWatchListener.ChangeType.MODIFIED: + if(version == newVersion) { + ready = resource.isReady() + } } } - if (deleted && newVersion > lastVersion) { + if (deleted && ready && newVersion > lastVersion) { latch.countDown() } } From 403fced0c6c681e27f7ed89905ce881194abec59 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Mon, 6 Jul 2020 10:20:52 +0200 Subject: [PATCH 16/54] Fix waiting for deployment --- .../org/ods/e2e/openshift/client/OpenShiftClient.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy index c1fd873..b64760d 100644 --- a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy +++ b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy @@ -112,7 +112,7 @@ class OpenShiftClient { @Override void received(IResource resource, IOpenShiftWatchListener.ChangeType change) { if (resource.kind == ResourceKind.POD && resource.getAnnotation('openshift.io/deployment-config.name') == name) { - def version = resource.getAnnotation('openshift.io/deployment-config.latest-version') + def version = Integer.parseInt(resource.getAnnotation('openshift.io/deployment-config.latest-version')) switch (change) { case IOpenShiftWatchListener.ChangeType.ADDED: newVersion = version @@ -124,7 +124,7 @@ class OpenShiftClient { } break; case IOpenShiftWatchListener.ChangeType.MODIFIED: - if(version == newVersion) { + if (version == newVersion) { ready = resource.isReady() } } From c69fd5200231ceab64e4f53dda2affcdde7f1a3d Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Mon, 6 Jul 2020 17:37:57 +0200 Subject: [PATCH 17/54] Fix waiting for deployment --- .../org/ods/e2e/openshift/client/OpenShiftClient.groovy | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy index b64760d..46483e2 100644 --- a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy +++ b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy @@ -102,7 +102,6 @@ class OpenShiftClient { } def waitForDeployment(name, lastVersion, project) { - System.out.println(new Timestamp(System.currentTimeMillis())) def listener = new IOpenShiftWatchListener.OpenShiftWatchListenerAdapter() { private CountDownLatch latch = new CountDownLatch(1) private int newVersion = 0 @@ -111,8 +110,9 @@ class OpenShiftClient { @Override void received(IResource resource, IOpenShiftWatchListener.ChangeType change) { - if (resource.kind == ResourceKind.POD && resource.getAnnotation('openshift.io/deployment-config.name') == name) { - def version = Integer.parseInt(resource.getAnnotation('openshift.io/deployment-config.latest-version')) + def matcher = resource.name =~ /$name-(\d+)-.*/ + if (resource.kind == ResourceKind.POD && matcher.matches()) { + def version = Integer.parseInt(matcher.group(1)) switch (change) { case IOpenShiftWatchListener.ChangeType.ADDED: newVersion = version @@ -149,7 +149,6 @@ class OpenShiftClient { } finally { watcher.stop() } - System.out.println(new Timestamp(System.currentTimeMillis())) return completed ? listener.getNewVersion() : 0 } From 5e1fa1d15fcbdac3c13c1947ca567691cdd22d46 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Mon, 6 Jul 2020 18:27:02 +0200 Subject: [PATCH 18/54] Fix wait for deployment --- .../e2e/openshift/client/OpenShiftClient.groovy | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy index 46483e2..95dff66 100644 --- a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy +++ b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy @@ -1,6 +1,5 @@ package org.ods.e2e.openshift.client - import com.openshift.internal.util.JBossDmrExtentions import com.openshift.restclient.ClientBuilder import com.openshift.restclient.IClient @@ -12,7 +11,6 @@ import com.openshift.restclient.model.IDeploymentConfig import com.openshift.restclient.model.IResource import org.ods.e2e.util.SpecHelper -import java.sql.Timestamp import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit @@ -115,18 +113,23 @@ class OpenShiftClient { def version = Integer.parseInt(matcher.group(1)) switch (change) { case IOpenShiftWatchListener.ChangeType.ADDED: - newVersion = version - ready = resource.isReady() - break; + if (version > newVersion) { + newVersion = version + ready = resource.isReady() + } + break case IOpenShiftWatchListener.ChangeType.DELETED: if (version == lastVersion) { deleted = true + } else if (version == newVersion) { + newVersion = 0 } - break; + break case IOpenShiftWatchListener.ChangeType.MODIFIED: if (version == newVersion) { ready = resource.isReady() } + break } } if (deleted && ready && newVersion > lastVersion) { From a7b0acb1de6e40882a933160f8cfd12f9fef1ebc Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Mon, 6 Jul 2020 18:31:29 +0200 Subject: [PATCH 19/54] Add diagnostics --- .../org/ods/e2e/openshift/client/OpenShiftClient.groovy | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy index 95dff66..7ebfd24 100644 --- a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy +++ b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy @@ -111,23 +111,28 @@ class OpenShiftClient { def matcher = resource.name =~ /$name-(\d+)-.*/ if (resource.kind == ResourceKind.POD && matcher.matches()) { def version = Integer.parseInt(matcher.group(1)) + println("Event type $change, resource ${resource.name}, version $version") switch (change) { case IOpenShiftWatchListener.ChangeType.ADDED: if (version > newVersion) { + println("New version $version, previous $newVersion, last $lastVersion") newVersion = version ready = resource.isReady() } break case IOpenShiftWatchListener.ChangeType.DELETED: if (version == lastVersion) { + println("Deleted version $version") deleted = true } else if (version == newVersion) { + println("Unexpected deletion $version") newVersion = 0 } break case IOpenShiftWatchListener.ChangeType.MODIFIED: if (version == newVersion) { ready = resource.isReady() + println("Resource modified: Ready = $ready") } break } From 1af7bbd63fa9df6178360cc130e372112cef2823 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Mon, 6 Jul 2020 18:42:22 +0200 Subject: [PATCH 20/54] More diagnostics --- .../org/ods/e2e/openshift/client/OpenShiftClient.groovy | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy index 7ebfd24..a333d3c 100644 --- a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy +++ b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy @@ -11,6 +11,7 @@ import com.openshift.restclient.model.IDeploymentConfig import com.openshift.restclient.model.IResource import org.ods.e2e.util.SpecHelper +import java.sql.Timestamp import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit @@ -111,7 +112,7 @@ class OpenShiftClient { def matcher = resource.name =~ /$name-(\d+)-.*/ if (resource.kind == ResourceKind.POD && matcher.matches()) { def version = Integer.parseInt(matcher.group(1)) - println("Event type $change, resource ${resource.name}, version $version") + println("Event type ${change.value}, resource ${resource.name}, version $version") switch (change) { case IOpenShiftWatchListener.ChangeType.ADDED: if (version > newVersion) { @@ -143,7 +144,10 @@ class OpenShiftClient { } def await(timeout, timeUnit) { - return latch.await(timeout, timeUnit) + println("Before wait " + new Timestamp(System.currentTimeMillis())) + def result = latch.await(timeout, timeUnit) + println('After wait ' + new Timestamp(System.currentTimeMillis()) + " Result $result") + return result } def getNewVersion() { From 74d1db404bcede39ca11486cbdb08e9a381b49d3 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Mon, 6 Jul 2020 18:52:01 +0200 Subject: [PATCH 21/54] Add pause after pod ready so that the app can boot --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 9b4a92b..d8259d6 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -520,7 +520,8 @@ class ODSSpec extends BaseSpec { and: 'Wait for deployment' def newVersion = client.waitForDeployment(provisioningAppDeployCfg, lastVersion) - + sleep(30000) + then: 'New deployment exists' newVersion > lastVersion report("step 6 - New deployment of provision app shown in console and new pod available.") From 6f7cd8cde6272b56dc4091ad407daae0515bfd23 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Mon, 6 Jul 2020 19:01:20 +0200 Subject: [PATCH 22/54] Remove diagnostics --- .../ods/e2e/openshift/client/OpenShiftClient.groovy | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy index a333d3c..8c3e899 100644 --- a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy +++ b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftClient.groovy @@ -112,28 +112,21 @@ class OpenShiftClient { def matcher = resource.name =~ /$name-(\d+)-.*/ if (resource.kind == ResourceKind.POD && matcher.matches()) { def version = Integer.parseInt(matcher.group(1)) - println("Event type ${change.value}, resource ${resource.name}, version $version") switch (change) { case IOpenShiftWatchListener.ChangeType.ADDED: if (version > newVersion) { - println("New version $version, previous $newVersion, last $lastVersion") newVersion = version ready = resource.isReady() } break case IOpenShiftWatchListener.ChangeType.DELETED: if (version == lastVersion) { - println("Deleted version $version") deleted = true - } else if (version == newVersion) { - println("Unexpected deletion $version") - newVersion = 0 } break case IOpenShiftWatchListener.ChangeType.MODIFIED: if (version == newVersion) { ready = resource.isReady() - println("Resource modified: Ready = $ready") } break } @@ -144,10 +137,7 @@ class OpenShiftClient { } def await(timeout, timeUnit) { - println("Before wait " + new Timestamp(System.currentTimeMillis())) - def result = latch.await(timeout, timeUnit) - println('After wait ' + new Timestamp(System.currentTimeMillis()) + " Result $result") - return result + return latch.await(timeout, timeUnit) } def getNewVersion() { From 101711a9f1dacf1ab7b4e22cc86bff7c44971da0 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 7 Jul 2020 09:50:26 +0200 Subject: [PATCH 23/54] Small fixes --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index d8259d6..97a7f59 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -25,7 +25,7 @@ class ODSSpec extends BaseSpec { def static OPENDEVSTACK = 'OPENDEVSTACK' def static E2E_TEST_BRANCH = 'e2e-test-branch' def static E2E_TEST_FILE = 'e2e-tests.txt' - def static E2E_TEST_QUICKSTARTER = 'E2ET3' + def static E2E_TEST_QUICKSTARTER = 'e2e-test-quickstarter' def projects = [ default: [ @@ -110,7 +110,7 @@ class ODSSpec extends BaseSpec { // STEP 1: Login to provisioning application with administrator privileges // Result: Login works, within a provisioning and history links // ------------------------------------------------------------------------------------------------------------- - given: 'We are logged in the provissioning app' + given: 'We are logged in the provisioning app' def project = projects.default baseUrl = baseUrlProvisioningApp @@ -142,7 +142,7 @@ class ODSSpec extends BaseSpec { and: 'Get the next key' def nextId = getNextId(project.key) project.name = String.format("$project.name - %02d", nextId) - project.key = String.format("$project.key%02d", nextId) + project.key = String.format("${project.key}%02d", nextId) and: 'We open the project creation form' provisionOptionChooser.doSelectCreateNewProject() @@ -521,7 +521,7 @@ class ODSSpec extends BaseSpec { and: 'Wait for deployment' def newVersion = client.waitForDeployment(provisioningAppDeployCfg, lastVersion) sleep(30000) - + then: 'New deployment exists' newVersion > lastVersion report("step 6 - New deployment of provision app shown in console and new pod available.") From b2e1a8b3f71feac31dbe3a1fa015cc380549a004 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 7 Jul 2020 12:28:42 +0200 Subject: [PATCH 24/54] projects must be static --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 97a7f59..4492eb4 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -27,7 +27,7 @@ class ODSSpec extends BaseSpec { def static E2E_TEST_FILE = 'e2e-tests.txt' def static E2E_TEST_QUICKSTARTER = 'e2e-test-quickstarter' - def projects = [ + def static projects = [ default: [ name : 'E2E Test Project', description : 'E2E Test Project', From 719f49a71e6d0525557a190ae344fee934b26452 Mon Sep 17 00:00:00 2001 From: OpenShift Date: Thu, 9 Jul 2020 09:31:40 +0200 Subject: [PATCH 25/54] Ignore JenkinsSpec --- src/test/groovy/org/ods/e2e/jenkins/JenkinsSpec.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/groovy/org/ods/e2e/jenkins/JenkinsSpec.groovy b/src/test/groovy/org/ods/e2e/jenkins/JenkinsSpec.groovy index ab67ead..e232df0 100644 --- a/src/test/groovy/org/ods/e2e/jenkins/JenkinsSpec.groovy +++ b/src/test/groovy/org/ods/e2e/jenkins/JenkinsSpec.groovy @@ -9,6 +9,7 @@ import org.ods.e2e.util.BaseSpec import org.ods.e2e.util.SpecHelper import spock.lang.Ignore +@Ignore class JenkinsSpec extends BaseSpec { static Properties applicationProperties = new SpecHelper().getApplicationProperties() From 4805ea862d1a753f57b295e2c2c930fbe4f8e3d0 Mon Sep 17 00:00:00 2001 From: OpenShift Date: Thu, 9 Jul 2020 15:57:30 +0200 Subject: [PATCH 26/54] Updated readme --- readme.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index c2d5a05..f66e0d2 100644 --- a/readme.md +++ b/readme.md @@ -11,20 +11,24 @@ You need to set several environment variables in order to make this work, as it | Variable | Value | |---|---| +| QUICKSTARTERS_CONFIGMAP | ConfigMap containing quickstarter configuration. Used to be application.properties, now quickstarters.properties | +| PROV_APP_PROJECT | Id of the OpenShift project of the provisioning app | +| PROV_APP_DEPLOY_CFG | Name of the deployment config of the provisioning app | +| PROV_APP_NAME | Name of the provisioning app, as it appears in the public URL | | PROV_APP_USER | Provisioning app user name | | PROV_APP_PASSWORD | Provisioning app password | | ATLASSIAN_USER | Atlassian user name | | ATLASSIAN_PASSWORD | Atlassian password | +| JIRA_URL | Url of Jira instance related with the prov app | | JENKINS_USER | Jenkins user name | | JENKINS_PASSWORD | Jenkins password | | OPENSHIFT_USER | Openshift user name | | OPENSHIFT_PASSWORD | Openshift password | -| PROV_APP_NAME | Name of the deployment of the provisioning app | -| JIRA_URL | Url of Jira instance related with the prov app | | OPENSHIFT_PROJECT | project identifier for prov app in the preliminary tests | | OPENSHIFT_PUBLIC_HOST | host where we can locate the prov app | | OPENSHIFT_CLUSTER | URL of the Openshift Cluster | | BITBUCKET_URL | Url of Bitbucket instance | +| BITBUCKET_BASE_BRANCH | Branch of the OpenShift project which should be treated as HEAD. In some cases, main may not be available. | | SIMULATE | Specify (true or false) if we skip the creation of project, components, etc | The following commands will launch the tests with the individual browsers: From 7d610780b171c8ab33557b70798801892161055c Mon Sep 17 00:00:00 2001 From: OpenShift Date: Thu, 9 Jul 2020 16:48:19 +0200 Subject: [PATCH 27/54] Improve cleanup --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 4492eb4..b9b21f6 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -566,6 +566,9 @@ class ODSSpec extends BaseSpec { configMapData.put('properties', propertyBackup) client.modifyConfigMap(configMap, configMapData) client.update(configMap) + client.deploy(provisioningAppDeployCfg) + GitUtil.checkout(gitRepository, baseBranchBitbucket) + client.waitForDeployment(provisioningAppDeployCfg, newVersion) } From be5953a63f167053ca03f9341a9f99660857c0f2 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Thu, 9 Jul 2020 17:10:40 +0200 Subject: [PATCH 28/54] Improve cleanup --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 2 +- src/test/groovy/org/ods/e2e/util/GitUtil.groovy | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index b9b21f6..be0a60d 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -567,7 +567,7 @@ class ODSSpec extends BaseSpec { client.modifyConfigMap(configMap, configMapData) client.update(configMap) client.deploy(provisioningAppDeployCfg) - GitUtil.checkout(gitRepository, baseBranchBitbucket) + GitUtil.deleteBranch(gitRepository, E2E_TEST_BRANCH, true) client.waitForDeployment(provisioningAppDeployCfg, newVersion) } diff --git a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy index 35dbc5b..41101f1 100644 --- a/src/test/groovy/org/ods/e2e/util/GitUtil.groovy +++ b/src/test/groovy/org/ods/e2e/util/GitUtil.groovy @@ -1,8 +1,6 @@ package org.ods.e2e.util - import org.eclipse.jgit.api.Git -import org.eclipse.jgit.transport.URIish import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider import javax.net.ssl.X509TrustManager @@ -108,4 +106,12 @@ class GitUtil { .addFilepattern(files) .call() } + + static deleteBranch(Git gitRepository, branch, remote = false) { + def branches = [branch] + if (remote) { + branches << 'origin/' + branch + } + gitRepository.branchDelete().setBranchNames(branches as String[]).call() + } } From d2626a4fafedbfade404aa435faf8420d23de048 Mon Sep 17 00:00:00 2001 From: OpenShift Date: Tue, 14 Jul 2020 16:03:58 +0200 Subject: [PATCH 29/54] Create a component --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 39 ++++++++++++++++++---- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index b9b21f6..d6b406c 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -26,6 +26,7 @@ class ODSSpec extends BaseSpec { def static E2E_TEST_BRANCH = 'e2e-test-branch' def static E2E_TEST_FILE = 'e2e-tests.txt' def static E2E_TEST_QUICKSTARTER = 'e2e-test-quickstarter' + def static E2E_TEST_COMPONENT = 'e2e-test-component' def static projects = [ default: [ @@ -541,14 +542,40 @@ class ODSSpec extends BaseSpec { and: 'We have selected modify project' provisionOptionChooser.doSelectModifyProject() - then: 'The new quickstarter available in the list' - projectModifyForm.getProjects().find { - entry -> entry.key == project.key + // ------------------------------------------------------------------------------------------------------------- + // STEP 8: Click on the Quickstarter dropdown list and select a boilerplate “Frontend implemented with Vue JS” + // Result: The component ID is listed: fe-vue + // ------------------------------------------------------------------------------------------------------------- + and: + projectModifyForm.doAddQuickStarter(E2E_TEST_QUICKSTARTER, E2E_TEST_COMPONENT) + projectModifyForm.addQuickStarterButton.click() + report("step 8 - add quickstarter") + + // ------------------------------------------------------------------------------------------------------------- + // STEP 9: Click on Start Provision + // Result: Message the provision is in progress. + // Another message (screen) appears with the links of: + // Jenkins, Bitbucket, Project link, Provisioning jobs, and others. + // ------------------------------------------------------------------------------------------------------------- + and: + if (!simulate) { + projectModifyForm.doStartProvision() + sleep(15000) + + waitFor { + $(".modal-dialog").css("display") != "hidden" + $("#resProject.alert-success") + $("#resButton").text() == "Close" + } + report('Status after Quickstarters Addition') } - report("step 7 - New quickstarter available in the list in provision application.") + + then: 'Quickstarter was added' + simulate ? true : $("#resProject.alert-success") + report("step 9 - quick starter provisioned") - // STEP 8: Go to bitbucket, locate the new repository and locate the file added in step 2 + // STEP 10: Go to bitbucket, locate the new repository and locate the file added in step 2 // Result: Repository and file available when: 'Visit bitbucket to grab evidences of adding files' @@ -560,7 +587,7 @@ class ODSSpec extends BaseSpec { then: 'Test file exists' files.find { file -> file.name == E2E_TEST_FILE } - report("step 8 - Repository and file available.") + report("step 10 - Repository and file available.") cleanup: 'Restore original contents of the config map' configMapData.put('properties', propertyBackup) From fc63552b19100a5ad8cdce503f488a5c17db0886 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 14 Jul 2020 16:35:35 +0200 Subject: [PATCH 30/54] Create component --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 13 ++++++------- .../groovy/org/ods/e2e/util/HealthCheckUtil.groovy | 7 +++++++ 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 src/test/groovy/org/ods/e2e/util/HealthCheckUtil.groovy diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 2d16a8c..58db584 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -578,15 +578,14 @@ class ODSSpec extends BaseSpec { // STEP 10: Go to bitbucket, locate the new repository and locate the file added in step 2 // Result: Repository and file available - when: 'Visit bitbucket to grab evidences of adding files' - baseUrl = baseUrlBitbucket - to RepositoryPage, OPENDEVSTACK, 'ods-quickstarters', filesPath, [at: E2E_TEST_BRANCH] - - and: 'Get the existing files' - def files = getFiles() + when: 'Grab evidences of adding files from bitbucket' + gitRepository = GitUtil.cloneRepository(projects.default.name, E2E_TEST_QUICKSTARTER, baseBranchBitbucket) + directory = gitRepository.repository.getWorkTree() + filesPath = 'files' + testFilePath = "$filesPath/$E2E_TEST_FILE" then: 'Test file exists' - files.find { file -> file.name == E2E_TEST_FILE } + new File("$directory/$testFilePath").text == 'Test file for FT_01_002' report("step 10 - Repository and file available.") cleanup: 'Restore original contents of the config map' diff --git a/src/test/groovy/org/ods/e2e/util/HealthCheckUtil.groovy b/src/test/groovy/org/ods/e2e/util/HealthCheckUtil.groovy new file mode 100644 index 0000000..be911eb --- /dev/null +++ b/src/test/groovy/org/ods/e2e/util/HealthCheckUtil.groovy @@ -0,0 +1,7 @@ +package org.ods.e2e.util + +class HealthCheckUtil { + def isReady(pod) { + + } +} From a3eeeb5d9b701c4405aec45497c3a5c8a77ced85 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 14 Jul 2020 17:08:49 +0200 Subject: [PATCH 31/54] Select project to modify --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 58db584..133382d 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -541,6 +541,7 @@ class ODSSpec extends BaseSpec { and: 'We have selected modify project' provisionOptionChooser.doSelectModifyProject() + projectModifyForm.doSelectProject(project.key) // ------------------------------------------------------------------------------------------------------------- // STEP 8: Click on the Quickstarter dropdown list and select a boilerplate “Frontend implemented with Vue JS” @@ -579,7 +580,7 @@ class ODSSpec extends BaseSpec { // Result: Repository and file available when: 'Grab evidences of adding files from bitbucket' - gitRepository = GitUtil.cloneRepository(projects.default.name, E2E_TEST_QUICKSTARTER, baseBranchBitbucket) + gitRepository = GitUtil.cloneRepository(project.key, E2E_TEST_QUICKSTARTER, baseBranchBitbucket) directory = gitRepository.repository.getWorkTree() filesPath = 'files' testFilePath = "$filesPath/$E2E_TEST_FILE" From e0b88354012ce38e11d8a16cf8224f303b656996 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 14 Jul 2020 17:35:40 +0200 Subject: [PATCH 32/54] Component id cannot contain numbers --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 133382d..f51fce0 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -26,7 +26,7 @@ class ODSSpec extends BaseSpec { def static E2E_TEST_BRANCH = 'e2e-test-branch' def static E2E_TEST_FILE = 'e2e-tests.txt' def static E2E_TEST_QUICKSTARTER = 'e2e-test-quickstarter' - def static E2E_TEST_COMPONENT = 'e2e-test-component' + def static E2E_TEST_COMPONENT = 'test-component' def static projects = [ default: [ From 6c0faa5e2134297695e9ff689a2477ef1e9407e1 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 14 Jul 2020 17:59:40 +0200 Subject: [PATCH 33/54] Wait for component job to finish --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index f51fce0..b49b240 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -575,8 +575,35 @@ class ODSSpec extends BaseSpec { simulate ? true : $("#resProject.alert-success") report("step 9 - quick starter provisioned") + // ------------------------------------------------------------------------------------------------------------- + // STEP 10: Go to your project’s Jenkins and locate the provision job of the component + // with the name you provided. + // Result: Instance can be found and green (successful) + // ------------------------------------------------------------------------------------------------------------- + when: + baseUrl = getJenkinsBaseUrl(project.key) + + and: + doJenkinsLoginProcess() + + then: 'The project folder exists' + assert $("#job_${project.key.toLowerCase()}-cd") + + when: 'Visit the jobs' + to JenkinsJobFolderPage, project.key + + and: + def componentJob = getComponentJobs(project.key, E2E_TEST_COMPONENT) + + then: 'The component startup jobs finished succesfully' + waitFor('verySlow') { + getComponentJobs(project.key, E2E_TEST_COMPONENT).jobs.find { + job -> job.value.odsStartupComponentJob && job.value.success + } + } + report("step 10 - provision job of the component") - // STEP 10: Go to bitbucket, locate the new repository and locate the file added in step 2 + // STEP 11: Go to bitbucket, locate the new repository and locate the file added in step 2 // Result: Repository and file available when: 'Grab evidences of adding files from bitbucket' @@ -587,7 +614,7 @@ class ODSSpec extends BaseSpec { then: 'Test file exists' new File("$directory/$testFilePath").text == 'Test file for FT_01_002' - report("step 10 - Repository and file available.") + report("step 11 - Repository and file available.") cleanup: 'Restore original contents of the config map' configMapData.put('properties', propertyBackup) From 2b5580897dbcce52bcd02808988adb1830930462 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 14 Jul 2020 18:27:43 +0200 Subject: [PATCH 34/54] Fix where to find the jenkins file --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index b49b240..bd4091f 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -490,7 +490,7 @@ class ODSSpec extends BaseSpec { properties.putAll(tmpProps) properties.setProperty("jenkinspipeline.quickstarter.${E2E_TEST_QUICKSTARTER}.branch".toString(), E2E_TEST_BRANCH) properties.setProperty("jenkinspipeline.quickstarter.${E2E_TEST_QUICKSTARTER}.jenkinsfile".toString(), - "$E2E_TEST_QUICKSTARTER/Jenkinsfile".toString()) + "$quickstarter/Jenkinsfile".toString()) and: 'Update config map' def sw = new StringWriter() @@ -592,9 +592,6 @@ class ODSSpec extends BaseSpec { when: 'Visit the jobs' to JenkinsJobFolderPage, project.key - and: - def componentJob = getComponentJobs(project.key, E2E_TEST_COMPONENT) - then: 'The component startup jobs finished succesfully' waitFor('verySlow') { getComponentJobs(project.key, E2E_TEST_COMPONENT).jobs.find { From 16bd3d744e2626ab367945d68e5afa26a3416fc6 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 14 Jul 2020 19:08:57 +0200 Subject: [PATCH 35/54] ACtivate refresh and wait for very long --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index bd4091f..445acd6 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -562,8 +562,7 @@ class ODSSpec extends BaseSpec { if (!simulate) { projectModifyForm.doStartProvision() sleep(15000) - - waitFor { + waitFor('extremelySlow') { $(".modal-dialog").css("display") != "hidden" $("#resProject.alert-success") $("#resButton").text() == "Close" @@ -580,7 +579,11 @@ class ODSSpec extends BaseSpec { // with the name you provided. // Result: Instance can be found and green (successful) // ------------------------------------------------------------------------------------------------------------- - when: + // ------------------------------------------------------------------------------------------------------------- + // We first need to check that the Jenkins jobs had finalized properly for the release manager + // Before continuing with the steps of the test + // ------------------------------------------------------------------------------------------------------------- + when: 'visit Jenkins' baseUrl = getJenkinsBaseUrl(project.key) and: @@ -589,11 +592,14 @@ class ODSSpec extends BaseSpec { then: 'The project folder exists' assert $("#job_${project.key.toLowerCase()}-cd") - when: 'Visit the jobs' + when: 'Retrieve the jobs related with the Release Manager deploy' to JenkinsJobFolderPage, project.key + if (activateAutorefreshLink) { + activateAutorefreshLink.click() + } - then: 'The component startup jobs finished succesfully' - waitFor('verySlow') { + then: 'The component startup job finished succesfully' + waitFor('extremelySlow') { getComponentJobs(project.key, E2E_TEST_COMPONENT).jobs.find { job -> job.value.odsStartupComponentJob && job.value.success } From 542661f6f81b7cd140d6ffe8a90fb0b995846c8f Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 14 Jul 2020 19:34:11 +0200 Subject: [PATCH 36/54] Only verySlow and fix detection of odsStartupComponentJob --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 2 +- .../org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 445acd6..5e4d135 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -599,7 +599,7 @@ class ODSSpec extends BaseSpec { } then: 'The component startup job finished succesfully' - waitFor('extremelySlow') { + waitFor('verySlow') { getComponentJobs(project.key, E2E_TEST_COMPONENT).jobs.find { job -> job.value.odsStartupComponentJob && job.value.success } diff --git a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy index 9a69768..e36a72f 100644 --- a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy +++ b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy @@ -25,7 +25,7 @@ class JenkinsConsolePage extends Page { id : (it.@id - "job_$projectKey-cd-") - 'ods-qs-', success : it.hasClass('job-status-blue'), notBuild : it.hasClass('job-status-nobuilt'), - odsStartupComponentJob: it.@id.contains('-ods-qs-'), + odsStartupComponentJob: it.@id.contains('ods-qs-'), running : it.hasClass('job-status-blue-anime') || it.hasClass('job-status-red-anime'), ] ] @@ -42,7 +42,7 @@ class JenkinsConsolePage extends Page { branch : ((it.@id - "job_$projectKey-cd-") - 'ods-qs-') - "$component-", success : it.hasClass('job-status-blue'), notBuild : it.hasClass('job-status-nobuilt'), - odsStartupComponentJob: it.@id.contains('-ods-qs-'), + odsStartupComponentJob: it.@id.contains('ods-qs-'), running : it.hasClass('job-status-blue-anime') || it.hasClass('job-status-red-anime') || it.hasClass('job-status-nobuilt-anime'), From a6a1a01ec016cb9e53c1672db868c8791aa965e2 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 14 Jul 2020 19:35:52 +0200 Subject: [PATCH 37/54] Fix prefix in job detection --- .../org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy index e36a72f..ebf6ef0 100644 --- a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy +++ b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy @@ -22,7 +22,7 @@ class JenkinsConsolePage extends Page { collectEntries { [it.@id - "job_$projectKey-cd-", [ - id : (it.@id - "job_$projectKey-cd-") - 'ods-qs-', + id : (it.@id - "job_$projectKey-cd/") - 'ods-qs-', success : it.hasClass('job-status-blue'), notBuild : it.hasClass('job-status-nobuilt'), odsStartupComponentJob: it.@id.contains('ods-qs-'), @@ -38,8 +38,8 @@ class JenkinsConsolePage extends Page { collectEntries { [it.@id - "job_$projectKey-cd-", [ - id : (it.@id - "job_$projectKey-cd-") - 'ods-qs-', - branch : ((it.@id - "job_$projectKey-cd-") - 'ods-qs-') - "$component-", + id : (it.@id - "job_$projectKey-cd/") - 'ods-qs-', + branch : ((it.@id - "job_$projectKey-cd/") - 'ods-qs-') - "$component-", success : it.hasClass('job-status-blue'), notBuild : it.hasClass('job-status-nobuilt'), odsStartupComponentJob: it.@id.contains('ods-qs-'), From fad9fa3d656d434e879ba96eaea284fa035239e2 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Tue, 14 Jul 2020 19:37:02 +0200 Subject: [PATCH 38/54] Fix prefix in job detection --- .../org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy index ebf6ef0..83d878e 100644 --- a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy +++ b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy @@ -20,7 +20,7 @@ class JenkinsConsolePage extends Page { def projectKey = project.toLowerCase() jobsTable.$("tr").findAll { it.@id }. collectEntries { - [it.@id - "job_$projectKey-cd-", + [it.@id - "job_$projectKey-cd/", [ id : (it.@id - "job_$projectKey-cd/") - 'ods-qs-', success : it.hasClass('job-status-blue'), @@ -36,7 +36,7 @@ class JenkinsConsolePage extends Page { def projectKey = project.toLowerCase() jobsTable.$("tr").findAll { it.@id.contains(component) }. collectEntries { - [it.@id - "job_$projectKey-cd-", + [it.@id - "job_$projectKey-cd/", [ id : (it.@id - "job_$projectKey-cd/") - 'ods-qs-', branch : ((it.@id - "job_$projectKey-cd/") - 'ods-qs-') - "$component-", From 364016b19e1a3bf5a97bf62dd1b2977ad8a22b81 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 15 Jul 2020 08:36:42 +0200 Subject: [PATCH 39/54] Revert "Fix prefix in job detection" This reverts commit fad9fa3d656d434e879ba96eaea284fa035239e2. --- .../org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy index 83d878e..ebf6ef0 100644 --- a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy +++ b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy @@ -20,7 +20,7 @@ class JenkinsConsolePage extends Page { def projectKey = project.toLowerCase() jobsTable.$("tr").findAll { it.@id }. collectEntries { - [it.@id - "job_$projectKey-cd/", + [it.@id - "job_$projectKey-cd-", [ id : (it.@id - "job_$projectKey-cd/") - 'ods-qs-', success : it.hasClass('job-status-blue'), @@ -36,7 +36,7 @@ class JenkinsConsolePage extends Page { def projectKey = project.toLowerCase() jobsTable.$("tr").findAll { it.@id.contains(component) }. collectEntries { - [it.@id - "job_$projectKey-cd/", + [it.@id - "job_$projectKey-cd-", [ id : (it.@id - "job_$projectKey-cd/") - 'ods-qs-', branch : ((it.@id - "job_$projectKey-cd/") - 'ods-qs-') - "$component-", From cdd75517083b360a6dcd4aa3eaf5e48da0d4a801 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 15 Jul 2020 08:37:44 +0200 Subject: [PATCH 40/54] Revert "Fix prefix in job detection" This reverts commit a6a1a01ec016cb9e53c1672db868c8791aa965e2. --- .../org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy index ebf6ef0..e36a72f 100644 --- a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy +++ b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy @@ -22,7 +22,7 @@ class JenkinsConsolePage extends Page { collectEntries { [it.@id - "job_$projectKey-cd-", [ - id : (it.@id - "job_$projectKey-cd/") - 'ods-qs-', + id : (it.@id - "job_$projectKey-cd-") - 'ods-qs-', success : it.hasClass('job-status-blue'), notBuild : it.hasClass('job-status-nobuilt'), odsStartupComponentJob: it.@id.contains('ods-qs-'), @@ -38,8 +38,8 @@ class JenkinsConsolePage extends Page { collectEntries { [it.@id - "job_$projectKey-cd-", [ - id : (it.@id - "job_$projectKey-cd/") - 'ods-qs-', - branch : ((it.@id - "job_$projectKey-cd/") - 'ods-qs-') - "$component-", + id : (it.@id - "job_$projectKey-cd-") - 'ods-qs-', + branch : ((it.@id - "job_$projectKey-cd-") - 'ods-qs-') - "$component-", success : it.hasClass('job-status-blue'), notBuild : it.hasClass('job-status-nobuilt'), odsStartupComponentJob: it.@id.contains('ods-qs-'), From 43a95045a993e9d773385224c33262af0eb783d1 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 15 Jul 2020 08:38:49 +0200 Subject: [PATCH 41/54] Reverting changes in job detection --- .../org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy index e36a72f..9a69768 100644 --- a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy +++ b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsolePage.groovy @@ -25,7 +25,7 @@ class JenkinsConsolePage extends Page { id : (it.@id - "job_$projectKey-cd-") - 'ods-qs-', success : it.hasClass('job-status-blue'), notBuild : it.hasClass('job-status-nobuilt'), - odsStartupComponentJob: it.@id.contains('ods-qs-'), + odsStartupComponentJob: it.@id.contains('-ods-qs-'), running : it.hasClass('job-status-blue-anime') || it.hasClass('job-status-red-anime'), ] ] @@ -42,7 +42,7 @@ class JenkinsConsolePage extends Page { branch : ((it.@id - "job_$projectKey-cd-") - 'ods-qs-') - "$component-", success : it.hasClass('job-status-blue'), notBuild : it.hasClass('job-status-nobuilt'), - odsStartupComponentJob: it.@id.contains('ods-qs-'), + odsStartupComponentJob: it.@id.contains('-ods-qs-'), running : it.hasClass('job-status-blue-anime') || it.hasClass('job-status-red-anime') || it.hasClass('job-status-nobuilt-anime'), From 2affa0e3376ba95b40b8c6880dd0c300ddfd5356 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 15 Jul 2020 09:28:39 +0200 Subject: [PATCH 42/54] getComponentJobs already returns jobs --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 5e4d135..a6b99ff 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -600,7 +600,7 @@ class ODSSpec extends BaseSpec { then: 'The component startup job finished succesfully' waitFor('verySlow') { - getComponentJobs(project.key, E2E_TEST_COMPONENT).jobs.find { + getComponentJobs(project.key, E2E_TEST_COMPONENT).find { job -> job.value.odsStartupComponentJob && job.value.success } } From a10c4f550758c1281f29f46fd046020cdad48412 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 15 Jul 2020 09:40:44 +0200 Subject: [PATCH 43/54] Fix test file location --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index a6b99ff..1cd2db9 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -610,10 +610,9 @@ class ODSSpec extends BaseSpec { // Result: Repository and file available when: 'Grab evidences of adding files from bitbucket' - gitRepository = GitUtil.cloneRepository(project.key, E2E_TEST_QUICKSTARTER, baseBranchBitbucket) + gitRepository = GitUtil.cloneRepository(project.key, E2E_TEST_COMPONENT, baseBranchBitbucket) directory = gitRepository.repository.getWorkTree() - filesPath = 'files' - testFilePath = "$filesPath/$E2E_TEST_FILE" + testFilePath = E2E_TEST_FILE then: 'Test file exists' new File("$directory/$testFilePath").text == 'Test file for FT_01_002' From 4ed5fd212ab985f2e41593c72594708b464a92fa Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 15 Jul 2020 09:50:02 +0200 Subject: [PATCH 44/54] In cleanup also wait for provapp to get ready --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 1cd2db9..63329a8 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -625,6 +625,7 @@ class ODSSpec extends BaseSpec { client.deploy(provisioningAppDeployCfg) GitUtil.deleteBranch(gitRepository, E2E_TEST_BRANCH, true) client.waitForDeployment(provisioningAppDeployCfg, newVersion) + sleep(30000) } From 36e6736bf3b0f84c1f0797345444082b27cab024 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 15 Jul 2020 17:17:06 +0200 Subject: [PATCH 45/54] Remove health check util --- src/test/groovy/org/ods/e2e/util/HealthCheckUtil.groovy | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/test/groovy/org/ods/e2e/util/HealthCheckUtil.groovy diff --git a/src/test/groovy/org/ods/e2e/util/HealthCheckUtil.groovy b/src/test/groovy/org/ods/e2e/util/HealthCheckUtil.groovy deleted file mode 100644 index be911eb..0000000 --- a/src/test/groovy/org/ods/e2e/util/HealthCheckUtil.groovy +++ /dev/null @@ -1,7 +0,0 @@ -package org.ods.e2e.util - -class HealthCheckUtil { - def isReady(pod) { - - } -} From a93b15806467fa1b586eb8977a89fb1e1a5efc53 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 15 Jul 2020 23:14:31 +0200 Subject: [PATCH 46/54] Try waitFor prov-app login page --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 63329a8..0768c85 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -521,7 +521,10 @@ class ODSSpec extends BaseSpec { and: 'Wait for deployment' def newVersion = client.waitForDeployment(provisioningAppDeployCfg, lastVersion) - sleep(30000) + baseUrl = baseUrlProvisioningApp + waitFor { + to ProvAppLoginPage + } then: 'New deployment exists' newVersion > lastVersion @@ -531,8 +534,6 @@ class ODSSpec extends BaseSpec { // Result: New quickstarter available in the list in provision application when: 'We are logged in the provissioning app' - baseUrl = baseUrlProvisioningApp - to ProvAppLoginPage doLoginProcess() and: 'We are in the provisioning page' From 70c9ae13341bc66bedb40fc6c0d2f100f45c5909 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Wed, 15 Jul 2020 23:33:53 +0200 Subject: [PATCH 47/54] Wait for prov-app login page in cleanup --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 0768c85..adba793 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -626,7 +626,10 @@ class ODSSpec extends BaseSpec { client.deploy(provisioningAppDeployCfg) GitUtil.deleteBranch(gitRepository, E2E_TEST_BRANCH, true) client.waitForDeployment(provisioningAppDeployCfg, newVersion) - sleep(30000) + baseUrl = baseUrlProvisioningApp + waitFor { + to ProvAppLoginPage + } } From 5653e80738857afe6ad36beba7ed24922da1b97c Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Thu, 16 Jul 2020 13:45:19 +0200 Subject: [PATCH 48/54] Manually merge README.md due to a conflict with upper and lowercase. --- README.md | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 56d5683..ea310a7 100644 --- a/README.md +++ b/README.md @@ -9,23 +9,27 @@ You can have a look at the `build.gradle` and `src/test/resources/GebConfig.groo ## Usage You need to set several environment variables in order to make this work, as it is intended to use in a container / pod lately. -| Variable | Value | Description | -|-----------------------|----------------------------------|----------------------------------------------------------------------------- | -| PROV_APP_USER | openshift | Provisioning app user name | -| PROV_APP_PASSWORD | openshift | Provisioning app password | -| ATLASSIAN_USER | openshift | Atlassian user name | -| ATLASSIAN_PASSWORD | openshift | Atlassian password | -| JENKINS_USER | developer | Jenkins user name | -| JENKINS_PASSWORD | any | Jenkins password | -| OPENSHIFT_USER | developer | Openshift user name | -| OPENSHIFT_PASSWORD | any | Openshift password | -| PROV_APP_NAME | openshift | Name of the deployment of the provisioning app | -| JIRA_URL | http://jira.odsbox.lan:8080/ | Url of Jira instance related with the prov app | -| OPENSHIFT_PROJECT | edpp | project identifier for prov app in the preliminary tests(jira tests) | -| OPENSHIFT_PUBLIC_HOST | ocp.odsbox.lan | host where we can locate the prov app | -| OPENSHIFT_CLUSTER | https://ocp.odsbox.lan:8443/ | URL of the Openshift Cluster | -| BITBUCKET_URL | http://bitbucket.odsbox.lan:7990 | Url of Bitbucket instance | -| SIMULATE | false | Specify (true or false) if we skip the creation of project, components, etc | +| Variable | Value | Description | +|-------------------------|----------------------------------|----------------------------------------------------------------------------- | +| QUICKSTARTERS_CONFIGMAP | quickstarters.properties | ConfigMap containing quickstarter configuration. | +| PROV_APP_PROJECT | ods | Id of the OpenShift project of the provisioning app | +| PROV_APP_DEPLOY_CFG | ods-provisioning-app | Name of the deployment config of the provisioning app | +| PROV_APP_NAME | prov-app-ods | Name of the provisioning app, as it appears in the public URL. | +| PROV_APP_USER | openshift | Provisioning app user name | +| PROV_APP_PASSWORD | openshift | Provisioning app password | +| ATLASSIAN_USER | openshift | Atlassian user name | +| ATLASSIAN_PASSWORD | openshift | Atlassian password | +| JENKINS_USER | developer | Jenkins user name | +| JENKINS_PASSWORD | any | Jenkins password | +| OPENSHIFT_USER | developer | Openshift user name | +| OPENSHIFT_PASSWORD | any | Openshift password | +| JIRA_URL | http://jira.odsbox.lan:8080/ | Url of Jira instance related with the prov app | +| OPENSHIFT_PROJECT | edpp | project identifier for prov app in the preliminary tests(jira tests) | +| OPENSHIFT_PUBLIC_HOST | ocp.odsbox.lan | host where we can locate the prov app | +| OPENSHIFT_CLUSTER | https://ocp.odsbox.lan:8443/ | URL of the Openshift Cluster | +| BITBUCKET_URL | http://bitbucket.odsbox.lan:7990 | Url of Bitbucket instance | +| BITBUCKET_BASE_BRANCH | master | Branch of the HEAD branch of the OpenShift project. Not always master. | +| SIMULATE | false | Specify (true or false) if we skip the creation of project, components, etc | Depending on the way you'll run the tests, there are 2 files that will help you to prepare those variables: From fb6ac1d6d18d72cea30b353ef94769e01076a078 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Thu, 16 Jul 2020 14:19:23 +0200 Subject: [PATCH 49/54] Don't use relative paths --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e4a0b54..4d89342 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ ### Set the default target .DEFAULT_GOAL := help -../../truststores/cacerts: +${HOME}/truststores/cacerts: ./scripts/buildtrust .env: echo "Please provide a valid .env file before running tests" && exit 127 -checkPreconditions: .env ../../truststores/cacerts +checkPreconditions: .env ${HOME}/truststores/cacerts .PHONY: checkPreconditions ### Use the headless chrome by default From 7587302edf67bd957df81803d5adcd4a2be3def8 Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Thu, 16 Jul 2020 15:44:28 +0200 Subject: [PATCH 50/54] Add variables to build.gradle --- build.gradle | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index 012b0cc..cdf02f6 100644 --- a/build.gradle +++ b/build.gradle @@ -23,27 +23,31 @@ ext { dotEnvFile = './.env' odsConfigFile = '../ods-configuration/ods-core.env' environmentVariables = [ - PROV_APP_USER : '', - PROV_APP_PASSWORD : '', - ATLASSIAN_USER : '', - ATLASSIAN_PASSWORD : '', - JENKINS_USER : '', - JENKINS_PASSWORD : '', - OPENSHIFT_USER : '', - OPENSHIFT_PASSWORD : '', - PROV_APP_NAME : '', - JIRA_URL : '', - OPENSHIFT_PROJECT : '', - OPENSHIFT_PUBLIC_HOST : '', - OPENSHIFT_CLUSTER : '', - BITBUCKET_URL : '', - SIMULATE : '', - NEXUS_URL : '', - NEXUS_USERNAME : '', - NEXUS_PASSWORD : '', - NEXUS_FOLDER_RELEASES : '', - NEXUS_FOLDER_SNAPSHOTS: '', - NO_NEXUS : '', + PROV_APP_DEPLOY_CFG : '', + PROV_APP_PROJECT : '', + BITBUCKET_BASE_BRANCH : '', + QUICKSTARTERS_CONFIGMAP : '', + PROV_APP_USER : '', + PROV_APP_PASSWORD : '', + ATLASSIAN_USER : '', + ATLASSIAN_PASSWORD : '', + JENKINS_USER : '', + JENKINS_PASSWORD : '', + OPENSHIFT_USER : '', + OPENSHIFT_PASSWORD : '', + PROV_APP_NAME : '', + JIRA_URL : '', + OPENSHIFT_PROJECT : '', + OPENSHIFT_PUBLIC_HOST : '', + OPENSHIFT_CLUSTER : '', + BITBUCKET_URL : '', + SIMULATE : '', + NEXUS_URL : '', + NEXUS_USERNAME : '', + NEXUS_PASSWORD : '', + NEXUS_FOLDER_RELEASES : '', + NEXUS_FOLDER_SNAPSHOTS : '', + NO_NEXUS : '', ] From 2804e06a371a039f3a29b599edd3b3c5ca3141eb Mon Sep 17 00:00:00 2001 From: "zxBCN Farre_Basurte,Juan_Antonio (IT EDS) EXTERNAL" Date: Mon, 27 Jul 2020 14:49:41 +0200 Subject: [PATCH 51/54] Fix problem when an env variable value contains special characters --- src/test/groovy/org/ods/e2e/util/SpecHelper.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/groovy/org/ods/e2e/util/SpecHelper.groovy b/src/test/groovy/org/ods/e2e/util/SpecHelper.groovy index c612acf..c9c71b5 100644 --- a/src/test/groovy/org/ods/e2e/util/SpecHelper.groovy +++ b/src/test/groovy/org/ods/e2e/util/SpecHelper.groovy @@ -3,6 +3,7 @@ package org.ods.e2e.util import groovy.json.JsonSlurperClassic import kong.unirest.Unirest +import java.util.regex.Matcher import java.util.regex.Pattern class SpecHelper { @@ -26,7 +27,7 @@ class SpecHelper { println "ERROR: Missing properties in configuration $match[0]" raiseError = true } else { - value = value.replaceAll(Pattern.quote(nameToReplace), valueToReplace) + value = value.replaceAll(Pattern.quote(nameToReplace), Matcher.quoteReplacement(valueToReplace)) properties[key] = value } } From fdb7bb9485456e87246c6b4e4d2e0a19dba36a18 Mon Sep 17 00:00:00 2001 From: Jorge Romero Date: Tue, 4 Aug 2020 19:45:34 +0200 Subject: [PATCH 52/54] Fixes to make it work in a onpremise environment with special needs. --- .env.example | 1 + README.md | 47 ++++---- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 110 +++++++++--------- ...JenkinsConsoleParametrizedBuildPage.groovy | 2 +- .../openshift/client/OpenShiftHelper.groovy | 57 +++++++++ .../openshift/pages/OpenShiftLoginPage.groovy | 7 ++ .../groovy/org/ods/e2e/util/BaseSpec.groovy | 6 +- src/test/resources/GebConfig.groovy | 2 +- src/test/resources/application.properties | 1 + 9 files changed, 154 insertions(+), 79 deletions(-) create mode 100644 src/test/groovy/org/ods/e2e/openshift/client/OpenShiftHelper.groovy diff --git a/.env.example b/.env.example index b11a6c8..ea74e20 100644 --- a/.env.example +++ b/.env.example @@ -13,6 +13,7 @@ OPENSHIFT_PROJECT=edpp OPENSHIFT_PUBLIC_HOST=.ocp.odsbox.lan OPENSHIFT_CLUSTER=https://ocp.odsbox.lan:8443/ SIMULATE=false +OPENSHIFT_TOKEN=THE_TOKEN # values provided by ods-configuration/ods-core.env if present JIRA_URL=http://jira.odsbox.lan:8080/ NEXUS_URL=https://nexus-ods.ocp.odsbox.lan diff --git a/README.md b/README.md index 7bf3497..7d69add 100644 --- a/README.md +++ b/README.md @@ -9,29 +9,30 @@ You can have a look at the `build.gradle` and `src/test/resources/GebConfig.groo ## Usage You need to set several environment variables in order to make this work, as it is intended to use in a container / pod lately. -| Variable | Value | Description | -|-----------------------|----------------------------------|----------------------------------------------------------------------------- | -| PROV_APP_USER | openshift | Provisioning app user name | -| PROV_APP_PASSWORD | openshift | Provisioning app password | -| ATLASSIAN_USER | openshift | Atlassian user name | -| ATLASSIAN_PASSWORD | openshift | Atlassian password | -| JENKINS_USER | developer | Jenkins user name | -| JENKINS_PASSWORD | any | Jenkins password | -| OPENSHIFT_USER | developer | Openshift user name | -| OPENSHIFT_PASSWORD | any | Openshift password | -| PROV_APP_NAME | openshift | Name of the deployment of the provisioning app | -| JIRA_URL | http://jira.odsbox.lan:8080/ | Url of Jira instance related with the prov app | -| OPENSHIFT_PROJECT | edpp | project identifier for prov app in the preliminary tests(jira tests) | -| OPENSHIFT_PUBLIC_HOST | .ocp.odsbox.lan | host where we can locate the prov app | -| OPENSHIFT_CLUSTER | https://ocp.odsbox.lan:8443/ | URL of the Openshift Cluster | -| BITBUCKET_URL | http://bitbucket.odsbox.lan:7990 | Url of Bitbucket instance | -| SIMULATE | false | Specify (true or false) if we skip the creation of project, components, etc | -| NO_NEXUS | true | In case you want to use the public repositories, if it set to true it is not needed to set the next 3 properties | -| NEXUS_URL | https://nexus-ods.ocp.odsbox.lan | The nexus url if we want to use an specific nexus instance | -| NEXUS_USERNAME | admin | The nexus user | -| NEXUS_PASSWORD | openshift | The nexus password | -|BITBUCKET_BASE_BRANCH | master | The branck used as base branch for the QS(useful when you are testing the box)| -|QUICKSTARTERS_CONFIGMAP| quickstarters.properties | The configmap name where the qs of the provisioning app gets its configuration| +| Variable | Value | Description | +|------------------------|----------------------------------|----------------------------------------------------------------------------- | +| PROV_APP_USER | openshift | Provisioning app user name | +| PROV_APP_PASSWORD | openshift | Provisioning app password | +| ATLASSIAN_USER | openshift | Atlassian user name | +| ATLASSIAN_PASSWORD | openshift | Atlassian password | +| JENKINS_USER | developer | Jenkins user name | +| JENKINS_PASSWORD | any | Jenkins password | +| OPENSHIFT_USER | developer | Openshift user name | +| OPENSHIFT_PASSWORD | any | Openshift password | +| PROV_APP_NAME | openshift | Name of the deployment of the provisioning app | +| JIRA_URL | http://jira.odsbox.lan:8080/ | Url of Jira instance related with the prov app | +| OPENSHIFT_PROJECT | edpp | project identifier for prov app in the preliminary tests(jira tests) | +| OPENSHIFT_PUBLIC_HOST | .ocp.odsbox.lan | host where we can locate the prov app | +| OPENSHIFT_CLUSTER | https://ocp.odsbox.lan:8443/ | URL of the Openshift Cluster | +| BITBUCKET_URL | http://bitbucket.odsbox.lan:7990 | Url of Bitbucket instance | +| SIMULATE | false | Specify (true or false) if we skip the creation of project, components, etc | +| NO_NEXUS | true | In case you want to use the public repositories, if it set to true it is not needed to set the next 3 properties | +| NEXUS_URL | https://nexus-ods.ocp.odsbox.lan | The nexus url if we want to use an specific nexus instance | +| NEXUS_USERNAME | admin | The nexus user | +| NEXUS_PASSWORD | openshift | The nexus password | +| BITBUCKET_BASE_BRANCH | master | The branck used as base branch for the QS(useful when you are testing the box)| +| QUICKSTARTERS_CONFIGMAP| quickstarters.properties | The configmap name where the qs of the provisioning app gets its configuration| +| OPENSHIFT_TOKEN | the_token | Token to login in Openshift to be use instead of the openshift user for specific tasks | ### Environment variables setup To get the information needed to run the tests there are 3 steps that override the previous one: diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index cc0b0c5..7a11205 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -1,15 +1,15 @@ package org.ods.e2e - import org.ods.e2e.bitbucket.pages.DashboardPage import org.ods.e2e.bitbucket.pages.LoginPage import org.ods.e2e.bitbucket.pages.ProjectPage import org.ods.e2e.bitbucket.pages.RepositoryPage import org.ods.e2e.jenkins.pages.JenkinsConsoleParametrizedBuildPage import org.ods.e2e.jenkins.pages.JenkinsJobFolderPage +import org.ods.e2e.jenkins.pages.JenkinsLoginPage import org.ods.e2e.openshift.client.OpenShiftClient +import org.ods.e2e.openshift.client.OpenShiftHelper import org.ods.e2e.openshift.pages.ConsoleDeploymentsPage -import org.ods.e2e.openshift.pages.ConsoleProjectsPage import org.ods.e2e.openshift.pages.ConsoleResourcesConfigMaps import org.ods.e2e.openshift.pages.PodsPage import org.ods.e2e.provapp.pages.HomePage @@ -19,6 +19,7 @@ import org.ods.e2e.util.BaseSpec import org.ods.e2e.util.GitUtil import org.yaml.snakeyaml.DumperOptions import org.yaml.snakeyaml.Yaml +import spock.lang.Ignore class ODSSpec extends BaseSpec { @@ -27,6 +28,7 @@ class ODSSpec extends BaseSpec { def static E2E_TEST_FILE = 'e2e-tests.txt' def static E2E_TEST_QUICKSTARTER = 'e2e-test-quickstarter' def static E2E_TEST_COMPONENT = 'test-component' + def static openshifHelper = new OpenShiftHelper() def static projects = [ default: [ @@ -87,6 +89,7 @@ class ODSSpec extends BaseSpec { println 'Tests setup' } + /** * Test Objective: * The purpose of this test case is to present a level of evidences that the use of Provisioning Application, @@ -112,6 +115,7 @@ class ODSSpec extends BaseSpec { // Result: Login works, within a provisioning and history links // ------------------------------------------------------------------------------------------------------------- given: 'We are logged in the provisioning app' + def openshifHelper = new OpenShiftHelper() def project = projects.default baseUrl = baseUrlProvisioningApp @@ -143,7 +147,9 @@ class ODSSpec extends BaseSpec { and: 'Get the next key' def nextId = getNextId(project.key) project.name = String.format("$project.name - %02d", nextId) - project.key = String.format("${project.key}%02d", nextId) + if (!simulate) { + project.key = String.format("${project.key}%02d", nextId) + } and: 'We open the project creation form' provisionOptionChooser.doSelectCreateNewProject() @@ -166,7 +172,7 @@ class ODSSpec extends BaseSpec { projectCreateForm.doStartProvision() // wait until project is created - waitFor { + waitFor('verySlow') { $(".modal-dialog").css("display") != "hidden" $("#resProject.alert-success") $("#resButton").text() == "Close" @@ -185,7 +191,9 @@ class ODSSpec extends BaseSpec { simulate ? true : $("#resProject.alert-success").size() == 1 report("step 4 - project has been created") - $("#resButton").click() + if (!simulate) { + $("#resButton").click() + } // ------------------------------------------------------------------------------------------------------------- @@ -207,6 +215,9 @@ class ODSSpec extends BaseSpec { then: 'We are in the project page' currentUrl.endsWith("projects/${project.key}/") + if (!simulate) { + $("h2.page-panel-content-header")?.text()?.contains('Repositories') + } report("step 5 - project in bitbucket") // ------------------------------------------------------------------------------------------------------------- @@ -214,41 +225,19 @@ class ODSSpec extends BaseSpec { // Result: Find a running Jenkins deployment – click on it and verify that the image used comes from the // CD namespace // ------------------------------------------------------------------------------------------------------------- - when: 'Visit Openshift' - baseUrl = baseUrlOpenshift - - and: 'and login in Openshift' - doOpenshiftLoginProcess() + when: 'Check if we have a Jenkins instance running' + baseUrl = getJenkinsBaseUrl(project.key) - then: "Visit all project page and check for the projects" - waitFor('mediumSlow') { - to ConsoleProjectsPage - findProjects(project.key).size() > 0 - findProjects(project.key).contains(project.key.toLowerCase() + '-cd') + and: + waitFor('extremelySlow') { + openshifHelper.existsNamespace(project.key.toLowerCase() + '-cd') } - - when: - 'Visit pods page' - to PodsPage, project.key.toLowerCase() + '-cd' - sleep(5000) - then: - waitFor('verySlow') { - getPods().find { pod -> - pod.name.startsWith('jenkins') && - pod.status == 'Running' && - !pod.isDeployPod && - pod.containersReady == '1/1' - } - - getPods().find { pod -> - pod.name.startsWith('webhook') && - pod.status == 'Running' && - !pod.isDeployPod && - pod.containersReady == '1/1' - } + waitFor('extremelySlow') { + doJenkinsLoginProcess() } + report("step 6 - existing jenkins instance for the project") // ------------------------------------------------------------------------------------------------------------- @@ -332,7 +321,7 @@ class ODSSpec extends BaseSpec { baseUrl = getJenkinsBaseUrl(project.key) and: - doJenkinsLoginProcess() + to JenkinsLoginPage then: 'The project folder exists' assert $("#job_${project.key.toLowerCase()}-cd") @@ -341,6 +330,11 @@ class ODSSpec extends BaseSpec { 'Visit the jobs' to JenkinsJobFolderPage, project.key + and: + if (activateAutorefreshLink) { + activateAutorefreshLink.click() + } + and: project.components.each { component -> component.jobs = getComponentJobs(project.key, component.componentId) @@ -349,11 +343,11 @@ class ODSSpec extends BaseSpec { then: 'The component startup jobs finished succesfully' waitFor('verySlow') { - project.components.each { + project.components.every { component -> - getComponentJobs(project.key, component.componentId).jobs.find { + getComponentJobs(project.key, component.componentId).find { job -> job.value.odsStartupComponentJob && job.value.success - } + } != null } } @@ -375,11 +369,11 @@ class ODSSpec extends BaseSpec { and: 'Checks that exists jobs that are not qs startup jobs for the components' waitFor('verySlow') { - project.components.each { + project.components.every { component -> - getComponentJobs(project.key, component.componentId).jobs.find { + getComponentJobs(project.key, component.componentId).find { job -> !job.value.odsStartupComponentJob && job.value.success - } + } != null } } @@ -394,6 +388,7 @@ class ODSSpec extends BaseSpec { * to the console/terminal logs of Jenkins, Nexus and SonarQube and have administrator access to the Bitbucket * repositories including the OpenDevStack one. */ + @Ignore def "FT_01_002"() { // STEP 1: Go to Bitbucket ODS project – into repository ods-quickstarters // Result: Project and repository available @@ -761,11 +756,15 @@ class ODSSpec extends BaseSpec { } } - and: 'Wait if the job is still running' + + // After adding the new component some changes are introduced to the configuration of the jenkins pod + // so the pod is restarted. + and: 'Wait if the job is still running or jenkins is still running' waitFor('verySlow') { - getComponentJobs(project.key, releaseManagerComponent.componentId).find { - job -> job.value.odsStartupComponentJob && job.value.success - } + $("body > div >h1").text()?.toLowerCase()?.contains('application is not available') != null || + getComponentJobs(project.key, releaseManagerComponent.componentId).find { + job -> job.value.odsStartupComponentJob && job.value.success + } != null } // ------------------------------------------------------------------------------------------------------------- @@ -843,25 +842,32 @@ class ODSSpec extends BaseSpec { metadataRepositories = metadataYml.getAt('repositories') } def component = project.components.first() - metadataRepositories.putAt(metadataRepositories.size, [ - id : component.componentId.toLowerCase(), - name: "$project.key-$component.componentId".toLowerCase(), type: 'ods']) + if (metadataRepositories.size() == 0 || metadataRepositories.findAll { it -> it.id == component.componentId.toLowerCase() }.size() == 0) { + metadataRepositories.putAt(metadataRepositories.size, [ + id : component.componentId.toLowerCase(), + name: "$project.key-$component.componentId".toLowerCase(), type: 'ods']) + } + and: 'Save metada.yml' parser.dump(metadataYml, new FileWriter("$repositoryFolder/metadata.yml")) and: 'Commit the file' - GitUtil.commitAddAll(gitRepository,'New component added') + GitUtil.commitAddAll(gitRepository, 'New component added') and: 'Push it to the repository' - GitUtil.push(gitRepository,'origin') + GitUtil.push(gitRepository, 'origin') // ------------------------------------------------------------------------------------------------------------- // 3.2 Trigger Jenkins build of the release manager. // ------------------------------------------------------------------------------------------------------------- - and: + and: 'Go to jenkins' baseUrl = getJenkinsBaseUrl(project.key) + and: 'Login again in jenkins as it has been rebooted' + waitFor('extremelySlow') { + doJenkinsLoginProcess() + } def parameters = [environment: 'dev', version: 'WIP',] to JenkinsConsoleParametrizedBuildPage, project.key, releaseManagerPipelineJob fillData(parameters) diff --git a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsoleParametrizedBuildPage.groovy b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsoleParametrizedBuildPage.groovy index 868f492..b2176a1 100644 --- a/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsoleParametrizedBuildPage.groovy +++ b/src/test/groovy/org/ods/e2e/jenkins/pages/JenkinsConsoleParametrizedBuildPage.groovy @@ -4,7 +4,7 @@ import geb.Page class JenkinsConsoleParametrizedBuildPage extends Page { - static url = '/job/' + static url = '/job' /** * Adapt the url to get to the jenkins job/jobfolder page * https://jenkins-url/job/$project$-cd/job/$job$/build?delay=0sec diff --git a/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftHelper.groovy b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftHelper.groovy new file mode 100644 index 0000000..02613a9 --- /dev/null +++ b/src/test/groovy/org/ods/e2e/openshift/client/OpenShiftHelper.groovy @@ -0,0 +1,57 @@ +package org.ods.e2e.openshift.client + + +import kong.unirest.Unirest +import org.ods.e2e.util.SpecHelper + +class OpenShiftHelper { + def specHelper = new SpecHelper() + + def existsNamespace(String projectKey) { + def namespaceFound = false + if (!projectKey?.trim()) { + throw new IllegalArgumentException("Error: unable to get namespace $projectKey.") + } + + Unirest.config().verifySsl(false); + String openshiftUrl = specHelper.applicationProperties."config.openshift.url" + openshiftUrl = openshiftUrl.endsWith('/') ? openshiftUrl.substring(0, openshiftUrl.size() - 1) : openshiftUrl + def response = Unirest.get("$openshiftUrl/api/v1/namespaces/{projectKey}") + .routeParam("projectKey", projectKey.toLowerCase()) + .header("Accept", "application/json") + .header("Authorization", "Bearer " + specHelper.applicationProperties."config.openshift.token") + .asString() + + response.ifFailure { + def message = "Error: unable to get the namaspace. Openshift responded with code: '${response.getStatus()}' and message: '${response.getBody()}'." + println message + } + response.ifSuccess { + namespaceFound = true + } + return namespaceFound + } + + def watchPods(projectKey, pod) { + if (!projectKey?.trim()) { + throw new IllegalArgumentException("Error: unable to get namespace $projectKey.") + } + + Unirest.config().verifySsl(false); + String openshiftUrl = specHelper.applicationProperties."config.openshift.url" + openshiftUrl = openshiftUrl.endsWith('/') ? openshiftUrl.substring(0, openshiftUrl.size() - 1) : openshiftUrl + def response = Unirest.get("$openshiftUrl/api/v1/watch/namespaces/{projectKey}/pods") + .routeParam("projectKey", projectKey.toLowerCase()) + .header("Accept", "application/json") + .header("Authorization", "Bearer " + specHelper.applicationProperties."config.openshift.token") + .asString() + + response.ifFailure { + def message = "Error: unable to get the namaspace. Openshift responded with code: '${response.getStatus()}' and message: '${response.getBody()}'." + println message + return false + } + + return true + } +} diff --git a/src/test/groovy/org/ods/e2e/openshift/pages/OpenShiftLoginPage.groovy b/src/test/groovy/org/ods/e2e/openshift/pages/OpenShiftLoginPage.groovy index a2c2814..3ae778d 100644 --- a/src/test/groovy/org/ods/e2e/openshift/pages/OpenShiftLoginPage.groovy +++ b/src/test/groovy/org/ods/e2e/openshift/pages/OpenShiftLoginPage.groovy @@ -20,4 +20,11 @@ class OpenShiftLoginPage extends Page { loginButton.click() sleep(3000) } + + def doJenkinsLogin() { + username.value(applicationProperties."config.jenkins.user.name") + password.value(applicationProperties."config.jenkins.user.password") + loginButton.click() + sleep(3000) + } } diff --git a/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy b/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy index 9df13d5..24856fe 100644 --- a/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy +++ b/src/test/groovy/org/ods/e2e/util/BaseSpec.groovy @@ -103,13 +103,15 @@ class BaseSpec extends GebReportingSpec { */ def doJenkinsLoginProcess() { via JenkinsLoginPage - loginButton.click() + if ($("a.btn.btn-lg.btn-primary").size() > 0) { + loginButton.click() + } if (extraLoginPage) { at(new JenkinsLoginSelectorPage()) ldapLink.click() } at OpenShiftLoginPage - doLogin() + doJenkinsLogin() if ($('input', name: 'approve')) { $('input', name: 'approve').click() } diff --git a/src/test/resources/GebConfig.groovy b/src/test/resources/GebConfig.groovy index b8f7e11..b9fb09c 100644 --- a/src/test/resources/GebConfig.groovy +++ b/src/test/resources/GebConfig.groovy @@ -22,7 +22,7 @@ waiting { presets { extremelySlow { timeout = 3600 - retryInterval = 2 + retryInterval = 5 } verySlow { timeout = 600 diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 57b3385..260da8c 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -42,6 +42,7 @@ config.openshift.user.name=${OPENSHIFT_USER} config.openshift.user.password=${OPENSHIFT_PASSWORD} config.openshift.url=${OPENSHIFT_CLUSTER} config.openshift.quickstarters.configMap=${QUICKSTARTERS_CONFIGMAP} +config.openshift.token=${OPENSHIFT_TOKEN} ### Reports dir config.reports.dir=build/e2e-geb-reports From 62e039f9404f69dfda893e8c306be092282a3160 Mon Sep 17 00:00:00 2001 From: Jorge Romero Date: Thu, 6 Aug 2020 14:47:30 +0200 Subject: [PATCH 53/54] fixes to make it work again it he box --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 7a11205..4138e15 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -865,9 +865,12 @@ class ODSSpec extends BaseSpec { baseUrl = getJenkinsBaseUrl(project.key) and: 'Login again in jenkins as it has been rebooted' - waitFor('extremelySlow') { - doJenkinsLoginProcess() + if ($("body > div >h1").text()?.toLowerCase()?.contains('application is not available') != null) { + waitFor('extremelySlow') { + doJenkinsLoginProcess() + } } + def parameters = [environment: 'dev', version: 'WIP',] to JenkinsConsoleParametrizedBuildPage, project.key, releaseManagerPipelineJob fillData(parameters) From 2fdebe121368dcdc0bcafd3427192bfb7ab61894 Mon Sep 17 00:00:00 2001 From: Jorge Romero Date: Mon, 10 Aug 2020 14:27:56 +0200 Subject: [PATCH 54/54] Activate Test FT_01_002 --- src/test/groovy/org/ods/e2e/ODSSpec.groovy | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/groovy/org/ods/e2e/ODSSpec.groovy b/src/test/groovy/org/ods/e2e/ODSSpec.groovy index 4138e15..7aa2373 100644 --- a/src/test/groovy/org/ods/e2e/ODSSpec.groovy +++ b/src/test/groovy/org/ods/e2e/ODSSpec.groovy @@ -19,7 +19,6 @@ import org.ods.e2e.util.BaseSpec import org.ods.e2e.util.GitUtil import org.yaml.snakeyaml.DumperOptions import org.yaml.snakeyaml.Yaml -import spock.lang.Ignore class ODSSpec extends BaseSpec { @@ -388,7 +387,6 @@ class ODSSpec extends BaseSpec { * to the console/terminal logs of Jenkins, Nexus and SonarQube and have administrator access to the Bitbucket * repositories including the OpenDevStack one. */ - @Ignore def "FT_01_002"() { // STEP 1: Go to Bitbucket ODS project – into repository ods-quickstarters // Result: Project and repository available