From 208cf554c92baaf741aae17dcfcfd665e68dfea8 Mon Sep 17 00:00:00 2001 From: Nathan Klick Date: Thu, 14 Sep 2023 17:36:30 -0500 Subject: [PATCH] chore: add test mocks and boiler plate items for test toolkit (#343) Signed-off-by: Nathan Klick --- ...m.hedera.fullstack.jpms-modules.gradle.kts | 1 + .../src/main/java/module-info.java | 1 + fullstack-examples/build.gradle.kts | 4 +- .../examples/signing/ExampleTest.java} | 32 +++++++---- .../signing/InvalidStateSignatureTest.java | 24 +++++++-- .../examples/signing/StatsSigningTest.java | 8 +-- .../java/module-info.java | 1 + .../{LogErrorMonitor.java => LogMonitor.java} | 2 +- .../readiness/NodeActiveReadinessCheck.java | 3 +- .../InvalidStateSignatureValidator.java | 33 ++++++++++++ .../validators/PlatformStatusValidator.java | 53 +++++++++++++++++++ .../src/main/java/module-info.java | 1 + .../annotations/core/ConfigurationValue.java | 14 ++++- .../annotations/core/FullStackSuite.java | 28 ++++++++++ .../annotations/core/FullStackTest.java | 27 ---------- .../core/ParameterizedFullStackTest.java | 9 ---- .../annotations/services/EnvoyProxy.java | 10 +++- .../annotations/services/HttpProxy.java | 10 +++- .../{HashIO.java => JsonRpcRelay.java} | 12 ++++- .../annotations/services/MirrorNode.java | 3 +- ...{HashScan.java => MirrorNodeExplorer.java} | 5 +- .../annotations/validation/Monitors.java | 8 +++ .../validation/ReadinessChecks.java | 8 +++ .../annotations/validation/Validators.java | 8 +++ .../support/mutators/core/CheckMutator.java | 28 ++++++++++ .../mutators/core/ConfigurationMutator.java | 28 ++++++++++ .../support/mutators/core/TestMutator.java | 37 +++++++++++++ .../src/main/java/module-info.java | 2 + .../fullstack/monitoring/api/Monitor.java | 6 +++ .../src/main/java/module-info.java | 2 + .../readiness/api/ReadinessCheck.java | 9 +++- .../src/main/java/module-info.java | 2 + .../src/main/java/module-info.java | 1 - .../src/test/java/module-info.java | 1 - .../build.gradle.kts | 0 .../gradle.properties | 0 .../fullstack/test/toolkit/core}/Dummy.java | 2 +- .../test/toolkit/core/package-info.java | 1 + .../src/main/java/module-info.java | 1 + .../src/test/java/module-info.java | 1 + fullstack-test-toolkit/build.gradle.kts | 23 ++++++++ fullstack-test-toolkit/gradle.properties | 18 +++++++ .../model/infrastructure/ApplicationNode.java | 21 ++++++++ .../api/model/infrastructure/Deployment.java | 27 ++++++++++ .../api/model/infrastructure/MirrorNode.java | 19 +++++++ .../api/model/infrastructure/Node.java | 22 ++++++++ .../api/model/infrastructure/NodeSet.java | 48 +++++++++++++++++ .../api/model/infrastructure/RelayNode.java | 21 ++++++++ .../toolkit/api/model/traits/Indexed.java | 29 ++++++++++ .../test/toolkit/api/model/traits/Named.java | 29 ++++++++++ .../test/toolkit/api/model/traits/Tagged.java | 31 +++++++++++ .../test/toolkit/api/package-info.java | 0 .../src/main/java/module-info.java | 3 ++ .../src/test/java/module-info.java | 1 + .../fullstack/validator/api/Validator.java | 6 +++ .../src/main/java/module-info.java | 2 + settings.gradle.kts | 4 +- 57 files changed, 657 insertions(+), 73 deletions(-) rename fullstack-examples/src/{fullStackTest/java/com/hedera/fullstack/examples/signing/PlatformSignatureVerificationTest.java => fullstack/java/com/hedera/fullstack/examples/signing/ExampleTest.java} (63%) rename fullstack-examples/src/{fullStackTest => fullstack}/java/com/hedera/fullstack/examples/signing/InvalidStateSignatureTest.java (73%) rename fullstack-examples/src/{fullStackTest => fullstack}/java/com/hedera/fullstack/examples/signing/StatsSigningTest.java (92%) rename fullstack-examples/src/{fullStackTest => fullstack}/java/module-info.java (88%) rename fullstack-examples/src/main/java/com/hedera/fullstack/examples/monitors/{LogErrorMonitor.java => LogMonitor.java} (94%) create mode 100644 fullstack-examples/src/main/java/com/hedera/fullstack/examples/validators/InvalidStateSignatureValidator.java create mode 100644 fullstack-examples/src/main/java/com/hedera/fullstack/examples/validators/PlatformStatusValidator.java rename fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/{HashIO.java => JsonRpcRelay.java} (68%) rename fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/{HashScan.java => MirrorNodeExplorer.java} (87%) create mode 100644 fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/CheckMutator.java create mode 100644 fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/ConfigurationMutator.java create mode 100644 fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/TestMutator.java delete mode 100644 fullstack-test-toolkit-api/src/main/java/module-info.java delete mode 100644 fullstack-test-toolkit-api/src/test/java/module-info.java rename {fullstack-test-toolkit-api => fullstack-test-toolkit-core}/build.gradle.kts (100%) rename {fullstack-test-toolkit-api => fullstack-test-toolkit-core}/gradle.properties (100%) rename {fullstack-test-toolkit-api/src/main/java/com/hedera/fullstack/test/toolkit/api => fullstack-test-toolkit-core/src/main/java/com/hedera/fullstack/test/toolkit/core}/Dummy.java (92%) create mode 100644 fullstack-test-toolkit-core/src/main/java/com/hedera/fullstack/test/toolkit/core/package-info.java create mode 100644 fullstack-test-toolkit-core/src/main/java/module-info.java create mode 100644 fullstack-test-toolkit-core/src/test/java/module-info.java create mode 100644 fullstack-test-toolkit/build.gradle.kts create mode 100644 fullstack-test-toolkit/gradle.properties create mode 100644 fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/ApplicationNode.java create mode 100644 fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/Deployment.java create mode 100644 fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/MirrorNode.java create mode 100644 fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/Node.java create mode 100644 fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/NodeSet.java create mode 100644 fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/RelayNode.java create mode 100644 fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Indexed.java create mode 100644 fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Named.java create mode 100644 fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Tagged.java rename {fullstack-test-toolkit-api => fullstack-test-toolkit}/src/main/java/com/hedera/fullstack/test/toolkit/api/package-info.java (100%) create mode 100644 fullstack-test-toolkit/src/main/java/module-info.java create mode 100644 fullstack-test-toolkit/src/test/java/module-info.java diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.jpms-modules.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.jpms-modules.gradle.kts index ab0cf0d6a..713db9cf0 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.jpms-modules.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.fullstack.jpms-modules.gradle.kts @@ -25,6 +25,7 @@ javaModuleDependencies { versionsFromConsistentResolution(":fullstack-helm-client") moduleNameToGA.put("com.hedera.fullstack.junit.support", "com.hedera.fullstack:fullstack-junit-support") + moduleNameToGA.put("com.hedera.fullstack.test.toolkit", "com.hedera.fullstack:fullstack-test-toolkit") } extraJavaModuleInfo { diff --git a/fullstack-base-api/src/main/java/module-info.java b/fullstack-base-api/src/main/java/module-info.java index 797375f7c..bbe6d372a 100644 --- a/fullstack-base-api/src/main/java/module-info.java +++ b/fullstack-base-api/src/main/java/module-info.java @@ -1,4 +1,5 @@ module com.hedera.fullstack.base.api { + exports com.hedera.fullstack.base.api.collections; exports com.hedera.fullstack.base.api.functional; exports com.hedera.fullstack.base.api.io; exports com.hedera.fullstack.base.api.os; diff --git a/fullstack-examples/build.gradle.kts b/fullstack-examples/build.gradle.kts index f143fe682..964ebac30 100644 --- a/fullstack-examples/build.gradle.kts +++ b/fullstack-examples/build.gradle.kts @@ -24,7 +24,7 @@ dependencies { api(platform(project(":fullstack-bom"))) } testing { suites { @Suppress("UnstableApiUsage", "unused") - val fullStackTest by + val fullstack by registering(JvmTestSuite::class) { useJUnitJupiter() dependencies { implementation(project(":fullstack-examples")) } @@ -32,4 +32,4 @@ testing { } } -tasks.assemble.configure { dependsOn(tasks.named("fullStackTestClasses")) } +tasks.assemble.configure { dependsOn(tasks.named("fullstackClasses")) } diff --git a/fullstack-examples/src/fullStackTest/java/com/hedera/fullstack/examples/signing/PlatformSignatureVerificationTest.java b/fullstack-examples/src/fullstack/java/com/hedera/fullstack/examples/signing/ExampleTest.java similarity index 63% rename from fullstack-examples/src/fullStackTest/java/com/hedera/fullstack/examples/signing/PlatformSignatureVerificationTest.java rename to fullstack-examples/src/fullstack/java/com/hedera/fullstack/examples/signing/ExampleTest.java index 908263afd..62c6665c2 100644 --- a/fullstack-examples/src/fullStackTest/java/com/hedera/fullstack/examples/signing/PlatformSignatureVerificationTest.java +++ b/fullstack-examples/src/fullstack/java/com/hedera/fullstack/examples/signing/ExampleTest.java @@ -20,11 +20,15 @@ import com.hedera.fullstack.junit.support.annotations.application.ApplicationNodes; import com.hedera.fullstack.junit.support.annotations.application.NamedApplicationNode; import com.hedera.fullstack.junit.support.annotations.application.NamedApplicationNodes; +import com.hedera.fullstack.junit.support.annotations.application.PlatformApplication; import com.hedera.fullstack.junit.support.annotations.core.FullStackSuite; import com.hedera.fullstack.junit.support.annotations.core.FullStackTest; import com.hedera.fullstack.junit.support.annotations.core.ParameterizedFullStackTest; +import com.hedera.fullstack.junit.support.annotations.core.TestExecutionMode; import com.hedera.fullstack.junit.support.annotations.flow.MaxTestExecutionTime; +import com.hedera.fullstack.junit.support.annotations.flow.WaitForDuration; import com.hedera.fullstack.junit.support.annotations.resource.ResourceShape; +import com.hedera.fullstack.junit.support.mutators.core.TestMutator; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; import org.junit.jupiter.api.DisplayName; @@ -33,26 +37,32 @@ import org.junit.jupiter.params.provider.MethodSource; @FullStackSuite -public class PlatformSignatureVerificationTest { +public class ExampleTest { - @FullStackTest - void testBasicCase() {} - - @FullStackTest + @FullStackTest(mode = TestExecutionMode.TIMED_EXECUTION) + @WaitForDuration(value = 5, unit = TimeUnit.MINUTES) @ApplicationNodes( value = 4, - shape = @ResourceShape(cpuInMillis = 10_000, memorySize = 64, memoryUnits = StorageUnits.GIGABYTES)) - @DisplayName("SSTT: Basic Signatures - Mixed Algorithms - 4 Nodes - 10k TPS") + shape = @ResourceShape(cpuInMillis = 18_000, memorySize = 2, memoryUnits = StorageUnits.GIGABYTES)) + @PlatformApplication( + fileName = "StatsSigningTestingTool.jar", + parameters = {"1", "3000", "0", "100", "-1", "10000", "5000"}) + @DisplayName("Crypto-Basic-10k-5m") void testBasicSignaturesMixedAlgorithms() {} @FullStackTest - @DisplayName("SSTT: Quick Basic Signatures - 2 Nodes - 500 TPS") @MaxTestExecutionTime(value = 5, unit = TimeUnit.MINUTES) @NamedApplicationNodes({ @NamedApplicationNode("node1"), - @NamedApplicationNode(value = "node2", shape = @ResourceShape(cpuInMillis = 2500)) + @NamedApplicationNode( + value = "node2", + shape = @ResourceShape(cpuInMillis = 18_000, memorySize = 4, memoryUnits = StorageUnits.GIGABYTES)) }) - void testQuickBasicSignatures() {} + @PlatformApplication( + fileName = "StatsSigningTestingTool.jar", + parameters = {"1", "3000", "0", "4000", "-1", "10000", "5000"}) + @DisplayName("Crypto-LargeTx-50k-20m.json") + void testLargeTxBasicSignatures() {} static Stream testScalingBasicSignatures() { return Stream.of(Arguments.of(Named.of("5k TPS", 5000)), Arguments.of(Named.of("10k TPS", 10000))); @@ -62,5 +72,5 @@ static Stream testScalingBasicSignatures() { @DisplayName("SSTT: Scaling Basic Signatures - 4 Nodes") @ApplicationNodes(6) @MethodSource - void testScalingBasicSignatures(int tps) {} + void testScalingBasicSignatures(int tps, TestMutator tm) {} } diff --git a/fullstack-examples/src/fullStackTest/java/com/hedera/fullstack/examples/signing/InvalidStateSignatureTest.java b/fullstack-examples/src/fullstack/java/com/hedera/fullstack/examples/signing/InvalidStateSignatureTest.java similarity index 73% rename from fullstack-examples/src/fullStackTest/java/com/hedera/fullstack/examples/signing/InvalidStateSignatureTest.java rename to fullstack-examples/src/fullstack/java/com/hedera/fullstack/examples/signing/InvalidStateSignatureTest.java index 3beacfc9c..1100a621b 100644 --- a/fullstack-examples/src/fullStackTest/java/com/hedera/fullstack/examples/signing/InvalidStateSignatureTest.java +++ b/fullstack-examples/src/fullstack/java/com/hedera/fullstack/examples/signing/InvalidStateSignatureTest.java @@ -17,10 +17,12 @@ package com.hedera.fullstack.examples.signing; import com.hedera.fullstack.examples.monitors.InvalidStateSignatureMonitor; -import com.hedera.fullstack.examples.monitors.LogErrorMonitor; +import com.hedera.fullstack.examples.monitors.LogMonitor; import com.hedera.fullstack.examples.monitors.NodeLivenessMonitor; import com.hedera.fullstack.examples.readiness.NodeActiveReadinessCheck; +import com.hedera.fullstack.examples.validators.InvalidStateSignatureValidator; import com.hedera.fullstack.examples.validators.NodeStatisticHealthValidator; +import com.hedera.fullstack.examples.validators.PlatformStatusValidator; import com.hedera.fullstack.junit.support.annotations.application.ApplicationNodes; import com.hedera.fullstack.junit.support.annotations.application.PlatformApplication; import com.hedera.fullstack.junit.support.annotations.application.PlatformConfiguration; @@ -34,6 +36,8 @@ import com.hedera.fullstack.junit.support.annotations.validation.Monitors; import com.hedera.fullstack.junit.support.annotations.validation.ReadinessChecks; import com.hedera.fullstack.junit.support.annotations.validation.Validators; +import com.hedera.fullstack.junit.support.mutators.core.TestMutator; +import com.hedera.fullstack.test.toolkit.api.model.infrastructure.Deployment; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.DisplayName; @@ -41,8 +45,13 @@ @ApplicationNodes(value = 4, shape = @ResourceShape(cpuInMillis = 8_000, memorySize = 8L)) @PlatformApplication(fileName = "ISSTestingTool.jar") @ReadinessChecks({NodeActiveReadinessCheck.class}) -@Monitors({NodeLivenessMonitor.class, LogErrorMonitor.class, InvalidStateSignatureMonitor.class}) -@Validators({NodeStatisticHealthValidator.class}) +@Monitors( + value = {NodeLivenessMonitor.class, LogMonitor.class, InvalidStateSignatureMonitor.class}, + config = + @ConfigurationValue( + name = "log.iss.expected.typeByNodeIndex", + values = {"catastrophic", "catastrophic", "catastrophic", "catastrophic"})) +@Validators({NodeStatisticHealthValidator.class, InvalidStateSignatureValidator.class}) @PlatformConfiguration({ @ConfigurationValue(name = "state.dumpStateOnAnyISS", value = "false"), @ConfigurationValue(name = "state.automatedSelfIssRecovery", value = "true"), @@ -60,5 +69,12 @@ class InvalidStateSignatureTest { @ConfigurationValue(name = "issTestingTool.plannedISSs", value = "180:0-1-2-3"), }) @DisplayName("ISS-catastrophic-1k-5m") - void catastrophic_1k_5m() {} + void catastrophic_1k_5m(Deployment deployment, TestMutator tm) { + final PlatformStatusValidator psv = PlatformStatusValidator.builder() + .nodeId("default") + .steps("REPLAYING_EVENTS", "OBSERVING", "CHECKING", "ACTIVE", "CHECKING") + .build(); + + tm.validators().add(psv); + } } diff --git a/fullstack-examples/src/fullStackTest/java/com/hedera/fullstack/examples/signing/StatsSigningTest.java b/fullstack-examples/src/fullstack/java/com/hedera/fullstack/examples/signing/StatsSigningTest.java similarity index 92% rename from fullstack-examples/src/fullStackTest/java/com/hedera/fullstack/examples/signing/StatsSigningTest.java rename to fullstack-examples/src/fullstack/java/com/hedera/fullstack/examples/signing/StatsSigningTest.java index 541269f48..915b4a848 100644 --- a/fullstack-examples/src/fullStackTest/java/com/hedera/fullstack/examples/signing/StatsSigningTest.java +++ b/fullstack-examples/src/fullstack/java/com/hedera/fullstack/examples/signing/StatsSigningTest.java @@ -17,7 +17,7 @@ package com.hedera.fullstack.examples.signing; import com.hedera.fullstack.examples.monitors.InvalidStateSignatureMonitor; -import com.hedera.fullstack.examples.monitors.LogErrorMonitor; +import com.hedera.fullstack.examples.monitors.LogMonitor; import com.hedera.fullstack.examples.monitors.NodeLivenessMonitor; import com.hedera.fullstack.examples.readiness.NodeActiveReadinessCheck; import com.hedera.fullstack.examples.validators.NodeStatisticHealthValidator; @@ -52,8 +52,8 @@ class StatsSigningTest { @ReadinessChecks({ NodeActiveReadinessCheck.class, }) - @Monitors({NodeLivenessMonitor.class, LogErrorMonitor.class, InvalidStateSignatureMonitor.class}) + @Monitors({NodeLivenessMonitor.class, LogMonitor.class, InvalidStateSignatureMonitor.class}) @Validators({NodeStatisticHealthValidator.class}) - @DisplayName("Basic 10k TPS - 20 minutes") - void basic() {} + @DisplayName("Crypto-Basic-10k-20m") + void crypto_basic_10k_20m() {} } diff --git a/fullstack-examples/src/fullStackTest/java/module-info.java b/fullstack-examples/src/fullstack/java/module-info.java similarity index 88% rename from fullstack-examples/src/fullStackTest/java/module-info.java rename to fullstack-examples/src/fullstack/java/module-info.java index afe8cd302..be2263a77 100644 --- a/fullstack-examples/src/fullStackTest/java/module-info.java +++ b/fullstack-examples/src/fullstack/java/module-info.java @@ -7,5 +7,6 @@ requires com.hedera.fullstack.examples; requires com.hedera.fullstack.junit.support; + requires com.hedera.fullstack.test.toolkit; requires org.junit.jupiter.api; } diff --git a/fullstack-examples/src/main/java/com/hedera/fullstack/examples/monitors/LogErrorMonitor.java b/fullstack-examples/src/main/java/com/hedera/fullstack/examples/monitors/LogMonitor.java similarity index 94% rename from fullstack-examples/src/main/java/com/hedera/fullstack/examples/monitors/LogErrorMonitor.java rename to fullstack-examples/src/main/java/com/hedera/fullstack/examples/monitors/LogMonitor.java index 7ef6e027e..27210db01 100644 --- a/fullstack-examples/src/main/java/com/hedera/fullstack/examples/monitors/LogErrorMonitor.java +++ b/fullstack-examples/src/main/java/com/hedera/fullstack/examples/monitors/LogMonitor.java @@ -19,7 +19,7 @@ import com.hedera.fullstack.monitoring.api.CheckOutcome; import com.hedera.fullstack.monitoring.api.Monitor; -public class LogErrorMonitor implements Monitor { +public class LogMonitor implements Monitor { @Override public CheckOutcome check() { return CheckOutcome.SUCCESS; diff --git a/fullstack-examples/src/main/java/com/hedera/fullstack/examples/readiness/NodeActiveReadinessCheck.java b/fullstack-examples/src/main/java/com/hedera/fullstack/examples/readiness/NodeActiveReadinessCheck.java index 92f120703..cec4e4f71 100644 --- a/fullstack-examples/src/main/java/com/hedera/fullstack/examples/readiness/NodeActiveReadinessCheck.java +++ b/fullstack-examples/src/main/java/com/hedera/fullstack/examples/readiness/NodeActiveReadinessCheck.java @@ -17,11 +17,12 @@ package com.hedera.fullstack.examples.readiness; import com.hedera.fullstack.readiness.api.ReadinessCheck; +import com.hedera.fullstack.test.toolkit.api.model.infrastructure.Deployment; public class NodeActiveReadinessCheck implements ReadinessCheck { @Override - public boolean ready() { + public boolean ready(final Deployment deployment) { return true; } } diff --git a/fullstack-examples/src/main/java/com/hedera/fullstack/examples/validators/InvalidStateSignatureValidator.java b/fullstack-examples/src/main/java/com/hedera/fullstack/examples/validators/InvalidStateSignatureValidator.java new file mode 100644 index 000000000..dbed50867 --- /dev/null +++ b/fullstack-examples/src/main/java/com/hedera/fullstack/examples/validators/InvalidStateSignatureValidator.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.examples.validators; + +import com.hedera.fullstack.validator.api.ValidationContext; +import com.hedera.fullstack.validator.api.ValidationResult; +import com.hedera.fullstack.validator.api.Validator; +import java.util.concurrent.Future; + +public class InvalidStateSignatureValidator implements Validator { + /** + * @param context + * @return + */ + @Override + public Future validate(ValidationContext context) { + return null; + } +} diff --git a/fullstack-examples/src/main/java/com/hedera/fullstack/examples/validators/PlatformStatusValidator.java b/fullstack-examples/src/main/java/com/hedera/fullstack/examples/validators/PlatformStatusValidator.java new file mode 100644 index 000000000..c5dfdebe2 --- /dev/null +++ b/fullstack-examples/src/main/java/com/hedera/fullstack/examples/validators/PlatformStatusValidator.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.examples.validators; + +import com.hedera.fullstack.validator.api.ValidationContext; +import com.hedera.fullstack.validator.api.ValidationResult; +import com.hedera.fullstack.validator.api.Validator; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Future; + +public class PlatformStatusValidator implements Validator { + + private PlatformStatusValidator() {} + + public static Builder builder() { + return new Builder(); + } + + @Override + public Future validate(ValidationContext context) { + return CompletableFuture.completedFuture(null); + } + + public static class Builder { + private Builder() {} + + public PlatformStatusValidator build() { + return new PlatformStatusValidator(); + } + + public Builder nodeId(String nodeId) { + return this; + } + + public Builder steps(String... targetStatuses) { + return this; + } + } +} diff --git a/fullstack-examples/src/main/java/module-info.java b/fullstack-examples/src/main/java/module-info.java index da2ebeab9..1a1e7338c 100644 --- a/fullstack-examples/src/main/java/module-info.java +++ b/fullstack-examples/src/main/java/module-info.java @@ -5,5 +5,6 @@ requires com.hedera.fullstack.readiness.api; requires com.hedera.fullstack.monitoring.api; + requires com.hedera.fullstack.test.toolkit; requires com.hedera.fullstack.validator.api; } diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/ConfigurationValue.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/ConfigurationValue.java index 1920f9986..cb62594a6 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/ConfigurationValue.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/ConfigurationValue.java @@ -20,7 +20,8 @@ /** * Represents a generic configuration value which comprises a key and value pair. This annotation may only be used - * in conjunction with other annotations and may not be directly applied to test classes or methods. + * in conjunction with other annotations and may not be directly applied to test classes or methods. Either the + * {@link #value()} or {@link #values()} must be specified but not both. */ @Inherited @Documented @@ -36,8 +37,17 @@ /** * The value of the specified configuration key/name. Depending on the context, the value format may vary. + * Mutually exclusive with {@link #values()}. * * @return the value of the specified configuration key/name. */ - String value(); + String value() default ""; + + /** + * The values of the specified configuration key/name. Depending on the context, the value format may vary. + * Mutually exclusive with {@link #value()}. + * + * @return the values of the specified configuration key/name. + */ + String[] values() default {}; } diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/FullStackSuite.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/FullStackSuite.java index 052c05b72..4394815f8 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/FullStackSuite.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/FullStackSuite.java @@ -58,6 +58,34 @@ * Please see the {@link ProvisioningModel} documentation for more information. * * @return the provisioning model to be used for the test suite. + * @see ProvisioningModel */ ProvisioningModel provisioningModel() default ProvisioningModel.CLEAN_ENV_PER_TEST; + + /** + * The Full Stack test execution framework for the node software. The default value is + * {@link TestExecutorType#JAVA_DIRECT}. + * + *

+ * Full Stack tests support two execution frameworks: + *

    + *
  • {@link TestExecutorType#JAVA_DIRECT}
  • + *
  • {@link TestExecutorType#NODE_MGMT_TOOLS}
  • + *
+ * + *

+ * The {@link TestExecutorType#JAVA_DIRECT} framework executes the node software using the {@code ubi8-init-java17} + * docker container image. The {@code ubi8-init-java17} image is built from the {@code ubi8-init} image and + * includes the Java 17 JDK. Tests using this framework are executed directly in the container using the embedded + * Java 17 JDK. Node Management Tools are not available when using this framework and are not used for any of the + * provisioning, configuration, or monitoring operations. + * + *

+ * The {@link TestExecutorType#NODE_MGMT_TOOLS} framework executes the node software using the {@code ubi8-init-dind} + * docker container image. The {@code ubi8-init-dind} image is built from the {@code ubi8-init} image and includes + * the Docker daemon. Tests using this framework are provisioned and executed via the Node Management Tools. + * + * @return the execution framework used by this test. + */ + TestExecutorType executor() default TestExecutorType.JAVA_DIRECT; } diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/FullStackTest.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/FullStackTest.java index b2d72d9f3..a905c8414 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/FullStackTest.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/FullStackTest.java @@ -66,31 +66,4 @@ * @see TestExecutionMode */ TestExecutionMode mode() default TestExecutionMode.DEFAULT; - - /** - * The Full Stack test execution framework for the node software. The default value is - * {@link TestExecutorType#JAVA_DIRECT}. - * - *

- * Full Stack tests support two execution frameworks: - *

    - *
  • {@link TestExecutorType#JAVA_DIRECT}
  • - *
  • {@link TestExecutorType#NODE_MGMT_TOOLS}
  • - *
- * - *

- * The {@link TestExecutorType#JAVA_DIRECT} framework executes the node software using the {@code ubi8-init-java17} - * docker container image. The {@code ubi8-init-java17} image is built from the {@code ubi8-init} image and - * includes the Java 17 JDK. Tests using this framework are executed directly in the container using the embedded - * Java 17 JDK. Node Management Tools are not available when using this framework and are not used for any of the - * provisioning, configuration, or monitoring operations. - * - *

- * The {@link TestExecutorType#NODE_MGMT_TOOLS} framework executes the node software using the {@code ubi8-init-dind} - * docker container image. The {@code ubi8-init-dind} image is built from the {@code ubi8-init} image and includes - * the Docker daemon. Tests using this framework are provisioned and executed via the Node Management Tools. - * - * @return the execution framework used by this test. - */ - TestExecutorType executor() default TestExecutorType.JAVA_DIRECT; } diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/ParameterizedFullStackTest.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/ParameterizedFullStackTest.java index 15dfb5d53..23f020b31 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/ParameterizedFullStackTest.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/core/ParameterizedFullStackTest.java @@ -40,13 +40,4 @@ * @return the execution flow used by this test. */ TestExecutionMode mode() default TestExecutionMode.DEFAULT; - - /** - * Please see the documentation for {@link FullStackTest#executor()} for a description of the supported execution - * frameworks. - * - * @see FullStackTest#executor() - * @return the execution framework used by this test. - */ - TestExecutorType executor() default TestExecutorType.JAVA_DIRECT; } diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/EnvoyProxy.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/EnvoyProxy.java index 57b5cce67..282a8cf7c 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/EnvoyProxy.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/EnvoyProxy.java @@ -26,4 +26,12 @@ @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) -public @interface EnvoyProxy {} +public @interface EnvoyProxy { + /** + * The number of Envoy Proxy servers to deploy. Defaults to 1 if not specified. The value provided must be greater + * than or equal to 1 and less than or equal to the total number of application nodes in the deployment. + * + * @return the number of Envoy Proxy servers to deploy. + */ + int value() default 1; +} diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/HttpProxy.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/HttpProxy.java index 31c20a4cf..75f0bcd03 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/HttpProxy.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/HttpProxy.java @@ -26,4 +26,12 @@ @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) -public @interface HttpProxy {} +public @interface HttpProxy { + /** + * The number of HAProxy servers to deploy. Defaults to 1 if not specified. The value provided must be greater + * than or equal to 1 and less than or equal to the total number of application nodes in the deployment. + * + * @return the number of HAProxy servers to deploy. + */ + int value() default 1; +} diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/HashIO.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/JsonRpcRelay.java similarity index 68% rename from fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/HashIO.java rename to fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/JsonRpcRelay.java index b5b56b7a9..331111eec 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/HashIO.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/JsonRpcRelay.java @@ -19,11 +19,19 @@ import java.lang.annotation.*; /** - * Indicates that the annotated test class or test method requires an HashIO server to be deployed and running. This + * Indicates that the annotated test class or test method requires an JsonRpcRelay server to be deployed and running. This * annotation also implicitly specifies the {@link MirrorNode} annotation. */ @Inherited @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) -public @interface HashIO {} +public @interface JsonRpcRelay { + /** + * The number of JSON RPC Relay servers to deploy. Defaults to 1 if not specified. The value provided must be greater + * than or equal to 1 and less than or equal to the total number of application nodes in the deployment. + * + * @return the number of JSON RPC Relay servers to deploy. + */ + int value() default 1; +} diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/MirrorNode.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/MirrorNode.java index 85aca3a93..7600c0850 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/MirrorNode.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/MirrorNode.java @@ -19,7 +19,8 @@ import java.lang.annotation.*; /** - * Indicates that the annotated test class or test method requires a mirror node to be deployed and running. + * Indicates that the annotated test class or test method requires a mirror node to be deployed and running. Only one + * Mirror Node per deployment is supported. */ @Inherited @Documented diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/HashScan.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/MirrorNodeExplorer.java similarity index 87% rename from fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/HashScan.java rename to fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/MirrorNodeExplorer.java index 9d1a88a0d..2e912dc2d 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/HashScan.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/services/MirrorNodeExplorer.java @@ -19,11 +19,12 @@ import java.lang.annotation.*; /** - * Indicates that the annotated test class or test method requires a HashScan server (Hedera Mirror Node Explorer) + * Indicates that the annotated test class or test method requires a Hedera Mirror Node Explorer server * to be deployed and running. This annotation also implicitly specifies the {@link MirrorNode} annotation. + * Only one Mirror Node Explorer per deployment is supported. */ @Inherited @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) -public @interface HashScan {} +public @interface MirrorNodeExplorer {} diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/Monitors.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/Monitors.java index 443315b6c..5655e9a11 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/Monitors.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/Monitors.java @@ -16,6 +16,7 @@ package com.hedera.fullstack.junit.support.annotations.validation; +import com.hedera.fullstack.junit.support.annotations.core.ConfigurationValue; import com.hedera.fullstack.junit.support.annotations.flow.SuppressMonitors; import com.hedera.fullstack.monitoring.api.Monitor; import java.lang.annotation.*; @@ -41,4 +42,11 @@ * @return an array of {@link Monitor} implementations. */ Class[] value(); + + /** + * An array of optional configuration key and value pairs to be passed to the {@link Monitor} implementations. + * + * @return an array of {@link ConfigurationValue} annotations. + */ + ConfigurationValue[] config() default {}; } diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/ReadinessChecks.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/ReadinessChecks.java index cb9f30df9..0b6cea345 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/ReadinessChecks.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/ReadinessChecks.java @@ -16,6 +16,7 @@ package com.hedera.fullstack.junit.support.annotations.validation; +import com.hedera.fullstack.junit.support.annotations.core.ConfigurationValue; import com.hedera.fullstack.junit.support.annotations.flow.SuppressReadinessChecks; import com.hedera.fullstack.readiness.api.ReadinessCheck; import java.lang.annotation.*; @@ -42,4 +43,11 @@ * @return an array of {@link ReadinessCheck} implementations. */ Class[] value(); + + /** + * An array of optional configuration key and value pairs to be passed to the {@link ReadinessCheck} implementations. + * + * @return an array of {@link ConfigurationValue} annotations. + */ + ConfigurationValue[] config() default {}; } diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/Validators.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/Validators.java index 97c3c6270..6522400d3 100644 --- a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/Validators.java +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/annotations/validation/Validators.java @@ -16,6 +16,7 @@ package com.hedera.fullstack.junit.support.annotations.validation; +import com.hedera.fullstack.junit.support.annotations.core.ConfigurationValue; import com.hedera.fullstack.junit.support.annotations.flow.SuppressValidators; import com.hedera.fullstack.validator.api.Validator; import java.lang.annotation.*; @@ -42,4 +43,11 @@ * @return an array of {@link Validator} implementations. */ Class[] value(); + + /** + * An array of optional configuration key and value pairs to be passed to the {@link Validator} implementations. + * + * @return an array of {@link ConfigurationValue} annotations. + */ + ConfigurationValue[] config() default {}; } diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/CheckMutator.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/CheckMutator.java new file mode 100644 index 000000000..753691191 --- /dev/null +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/CheckMutator.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.junit.support.mutators.core; + +public interface CheckMutator { + + CheckMutator add(T check); + + CheckMutator remove(Class checkType); + + ConfigurationMutator> configure(); + + P and(); +} diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/ConfigurationMutator.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/ConfigurationMutator.java new file mode 100644 index 000000000..689221a52 --- /dev/null +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/ConfigurationMutator.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.junit.support.mutators.core; + +public interface ConfigurationMutator

{ + + ConfigurationMutator

add(String key, String value); + + ConfigurationMutator

add(String key, String... values); + + ConfigurationMutator

remove(String key); + + P and(); +} diff --git a/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/TestMutator.java b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/TestMutator.java new file mode 100644 index 000000000..c1e13b7ff --- /dev/null +++ b/fullstack-junit-support/src/main/java/com/hedera/fullstack/junit/support/mutators/core/TestMutator.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.junit.support.mutators.core; + +import com.hedera.fullstack.monitoring.api.Monitor; +import com.hedera.fullstack.readiness.api.ReadinessCheck; +import com.hedera.fullstack.test.toolkit.api.model.infrastructure.ApplicationNode; +import com.hedera.fullstack.validator.api.Validator; + +public interface TestMutator { + + CheckMutator validators(); + + CheckMutator validators(ApplicationNode node); + + CheckMutator monitors(); + + CheckMutator monitors(ApplicationNode node); + + CheckMutator readinessChecks(); + + CheckMutator readinessChecks(ApplicationNode node); +} diff --git a/fullstack-junit-support/src/main/java/module-info.java b/fullstack-junit-support/src/main/java/module-info.java index 8e130a5ed..4b3226758 100644 --- a/fullstack-junit-support/src/main/java/module-info.java +++ b/fullstack-junit-support/src/main/java/module-info.java @@ -7,6 +7,7 @@ exports com.hedera.fullstack.junit.support.annotations.services; exports com.hedera.fullstack.junit.support.annotations.validation; exports com.hedera.fullstack.junit.support.events.application; + exports com.hedera.fullstack.junit.support.mutators.core; // Targeted Exports exports com.hedera.fullstack.junit.support.extensions to @@ -17,6 +18,7 @@ requires transitive com.hedera.fullstack.validator.api; requires transitive com.hedera.fullstack.monitoring.api; requires transitive com.hedera.fullstack.readiness.api; + requires transitive com.hedera.fullstack.test.toolkit; requires transitive org.junit.jupiter.api; requires transitive org.junit.jupiter.params; diff --git a/fullstack-monitoring-api/src/main/java/com/hedera/fullstack/monitoring/api/Monitor.java b/fullstack-monitoring-api/src/main/java/com/hedera/fullstack/monitoring/api/Monitor.java index a47304b6d..325b028f4 100644 --- a/fullstack-monitoring-api/src/main/java/com/hedera/fullstack/monitoring/api/Monitor.java +++ b/fullstack-monitoring-api/src/main/java/com/hedera/fullstack/monitoring/api/Monitor.java @@ -16,6 +16,8 @@ package com.hedera.fullstack.monitoring.api; +import com.hedera.fullstack.test.toolkit.api.model.infrastructure.ApplicationNode; +import com.hedera.fullstack.test.toolkit.api.model.infrastructure.Node; import java.time.Duration; @FunctionalInterface @@ -28,4 +30,8 @@ public interface Monitor { default Duration checkInterval() { return DEFAULT_CHECK_INTERVAL; } + + default boolean appliesTo(Class> nodeClass) { + return ApplicationNode.class.isAssignableFrom(nodeClass); + } } diff --git a/fullstack-monitoring-api/src/main/java/module-info.java b/fullstack-monitoring-api/src/main/java/module-info.java index f8671b8d5..dd2c90f93 100644 --- a/fullstack-monitoring-api/src/main/java/module-info.java +++ b/fullstack-monitoring-api/src/main/java/module-info.java @@ -1,3 +1,5 @@ module com.hedera.fullstack.monitoring.api { exports com.hedera.fullstack.monitoring.api; + + requires com.hedera.fullstack.test.toolkit; } diff --git a/fullstack-readiness-api/src/main/java/com/hedera/fullstack/readiness/api/ReadinessCheck.java b/fullstack-readiness-api/src/main/java/com/hedera/fullstack/readiness/api/ReadinessCheck.java index 8b37e9542..8e93baf2c 100644 --- a/fullstack-readiness-api/src/main/java/com/hedera/fullstack/readiness/api/ReadinessCheck.java +++ b/fullstack-readiness-api/src/main/java/com/hedera/fullstack/readiness/api/ReadinessCheck.java @@ -16,6 +16,9 @@ package com.hedera.fullstack.readiness.api; +import com.hedera.fullstack.test.toolkit.api.model.infrastructure.ApplicationNode; +import com.hedera.fullstack.test.toolkit.api.model.infrastructure.Deployment; +import com.hedera.fullstack.test.toolkit.api.model.infrastructure.Node; import java.time.Duration; @FunctionalInterface @@ -23,7 +26,7 @@ public interface ReadinessCheck { Duration DEFAULT_CHECK_INTERVAL = Duration.ofSeconds(1); Duration DEFAULT_CHECK_TIMEOUT = Duration.ofSeconds(60); - boolean ready(); + boolean ready(Deployment deployment); default Duration checkInterval() { return DEFAULT_CHECK_INTERVAL; @@ -32,4 +35,8 @@ default Duration checkInterval() { default Duration checkTimeout() { return DEFAULT_CHECK_TIMEOUT; } + + default boolean appliesTo(Class> nodeClass) { + return ApplicationNode.class.isAssignableFrom(nodeClass); + } } diff --git a/fullstack-readiness-api/src/main/java/module-info.java b/fullstack-readiness-api/src/main/java/module-info.java index 0d7dd0791..d778bd14b 100644 --- a/fullstack-readiness-api/src/main/java/module-info.java +++ b/fullstack-readiness-api/src/main/java/module-info.java @@ -1,3 +1,5 @@ module com.hedera.fullstack.readiness.api { exports com.hedera.fullstack.readiness.api; + + requires com.hedera.fullstack.test.toolkit; } diff --git a/fullstack-test-toolkit-api/src/main/java/module-info.java b/fullstack-test-toolkit-api/src/main/java/module-info.java deleted file mode 100644 index 0fe696c7a..000000000 --- a/fullstack-test-toolkit-api/src/main/java/module-info.java +++ /dev/null @@ -1 +0,0 @@ -module com.hedera.fullstack.test.toolkit.api {} diff --git a/fullstack-test-toolkit-api/src/test/java/module-info.java b/fullstack-test-toolkit-api/src/test/java/module-info.java deleted file mode 100644 index 4c8ba242b..000000000 --- a/fullstack-test-toolkit-api/src/test/java/module-info.java +++ /dev/null @@ -1 +0,0 @@ -module com.hedera.fullstack.test.toolkit.api.test {} diff --git a/fullstack-test-toolkit-api/build.gradle.kts b/fullstack-test-toolkit-core/build.gradle.kts similarity index 100% rename from fullstack-test-toolkit-api/build.gradle.kts rename to fullstack-test-toolkit-core/build.gradle.kts diff --git a/fullstack-test-toolkit-api/gradle.properties b/fullstack-test-toolkit-core/gradle.properties similarity index 100% rename from fullstack-test-toolkit-api/gradle.properties rename to fullstack-test-toolkit-core/gradle.properties diff --git a/fullstack-test-toolkit-api/src/main/java/com/hedera/fullstack/test/toolkit/api/Dummy.java b/fullstack-test-toolkit-core/src/main/java/com/hedera/fullstack/test/toolkit/core/Dummy.java similarity index 92% rename from fullstack-test-toolkit-api/src/main/java/com/hedera/fullstack/test/toolkit/api/Dummy.java rename to fullstack-test-toolkit-core/src/main/java/com/hedera/fullstack/test/toolkit/core/Dummy.java index 584bceffe..d826a5ff0 100644 --- a/fullstack-test-toolkit-api/src/main/java/com/hedera/fullstack/test/toolkit/api/Dummy.java +++ b/fullstack-test-toolkit-core/src/main/java/com/hedera/fullstack/test/toolkit/core/Dummy.java @@ -14,6 +14,6 @@ * limitations under the License. */ -package com.hedera.fullstack.test.toolkit.api; +package com.hedera.fullstack.test.toolkit.core; public class Dummy {} diff --git a/fullstack-test-toolkit-core/src/main/java/com/hedera/fullstack/test/toolkit/core/package-info.java b/fullstack-test-toolkit-core/src/main/java/com/hedera/fullstack/test/toolkit/core/package-info.java new file mode 100644 index 000000000..2494d6a3c --- /dev/null +++ b/fullstack-test-toolkit-core/src/main/java/com/hedera/fullstack/test/toolkit/core/package-info.java @@ -0,0 +1 @@ +package com.hedera.fullstack.test.toolkit.core; diff --git a/fullstack-test-toolkit-core/src/main/java/module-info.java b/fullstack-test-toolkit-core/src/main/java/module-info.java new file mode 100644 index 000000000..94a579ad3 --- /dev/null +++ b/fullstack-test-toolkit-core/src/main/java/module-info.java @@ -0,0 +1 @@ +module com.hedera.fullstack.test.toolkit.core {} diff --git a/fullstack-test-toolkit-core/src/test/java/module-info.java b/fullstack-test-toolkit-core/src/test/java/module-info.java new file mode 100644 index 000000000..a80cd1a94 --- /dev/null +++ b/fullstack-test-toolkit-core/src/test/java/module-info.java @@ -0,0 +1 @@ +module com.hedera.fullstack.test.toolkit.core.test {} diff --git a/fullstack-test-toolkit/build.gradle.kts b/fullstack-test-toolkit/build.gradle.kts new file mode 100644 index 000000000..557cccaaf --- /dev/null +++ b/fullstack-test-toolkit/build.gradle.kts @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("com.hedera.fullstack.conventions") + id("com.hedera.fullstack.jpms-modules") + // id("com.hedera.fullstack.maven-publish") +} + +dependencies { api(platform(project(":fullstack-bom"))) } diff --git a/fullstack-test-toolkit/gradle.properties b/fullstack-test-toolkit/gradle.properties new file mode 100644 index 000000000..cc7fe5a37 --- /dev/null +++ b/fullstack-test-toolkit/gradle.properties @@ -0,0 +1,18 @@ +# +# Copyright (C) 2023 Hedera Hashgraph, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +mavenPublishingEnabled = false + diff --git a/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/ApplicationNode.java b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/ApplicationNode.java new file mode 100644 index 000000000..c9556ff75 --- /dev/null +++ b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/ApplicationNode.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.test.toolkit.api.model.infrastructure; + +import com.hedera.fullstack.test.toolkit.api.model.traits.Indexed; + +public non-sealed interface ApplicationNode extends Indexed, Node {} diff --git a/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/Deployment.java b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/Deployment.java new file mode 100644 index 000000000..1126d733f --- /dev/null +++ b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/Deployment.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.test.toolkit.api.model.infrastructure; + +import com.hedera.fullstack.test.toolkit.api.model.traits.Named; + +public interface Deployment extends Named { + NodeSet nodes(); + + NodeSet relayNodes(); + + MirrorNode mirrorNode(); +} diff --git a/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/MirrorNode.java b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/MirrorNode.java new file mode 100644 index 000000000..4860ea823 --- /dev/null +++ b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/MirrorNode.java @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.test.toolkit.api.model.infrastructure; + +public non-sealed interface MirrorNode extends Node {} diff --git a/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/Node.java b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/Node.java new file mode 100644 index 000000000..6e8184fd2 --- /dev/null +++ b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/Node.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.test.toolkit.api.model.infrastructure; + +import com.hedera.fullstack.test.toolkit.api.model.traits.Named; +import com.hedera.fullstack.test.toolkit.api.model.traits.Tagged; + +public sealed interface Node extends Named, Tagged, Comparable permits ApplicationNode, MirrorNode, RelayNode {} diff --git a/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/NodeSet.java b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/NodeSet.java new file mode 100644 index 000000000..6e49c6727 --- /dev/null +++ b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/NodeSet.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.test.toolkit.api.model.infrastructure; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +/** + * An ordered, indexed set of {@link Node} instances. + * + * @implSpec Implementations are required to support both iteration and indexed access. + */ +public interface NodeSet> extends Iterable { + + Optional first(); + + Optional last(); + + List withTag(String tag); + + T named(String name); + + T indexOf(int index); + + int size(); + + boolean isEmpty(); + + default Stream stream() { + return StreamSupport.stream(spliterator(), false); + } +} diff --git a/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/RelayNode.java b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/RelayNode.java new file mode 100644 index 000000000..46b02a350 --- /dev/null +++ b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/infrastructure/RelayNode.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.test.toolkit.api.model.infrastructure; + +import com.hedera.fullstack.test.toolkit.api.model.traits.Indexed; + +public non-sealed interface RelayNode extends Indexed, Node {} diff --git a/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Indexed.java b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Indexed.java new file mode 100644 index 000000000..23215a2b5 --- /dev/null +++ b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Indexed.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.test.toolkit.api.model.traits; + +/** + * A trait for objects that have an index and are aware of their own index. + */ +public interface Indexed { + /** + * The well-known index of this object instance. + * + * @return the known index. + */ + int index(); +} diff --git a/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Named.java b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Named.java new file mode 100644 index 000000000..9a660791a --- /dev/null +++ b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Named.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.test.toolkit.api.model.traits; + +/** + * A trait for objects that have a name and are aware of their own name. + */ +public interface Named { + /** + * The well-known name of this object instance. + * + * @return the known name. + */ + String name(); +} diff --git a/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Tagged.java b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Tagged.java new file mode 100644 index 000000000..02cd2014b --- /dev/null +++ b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/model/traits/Tagged.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.fullstack.test.toolkit.api.model.traits; + +import java.util.List; + +/** + * A trait for objects that have tags and are aware of their own tags. + */ +public interface Tagged { + /** + * The well-known tags of this object instance. + * + * @return the known tags. + */ + List tags(); +} diff --git a/fullstack-test-toolkit-api/src/main/java/com/hedera/fullstack/test/toolkit/api/package-info.java b/fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/package-info.java similarity index 100% rename from fullstack-test-toolkit-api/src/main/java/com/hedera/fullstack/test/toolkit/api/package-info.java rename to fullstack-test-toolkit/src/main/java/com/hedera/fullstack/test/toolkit/api/package-info.java diff --git a/fullstack-test-toolkit/src/main/java/module-info.java b/fullstack-test-toolkit/src/main/java/module-info.java new file mode 100644 index 000000000..28290e416 --- /dev/null +++ b/fullstack-test-toolkit/src/main/java/module-info.java @@ -0,0 +1,3 @@ +module com.hedera.fullstack.test.toolkit { + exports com.hedera.fullstack.test.toolkit.api.model.infrastructure; +} diff --git a/fullstack-test-toolkit/src/test/java/module-info.java b/fullstack-test-toolkit/src/test/java/module-info.java new file mode 100644 index 000000000..5fdd26469 --- /dev/null +++ b/fullstack-test-toolkit/src/test/java/module-info.java @@ -0,0 +1 @@ +module com.hedera.fullstack.test.toolkit.test {} diff --git a/fullstack-validator-api/src/main/java/com/hedera/fullstack/validator/api/Validator.java b/fullstack-validator-api/src/main/java/com/hedera/fullstack/validator/api/Validator.java index 4576cf20e..9e4f7703a 100644 --- a/fullstack-validator-api/src/main/java/com/hedera/fullstack/validator/api/Validator.java +++ b/fullstack-validator-api/src/main/java/com/hedera/fullstack/validator/api/Validator.java @@ -16,6 +16,8 @@ package com.hedera.fullstack.validator.api; +import com.hedera.fullstack.test.toolkit.api.model.infrastructure.ApplicationNode; +import com.hedera.fullstack.test.toolkit.api.model.infrastructure.Node; import java.util.concurrent.Future; /** @@ -23,6 +25,10 @@ */ @FunctionalInterface public interface Validator { + default boolean appliesTo(Class> nodeClass) { + return ApplicationNode.class.isAssignableFrom(nodeClass); + } + /** * * @param context diff --git a/fullstack-validator-api/src/main/java/module-info.java b/fullstack-validator-api/src/main/java/module-info.java index 571b4ee18..5724f4d08 100644 --- a/fullstack-validator-api/src/main/java/module-info.java +++ b/fullstack-validator-api/src/main/java/module-info.java @@ -4,5 +4,7 @@ exports com.hedera.fullstack.validator.api; exports com.hedera.fullstack.validator.api.annotations; + requires com.hedera.fullstack.test.toolkit; + uses Validator; } diff --git a/settings.gradle.kts b/settings.gradle.kts index ffc5a98b3..07befff7a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -69,7 +69,9 @@ include(":fullstack-resource-generator-core") include(":fullstack-service-locator") -include(":fullstack-test-toolkit-api") +include(":fullstack-test-toolkit") + +include(":fullstack-test-toolkit-core") include(":fullstack-validator-api")