From 139464a2cc8846c59c75a7aea4b1e9ddaabc05ef Mon Sep 17 00:00:00 2001 From: Alexander Dejanovski Date: Tue, 17 Dec 2024 13:01:26 +0100 Subject: [PATCH] fix failing tests that relied on a bug to succeed --- .../acceptance/BasicSteps.java | 1 + .../acceptance/ReaperMetricsIT.java | 24 +++++++++++++++++++ .../cassandra-reaper-metrics-test.yaml | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/server/src/test/java/io/cassandrareaper/acceptance/BasicSteps.java b/src/server/src/test/java/io/cassandrareaper/acceptance/BasicSteps.java index d1cf856b8..2f8eec8dd 100644 --- a/src/server/src/test/java/io/cassandrareaper/acceptance/BasicSteps.java +++ b/src/server/src/test/java/io/cassandrareaper/acceptance/BasicSteps.java @@ -562,6 +562,7 @@ public void a_new_daily_repair_schedule_is_added_for_the_last_added_cluster_and_ params.put("intensity", "0.9"); params.put("scheduleDaysBetween", "1"); params.put("scheduleTriggerTime", DateTime.now().plusSeconds(1).toString()); + params.put("segmentCountPerNode", "1"); ReaperTestJettyRunner runner = RUNNERS.get(RAND.nextInt(RUNNERS.size())); Response response = runner.callReaper("POST", "/repair_schedule", Optional.of(params)); int responseStatus = response.getStatus(); diff --git a/src/server/src/test/java/io/cassandrareaper/acceptance/ReaperMetricsIT.java b/src/server/src/test/java/io/cassandrareaper/acceptance/ReaperMetricsIT.java index 9e2ddcbed..d4f03d892 100644 --- a/src/server/src/test/java/io/cassandrareaper/acceptance/ReaperMetricsIT.java +++ b/src/server/src/test/java/io/cassandrareaper/acceptance/ReaperMetricsIT.java @@ -17,6 +17,13 @@ package io.cassandrareaper.acceptance; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Comparator; +import java.util.stream.Stream; + import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; import org.junit.AfterClass; @@ -25,6 +32,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; + @RunWith(Cucumber.class) @CucumberOptions( features = { @@ -46,6 +54,8 @@ public static void setUp() throws Exception { "setting up testing Reaper runner with {} seed hosts defined and memory storage", TestContext.TEST_CLUSTER_SEED_HOSTS.size()); + // We now have persistence in the memory store, so we need to clean up the storage folder before starting the tests + deleteFolderContents("/tmp/reaper/storage/"); runner = new ReaperTestJettyRunner(MEMORY_CONFIG_FILE); BasicSteps.addReaperRunner(runner); } @@ -56,4 +66,18 @@ public static void tearDown() { runner.runnerInstance.after(); } + public static void deleteFolderContents(String folderPath) throws IOException { + Path path = Paths.get(folderPath); + try (Stream walk = Files.walk(path)) { + walk.sorted(Comparator.reverseOrder()) + .forEach(p -> { + try { + Files.delete(p); + } catch (IOException e) { + throw new RuntimeException("Failed to delete " + p, e); + } + }); + } + } + } diff --git a/src/server/src/test/resources/cassandra-reaper-metrics-test.yaml b/src/server/src/test/resources/cassandra-reaper-metrics-test.yaml index e8ed291f1..ecedb61fe 100644 --- a/src/server/src/test/resources/cassandra-reaper-metrics-test.yaml +++ b/src/server/src/test/resources/cassandra-reaper-metrics-test.yaml @@ -28,7 +28,7 @@ enableDynamicSeedList: false jmxConnectionTimeoutInSeconds: 10 datacenterAvailability: LOCAL percentRepairedCheckIntervalMinutes: 1 -repairManagerSchedulingIntervalSeconds: 0 +repairManagerSchedulingIntervalSeconds: 1 logging: level: WARN