From 2de2d0e002e3db82dd1a4cd10d9c3695c34a2e6b Mon Sep 17 00:00:00 2001 From: Esta Nagy Date: Sun, 12 Jun 2022 17:58:48 +0200 Subject: [PATCH] Configure Abort-Mission selective test runs (#203) - Updates Abort-Mission version to 3.2.0 - Adds keywords to Abort-Mission evaluators - Configures Gradle build to allow simple selection of Docker test scope Resolves #202 {patch} Signed-off-by: Esta Nagy --- build.gradle | 2 + gradle/libs.versions.toml | 2 +- gradle/verification-metadata.xml | 40 +++++++++---------- .../lowkeyvault/MissionOutlineDefinition.java | 8 ++++ .../VaultManagementControllerTest.java | 2 +- .../LowkeyVaultManagementClientImplTest.java | 2 +- lowkey-vault-docker/build.gradle | 2 + .../hook/MissionOutlineDefinition.java | 7 +++- 8 files changed, 40 insertions(+), 25 deletions(-) diff --git a/build.gradle b/build.gradle index 58760f4c..5d890462 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,8 @@ project.ext { ossIndexPass = project.hasProperty('ossIndexPassword') ? (project.property('ossIndexPassword') as String) : '' ossIndexExclusions = ["CVE-2016-1000027"] keyToolDir = project.hasProperty('keyToolDir') ? (project.property('keyToolDir') as String) : '' + dockerAbortGroups = project.hasProperty('dockerSuppressGroups') ? 'all' : '' + dockerSuppressGroups = project.hasProperty('dockerSuppressGroups') ? (project.property('dockerSuppressGroups') as String) : '' repoUrl = 'https://github.com/nagyesta/lowkey-vault' licenseName = 'MIT License' licenseUrl = 'https://raw.githubusercontent.com/nagyesta/lowkey-vault/main/LICENSE' diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ba6ca569..e1895ebc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ testcontainers = "1.17.2" cucumber = "7.3.4" mockitoCore = "4.6.1" jupiter = "5.8.2" -abortMission = "3.1.0" +abortMission = "3.2.0" checkstyle = "9.2.1" jacoco = "0.8.2" jacksonBom = { strictly = "2.13.3" } diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 268db327..94800198 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -303,12 +303,12 @@ - - - + + + - - + + @@ -316,28 +316,28 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/MissionOutlineDefinition.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/MissionOutlineDefinition.java index e2d8007c..f9c648ba 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/MissionOutlineDefinition.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/MissionOutlineDefinition.java @@ -17,10 +17,18 @@ protected Map> defineOutline() { return Map.of(SHARED_CONTEXT, ops -> { final MissionHealthCheckMatcher integrationTestMatcher = matcher().classNamePattern(".*IntegrationTest").build(); final MissionHealthCheckEvaluator integrationTests = percentageBasedEvaluator(integrationTestMatcher) + .overrideKeyword("IT") + .build(); + final MissionHealthCheckMatcher notIntegrationTest = matcher().not(integrationTestMatcher).build(); + final MissionHealthCheckMatcher test = matcher().classNamePattern(".*Test").build(); + final MissionHealthCheckEvaluator unitTests = reportOnlyEvaluator(matcher().and(notIntegrationTest).andAtLast(test).build()) + .overrideKeyword("UT") .build(); final MissionHealthCheckEvaluator reportOnly = reportOnlyEvaluator(matcher().anyClass().build()) + .overrideKeyword("all") .build(); ops.registerHealthCheck(integrationTests); + ops.registerHealthCheck(unitTests); ops.registerHealthCheck(reportOnly); }); } diff --git a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultManagementControllerTest.java b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultManagementControllerTest.java index 4bbbbe39..8b269550 100644 --- a/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultManagementControllerTest.java +++ b/lowkey-vault-app/src/test/java/com/github/nagyesta/lowkeyvault/controller/VaultManagementControllerTest.java @@ -72,7 +72,7 @@ void testConstructorThrowsExceptionWhenCalledWithNull( } @Nested - class FunctionalTests { + class FunctionalTest { @Mock private VaultService vaultService; @Mock diff --git a/lowkey-vault-client/src/test/java/com/github/nagyesta/lowkeyvault/http/management/impl/LowkeyVaultManagementClientImplTest.java b/lowkey-vault-client/src/test/java/com/github/nagyesta/lowkeyvault/http/management/impl/LowkeyVaultManagementClientImplTest.java index bb716b6e..38a4de9d 100644 --- a/lowkey-vault-client/src/test/java/com/github/nagyesta/lowkeyvault/http/management/impl/LowkeyVaultManagementClientImplTest.java +++ b/lowkey-vault-client/src/test/java/com/github/nagyesta/lowkeyvault/http/management/impl/LowkeyVaultManagementClientImplTest.java @@ -95,7 +95,7 @@ void testCreateVaultShouldThrowExceptionWhenCalledWithNull( } @Nested - class FunctionalTests { + class FunctionalTest { @Mock private ObjectReader objectReader; diff --git a/lowkey-vault-docker/build.gradle b/lowkey-vault-docker/build.gradle index d80deff6..219896a9 100644 --- a/lowkey-vault-docker/build.gradle +++ b/lowkey-vault-docker/build.gradle @@ -78,6 +78,8 @@ test { systemProperty("cucumber.filter.tags", "not @ignore") useTestNG { systemProperty("abort-mission.report.directory", file("${buildDir}/reports/abort-mission/")) + systemProperty("abort-mission.force.abort.evaluators", rootProject.ext.dockerAbortGroups) + systemProperty("abort-mission.suppress.abort.evaluators", rootProject.ext.dockerSuppressGroups) } } test.outputs.upToDateWhen { false } diff --git a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/hook/MissionOutlineDefinition.java b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/hook/MissionOutlineDefinition.java index 24894c5d..dd53c3dd 100644 --- a/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/hook/MissionOutlineDefinition.java +++ b/lowkey-vault-docker/src/test/java/com/github/nagyesta/lowkeyvault/hook/MissionOutlineDefinition.java @@ -14,8 +14,7 @@ import java.util.function.Consumer; import java.util.stream.Stream; -import static com.github.nagyesta.abortmission.core.MissionControl.matcher; -import static com.github.nagyesta.abortmission.core.MissionControl.percentageBasedEvaluator; +import static com.github.nagyesta.abortmission.core.MissionControl.*; import static com.github.nagyesta.abortmission.core.outline.MissionOutline.SHARED_CONTEXT; public class MissionOutlineDefinition extends LaunchAbortHook { @@ -28,11 +27,13 @@ public class MissionOutlineDefinition extends LaunchAbortHook { protected Map> defineOutline() { return Map.of(SHARED_CONTEXT, ops -> { final TagDependencyNameExtractor extractor = new TagDependencyNameExtractor(); + ops.registerHealthCheck(reportOnlyEvaluator(anyScenarioMatcher()).overrideKeyword("all").build()); Stream.of("Key", "Secret").forEach(type -> { final MissionHealthCheckMatcher typeMatcher = matcher().dependencyWith(type).extractor(extractor).build(); final MissionHealthCheckEvaluator featurePercentage = percentageBasedEvaluator(typeMatcher) .abortThreshold(ABORT_THRESHOLD) .burnInTestCount(TOTAL_BURN_IN_TEST_COUNT) + .overrideKeyword(type) .build(); ops.registerHealthCheck(featurePercentage); @@ -43,6 +44,7 @@ protected Map> defineOutline() { final MissionHealthCheckEvaluator subFeaturePercentage = percentageBasedEvaluator(subTypeMatcher) .abortThreshold(ABORT_THRESHOLD) .burnInTestCount(BURN_IN_TEST_COUNT) + .overrideKeyword(type + subtype) .build(); ops.registerHealthCheck(subFeaturePercentage); }); @@ -53,6 +55,7 @@ protected Map> defineOutline() { final MissionHealthCheckEvaluator tagPercentage = percentageBasedEvaluator(matcher) .abortThreshold(ABORT_THRESHOLD) .burnInTestCount(BURN_IN_TEST_COUNT) + .overrideKeyword(tag) .build(); ops.registerHealthCheck(tagPercentage); });