Skip to content

Commit

Permalink
feat: Add simulator as dependency in Suites
Browse files Browse the repository at this point in the history
Signed-off-by: georgi-l95 <[email protected]>
  • Loading branch information
georgi-l95 committed Oct 10, 2024
1 parent d55321f commit 3e3e04c
Show file tree
Hide file tree
Showing 35 changed files with 56 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ extraJavaModuleInfo {
"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") {
Expand Down
1 change: 1 addition & 0 deletions simulator/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/** Runtime module of the simulator. */
module com.hedera.block.simulator {
exports com.hedera.block.simulator.config.data;
exports com.hedera.block.simulator;

requires static com.github.spotbugs.annotations;
requires static com.google.auto.service;
Expand Down
14 changes: 10 additions & 4 deletions suites/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,25 @@ plugins {

description = "Hedera Block Node E2E Suites"

dependencies{
implementation(project(":simulator"))
}

application {
mainModule = "com.hedera.block.suites"
mainClass = "com.hedera.block.suites.BaseSuite"
}

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")
runtimeOnly("org.testcontainers")
runtimeOnly("com.swirlds.config.impl")
}

// workaround until https://github.com/hashgraph/hedera-block-node/pull/216 is integrated
dependencies.constraints { implementation("org.slf4j:slf4j-api:2.0.6") }

val updateDockerEnv =
tasks.register<Exec>("updateDockerEnv") {
description =
Expand All @@ -58,6 +63,7 @@ tasks.register<Exec>("createDockerImage") {
tasks.register<Test>("runSuites") {
description = "Runs E2E Test Suites"
group = "suites"
modularity.inferModulePath = false
dependsOn("createDockerImage")

useJUnitPlatform()
Expand Down
32 changes: 31 additions & 1 deletion suites/src/main/java/com/hedera/block/suites/BaseSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@

package com.hedera.block.suites;

import com.hedera.block.simulator.BlockStreamSimulatorApp;
import com.hedera.block.simulator.BlockStreamSimulatorInjectionComponent;
import com.hedera.block.simulator.DaggerBlockStreamSimulatorInjectionComponent;
import com.swirlds.config.api.Configuration;
import com.swirlds.config.api.ConfigurationBuilder;
import com.swirlds.config.extensions.sources.ClasspathFileConfigSource;
import com.swirlds.config.extensions.sources.SystemEnvironmentConfigSource;
import com.swirlds.config.extensions.sources.SystemPropertiesConfigSource;
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;

import java.io.IOException;
import java.nio.file.Path;

/**
* 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.
Expand All @@ -44,6 +55,8 @@ public abstract class BaseSuite {
/** Port that is used by the Block Node Application */
protected static int blockNodePort;

/** Block Simulator Application instance */
protected static BlockStreamSimulatorApp blockStreamSimulatorApp;
/**
* Default constructor for the BaseSuite class.
*
Expand All @@ -60,9 +73,15 @@ public BaseSuite() {
* <p>This method initializes the Block Node server container using Testcontainers.
*/
@BeforeAll
public static void setup() {
public static void setup() throws IOException {
blockNodeContainer = getConfiguration();
blockNodeContainer.start();

//TODO remove in the next PR which adds tests
BlockStreamSimulatorInjectionComponent DIComponent =
DaggerBlockStreamSimulatorInjectionComponent.factory().create(loadDefaultConfiguration());

BlockStreamSimulatorApp blockStreamSimulatorApp = DIComponent.getBlockStreamSimulatorApp();
}

/**
Expand Down Expand Up @@ -107,6 +126,17 @@ public static GenericContainer<?> getConfiguration() {
return blockNodeContainer;
}

private static Configuration loadDefaultConfiguration() throws IOException {
ConfigurationBuilder configurationBuilder =
ConfigurationBuilder.create()
.withSource(SystemEnvironmentConfigSource.getInstance())
.withSource(SystemPropertiesConfigSource.getInstance())
.withSource(new ClasspathFileConfigSource(Path.of("app.properties")))
.autoDiscoverExtensions();

return configurationBuilder.build();
}

/**
* Retrieves the Block Node server version from the .env file.
*
Expand Down
14 changes: 14 additions & 0 deletions suites/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** Runtime module of the suites. */
module com.hedera.block.node.suites {
requires com.hedera.block.simulator;
requires com.swirlds.config.api;
requires com.swirlds.config.extensions;

// Require testing libraries
requires io.github.cdimascio;
requires org.junit.jupiter.api;
requires org.junit.platform.suite.api;
requires org.testcontainers;

exports com.hedera.block.suites to org.junit.platform.commons;
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 3e3e04c

Please sign in to comment.