Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

HMAN-514 use jenkins stage for functional tests #135

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
71 changes: 44 additions & 27 deletions Jenkinsfile_CNP
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!groovy
import uk.gov.hmcts.contino.AppPipelineDsl
import uk.gov.hmcts.contino.GithubAPI
import uk.gov.hmcts.contino.GradleBuilder
import uk.gov.hmcts.contino.HealthChecker

properties([
[
Expand All @@ -15,7 +15,7 @@ properties([
disableConcurrentBuilds()
])

@Library("Infrastructure")
@Library("Infrastructure@HMAN-514_functionalTest_nonServiceApp")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary change should be reversed once hmcts/cnp-jenkins-library#987 is released.


def type = "java"
def product = "ccd"
Expand Down Expand Up @@ -90,15 +90,19 @@ withPipeline(type, product, component) {
}
onPR {
enableSlackNotifications('#ccd-pr-builds')

env.ENV='preview'
env.TEST_URL="https://ccd-data-store-api-ccd-next-hearing-date-updater-pr-${CHANGE_ID}.service.core-compute-preview.internal" // This is really not needed but here as a hack around TLS url
env.CCD_DATA_STORE_API_BASE_URL = "https://ccd-data-store-api-ccd-next-hearing-date-updater-pr-${CHANGE_ID}.service.core-compute-preview.internal"
env.DEFINITION_STORE_URL_BASE = "https://ccd-definition-store-ccd-next-hearing-date-updater-pr-${CHANGE_ID}.service.core-compute-preview.internal"
env.TEST_STUB_SERVICE_BASE_URL = "http://ccd-next-hearing-date-updater-pr-${CHANGE_ID}-ccd-test-stubs-service" // NB : when def file is imported this will lead to data-store.preview -> test-stub.preview.

def githubApi = new GithubAPI(this)
if (!githubApi.getLabelsbyPattern(env.BRANCH_NAME, "keep-helm")) {
enableCleanupOfHelmReleaseAlways()
}
}
onNonPR {
env.ENV='aat'
env.TEST_URL="http://ccd-data-store-api-aat.service.core-compute-aat.internal"
env.CCD_DATA_STORE_API_BASE_URL = "http://ccd-data-store-api-aat.service.core-compute-aat.internal"
env.DEFINITION_STORE_URL_BASE = "http://ccd-definition-store-api-aat.service.core-compute-aat.internal"
}
Expand All @@ -109,6 +113,8 @@ withPipeline(type, product, component) {
nonServiceApp()
syncBranchesWithMaster(branchesToSync)

enableFullFunctionalTestNonServiceApp(env.CCD_DATA_STORE_API_BASE_URL)

afterAlways('test') {
// hmcts/cnp-jenkins-library may fail to copy artifacts after checkstyle error so repeat command (see /src/uk/gov/hmcts/contino/GradleBuilder.groovy)
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/reports/checkstyle/*.html'
Expand All @@ -135,32 +141,43 @@ withPipeline(type, product, component) {
junit '**/test-results/test/*.xml'
}

afterAlways('akschartsinstall') {

// check data-store instance is up
def healthChecker = new HealthChecker(this)
healthChecker.check("$CCD_DATA_STORE_API_BASE_URL/health", 10, 40)
before('functionalTest:preview') {
// NB: override IDAM_API_URL late so its value does not corrupt config used in integration tests
env.IDAM_API_URL = env.IDAM_API_URL_BASE

try {
// NB: override IDAM_API_URL late so its value does not corrupt config used in integration tests
env.IDAM_API_URL = env.IDAM_API_URL_BASE
// suppress SSL warnings as we are crossing boundary jenkins -> preview `feign.httpclient.disable-ssl-validation: true`
env.FEIGN_HTTPCLIENT_DISABLE_SSL_VALIDATION = true
}

// suppress SSL warnings as we are crossing boundary jenkins -> preview `feign.httpclient.disable-ssl-validation: true`
env.FEIGN_HTTPCLIENT_DISABLE_SSL_VALIDATION = true
before('functionalTest:aat') {
// NB: override IDAM_API_URL late so its value does not corrupt config used in integration tests
env.IDAM_API_URL = env.IDAM_API_URL_BASE
}

builder.functionalTest()
} finally {
afterAlways('functionalTest:preview') {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/functional",
reportFiles : "overview-features.html,overview-failures.html,",
reportTitles : "Features,Failures",
reportName : "Next Hearing Date Updater Functional Test Report"
]
junit '**/test-results/functional/*.xml'
}

publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/functional",
reportFiles : "overview-features.html,overview-failures.html,",
reportTitles : "Features,Failures",
reportName : "Next Hearing Date Updater Functional Test Report"
]
junit '**/test-results/functional/*.xml'
}
afterAlways('functionalTest:aat') {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/functional",
reportFiles : "overview-features.html,overview-failures.html,",
reportTitles : "Features,Failures",
reportName : "Next Hearing Date Updater Functional Test Report"
]
junit '**/test-results/functional/*.xml'
}

}
49 changes: 17 additions & 32 deletions Jenkinsfile_nightly
Original file line number Diff line number Diff line change
Expand Up @@ -78,48 +78,33 @@ withNightlyPipeline(type, product, component) {

// apply standard `onNonPR` env variables for nightly
env.ENV='aat'
env.TEST_URL="http://ccd-data-store-api-aat.service.core-compute-aat.internal"
env.CCD_DATA_STORE_API_BASE_URL = "http://ccd-data-store-api-aat.service.core-compute-aat.internal"
env.DEFINITION_STORE_URL_BASE = "http://ccd-definition-store-api-aat.service.core-compute-aat.internal"


enableAksStagingDeployment()
disableLegacyDeployment()
loadVaultSecrets(secrets)
nonServiceApp()
enableMutationTest()
enableFullFunctionalTest()

afterAlways('fortify-scan') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/Fortify Scan/**/*'
}
enableFullFunctionalTestNonServiceApp(env.CCD_DATA_STORE_API_BASE_URL)

before('fullFunctionalTest') {
echo "Loading the secrets"
loadVaultSecrets(secrets)


// Execute functional tests
echo "Just waiting a while to ensure that the pod has run the job"
sh "sleep 30s"
echo "Verifying that functional test run correctly"
try {
// NB: override IDAM_API_URL late as per `Jenkinsfile_CNP` tests
env.IDAM_API_URL = env.IDAM_API_URL_BASE

builder.functionalTest()
} finally {

publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/functional",
reportFiles : "overview-features.html,overview-failures.html,",
reportTitles : "Features,Failures",
reportName : "Next Hearing Date Updater Functional Test Report"
]
junit '**/test-results/functional/*.xml'
}
// NB: override IDAM_API_URL late as per `Jenkinsfile_CNP` tests
env.IDAM_API_URL = env.IDAM_API_URL_BASE
}

afterAlways('fullFunctionalTest') {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/functional",
reportFiles : "overview-features.html,overview-failures.html,",
reportTitles : "Features,Failures",
reportName : "Next Hearing Date Updater Functional Test Report"
]
junit '**/test-results/functional/*.xml'
}

}
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
id 'org.springframework.boot' version '2.7.5'
id 'com.github.ben-manes.versions' version '0.42.0'
id 'org.sonarqube' version '3.3'
id 'uk.gov.hmcts.java' version '0.12.34'
id 'uk.gov.hmcts.java' version '0.12.39'
id 'com.github.hmcts.rse-cft-lib' version '0.19.496'
id 'com.github.spacialcircumstances.gradle-cucumber-reporting' version '0.1.23'
}
Expand Down Expand Up @@ -335,8 +335,8 @@ dependencies {
functionalTestImplementation group: 'io.vavr', name: 'vavr', version: '0.10.4'
functionalTestImplementation group: 'io.rest-assured', name: 'rest-assured', version: '4.4.0'

functionalTestImplementation group: 'com.github.hmcts', name: 'befta-fw', version: '8.7.6'
functionalTestImplementation group: 'com.github.hmcts', name: 'ccd-test-definitions', version: '7.19.5'
functionalTestImplementation group: 'com.github.hmcts', name: 'befta-fw', version: '8.7.10'
functionalTestImplementation group: 'com.github.hmcts', name: 'ccd-test-definitions', version: '7.19.12'

}

Expand Down