Skip to content

Commit

Permalink
feat: create mock junit annotations (#104)
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Klick <[email protected]>
  • Loading branch information
nathanklick authored Aug 13, 2023
1 parent cd0e331 commit 752b2df
Show file tree
Hide file tree
Showing 64 changed files with 1,863 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ plugins {

javaModuleDependencies {
versionsFromConsistentResolution(":fullstack-helm-client")

moduleNameToGA.put("com.hedera.fullstack.junit.support", "com.hedera.fullstack:fullstack-junit-support")
}

extraJavaModuleInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
* limitations under the License.
*/

package com.hedera.fullstack.junit.support.annotations;
package com.hedera.fullstack.base.api.units;

import java.lang.annotation.*;

@Inherited
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface EnableHashIO {}
public enum StorageUnits {
BYTES,
KILOBYTES,
MEGABYTES,
GIGABYTES,
TERABYTES,
PETABYTES,
EXABYTES
}
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
Expand Up @@ -5,5 +5,6 @@
exports com.hedera.fullstack.base.api.reflect;
exports com.hedera.fullstack.base.api.resource;
exports com.hedera.fullstack.base.api.util;
exports com.hedera.fullstack.base.api.units;
exports com.hedera.fullstack.base.api.version;
}
13 changes: 13 additions & 0 deletions fullstack-examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,16 @@
plugins { id("com.hedera.fullstack.conventions") }

dependencies { api(platform(project(":fullstack-bom"))) }

testing {
suites {
@Suppress("UnstableApiUsage", "unused")
val fullStackTest by
registering(JvmTestSuite::class) {
useJUnitJupiter()
dependencies { implementation(project(":fullstack-examples")) }
}
}
}

tasks.assemble.configure { dependsOn(tasks.named("fullStackTestClasses")) }
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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.signing;

import com.hedera.fullstack.examples.monitors.InvalidStateSignatureMonitor;
import com.hedera.fullstack.examples.monitors.LogErrorMonitor;
import com.hedera.fullstack.examples.monitors.NodeLivenessMonitor;
import com.hedera.fullstack.examples.readiness.NodeActiveReadinessCheck;
import com.hedera.fullstack.examples.validators.NodeStatisticHealthValidator;
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;
import com.hedera.fullstack.junit.support.annotations.core.ConfigurationValue;
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.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.annotations.validation.Monitors;
import com.hedera.fullstack.junit.support.annotations.validation.ReadinessChecks;
import com.hedera.fullstack.junit.support.annotations.validation.Validators;
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})
@PlatformConfiguration({
@ConfigurationValue(name = "state.dumpStateOnAnyISS", value = "false"),
@ConfigurationValue(name = "state.automatedSelfIssRecovery", value = "true"),
@ConfigurationValue(name = "state.haltOnCatastrophicIss", value = "true"),
@ConfigurationValue(name = "event.preconsensus.enableReplay", value = "false"),
@ConfigurationValue(name = "event.preconsensus.enableStorage", value = "false")
})
@DisplayName("Invalid State Signature Testing Tool")
class InvalidStateSignatureTest {

@FullStackTest(mode = TestExecutionMode.TIMED_EXECUTION)
@WaitForDuration(value = 5, unit = TimeUnit.MINUTES)
@MaxTestExecutionTime(value = 15, unit = TimeUnit.MINUTES)
@PlatformConfiguration({
@ConfigurationValue(name = "issTestingTool.plannedISSs", value = "180:0-1-2-3"),
})
@DisplayName("ISS-catastrophic-1k-5m")
void catastrophic_1k_5m() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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.signing;

import com.hedera.fullstack.base.api.units.StorageUnits;
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.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.flow.MaxTestExecutionTime;
import com.hedera.fullstack.junit.support.annotations.resource.ResourceShape;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Named;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

@FullStackSuite
public class PlatformSignatureVerificationTest {

@FullStackTest
void testBasicCase() {}

@FullStackTest
@ApplicationNodes(
value = 4,
shape = @ResourceShape(cpuInMillis = 10_000, memorySize = 64, memoryUnits = StorageUnits.GIGABYTES))
@DisplayName("SSTT: Basic Signatures - Mixed Algorithms - 4 Nodes - 10k TPS")
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))
})
void testQuickBasicSignatures() {}

