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

added provider and consumer verification tests #494

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ withPipeline(type, product, app) {

disableLegacyDeployment()

// onMaster() {
// enablePactAs([
// AppPipelineDsl.PactRoles.PROVIDER,
// AppPipelineDsl.PactRoles.CONSUMER
// ])
// }
// onPR() {
// enablePactAs([
// AppPipelineDsl.PactRoles.PROVIDER,
// AppPipelineDsl.PactRoles.CONSUMER
// ])
// }

//Sync demo,ithc and perftest with master branch
syncBranchesWithMaster(branchesToSync)
}
3 changes: 3 additions & 0 deletions api-contract/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

description = ''

dependencies {
compile 'com.fasterxml.jackson.core:jackson-annotations'
compile 'org.hibernate:hibernate-validator'
Expand Down
10 changes: 10 additions & 0 deletions api-contract/src/test/java/TestJunit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import org.junit.Assert;
import org.junit.Test;

public class TestJunit {

@Test
public void mockTest() {
Assert.assertTrue(true);
}
}
53 changes: 53 additions & 0 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,59 @@ task functionalTest(type: Test, description: 'Runs the smoke functional', group:

functionalTest.finalizedBy(aggregate)

project.ext {
pactVersion = getCheckedOutGitCommitHash()
pacticipant = 'bar_App'
pacticipantVersion = getCheckedOutGitCommitHash()
}

task consumerContractTest(type: Test) {
logger.lifecycle("Running consumer contract Tests")
useJUnitPlatform()
// include "uk/gov/hmcts/fees.register/api/controllers/consumer/**"
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
systemProperty 'pact.rootDir', "pacts"
systemProperty 'pact.provider.version', project.pactVersion

}

task providerContractTest(type: Test) {
logger.lifecycle("Running contract provider Tests")
useJUnitPlatform()
// include "uk/gov/hmcts/fees.register/api/controllers/provider/**"
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
systemProperty 'pact.rootDir', "pacts"
systemProperty 'pact.verifier.publishResults', System.getProperty('pact.verifier.publishResults')
systemProperty 'pact.provider.version', project.pactVersion

}

task runProviderPactVerification(type: Test) {
logger.lifecycle("Runs pact provider Tests")
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}

task runAndPublishConsumerPactTests(type: Test, description: 'Publish pact test to broker.', group: 'Verification') {
logger.lifecycle("Runs pact consumer Tests")
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}

runAndPublishConsumerPactTests.dependsOn consumerContractTest

runAndPublishConsumerPactTests.finalizedBy pactPublish

runProviderPactVerification.dependsOn providerContractTest

runProviderPactVerification.finalizedBy pactVerify

def getCheckedOutGitCommitHash() {
'git rev-parse --verify --short HEAD'.execute().text.trim()
}

pitest {
targetClasses = ['uk.gov.hmcts.bar.api.*']
excludedClasses = ['uk.gov.hmcts.bar.api.configuration.*']
Expand Down
47 changes: 47 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id "com.gorylenko.gradle-git-properties" version "1.4.21"
id "org.sonarqube" version "2.6.2"
id 'jacoco'
id "au.com.dius.pact" version "4.1.7"
}
def springBootVersion = '2.3.6.RELEASE'

Expand All @@ -18,6 +19,7 @@ def versions = [
allprojects {
apply plugin: 'maven'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'au.com.dius.pact'

group = 'uk.gov.hmcts.reform.bar'
ext {
Expand Down Expand Up @@ -185,6 +187,51 @@ sonarqube {

project.tasks['sonarqube'].dependsOn codeCoverageReport

project.ext {
pactVersion = getCheckedOutGitCommitHash()
}
def getCheckedOutGitCommitHash() {
'git rev-parse --verify --short HEAD'.execute().text.trim()
}

def pactBrokerUrl = System.getenv("PACT_BROKER_URL")

pact {
serviceProviders {
'barApp_lookUp' {
protocol = 'http'
host = 'bar-app-api-aat.service.core-compute-aat.internal'
port = 80
if (pactBrokerUrl) hasPactsFromPactBroker(pactBrokerUrl)
publish {
if (pactBrokerUrl) pactBrokerUrl = pactBrokerUrl
pactBrokerUrl = System.getProperty("PACT_BROKER_URL") ?: 'http://localhost:80'
tags = ['master']
}
project.version = pactVersion.toString();
}
}
reports {
defaultReports()
markdown

}
}

task runAndPublishConsumerPactTests(type: Test){
logger.lifecycle("Running Pact consumer verification Tests")
systemProperty 'pact.verifier.publishResults',System.getProperty("pact.verifier.publishResults")
}

runAndPublishConsumerPactTests.finalizedBy pactVerify

task runProviderPactVerification(type: Test){
logger.lifecycle("Running Pact provider verification Tests")
systemProperty 'pact.verifier.publishResults',System.getProperty("pact.verifier.publishResults")
}

runProviderPactVerification.finalizedBy pactVerify

task smoke(type: GradleBuild, description: 'Runs smoke tests', group: 'Verification') {
buildFile = './api/build.gradle'
tasks = ['smokeTest']
Expand Down
4 changes: 2 additions & 2 deletions charts/bar-api/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ appVersion: "2.0"
description: Helm chart for the HMCTS bar api
name: bar-api
home: https://github.com/hmcts/bar-app
version: 0.2.10
version: 0.2.11
maintainers:
- name: HMCTS Bar Dev Team
email: [email protected]
dependencies:
- name: java
version: 3.4.5
repository: '@hmctspublic'
repository: 'https://hmctspublic.azurecr.io/helm/v1/repo/'
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ rootProject.name = 'bar-app'

include ':bar-api'
include ':bar-client'
include ':api-contract'

project(':bar-api').projectDir = "$rootDir/api" as File
project(':bar-client').projectDir = "$rootDir/client" as File
project(':api-contract').projectDir = "$rootDir/api-contract" as File