From eae5eb80cba6ec4d9c89b9ddda5616035cfaab9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mathieu?= Date: Fri, 12 Dec 2025 11:03:26 +0100 Subject: [PATCH] fix(test): use a separate tenant for each test --- .../core/runners/AbstractRunnerConcurrencyTest.java | 4 ++-- .../kestra/core/runners/FlowConcurrencyCaseTest.java | 2 +- .../flows/valids/flow-concurrency-cancel.yml | 2 +- .../kestra/jdbc/runner/JdbcConcurrencyRunnerTest.java | 11 +++++------ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/test/java/io/kestra/core/runners/AbstractRunnerConcurrencyTest.java b/core/src/test/java/io/kestra/core/runners/AbstractRunnerConcurrencyTest.java index de20dcbdb1..09be0b1dcb 100644 --- a/core/src/test/java/io/kestra/core/runners/AbstractRunnerConcurrencyTest.java +++ b/core/src/test/java/io/kestra/core/runners/AbstractRunnerConcurrencyTest.java @@ -50,9 +50,9 @@ public abstract class AbstractRunnerConcurrencyTest { } @Test - @LoadFlows(value = {"flows/valids/flow-concurrency-queue-fail.yml"}, tenantId = "concurrency-queue-fail") + @LoadFlows(value = {"flows/valids/flow-concurrency-queue-fail.yml"}, tenantId = "concurrency-queue-restarted") protected void concurrencyQueueRestarted() throws Exception { - flowConcurrencyCaseTest.flowConcurrencyQueueRestarted("concurrency-queue-fail"); + flowConcurrencyCaseTest.flowConcurrencyQueueRestarted("concurrency-queue-restarted"); } @Test diff --git a/core/src/test/java/io/kestra/core/runners/FlowConcurrencyCaseTest.java b/core/src/test/java/io/kestra/core/runners/FlowConcurrencyCaseTest.java index 1c0f150786..94dc66bac8 100644 --- a/core/src/test/java/io/kestra/core/runners/FlowConcurrencyCaseTest.java +++ b/core/src/test/java/io/kestra/core/runners/FlowConcurrencyCaseTest.java @@ -215,7 +215,7 @@ public class FlowConcurrencyCaseTest { List subFlowExecs = runnerUtils.awaitFlowExecutionNumber(2, tenantId, NAMESPACE, "flow-concurrency-cancel"); assertThat(subFlowExecs).extracting(e -> e.getState().getCurrent()).containsExactlyInAnyOrder(Type.SUCCESS, Type.CANCELLED); - // run another execution to be sure that everything work (purge is correctly done) + // run another execution to be sure that everything works (purge is correctly done) Execution execution3 = runnerUtils.runOne(tenantId, NAMESPACE, "flow-concurrency-subflow"); assertThat(execution3.getState().getCurrent()).isEqualTo(Type.SUCCESS); runnerUtils.awaitFlowExecution(e -> e.getState().getCurrent().equals(Type.SUCCESS), tenantId, NAMESPACE, "flow-concurrency-cancel"); diff --git a/core/src/test/resources/flows/valids/flow-concurrency-cancel.yml b/core/src/test/resources/flows/valids/flow-concurrency-cancel.yml index 9e7b676da6..4ee2b6d024 100644 --- a/core/src/test/resources/flows/valids/flow-concurrency-cancel.yml +++ b/core/src/test/resources/flows/valids/flow-concurrency-cancel.yml @@ -8,4 +8,4 @@ concurrency: tasks: - id: sleep type: io.kestra.plugin.core.flow.Sleep - duration: PT10S + duration: PT2S diff --git a/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcConcurrencyRunnerTest.java b/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcConcurrencyRunnerTest.java index 95c0190aa8..0d1eff2f75 100644 --- a/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcConcurrencyRunnerTest.java +++ b/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcConcurrencyRunnerTest.java @@ -16,7 +16,6 @@ import org.junit.jupiter.api.Test; import java.time.Duration; import java.util.Optional; -import static io.kestra.core.tenant.TenantService.MAIN_TENANT; import static org.assertj.core.api.Assertions.assertThat; public abstract class JdbcConcurrencyRunnerTest extends AbstractRunnerConcurrencyTest { @@ -35,19 +34,19 @@ public abstract class JdbcConcurrencyRunnerTest extends AbstractRunnerConcurrenc private TestRunnerUtils runnerUtils; @Test - @LoadFlows({"flows/valids/flow-concurrency-queue.yml"}) + @LoadFlows(value = {"flows/valids/flow-concurrency-queue.yml"}, tenantId = "flow-concurrency-queued-protection") void flowConcurrencyQueuedProtection() throws QueueException, InterruptedException { - Execution execution1 = runnerUtils.runOneUntilRunning(MAIN_TENANT, NAMESPACE, "flow-concurrency-queue", null, null, Duration.ofSeconds(30)); + Execution execution1 = runnerUtils.runOneUntilRunning("flow-concurrency-queued-protection", NAMESPACE, "flow-concurrency-queue", null, null, Duration.ofSeconds(30)); assertThat(execution1.getState().isRunning()).isTrue(); Flow flow = flowRepository - .findById(MAIN_TENANT, NAMESPACE, "flow-concurrency-queue", Optional.empty()) + .findById("flow-concurrency-queued-protection", NAMESPACE, "flow-concurrency-queue", Optional.empty()) .orElseThrow(); Execution execution2 = runnerUtils.emitAndAwaitExecution(e -> e.getState().getCurrent().equals(State.Type.QUEUED), Execution.newExecution(flow, null, null, Optional.empty())); assertThat(execution2.getState().getCurrent()).isEqualTo(State.Type.QUEUED); // manually update the concurrency count so that queued protection kicks in and no new execution would be popped - ConcurrencyLimit concurrencyLimit = concurrencyLimitStorage.findById(MAIN_TENANT, NAMESPACE, "flow-concurrency-queue").orElseThrow(); + ConcurrencyLimit concurrencyLimit = concurrencyLimitStorage.findById("flow-concurrency-queued-protection", NAMESPACE, "flow-concurrency-queue").orElseThrow(); concurrencyLimit = concurrencyLimit.withRunning(concurrencyLimit.getRunning() + 1); concurrencyLimitStorage.update(concurrencyLimit); @@ -56,7 +55,7 @@ public abstract class JdbcConcurrencyRunnerTest extends AbstractRunnerConcurrenc // we wait for a few ms and checked that the second execution is still queued Thread.sleep(500); - Execution executionResult2 = executionRepository.findById(MAIN_TENANT, execution2.getId()).orElseThrow(); + Execution executionResult2 = executionRepository.findById("flow-concurrency-queued-protection", execution2.getId()).orElseThrow(); assertThat(executionResult2.getState().getCurrent()).isEqualTo(State.Type.QUEUED); // we manually reset the concurrency count to avoid messing with any other tests