From 520793f342234ff0e381f7599e74d63808b6d4dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20F=C4=85derski?= Date: Fri, 22 Nov 2024 17:57:00 +0100 Subject: [PATCH] Restarting all containers --- .../setup/HermesExtension.java | 54 ++++++++++++------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/integration-tests/src/common/java/pl/allegro/tech/hermes/integrationtests/setup/HermesExtension.java b/integration-tests/src/common/java/pl/allegro/tech/hermes/integrationtests/setup/HermesExtension.java index 5c3be934c8..b18e851b00 100644 --- a/integration-tests/src/common/java/pl/allegro/tech/hermes/integrationtests/setup/HermesExtension.java +++ b/integration-tests/src/common/java/pl/allegro/tech/hermes/integrationtests/setup/HermesExtension.java @@ -4,7 +4,6 @@ import static pl.allegro.tech.hermes.integrationtests.setup.HermesManagementTestApp.AUDIT_EVENT_PATH; import static pl.allegro.tech.hermes.test.helper.endpoint.TimeoutAdjuster.adjust; -import java.io.IOException; import java.time.Duration; import java.util.List; import java.util.stream.Stream; @@ -45,16 +44,15 @@ public class HermesExtension public static final TestSubscribersExtension auditEventsReceiver = new TestSubscribersExtension(); - private static final ZookeeperContainer hermesZookeeper = - new ZookeeperContainer("HermesZookeeper"); - private static final KafkaContainerCluster kafka = new KafkaContainerCluster(1); - public static final ConfluentSchemaRegistryContainer schemaRegistry = + private static ZookeeperContainer hermesZookeeper = new ZookeeperContainer("HermesZookeeper"); + private static KafkaContainerCluster kafka = new KafkaContainerCluster(1); + public static ConfluentSchemaRegistryContainer schemaRegistry = new ConfluentSchemaRegistryContainer().withKafkaCluster(kafka); - private static final HermesConsumersTestApp consumers = + private static HermesConsumersTestApp consumers = new HermesConsumersTestApp(hermesZookeeper, kafka, schemaRegistry); - private static final HermesManagementTestApp management = + private static HermesManagementTestApp management = new HermesManagementTestApp(hermesZookeeper, kafka, schemaRegistry); - private static final HermesFrontendTestApp frontend = + private static HermesFrontendTestApp frontend = new HermesFrontendTestApp(hermesZookeeper, kafka, schemaRegistry); private HermesTestClient hermesTestClient; private HermesInitHelper hermesInitHelper; @@ -77,14 +75,18 @@ public void beforeAll(ExtensionContext context) { Stream.of(consumers, frontend).forEach(HermesTestApp::start); started = true; } - Stream.of(management, consumers, frontend) - .forEach( - app -> { - if (app.shouldBeRestarted()) { - app.stop(); - app.start(); - } - }); + boolean needsRestart = + Stream.of(management, consumers, frontend).anyMatch(HermesTestApp::shouldBeRestarted); + if (needsRestart) { + restart(); + } + // .forEach( + // app -> { + // if (app.shouldBeRestarted()) { + // app.stop(); + // app.start(); + // } + // }); hermesTestClient = new HermesTestClient(management.getPort(), frontend.getPort(), consumers.getPort()); hermesInitHelper = new HermesInitHelper(management.getPort(), frontend); @@ -102,10 +104,22 @@ public void close() { } } - public void restart() throws IOException, InterruptedException { - Stream.of(management, consumers, frontend).forEach(HermesTestApp::stop); - hermesZookeeper.restart(); - Stream.of(management, consumers, frontend).forEach(HermesTestApp::start); + public void restart() { + Stream.of(management, consumers, frontend).parallel().forEach(HermesTestApp::stop); + Stream.of(hermesZookeeper, kafka, schemaRegistry).parallel().forEach(Startable::stop); + + hermesZookeeper = new ZookeeperContainer("HermesZookeeper"); + kafka = new KafkaContainerCluster(1); + schemaRegistry = new ConfluentSchemaRegistryContainer().withKafkaCluster(kafka); + consumers = new HermesConsumersTestApp(hermesZookeeper, kafka, schemaRegistry); + management = new HermesManagementTestApp(hermesZookeeper, kafka, schemaRegistry); + frontend = new HermesFrontendTestApp(hermesZookeeper, kafka, schemaRegistry); + + Stream.of(hermesZookeeper, kafka).parallel().forEach(Startable::start); + schemaRegistry.start(); + management.addEventAuditorListener(auditEventsReceiver.getPort()); + management.start(); + Stream.of(consumers, frontend).forEach(HermesTestApp::start); } public int getFrontendPort() {