From 0b771cbd27af33956b1a032325355efac5105f33 Mon Sep 17 00:00:00 2001 From: georgi-l95 Date: Thu, 12 Sep 2024 12:42:01 +0300 Subject: [PATCH 1/6] add initial structure Signed-off-by: georgi-l95 apply spotless Signed-off-by: georgi-l95 fix workflow Signed-off-by: georgi-l95 --- .github/workflows/e2e-tests.yaml | 66 +++++++++++++++++++ .../kotlin/com.hedera.block.suites.gradle.kts | 25 +++++++ settings.gradle.kts | 2 + suites/build.gradle.kts | 42 ++++++++++++ .../com/hedera/block/suites/BaseSuite.java | 35 ++++++++++ .../block/suites/stream/StreamTestSuites.java | 28 ++++++++ .../negative/NegativeBlockStreamTests.java | 37 +++++++++++ .../positive/PositiveBlockStreamTests.java | 31 +++++++++ 8 files changed, 266 insertions(+) create mode 100644 .github/workflows/e2e-tests.yaml create mode 100644 buildSrc/src/main/kotlin/com.hedera.block.suites.gradle.kts create mode 100644 suites/build.gradle.kts create mode 100644 suites/src/main/java/com/hedera/block/suites/BaseSuite.java create mode 100644 suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java create mode 100644 suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java create mode 100644 suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml new file mode 100644 index 000000000..e3f428b4f --- /dev/null +++ b/.github/workflows/e2e-tests.yaml @@ -0,0 +1,66 @@ +## +# Copyright (C) 2024 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. +## +name: "E2E Test Suites" +on: + push: + branches: + - main + - release/* + pull_request: + branches: + - "*" + +defaults: + run: + shell: bash + +env: + GRADLE_EXEC: ./gradlew + +jobs: + e2e-tests: + runs-on: block-node-linux-medium + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + + - name: Checkout code + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + fetch-depth: 0 + + - name: Expand Shallow Clone for Spotless + run: | + if [ -f .git/shallow ]; then + git fetch --unshallow --no-recurse-submodules + else + echo "Repository is not shallow, no need to unshallow." + fi + + - name: Set up JDK 21 + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + with: + distribution: 'temurin' + java-version: '21' + + - name: Build application + run: ${{ env.GRADLE_EXEC }} build + + - name: Run Acceptance Tests + id: acceptance-tests + run: ${GRADLE_EXEC} runSuites diff --git a/buildSrc/src/main/kotlin/com.hedera.block.suites.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.suites.gradle.kts new file mode 100644 index 000000000..f5361b330 --- /dev/null +++ b/buildSrc/src/main/kotlin/com.hedera.block.suites.gradle.kts @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 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("application") + id("com.hedera.block.conventions") + id("me.champeau.jmh") +} + +val maven = publishing.publications.create("maven") { from(components["java"]) } + +signing.sign(maven) diff --git a/settings.gradle.kts b/settings.gradle.kts index 5cdb9b67e..da281ec3b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,6 +19,7 @@ plugins { } // Include the subprojects +include(":suites") include(":stream") include(":server") include(":simulator") @@ -95,6 +96,7 @@ dependencyResolutionManagement { // Testing only versions version("org.assertj.core", "3.23.1") version("org.junit.jupiter.api", "5.10.2") + version("org.junit.platform", "1.11.0") version("org.mockito", "5.8.0") version("org.mockito.junit.jupiter", "5.8.0") diff --git a/suites/build.gradle.kts b/suites/build.gradle.kts new file mode 100644 index 000000000..3a44ae157 --- /dev/null +++ b/suites/build.gradle.kts @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022-2024 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("application") + id("com.hedera.block.suites") +} + +description = "Hedera Block Node E2E Suites" + +application { + mainModule = "com.hedera.block.suites" + mainClass = "com.hedera.block.suites.BaseSuite" +} + +mainModuleInfo { + requires("org.junit.jupiter.api") + requires("org.junit.platform.suite.api") + runtimeOnly("org.junit.jupiter.engine") +} + +tasks.register("runSuites") { + description = "Runs E2E Test Suites" + group = "suites" + + useJUnitPlatform() + testClassesDirs = sourceSets["main"].output.classesDirs + classpath = sourceSets["main"].runtimeClasspath +} diff --git a/suites/src/main/java/com/hedera/block/suites/BaseSuite.java b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java new file mode 100644 index 000000000..875b63b46 --- /dev/null +++ b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2022-2024 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.block.suites; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; + +public abstract class BaseSuite { + @BeforeAll + public static void setup() { + // initilize simulator + // initilize block node application + // start both applications + } + + @AfterAll + public static void teardown() { + // tear down and stop simulator + // tear down and stop block node app + } +} diff --git a/suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java b/suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java new file mode 100644 index 000000000..18c3353b1 --- /dev/null +++ b/suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2022-2024 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.block.suites.stream; + +import com.hedera.block.suites.stream.negative.NegativeBlockStreamTests; +import com.hedera.block.suites.stream.positive.PositiveBlockStreamTests; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; + +@Suite +@SelectClasses({PositiveBlockStreamTests.class, NegativeBlockStreamTests.class}) +public class StreamTestSuites { + // This class only serves as a suite entry point; no need to add any logic here. +} diff --git a/suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java b/suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java new file mode 100644 index 000000000..3aeb3cce2 --- /dev/null +++ b/suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2022-2024 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.block.suites.stream.negative; + +import static org.junit.jupiter.api.Assertions.assertFalse; + +import com.hedera.block.suites.BaseSuite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +@DisplayName("Negative Block Stream Tests") +public class NegativeBlockStreamTests extends BaseSuite { + @BeforeEach + public void prepare() { + System.out.println("NegativeBlockStreamTests Prepare"); + } + + @Test + public void testInvalidBlockStreamProcessing() { + assertFalse(false); + } +} diff --git a/suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java b/suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java new file mode 100644 index 000000000..3c1bbc663 --- /dev/null +++ b/suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2022-2024 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.block.suites.stream.positive; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.hedera.block.suites.BaseSuite; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +@DisplayName("Positive Block Stream Tests") +public class PositiveBlockStreamTests extends BaseSuite { + @Test + public void testValidBlockStreamProcessing() { + assertTrue(true); + } +} From ffead9a161bd4aeef37b9922d4fb2334325f4e61 Mon Sep 17 00:00:00 2001 From: georgi-l95 Date: Tue, 17 Sep 2024 15:19:47 +0300 Subject: [PATCH 2/6] add testcontainers and javadoc Signed-off-by: georgi-l95 spotless apply Signed-off-by: georgi-l95 --- .../com.hedera.block.jpms-modules.gradle.kts | 8 ++ gradle/modules.properties | 7 ++ settings.gradle.kts | 5 +- suites/build.gradle.kts | 25 +++++++ .../com/hedera/block/suites/BaseSuite.java | 73 +++++++++++++++++-- .../block/suites/stream/StreamTestSuites.java | 24 +++++- .../negative/NegativeBlockStreamTests.java | 19 +++-- .../positive/PositiveBlockStreamTests.java | 15 +++- 8 files changed, 162 insertions(+), 14 deletions(-) diff --git a/buildSrc/src/main/kotlin/com.hedera.block.jpms-modules.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.jpms-modules.gradle.kts index 964d27a85..600342b75 100644 --- a/buildSrc/src/main/kotlin/com.hedera.block.jpms-modules.gradle.kts +++ b/buildSrc/src/main/kotlin/com.hedera.block.jpms-modules.gradle.kts @@ -167,6 +167,14 @@ extraJavaModuleInfo { module("org.jetbrains.kotlinx:kotlinx-metadata-jvm", "kotlinx.metadata.jvm") // Test clients only + module("com.github.docker-java:docker-java-api", "com.github.dockerjava.api") + module("com.github.docker-java:docker-java-transport", "com.github.dockerjava.transport") + module( + "com.github.docker-java:docker-java-transport-zerodep", + "com.github.dockerjava.transport.zerodep" + ) + module("org.slf4j:slf4j-api", "org.slf4j") { patchRealModule() } + module("io.github.cdimascio:java-dotenv", "io.github.cdimascio") module("com.google.protobuf:protobuf-java-util", "com.google.protobuf.util") module("com.squareup:javapoet", "com.squareup.javapoet") { exportAllPackages() diff --git a/gradle/modules.properties b/gradle/modules.properties index 8290bd368..fcc1dcb94 100644 --- a/gradle/modules.properties +++ b/gradle/modules.properties @@ -31,6 +31,13 @@ org.apache.commons.io=commons-io:commons-io org.apache.commons.lang3=org.apache.commons:commons-lang3 org.apache.commons.compress=org.apache.commons:commons-compress +org.testcontainers=org.testcontainers:testcontainers +org.testcontainers.junit-jupiter=org.testcontainers:junit-jupiter +com.github.dockerjava.api=com.github.docker-java:docker-java-api +com.github.docker-java.transport.zerodep=com.github.docker-java:docker-java-transport-zerodep +com.github.docker-java.transport.httpclient5=com.github.docker-java:docker-java-transport-httpclient5 +io.github.cdimascio=io.github.cdimascio:java-dotenv + java.annotation=javax.annotation:javax.annotation-api org.apache.logging.log4j.slf4j2.impl=org.apache.logging.log4j:log4j-slf4j2-impl diff --git a/settings.gradle.kts b/settings.gradle.kts index da281ec3b..0d1d79c6d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -99,7 +99,10 @@ dependencyResolutionManagement { version("org.junit.platform", "1.11.0") version("org.mockito", "5.8.0") version("org.mockito.junit.jupiter", "5.8.0") - + version("org.testcontainers", "1.20.1") + version("org.testcontainers.junit-jupiter", "1.20.1") + version("com.github.docker-java", "3.4.0") + version("io.github.cdimascio", "5.2.2") } } } diff --git a/suites/build.gradle.kts b/suites/build.gradle.kts index 3a44ae157..4ed80e300 100644 --- a/suites/build.gradle.kts +++ b/suites/build.gradle.kts @@ -29,14 +29,39 @@ application { mainModuleInfo { requires("org.junit.jupiter.api") requires("org.junit.platform.suite.api") + requires("org.testcontainers") + requires("io.github.cdimascio") + runtimeOnly("org.testcontainers.junit-jupiter") runtimeOnly("org.junit.jupiter.engine") } +val updateDockerEnv = + tasks.register("updateDockerEnv") { + description = + "Creates the .env file in the docker folder that contains environment variables for Docker" + group = "docker" + + workingDir(layout.projectDirectory.dir("../server/docker")) + commandLine("./update-env.sh", project.version) + } + +// Task to build the Docker image +tasks.register("createDockerImage") { + description = "Creates the Docker image of the Block Node Server based on the current version" + group = "docker" + + dependsOn(updateDockerEnv, tasks.assemble) + workingDir(layout.projectDirectory.dir("../server/docker")) + commandLine("./docker-build.sh", project.version, layout.projectDirectory.dir("..").asFile) +} + tasks.register("runSuites") { description = "Runs E2E Test Suites" group = "suites" + dependsOn("createDockerImage") useJUnitPlatform() + testLogging { events("passed", "skipped", "failed") } testClassesDirs = sourceSets["main"].output.classesDirs classpath = sourceSets["main"].runtimeClasspath } diff --git a/suites/src/main/java/com/hedera/block/suites/BaseSuite.java b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java index 875b63b46..a8b373da4 100644 --- a/suites/src/main/java/com/hedera/block/suites/BaseSuite.java +++ b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java @@ -16,20 +16,83 @@ package com.hedera.block.suites; +import io.github.cdimascio.dotenv.Dotenv; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.utility.DockerImageName; +/** + * BaseSuite is an abstract class that provides common setup and teardown functionality for test + * suites using Testcontainers to manage a Docker container for the Block Node server. + * + *

