Skip to content

Commit

Permalink
Add WdsContractVerificationTest
Browse files Browse the repository at this point in the history
This pairs with
DataBiosphere/terra-workspace-data-service#372
to establish a contract between WDS and WSM, initially focused on
`ReferencedGcpResourceController`.
  • Loading branch information
jladieu committed Oct 25, 2023
1 parent fe726d7 commit a53dd38
Show file tree
Hide file tree
Showing 5 changed files with 306 additions and 150 deletions.
4 changes: 4 additions & 0 deletions service/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ au.com.dius.pact.core:matchers:4.1.7=testCompileClasspath,testRuntimeClasspath
au.com.dius.pact.core:model:4.1.7=testCompileClasspath,testRuntimeClasspath
au.com.dius.pact.core:pactbroker:4.1.7=testCompileClasspath,testRuntimeClasspath
au.com.dius.pact.core:support:4.1.7=testCompileClasspath,testRuntimeClasspath
au.com.dius.pact.provider:junit5:4.1.7=testCompileClasspath,testRuntimeClasspath
au.com.dius.pact.provider:junit5spring:4.1.7=testCompileClasspath,testRuntimeClasspath
au.com.dius.pact:consumer:4.1.7=testCompileClasspath,testRuntimeClasspath
au.com.dius.pact:provider:4.1.7=testCompileClasspath,testRuntimeClasspath
bio.terra:billing-profile-manager-client:0.1.29-SNAPSHOT=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
bio.terra:datarepo-client:1.41.0-SNAPSHOT=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
bio.terra:stairway-gcp:0.0.76-SNAPSHOT=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand Down Expand Up @@ -341,6 +344,7 @@ org.bouncycastle:bcutil-jdk18on:1.72=compileClasspath,productionRuntimeClasspath
org.broadinstitute.dsde.workbench:sam-client_2.13:0.1-fd8ee25=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.checkerframework:checker-compat-qual:2.5.5=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.checkerframework:checker-qual:3.22.2=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.codehaus.groovy:groovy:3.0.19=testRuntimeClasspath
org.codehaus.mojo:animal-sniffer-annotations:1.21=productionRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
org.codehaus.plexus:plexus-utils:3.2.1=productionRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
org.codehaus.woodstox:stax2-api:4.2.1=compileClasspath,productionRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand Down
2 changes: 2 additions & 0 deletions service/gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ dependencies {

// pact
testImplementation 'au.com.dius.pact.consumer:junit5:4.1.7'
testImplementation 'au.com.dius.pact.provider:junit5:4.1.7'
testImplementation 'au.com.dius.pact.provider:junit5spring:4.1.7'

annotationProcessor group: "com.google.auto.value", name: "auto-value", version: "1.7.4"
annotationProcessor group: "org.springframework.boot", name: "spring-boot-configuration-processor", version: "2.6.6"
Expand Down
311 changes: 161 additions & 150 deletions service/gradle/testing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
// Created by scripts/write_config.sh
def googleCredentialsFile = "${rootDir}/config/wsm-sa.json"
bootRun {
environment.put("GOOGLE_APPLICATION_CREDENTIALS", "${googleCredentialsFile}")
environment.put("GOOGLE_APPLICATION_CREDENTIALS", "${googleCredentialsFile}")
}

tasks.withType(Test).configureEach {
environment.put("GOOGLE_APPLICATION_CREDENTIALS", "${googleCredentialsFile}")
systemProperty 'spring.profiles.include', 'human-readable-logging'
testLogging {
if (System.getenv('PRINT_STANDARD_STREAMS') == null) {
events = ["passed", "failed", "skipped", "started"]
} else {
events = ["passed", "failed", "skipped", "started", "standard_out", "standard_error"]
}
}
environment.put("GOOGLE_APPLICATION_CREDENTIALS", "${googleCredentialsFile}")
systemProperty 'spring.profiles.include', 'human-readable-logging'
testLogging {
if (System.getenv('PRINT_STANDARD_STREAMS') == null) {
events = ["passed", "failed", "skipped", "started"]
} else {
events = ["passed", "failed", "skipped", "started", "standard_out", "standard_error"]
}
}
}

// We don't want to use up all the cores on a developer's machine because it locks them out of doing other
Expand All @@ -28,187 +28,198 @@ def singleThread = System.getenv().containsKey("TEST_SINGLE_THREAD")
runnerThreads = singleThread ? 1 : runnerThreads

test {
useJUnitPlatform {
includeTags "unit"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport

// For GHA runs, retry failing tests. If 2nd time passes, workflow will still
// fail and oncall will still be notified. This way, oncall dosen't have to
// rerun workflow in GHA.
retry {
// This is set automatically on Github Actions runners, and never set
// otherwise.
if (System.getenv().containsKey("CI")) {
// Max retries per test.
maxRetries = 1
// Max total test failures.
// This is an estimate based on current failure rates, but if more
// than 5 tests fail in a run it's likely a real source of failure
// and we should stop retrying.
maxFailures = 5
}
failOnPassedAfterRetry = true
}
maxParallelForks = runnerThreads
useJUnitPlatform {
includeTags "unit"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport

// For GHA runs, retry failing tests. If 2nd time passes, workflow will still
// fail and oncall will still be notified. This way, oncall dosen't have to
// rerun workflow in GHA.
retry {
// This is set automatically on Github Actions runners, and never set
// otherwise.
if (System.getenv().containsKey("CI")) {
// Max retries per test.
maxRetries = 1
// Max total test failures.
// This is an estimate based on current failure rates, but if more
// than 5 tests fail in a run it's likely a real source of failure
// and we should stop retrying.
maxFailures = 5
}
failOnPassedAfterRetry = true
}
maxParallelForks = runnerThreads
}

// GCP, non-cloud-specific

task unitTest(type: Test) {
useJUnitPlatform {
includeTags "unit"
}
outputs.upToDateWhen { false }
maxParallelForks = runnerThreads
finalizedBy tasks.combinedJaCoCoReport
useJUnitPlatform {
includeTags "unit"
excludeTags "pact-verification"
}
outputs.upToDateWhen { false }
maxParallelForks = runnerThreads
finalizedBy tasks.combinedJaCoCoReport
}

task connectedPlusTest(type: Test) {
environment.put('TEST_ENV', System.getenv("TEST_ENV"))
useJUnitPlatform {
includeTags "connectedPlus"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport

// For GHA runs, retry failing tests. If 2nd time passes, workflow will still
// fail and oncall will still be notified. This way, oncall dosen't have to
// rerun workflow in GHA.
retry {
// This is set automatically on Github Actions runners, and never set
// otherwise.
if (System.getenv().containsKey("CI")) {
// Max retries per test.
maxRetries = 1
// Max total test failures.
// This is an estimate based on current failure rates, but if more
// than 5 tests fail in a run it's likely a real source of failure
// and we should stop retrying.
maxFailures = 5
}
failOnPassedAfterRetry = true
}
maxParallelForks = runnerThreads
environment.put('TEST_ENV', System.getenv("TEST_ENV"))
useJUnitPlatform {
includeTags "connectedPlus"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport

// For GHA runs, retry failing tests. If 2nd time passes, workflow will still
// fail and oncall will still be notified. This way, oncall dosen't have to
// rerun workflow in GHA.
retry {
// This is set automatically on Github Actions runners, and never set
// otherwise.
if (System.getenv().containsKey("CI")) {
// Max retries per test.
maxRetries = 1
// Max total test failures.
// This is an estimate based on current failure rates, but if more
// than 5 tests fail in a run it's likely a real source of failure
// and we should stop retrying.
maxFailures = 5
}
failOnPassedAfterRetry = true
}
maxParallelForks = runnerThreads
}

// Use the connected test tag for PR runs.
// No retries; devs can manually rerun
task connectedTest(type: Test) {
environment.put('TEST_ENV', System.getenv("TEST_ENV"))
useJUnitPlatform {
includeTags "connected"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport
maxParallelForks = runnerThreads
environment.put('TEST_ENV', System.getenv("TEST_ENV"))
useJUnitPlatform {
includeTags "connected"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport
maxParallelForks = runnerThreads
}

// AZURE

task azureUnitTest(type: Test) {
useJUnitPlatform {
includeTags "azure-unit"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport
maxParallelForks = runnerThreads
useJUnitPlatform {
includeTags "azure-unit"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport
maxParallelForks = runnerThreads
}

// Use the azureConnected test tag for PR runs.
// No retries; devs can manually rerun
task azureConnectedTest(type: Test) {
useJUnitPlatform {
includeTags "azureConnected"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport
maxParallelForks = runnerThreads
useJUnitPlatform {
includeTags "azureConnected"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport
maxParallelForks = runnerThreads
}

task azureConnectedPlusTest(type: Test) {
environment.put('TEST_ENV', System.getenv("TEST_ENV"))
useJUnitPlatform {
includeTags "azureConnectedPlus"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport

// For GHA runs, retry failing tests. If 2nd time passes, workflow will still
// fail and oncall will still be notified. This way, oncall dosen't have to
// rerun workflow in GHA.
retry {
// This is set automatically on Github Actions runners, and never set
// otherwise.
if (System.getenv().containsKey("CI")) {
// Max retries per test.
maxRetries = 1
// Max total test failures.
// This is an estimate based on current failure rates, but if more
// than 5 tests fail in a run it's likely a real source of failure
// and we should stop retrying.
maxFailures = 5
}
failOnPassedAfterRetry = true
}
maxParallelForks = runnerThreads
environment.put('TEST_ENV', System.getenv("TEST_ENV"))
useJUnitPlatform {
includeTags "azureConnectedPlus"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport

// For GHA runs, retry failing tests. If 2nd time passes, workflow will still
// fail and oncall will still be notified. This way, oncall dosen't have to
// rerun workflow in GHA.
retry {
// This is set automatically on Github Actions runners, and never set
// otherwise.
if (System.getenv().containsKey("CI")) {
// Max retries per test.
maxRetries = 1
// Max total test failures.
// This is an estimate based on current failure rates, but if more
// than 5 tests fail in a run it's likely a real source of failure
// and we should stop retrying.
maxFailures = 5
}
failOnPassedAfterRetry = true
}
maxParallelForks = runnerThreads
}

// AWS

task awsUnitTest(type: Test) {
useJUnitPlatform {
includeTags "aws-unit"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport
maxParallelForks = runnerThreads
useJUnitPlatform {
includeTags "aws-unit"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport
maxParallelForks = runnerThreads
}

task awsConnectedTest(type: Test) {
useJUnitPlatform {
includeTags "aws-connected"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport
maxParallelForks = runnerThreads
useJUnitPlatform {
includeTags "aws-connected"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport
maxParallelForks = runnerThreads
}

task awsConnectedPlusTest(type: Test) {
useJUnitPlatform {
includeTags "aws-connected-plus"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport

// For GHA runs, retry failing tests. If 2nd time passes, workflow will still
// fail and oncall will still be notified. This way, oncall dosen't have to
// rerun workflow in GHA.
retry {
// This is set automatically on Github Actions runners, and never set
// otherwise.
if (System.getenv().containsKey("CI")) {
// Max retries per test.
maxRetries = 1
// Max total test failures.
// This is an estimate based on current failure rates, but if more
// than 5 tests fail in a run it's likely a real source of failure
// and we should stop retrying.
maxFailures = 5
}
failOnPassedAfterRetry = true
}
maxParallelForks = runnerThreads
useJUnitPlatform {
includeTags "aws-connected-plus"
}
outputs.upToDateWhen { false }
finalizedBy tasks.combinedJaCoCoReport

// For GHA runs, retry failing tests. If 2nd time passes, workflow will still
// fail and oncall will still be notified. This way, oncall dosen't have to
// rerun workflow in GHA.
retry {
// This is set automatically on Github Actions runners, and never set
// otherwise.
if (System.getenv().containsKey("CI")) {
// Max retries per test.
maxRetries = 1
// Max total test failures.
// This is an estimate based on current failure rates, but if more
// than 5 tests fail in a run it's likely a real source of failure
// and we should stop retrying.
maxFailures = 5
}
failOnPassedAfterRetry = true
}
maxParallelForks = runnerThreads
}

// PACT

task pactTests(type: Test) {
useJUnitPlatform {
includeTags "pact-test"
}
environment.put('pact.rootDir', "$buildDir/pacts")
environment.put('pact.provider.version', "$project.version")
useJUnitPlatform {
includeTags "pact-test"
}
environment.put('pact.rootDir', "$buildDir/pacts")
environment.put('pact.provider.version', "$project.version")
}

// verify the provider side of pacts WSM has with other services
task verifyPacts(type: Test) {
useJUnitPlatform {
includeTags "pact-verification"
}
systemProperty 'pactbroker.host', System.getenv('PACTBROKER_HOST')
systemProperty 'pact.provider.version', System.getenv('PACT_PROVIDER_COMMIT')
systemProperty 'pact.provider.branch', System.getenv('PACT_PROVIDER_BRANCH')
systemProperty 'pact.verifier.publishResults', System.getenv('PACT_PUBLISH_RESULTS')
}
Loading

0 comments on commit a53dd38

Please sign in to comment.