Skip to content

Commit

Permalink
chore: add test mocks and boiler plate items for test toolkit (#343)
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Klick <nathan@swirldslabs.com>
  • Loading branch information
nathanklick committed Sep 14, 2023
1 parent b7e15a3 commit 208cf55
Show file tree
Hide file tree
Showing 57 changed files with 657 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions fullstack-base-api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions fullstack-examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ 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")) }
}
}
}

tasks.assemble.configure { dependsOn(tasks.named("fullStackTestClasses")) }
tasks.assemble.configure { dependsOn(tasks.named("fullstackClasses")) }
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Arguments> testScalingBasicSignatures() {
return Stream.of(Arguments.of(Named.of("5k TPS", 5000)), Arguments.of(Named.of("10k TPS", 10000)));
Expand All @@ -62,5 +72,5 @@ static Stream<Arguments> testScalingBasicSignatures() {
@DisplayName("SSTT: Scaling Basic Signatures - 4 Nodes")
@ApplicationNodes(6)
@MethodSource
void testScalingBasicSignatures(int tps) {}
void testScalingBasicSignatures(int tps, TestMutator tm) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,15 +36,22 @@
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;

@FullStackSuite
@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"),
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<ValidationResult> validate(ValidationContext context) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -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<ValidationResult> 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;
}
}
}
1 change: 1 addition & 0 deletions fullstack-examples/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {};
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
*
* <p>
* Full Stack tests support two execution frameworks:
* <ul>
* <li>{@link TestExecutorType#JAVA_DIRECT}</li>
* <li>{@link TestExecutorType#NODE_MGMT_TOOLS}</li>
* </ul>
*
* <p>
* 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.
*
* <p>
* 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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
*
* <p>
* Full Stack tests support two execution frameworks:
* <ul>
* <li>{@link TestExecutorType#JAVA_DIRECT}</li>
* <li>{@link TestExecutorType#NODE_MGMT_TOOLS}</li>
* </ul>
*
* <p>
* 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.
*
* <p>
* 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;
}
Loading

0 comments on commit 208cf55

Please sign in to comment.