This class is responsible for: + * + *

    + *
  • Starting a Docker container running the Block Node server with a specified version. + *
  • Stopping the container after tests have been executed. + *
+ * + *

The Block Node server version is retrieved dynamically from an environment file (.env). + */ public abstract class BaseSuite { + + /** Container running the Block Node server */ + protected static GenericContainer blockNodeContainer; + + /** + * Default constructor for the BaseSuite class. + * + *

This constructor can be used by subclasses or the testing framework to initialize the + * BaseSuite. It does not perform any additional setup. + */ + public BaseSuite() { + // No additional setup required + } + + /** + * Setup method to be executed before all tests. + * + *

This method initializes the Block Node server container using Testcontainers. + */ @BeforeAll public static void setup() { - // initilize simulator - // initilize block node application - // start both applications + String blockNodeVersion = BaseSuite.getBlockNodeVersion(); + blockNodeContainer = + new GenericContainer<>( + DockerImageName.parse("block-node-server:" + blockNodeVersion)) + .withExposedPorts(8080) + .withEnv("VERSION", blockNodeVersion) + .waitingFor(Wait.forListeningPort()); + blockNodeContainer.start(); } + /** + * Teardown method to be executed after all tests. + * + *

This method stops the Block Node server container if it is running. It ensures that + * resources are cleaned up after the test suite execution is complete. + */ @AfterAll public static void teardown() { - // tear down and stop simulator - // tear down and stop block node app + if (blockNodeContainer != null) { + blockNodeContainer.stop(); + } + } + + /** + * Retrieves the Block Node server version from the .env file. + * + *

This method loads the .env file from the "../server/docker" directory and extracts the + * value of the "VERSION" environment variable, which represents the version of the Block Node + * server to be used in the container. + * + * @return the version of the Block Node server as a string + */ + private static String getBlockNodeVersion() { + Dotenv dotenv = Dotenv.configure().directory("../server/docker").filename(".env").load(); + + return dotenv.get("VERSION"); } } diff --git a/suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java b/suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java index 18c3353b1..733b1b0d2 100644 --- a/suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java +++ b/suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java @@ -21,8 +21,30 @@ import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; +/** + * StreamTestSuites is a test suite that aggregates and runs a set of test classes related to the + * stream processing functionality of the Block Node. + * + *

This suite includes both positive and negative test cases. + * + *

The suite uses the {@link org.junit.platform.suite.api.Suite} annotation to indicate that this + * class is an entry point for running multiple test classes together. It selects the following test + * classes: + * + *

    + *
  • {@link com.hedera.block.suites.stream.positive.PositiveBlockStreamTests} + *
  • {@link com.hedera.block.suites.stream.negative.NegativeBlockStreamTests} + *
+ */ @Suite @SelectClasses({PositiveBlockStreamTests.class, NegativeBlockStreamTests.class}) public class StreamTestSuites { - // This class only serves as a suite entry point; no need to add any logic here. + /** + * Default constructor for the StreamTestSuites class. + * + *

This constructor is required by the JUnit framework to run the suite. + */ + public StreamTestSuites() { + // No additional setup required + } } diff --git a/suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java b/suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java index 3aeb3cce2..f013a2e0f 100644 --- a/suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java +++ b/suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java @@ -16,22 +16,29 @@ package com.hedera.block.suites.stream.negative; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.hedera.block.suites.BaseSuite; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +/** TBD */ @DisplayName("Negative Block Stream Tests") public class NegativeBlockStreamTests extends BaseSuite { - @BeforeEach - public void prepare() { - System.out.println("NegativeBlockStreamTests Prepare"); + + /** + * Default constructor for the NegativeBlockStreamTests class. + * + *

This constructor is required by the testing framework (JUnit) to create instances of the + * test class. It does not perform any additional setup. + */ + public NegativeBlockStreamTests() { + // No additional setup required } + /** TBD */ @Test public void testInvalidBlockStreamProcessing() { - assertFalse(false); + assertTrue(blockNodeContainer.isRunning()); } } diff --git a/suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java b/suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java index 3c1bbc663..6749521c6 100644 --- a/suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java +++ b/suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java @@ -22,10 +22,23 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +/** TBD */ @DisplayName("Positive Block Stream Tests") public class PositiveBlockStreamTests extends BaseSuite { + + /** + * Default constructor for the PositiveBlockStreamTests class. + * + *

This constructor is required by the testing framework (JUnit) to create instances of the + * test class. It does not perform any additional setup. + */ + public PositiveBlockStreamTests() { + // No additional setup required + } + + /** TBD */ @Test public void testValidBlockStreamProcessing() { - assertTrue(true); + assertTrue(blockNodeContainer.isRunning()); } } From 6ac8e9bc41202d81b6eb4f5f8de04835ef25fff0 Mon Sep 17 00:00:00 2001 From: georgi-l95 Date: Wed, 18 Sep 2024 14:24:31 +0300 Subject: [PATCH 3/6] add actual positive tests Signed-off-by: georgi-l95 --- server/docker/Dockerfile | 5 ++ .../com/hedera/block/suites/BaseSuite.java | 15 ++-- .../block/suites/grpc/GrpcTestSuites.java | 41 +++++++++++ .../NegativeServerAvailabilityTests.java | 29 ++++++++ .../PositiveServerAvailabilityTests.java | 69 +++++++++++++++++++ .../block/suites/stream/StreamTestSuites.java | 50 -------------- .../negative/NegativeBlockStreamTests.java | 44 ------------ .../positive/PositiveBlockStreamTests.java | 44 ------------ 8 files changed, 154 insertions(+), 143 deletions(-) create mode 100644 suites/src/main/java/com/hedera/block/suites/grpc/GrpcTestSuites.java create mode 100644 suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java create mode 100644 suites/src/main/java/com/hedera/block/suites/grpc/positive/PositiveServerAvailabilityTests.java delete mode 100644 suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java delete mode 100644 suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java delete mode 100644 suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java diff --git a/server/docker/Dockerfile b/server/docker/Dockerfile index 50b1c5ad4..2e3bfb056 100644 --- a/server/docker/Dockerfile +++ b/server/docker/Dockerfile @@ -27,5 +27,10 @@ RUN tar -xvf server-${VERSION}.tar # Copy the logging properties file COPY logging.properties logging.properties +# HEALTHCHECK for liveness and readiness +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:8080/healthz/livez || exit 1 && \ + curl -f http://localhost:8080/healthz/readyz || exit 1 + # RUN the bin script for starting the server ENTRYPOINT ["/bin/bash", "-c", "/app/server-${VERSION}/bin/server"] diff --git a/suites/src/main/java/com/hedera/block/suites/BaseSuite.java b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java index a8b373da4..287a33b62 100644 --- a/suites/src/main/java/com/hedera/block/suites/BaseSuite.java +++ b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java @@ -30,17 +30,20 @@ *

This class is responsible for: * *

    - *
  • Starting a Docker container running the Block Node server with a specified version. + *
  • Starting a Docker container running the Block Node Application with a specified version. *
  • Stopping the container after tests have been executed. *
* - *

The Block Node server version is retrieved dynamically from an environment file (.env). + *

The Block Node Application version is retrieved dynamically from an environment file (.env). */ public abstract class BaseSuite { - /** Container running the Block Node server */ + /** Container running the Block Node Application */ protected static GenericContainer blockNodeContainer; + /** Port that is used by the Block Node Application */ + protected static int blockNodePort; + /** * Default constructor for the BaseSuite class. * @@ -59,12 +62,14 @@ public BaseSuite() { @BeforeAll public static void setup() { String blockNodeVersion = BaseSuite.getBlockNodeVersion(); + blockNodePort = 8080; blockNodeContainer = new GenericContainer<>( DockerImageName.parse("block-node-server:" + blockNodeVersion)) - .withExposedPorts(8080) + .withExposedPorts(blockNodePort) .withEnv("VERSION", blockNodeVersion) - .waitingFor(Wait.forListeningPort()); + .waitingFor(Wait.forListeningPort()) + .waitingFor(Wait.forHealthcheck()); blockNodeContainer.start(); } diff --git a/suites/src/main/java/com/hedera/block/suites/grpc/GrpcTestSuites.java b/suites/src/main/java/com/hedera/block/suites/grpc/GrpcTestSuites.java new file mode 100644 index 000000000..9210c8f9b --- /dev/null +++ b/suites/src/main/java/com/hedera/block/suites/grpc/GrpcTestSuites.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2022-2024 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.block.suites.grpc; + +import com.hedera.block.suites.grpc.negative.NegativeServerAvailabilityTests; +import com.hedera.block.suites.grpc.positive.PositiveServerAvailabilityTests; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; + +/** + * Test suite for running gRPC server availability tests, including both positive and negative test + * scenarios. + * + *

This suite aggregates the tests from {@link PositiveServerAvailabilityTests} and {@link + * NegativeServerAvailabilityTests}. The {@code @Suite} annotation allows running all selected + * classes in a single test run. + */ +@Suite +@SelectClasses({PositiveServerAvailabilityTests.class, NegativeServerAvailabilityTests.class}) +public class GrpcTestSuites { + + /** + * Default constructor for the {@link GrpcTestSuites} class. This constructor is empty as it + * does not need to perform any initialization. + */ + public GrpcTestSuites() {} +} diff --git a/suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java b/suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java new file mode 100644 index 000000000..43e6c2524 --- /dev/null +++ b/suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2022-2024 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.block.suites.grpc.negative; + +import org.junit.jupiter.api.DisplayName; + +@DisplayName("Negative Server Availability Tests") +public class NegativeServerAvailabilityTests { + + public NegativeServerAvailabilityTests() {} + + public void handleServerStartupWithMissingConfig() {} + + public void handleServerStartupWithTakenPort() {} +} diff --git a/suites/src/main/java/com/hedera/block/suites/grpc/positive/PositiveServerAvailabilityTests.java b/suites/src/main/java/com/hedera/block/suites/grpc/positive/PositiveServerAvailabilityTests.java new file mode 100644 index 000000000..e675e3f56 --- /dev/null +++ b/suites/src/main/java/com/hedera/block/suites/grpc/positive/PositiveServerAvailabilityTests.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2022-2024 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.block.suites.grpc.positive; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.hedera.block.suites.BaseSuite; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +/** + * Test class for verifying the positive scenarios for server availability, specifically related to + * the gRPC server. This class contains tests to check that the gRPC server starts successfully and + * listens on the correct port. + * + *

Inherits from {@link BaseSuite} to reuse the container setup and teardown logic for the Block + * Node. + */ +@DisplayName("Positive Server Availability Tests") +public class PositiveServerAvailabilityTests extends BaseSuite { + + /** Default constructor for the {@link PositiveServerAvailabilityTests} class. */ + public PositiveServerAvailabilityTests() {} + + /** + * Test to verify that the gRPC server starts successfully. + * + *

The test checks if the Block Node container is running and marked as healthy. + */ + @Test + public void verifyGrpcServerStartsSuccessfully() { + assertTrue(blockNodeContainer.isRunning(), "Block Node container should be running."); + assertTrue(blockNodeContainer.isHealthy(), "Block Node container should be healthy."); + } + + /** + * Test to verify that the gRPC server is listening on the correct port. + * + *

The test asserts that the container is running, exposes exactly one port, and that the + * exposed port matches the expected gRPC server port. + */ + @Test + public void verifyGrpcServerListeningOnCorrectPort() { + assertTrue(blockNodeContainer.isRunning(), "Block Node container should be running."); + assertEquals( + 1, + blockNodeContainer.getExposedPorts().size(), + "There should be exactly one exposed port."); + assertEquals( + blockNodePort, + blockNodeContainer.getExposedPorts().getFirst(), + "The exposed port should match the expected gRPC server port."); + } +} diff --git a/suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java b/suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java deleted file mode 100644 index 733b1b0d2..000000000 --- a/suites/src/main/java/com/hedera/block/suites/stream/StreamTestSuites.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2022-2024 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.block.suites.stream; - -import com.hedera.block.suites.stream.negative.NegativeBlockStreamTests; -import com.hedera.block.suites.stream.positive.PositiveBlockStreamTests; -import org.junit.platform.suite.api.SelectClasses; -import org.junit.platform.suite.api.Suite; - -/** - * StreamTestSuites is a test suite that aggregates and runs a set of test classes related to the - * stream processing functionality of the Block Node. - * - *

This suite includes both positive and negative test cases. - * - *

The suite uses the {@link org.junit.platform.suite.api.Suite} annotation to indicate that this - * class is an entry point for running multiple test classes together. It selects the following test - * classes: - * - *

    - *
  • {@link com.hedera.block.suites.stream.positive.PositiveBlockStreamTests} - *
  • {@link com.hedera.block.suites.stream.negative.NegativeBlockStreamTests} - *
- */ -@Suite -@SelectClasses({PositiveBlockStreamTests.class, NegativeBlockStreamTests.class}) -public class StreamTestSuites { - /** - * Default constructor for the StreamTestSuites class. - * - *

This constructor is required by the JUnit framework to run the suite. - */ - public StreamTestSuites() { - // No additional setup required - } -} diff --git a/suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java b/suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java deleted file mode 100644 index f013a2e0f..000000000 --- a/suites/src/main/java/com/hedera/block/suites/stream/negative/NegativeBlockStreamTests.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2022-2024 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.block.suites.stream.negative; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.hedera.block.suites.BaseSuite; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -/** TBD */ -@DisplayName("Negative Block Stream Tests") -public class NegativeBlockStreamTests extends BaseSuite { - - /** - * Default constructor for the NegativeBlockStreamTests class. - * - *

This constructor is required by the testing framework (JUnit) to create instances of the - * test class. It does not perform any additional setup. - */ - public NegativeBlockStreamTests() { - // No additional setup required - } - - /** TBD */ - @Test - public void testInvalidBlockStreamProcessing() { - assertTrue(blockNodeContainer.isRunning()); - } -} diff --git a/suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java b/suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java deleted file mode 100644 index 6749521c6..000000000 --- a/suites/src/main/java/com/hedera/block/suites/stream/positive/PositiveBlockStreamTests.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2022-2024 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.block.suites.stream.positive; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.hedera.block.suites.BaseSuite; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -/** TBD */ -@DisplayName("Positive Block Stream Tests") -public class PositiveBlockStreamTests extends BaseSuite { - - /** - * Default constructor for the PositiveBlockStreamTests class. - * - *

This constructor is required by the testing framework (JUnit) to create instances of the - * test class. It does not perform any additional setup. - */ - public PositiveBlockStreamTests() { - // No additional setup required - } - - /** TBD */ - @Test - public void testValidBlockStreamProcessing() { - assertTrue(blockNodeContainer.isRunning()); - } -} From b6bb0ecfb81ba84aae6d6e66c764566c7f658ba1 Mon Sep 17 00:00:00 2001 From: georgi-l95 Date: Wed, 18 Sep 2024 15:29:16 +0300 Subject: [PATCH 4/6] add improvements and negative test Signed-off-by: georgi-l95 --- server/docker/Dockerfile | 2 +- .../com/hedera/block/suites/BaseSuite.java | 38 ++++++++++---- .../NegativeServerAvailabilityTests.java | 50 +++++++++++++++++-- 3 files changed, 77 insertions(+), 13 deletions(-) diff --git a/server/docker/Dockerfile b/server/docker/Dockerfile index 2e3bfb056..0af9bdb80 100644 --- a/server/docker/Dockerfile +++ b/server/docker/Dockerfile @@ -28,7 +28,7 @@ RUN tar -xvf server-${VERSION}.tar COPY logging.properties logging.properties # HEALTHCHECK for liveness and readiness -HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ +HEALTHCHECK --interval=30s --timeout=10s --start-period=3s --retries=3 \ CMD curl -f http://localhost:8080/healthz/livez || exit 1 && \ curl -f http://localhost:8080/healthz/readyz || exit 1 diff --git a/suites/src/main/java/com/hedera/block/suites/BaseSuite.java b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java index 287a33b62..96cb09766 100644 --- a/suites/src/main/java/com/hedera/block/suites/BaseSuite.java +++ b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java @@ -61,15 +61,7 @@ public BaseSuite() { */ @BeforeAll public static void setup() { - String blockNodeVersion = BaseSuite.getBlockNodeVersion(); - blockNodePort = 8080; - blockNodeContainer = - new GenericContainer<>( - DockerImageName.parse("block-node-server:" + blockNodeVersion)) - .withExposedPorts(blockNodePort) - .withEnv("VERSION", blockNodeVersion) - .waitingFor(Wait.forListeningPort()) - .waitingFor(Wait.forHealthcheck()); + blockNodeContainer = getConfiguration(); blockNodeContainer.start(); } @@ -86,6 +78,34 @@ public static void teardown() { } } + /** + * Retrieves the configuration for the Block Node server container. + * + *

This method initializes the Block Node container with the version retrieved from the .env + * file. It configures the container and returns it. + * + *

Specific configuration steps include: + *

    + *
  • Setting the environment variable "VERSION" from the .env file. + *
  • Exposing the default gRPC port (8080). + *
  • Using the Testcontainers health check mechanism to ensure the container is ready. + *
+ * + * @return a configured {@link GenericContainer} instance for the Block Node server + */ + public static GenericContainer getConfiguration() { + String blockNodeVersion = BaseSuite.getBlockNodeVersion(); + blockNodePort = 8080; + blockNodeContainer = + new GenericContainer<>( + DockerImageName.parse("block-node-server:" + blockNodeVersion)) + .withExposedPorts(blockNodePort) + .withEnv("VERSION", blockNodeVersion) + .waitingFor(Wait.forListeningPort()) + .waitingFor(Wait.forHealthcheck()); + return blockNodeContainer; + } + /** * Retrieves the Block Node server version from the .env file. * diff --git a/suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java b/suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java index 43e6c2524..40746d791 100644 --- a/suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java +++ b/suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java @@ -16,14 +16,58 @@ package com.hedera.block.suites.grpc.negative; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import com.hedera.block.suites.BaseSuite; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.testcontainers.containers.ContainerLaunchException; +/** + * Test class for verifying negative scenarios related to server availability for the Block Node application. + * This class is part of the gRPC module and aims to test how the Block Node handles incorrect configurations + * or failures during server startup. + *

+ * Inherits from {@link BaseSuite} to reuse the container setup and teardown logic for the Block Node. + *

+ */ @DisplayName("Negative Server Availability Tests") -public class NegativeServerAvailabilityTests { +public class NegativeServerAvailabilityTests extends BaseSuite { + /** + * Default constructor for the {@link NegativeServerAvailabilityTests} class. + * This constructor does not require any specific initialization. + */ public NegativeServerAvailabilityTests() {} - public void handleServerStartupWithMissingConfig() {} + /** + * Clean up method executed after each test. + *

+ * This method stops the running container, resets the container configuration + * by retrieving a new one through {@link BaseSuite#getConfiguration()}, and then + * starts the Block Node container again. + *

+ */ + @AfterEach + public void cleanUp() { + blockNodeContainer.stop(); + blockNodeContainer = getConfiguration(); + blockNodeContainer.start(); + } - public void handleServerStartupWithTakenPort() {} + /** + * Test to verify that the Block Node server fails to start when provided with an invalid configuration. + *

+ * Specifically, this test modifies the environment variable "VERSION" with an invalid value, + * which causes the server to fail during startup. The test expects a {@link ContainerLaunchException} + * to be thrown. + *

+ */ + @Test + public void serverStartupThrowsForInvalidConfiguration() { + blockNodeContainer.stop(); + blockNodeContainer.addEnv("VERSION", "Wrong!"); + assertThrows(ContainerLaunchException.class, () -> blockNodeContainer.start(), "Starting the Block Node container with invalid configuration should throw ContainerLaunchException."); + } } From 1187ef6d8e5c5a91bf01dd7cdd2e5e68685a464d Mon Sep 17 00:00:00 2001 From: georgi-l95 Date: Wed, 18 Sep 2024 16:25:47 +0300 Subject: [PATCH 5/6] fix smoke test Signed-off-by: georgi-l95 --- .github/workflows/smoke-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smoke-test.yaml b/.github/workflows/smoke-test.yaml index e2935a070..a8c1f0de4 100644 --- a/.github/workflows/smoke-test.yaml +++ b/.github/workflows/smoke-test.yaml @@ -81,7 +81,7 @@ jobs: - name: Run application in background, capture logs in app.log run: | - ${{ env.GRADLE_EXEC }} run 2> server/src/test/resources/app.log < /dev/null & + ${{ env.GRADLE_EXEC }} run -x :suites:run 2> server/src/test/resources/app.log < /dev/null & echo "Application started with PID $APP_PID" sleep 10 From 1bdf3808925e9c536a835fd215f44313cdb8f3d3 Mon Sep 17 00:00:00 2001 From: georgi-l95 Date: Wed, 18 Sep 2024 16:30:10 +0300 Subject: [PATCH 6/6] spotless apply Signed-off-by: georgi-l95 --- .../com/hedera/block/suites/BaseSuite.java | 3 +- .../NegativeServerAvailabilityTests.java | 43 ++++++++++--------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/suites/src/main/java/com/hedera/block/suites/BaseSuite.java b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java index 96cb09766..9e976be6e 100644 --- a/suites/src/main/java/com/hedera/block/suites/BaseSuite.java +++ b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java @@ -85,6 +85,7 @@ public static void teardown() { * file. It configures the container and returns it. * *

Specific configuration steps include: + * *

    *
  • Setting the environment variable "VERSION" from the .env file. *
  • Exposing the default gRPC port (8080). @@ -98,7 +99,7 @@ public static GenericContainer getConfiguration() { blockNodePort = 8080; blockNodeContainer = new GenericContainer<>( - DockerImageName.parse("block-node-server:" + blockNodeVersion)) + DockerImageName.parse("block-node-server:" + blockNodeVersion)) .withExposedPorts(blockNodePort) .withEnv("VERSION", blockNodeVersion) .waitingFor(Wait.forListeningPort()) diff --git a/suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java b/suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java index 40746d791..86e953eec 100644 --- a/suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java +++ b/suites/src/main/java/com/hedera/block/suites/grpc/negative/NegativeServerAvailabilityTests.java @@ -25,29 +25,28 @@ import org.testcontainers.containers.ContainerLaunchException; /** - * Test class for verifying negative scenarios related to server availability for the Block Node application. - * This class is part of the gRPC module and aims to test how the Block Node handles incorrect configurations - * or failures during server startup. - *

    - * Inherits from {@link BaseSuite} to reuse the container setup and teardown logic for the Block Node. - *

    + * Test class for verifying negative scenarios related to server availability for the Block Node + * application. This class is part of the gRPC module and aims to test how the Block Node handles + * incorrect configurations or failures during server startup. + * + *

    Inherits from {@link BaseSuite} to reuse the container setup and teardown logic for the Block + * Node. */ @DisplayName("Negative Server Availability Tests") public class NegativeServerAvailabilityTests extends BaseSuite { /** - * Default constructor for the {@link NegativeServerAvailabilityTests} class. - * This constructor does not require any specific initialization. + * Default constructor for the {@link NegativeServerAvailabilityTests} class. This constructor + * does not require any specific initialization. */ public NegativeServerAvailabilityTests() {} /** * Clean up method executed after each test. - *

    - * This method stops the running container, resets the container configuration - * by retrieving a new one through {@link BaseSuite#getConfiguration()}, and then - * starts the Block Node container again. - *

    + * + *

    This method stops the running container, resets the container configuration by retrieving + * a new one through {@link BaseSuite#getConfiguration()}, and then starts the Block Node + * container again. */ @AfterEach public void cleanUp() { @@ -57,17 +56,21 @@ public void cleanUp() { } /** - * Test to verify that the Block Node server fails to start when provided with an invalid configuration. - *

    - * Specifically, this test modifies the environment variable "VERSION" with an invalid value, - * which causes the server to fail during startup. The test expects a {@link ContainerLaunchException} - * to be thrown. - *

    + * Test to verify that the Block Node server fails to start when provided with an invalid + * configuration. + * + *

    Specifically, this test modifies the environment variable "VERSION" with an invalid value, + * which causes the server to fail during startup. The test expects a {@link + * ContainerLaunchException} to be thrown. */ @Test public void serverStartupThrowsForInvalidConfiguration() { blockNodeContainer.stop(); blockNodeContainer.addEnv("VERSION", "Wrong!"); - assertThrows(ContainerLaunchException.class, () -> blockNodeContainer.start(), "Starting the Block Node container with invalid configuration should throw ContainerLaunchException."); + assertThrows( + ContainerLaunchException.class, + () -> blockNodeContainer.start(), + "Starting the Block Node container with invalid configuration should throw" + + " ContainerLaunchException."); } }