static Stream<Arguments> testScalingBasicSignatures() {
return Stream.of(Arguments.of(Named.of("5k TPS", 5000)), Arguments.of(Named.of("10k TPS", 10000)));
}

@ParameterizedFullStackTest
@DisplayName("SSTT: Scaling Basic Signatures - 4 Nodes")
@ApplicationNodes(6)
@MethodSource
void testScalingBasicSignatures(int tps) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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.signing;

import com.hedera.fullstack.examples.monitors.InvalidStateSignatureMonitor;
import com.hedera.fullstack.examples.monitors.LogErrorMonitor;
import com.hedera.fullstack.examples.monitors.NodeLivenessMonitor;
import com.hedera.fullstack.examples.readiness.NodeActiveReadinessCheck;
import com.hedera.fullstack.examples.validators.NodeStatisticHealthValidator;
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.core.FullStackSuite;
import com.hedera.fullstack.junit.support.annotations.core.FullStackTest;
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.annotations.validation.Monitors;
import com.hedera.fullstack.junit.support.annotations.validation.ReadinessChecks;
import com.hedera.fullstack.junit.support.annotations.validation.Validators;
import org.junit.jupiter.api.DisplayName;

@FullStackSuite
@DisplayName("Stats Signing Testing Tool")
class StatsSigningTest {

/**
* Replaces the existing {@code Crypto-Basic-10k-4N} test.
* This test will run the StatsSigningTestingTool.jar at 10k TPS for 20 minutes.
*/
@FullStackTest(mode = TestExecutionMode.TIMED_EXECUTION)
@ApplicationNodes(value = 4, shape = @ResourceShape(cpuInMillis = 32_000))
@WaitForDuration(value = 20, unit = java.util.concurrent.TimeUnit.MINUTES)
@MaxTestExecutionTime(value = 30, unit = java.util.concurrent.TimeUnit.MINUTES)
@PlatformApplication(
fileName = "StatsSigningTestingTool.jar",
parameters = {"1", "3000", "0", "100", "-1", "10000", "5000"})
@ReadinessChecks({
NodeActiveReadinessCheck.class,
})
@Monitors({NodeLivenessMonitor.class, LogErrorMonitor.class, InvalidStateSignatureMonitor.class})
@Validators({NodeStatisticHealthValidator.class})
@DisplayName("Basic 10k TPS - 20 minutes")
void basic() {}
}
11 changes: 11 additions & 0 deletions fullstack-examples/src/fullStackTest/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module com.hedera.fullstack.examples.fullstacktest {
exports com.hedera.fullstack.examples.signing to
org.junit.platform.commons;

opens com.hedera.fullstack.examples.signing to
org.junit.platform.commons;

requires com.hedera.fullstack.examples;
requires com.hedera.fullstack.junit.support;
requires org.junit.jupiter.api;
}
Original file line number Diff line number Diff line change
@@ -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.examples.monitors;

import com.hedera.fullstack.monitoring.api.CheckOutcome;
import com.hedera.fullstack.monitoring.api.Monitor;

public class InvalidStateSignatureMonitor implements Monitor {
@Override
public CheckOutcome check() {
return CheckOutcome.SUCCESS;
}
}
Original file line number Diff line number Diff line change
@@ -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.examples.monitors;

import com.hedera.fullstack.monitoring.api.CheckOutcome;
import com.hedera.fullstack.monitoring.api.Monitor;

public class LogErrorMonitor implements Monitor {
@Override
public CheckOutcome check() {
return CheckOutcome.SUCCESS;
}
}
Original file line number Diff line number Diff line change
@@ -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.examples.monitors;

import com.hedera.fullstack.monitoring.api.CheckOutcome;
import com.hedera.fullstack.monitoring.api.Monitor;

public class NodeLivenessMonitor implements Monitor {
@Override
public CheckOutcome check() {
return CheckOutcome.SUCCESS;
}
}
Original file line number Diff line number Diff line change
@@ -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.examples.readiness;

import com.hedera.fullstack.readiness.api.ReadinessCheck;

public class NodeActiveReadinessCheck implements ReadinessCheck {

@Override
public boolean ready() {
return true;
}
}
Loading

0 comments on commit 752b2df

Please sign in to comment.