diff --git a/.github/workflows/integration-tests-oss.yml b/.github/workflows/integration-tests-oss.yml new file mode 100644 index 000000000..412b8a0ed --- /dev/null +++ b/.github/workflows/integration-tests-oss.yml @@ -0,0 +1,127 @@ +name: Java Client Integration Tests (OSS) + +# Runs the integration suite against a local, disposable Conductor OSS stack +# (scripts/docker-compose-oss.yaml) instead of the Orkes deployment that +# integration-tests.yml targets. Orkes-Enterprise-only tests skip themselves via +# @DisabledOnOss, which checks CONDUCTOR_SERVER_TYPE=oss. +# scripts/run-integration-oss.sh runs the same suite locally. +# +# This is a plain pull_request workflow, like the OSS jobs in the other SDK repos, +# rather than a job in integration-tests.yml: that file is triggered by workflow_run, +# which runs PR code with the base repo's write-scoped token. Here a fork PR gets a +# read-only token, and GITHUB_SHA is the PR's commit, so the test report lands on +# the PR. +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + inputs: + oss_conductor_version: + description: 'OSS Conductor image tag (falls back to the E2E_TEST_OSS_CONDUCTOR_VERSION org var, then to the default in scripts/docker-compose-oss.yaml on fork PRs)' + required: false + type: string + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + integration-tests-oss: + runs-on: ubuntu-latest + name: Integration Tests (OSS) + timeout-minutes: 30 + + permissions: + contents: read # minimal read access + checks: write # needed for the test report check run + + env: + CONDUCTOR_SERVER_URL: http://localhost:8080/api + CONDUCTOR_SERVER_TYPE: oss + IS_FORK_PR: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }} + + steps: + # OSS_CONDUCTOR_VERSION is resolved here rather than in the job `env` so + # that the two ways it can come back empty get different treatment: + # + # - Fork PR: GitHub withholds org/repo variables from pull_request runs + # on forks exactly as it withholds secrets, so vars.* is always "" for + # an outside contributor (observed in csharp-sdk#178). This job needs + # no secrets, only a tag, so leave the var unset and let the default + # baked into the `image:` line of scripts/docker-compose-oss.yaml + # apply. That is the same tag a plain local run of + # scripts/run-integration-oss.sh gets, and the one place it is + # written -- no second copy to drift out of sync here. + # - Anything else: the org variable is genuinely missing or its + # repository access policy no longer covers this repo. Fail loudly + # rather than silently drifting onto the default. + - name: Resolve OSS Conductor version + env: + REQUESTED_VERSION: ${{ inputs.oss_conductor_version || vars.E2E_TEST_OSS_CONDUCTOR_VERSION }} + run: | + if [ -n "$REQUESTED_VERSION" ]; then + echo "OSS_CONDUCTOR_VERSION=${REQUESTED_VERSION}" >> "$GITHUB_ENV" + elif [ "$IS_FORK_PR" = "true" ]; then + echo "::notice::Fork PR: org variables are withheld, falling back to the default tag in scripts/docker-compose-oss.yaml" + else + echo "::error::No Conductor OSS image tag resolved. Set the E2E_TEST_OSS_CONDUCTOR_VERSION organization variable (and ensure its repository access policy includes this repo), or pass the oss_conductor_version input via workflow_dispatch." + exit 1 + fi + + - name: Checkout + uses: actions/checkout@v6 + with: + # The build below runs PR code; don't leave the token in .git/config for it. + persist-credentials: false + + - name: Set up Zulu JDK 21 + uses: actions/setup-java@v5 + with: + distribution: "zulu" + java-version: "21" + + # `docker compose up` only pulls an image when it is missing locally. On a + # GitHub-hosted runner the VM is ephemeral and starts with no cached copy + # of this image, so `up` would pull anyway and this step is redundant + # today. It is here deliberately: it costs no extra network pull (`up` + # then finds the image locally), it separates "couldn't pull the image" + # from "the stack didn't come up" into two distinct red steps, and it is + # what keeps a mutable tag from going stale if this job ever moves to a + # self-hosted runner with a warm Docker daemon -- the same reason + # scripts/run-integration-oss.sh pulls. It also prints the tag actually in + # use, which for a fork PR comes from the compose file's default. + - name: Pull Conductor OSS image + run: | + echo "Using $(docker compose -f scripts/docker-compose-oss.yaml config --images | grep -m1 '^conductoross/conductor:')" + docker compose -f scripts/docker-compose-oss.yaml pull conductor-server + + - name: Start Conductor OSS stack + run: docker compose -f scripts/docker-compose-oss.yaml up -d + + - name: Wait for Conductor to be healthy + # Matches HEALTH_TIMEOUT in scripts/run-integration-oss.sh, and stays under the compose + # healthcheck's own ~200s budget. + run: timeout 180 bash -c 'until curl -sf http://localhost:8080/health; do sleep 5; done' + + - name: Run integration tests (OSS) + run: ./gradlew :tests:test -PIntegrationTests + + - name: Dump Conductor logs + if: failure() + run: docker compose -f scripts/docker-compose-oss.yaml logs conductor-server + + - name: Publish Test Report + if: always() + uses: mikepenz/action-junit-report@v6 + with: + report_paths: 'tests/build/test-results/test/TEST-*.xml' + # Distinct from integration-tests.yml's report and ci.yml's unit report. The action + # defaults every caller to 'JUnit Test Report', so they would overwrite each other. + check_name: OSS Integration Test Report + # A fork PR's token is read-only and cannot create a check run; report through + # annotations and the job summary instead. + annotate_only: ${{ env.IS_FORK_PR == 'true' }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7bfa1458c..d5105f61e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,6 +23,50 @@ Run the SDK test suite: ./gradlew test jacocoTestReport ``` +### Running the OSS integration suite locally + +The `tests` module also has an integration suite (`-PIntegrationTests`) that runs against a +real Conductor server, separate from the unit suite above. `scripts/run-integration-oss.sh` +mirrors the `.github/workflows/integration-tests-oss.yml` workflow: it starts a local Conductor OSS + +Postgres stack (defined in `scripts/docker-compose-oss.yaml`), waits for `/health`, runs the +integration suite, and tears the stack down on exit. + +```shell +scripts/run-integration-oss.sh # against the default tag in scripts/docker-compose-oss.yaml +scripts/run-integration-oss.sh --version 3.32.0-rc18 +scripts/run-integration-oss.sh --keep-up # leave the stack running afterwards +scripts/run-integration-oss.sh --include-gated # also run tests normally skipped as Orkes-only +``` + +The script always prints the resolved `conductoross/conductor` tag and pulls it before +starting the stack, since a tag can be re-pushed (an rc, or `latest` via `--version latest`) — +without an explicit pull, `docker compose up` would silently reuse a stale cached image +instead of fetching the current one. It also always runs Gradle with `--rerun-tasks`, since the `test` +task's up-to-date check doesn't account for env vars like `CONDUCTOR_SERVER_TYPE` or the +state of the live server underneath — without it, a rerun after changing gating or switching +server versions could silently report a stale cached result instead of executing anything. + +The script doesn't pin a JDK itself, but CI runs on Zulu 21. If your local default JDK is +newer (e.g. 23) you may hit `Unsupported class file major version` errors compiling tests — +set `JAVA_HOME` explicitly to match CI: + +```shell +JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home ./scripts/run-integration-oss.sh +``` + +Tests annotated `@DisabledOnOss("")` skip themselves when `CONDUCTOR_SERVER_TYPE=oss`, +because they exercise Orkes-managed-only features that plain OSS lacks (e.g. the Service Registry, Authorization, Prompts/Integrations, Environment Variables, and +Secrets APIs, plus a handful of task/workflow endpoints OSS doesn't implement, and OSS gaps +with an open issue, such as start-workflow idempotency keys). Each annotation's +reason documents the specific, empirically-confirmed gap — treat those as the source +of truth rather than a list here, since they can drift as OSS gains features. If you add or +remove that annotation, re-verify against a freshly-pulled image first: a test that fails +against a stale local image may pass against current OSS, and vice versa. + +Before gating a test, check that it doesn't depend on something only the shared Orkes cluster +provides, such as workers already polling a task type or prior execution history. Those tests +can usually be fixed to pass on both servers instead. + Compile the maintained agent examples when changing their APIs or documentation: ```shell diff --git a/conductor-client/src/main/java/com/netflix/conductor/client/automator/TaskRunnerConfigurer.java b/conductor-client/src/main/java/com/netflix/conductor/client/automator/TaskRunnerConfigurer.java index 030246917..1dfd9fb92 100644 --- a/conductor-client/src/main/java/com/netflix/conductor/client/automator/TaskRunnerConfigurer.java +++ b/conductor-client/src/main/java/com/netflix/conductor/client/automator/TaskRunnerConfigurer.java @@ -159,9 +159,11 @@ public void shutdown() { } } scheduledExecutorService.shutdown(); + // Only this configurer's own dispatcher. The TaskClient is the caller's and may outlive + // this configurer (AnnotatedWorkerExecutor reuses it for the next runner), so its + // listeners are left in place. if (metricsCollector != null) { ListenerRegister.unregister(metricsCollector, eventDispatcher); - taskClient.unregisterListeners(); } } diff --git a/conductor-client/src/main/java/com/netflix/conductor/client/http/TaskClient.java b/conductor-client/src/main/java/com/netflix/conductor/client/http/TaskClient.java index 6dfd78170..abd23d08f 100644 --- a/conductor-client/src/main/java/com/netflix/conductor/client/http/TaskClient.java +++ b/conductor-client/src/main/java/com/netflix/conductor/client/http/TaskClient.java @@ -170,8 +170,9 @@ public void registerTaskRunnerListener(TaskRunnerEventsListener listener) { /** * Detaches the auto-wired {@link MetricsCollector} (if any) from this - * client's dispatchers. Called during shutdown to release the entries from - * {@link ListenerRegister}'s static registry. + * client's dispatchers, after which this client emits no metrics events. + * The dispatchers belong to this instance, so this is not needed to free + * them; call it only to stop metrics on a client that stays in use. */ public void unregisterListeners() { if (metricsCollector != null) { diff --git a/conductor-client/src/main/java/com/netflix/conductor/sdk/workflow/executor/WorkflowExecutor.java b/conductor-client/src/main/java/com/netflix/conductor/sdk/workflow/executor/WorkflowExecutor.java index 33654d78d..d975e18ab 100644 --- a/conductor-client/src/main/java/com/netflix/conductor/sdk/workflow/executor/WorkflowExecutor.java +++ b/conductor-client/src/main/java/com/netflix/conductor/sdk/workflow/executor/WorkflowExecutor.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -80,6 +81,19 @@ public class WorkflowExecutor { private final Map> runningWorkflowFutures = new ConcurrentHashMap<>(); + /** + * How long a workflow's polls must keep failing before the monitor stops tracking it and fails + * its future. Long enough for a server restart or failover to pass without failing workflows + * that are still running. + */ + static final long DEFAULT_POLL_FAILURE_TIMEOUT_MILLIS = TimeUnit.MINUTES.toMillis(1); + + private volatile long pollFailureTimeoutMillis = DEFAULT_POLL_FAILURE_TIMEOUT_MILLIS; + + // When each workflow's current run of failed polls started, in System.nanoTime() units. + // Only accessed from the single monitor thread. + private final Map pollFailingSinceNanos = new HashMap<>(); + private final ObjectMapper objectMapper = new ObjectMapperProvider().getObjectMapper(); private final TaskClient taskClient; @@ -174,10 +188,37 @@ private void initMonitor() { for (Map.Entry> entry : runningWorkflowFutures.entrySet()) { String workflowId = entry.getKey(); CompletableFuture future = entry.getValue(); - Workflow workflow = workflowClient.getWorkflow(workflowId, true); - if (workflow.getStatus().isTerminal()) { - future.complete(workflow); + try { + Workflow workflow = workflowClient.getWorkflow(workflowId, true); + pollFailingSinceNanos.remove(workflowId); + if (workflow.getStatus().isTerminal()) { + future.complete(workflow); + runningWorkflowFutures.remove(workflowId); + } + } catch (Exception e) { + // scheduleAtFixedRate silently kills all future ticks on any uncaught + // exception, so this must not escape: one failed poll would otherwise + // stop completion tracking for every workflow, forever. + long now = System.nanoTime(); + Long failingSince = pollFailingSinceNanos.putIfAbsent(workflowId, now); + if (failingSince == null) { + LOGGER.warn("Error polling workflow {} for completion; will retry for up " + + "to {} ms: {}", workflowId, pollFailureTimeoutMillis, e.getMessage()); + continue; + } + long failingForMillis = TimeUnit.NANOSECONDS.toMillis(now - failingSince); + if (failingForMillis < pollFailureTimeoutMillis) { + // Already warned for this run of failures; at the polling interval a + // WARN per tick would flood the log during an outage. + LOGGER.debug("Still failing to poll workflow {} for completion ({} ms so " + + "far): {}", workflowId, failingForMillis, e.getMessage()); + continue; + } + LOGGER.error("Polling workflow {} for completion has failed for {} ms; " + + "completing its future exceptionally", workflowId, failingForMillis, e); + pollFailingSinceNanos.remove(workflowId); runningWorkflowFutures.remove(workflowId); + future.completeExceptionally(e); } } }, @@ -186,6 +227,11 @@ private void initMonitor() { TimeUnit.MILLISECONDS); } + // Lets tests shorten the timeout instead of waiting out the default. + void setPollFailureTimeoutMillis(long pollFailureTimeoutMillis) { + this.pollFailureTimeoutMillis = pollFailureTimeoutMillis; + } + public void initWorkers(String... packagesToScan) { annotatedWorkerExecutor.initWorkers(packagesToScan); } diff --git a/conductor-client/src/main/java/com/netflix/conductor/sdk/workflow/executor/task/AnnotatedWorkerExecutor.java b/conductor-client/src/main/java/com/netflix/conductor/sdk/workflow/executor/task/AnnotatedWorkerExecutor.java index e2ed6d107..634f9399f 100644 --- a/conductor-client/src/main/java/com/netflix/conductor/sdk/workflow/executor/task/AnnotatedWorkerExecutor.java +++ b/conductor-client/src/main/java/com/netflix/conductor/sdk/workflow/executor/task/AnnotatedWorkerExecutor.java @@ -52,6 +52,12 @@ public class AnnotatedWorkerExecutor { private final Set scannedPackages = new HashSet<>(); + /** + * Set whenever a worker is added, cleared whenever {@link #startPolling()} builds a task runner. + * Lets startPolling() distinguish a real (re)start from a redundant duplicate call. + */ + private boolean workersChanged = false; + private final WorkerConfiguration workerConfiguration; public AnnotatedWorkerExecutor(TaskClient taskClient) { @@ -77,6 +83,9 @@ public AnnotatedWorkerExecutor(TaskClient taskClient, WorkerConfiguration worker */ public synchronized void initWorkers(String... basePackages) { scanWorkers(basePackages); + // scanWorkers() -> initWorkersFromClasses() -> initWorkersFromInstances() already reaches + // startPolling(). This second call is therefore redundant, but startPolling() is idempotent + // while the worker set is unchanged, so it is a no-op rather than a task runner restart. startPolling(); } @@ -109,10 +118,18 @@ public synchronized void initWorkersFromClasses(List> classes } - /** Shuts down the workers */ - public void shutdown() { + /** + * Shuts down the workers. + * + *

Clears the task runner as well as shutting it down, so a later {@link #startPolling()} + * builds a fresh one and resumes. A {@link TaskRunnerConfigurer} is single-use — its + * shutdown closes the executor backing it — so leaving the field set would make + * startPolling() take its already-polling fast path and never poll again. + */ + public synchronized void shutdown() { if (taskRunner != null) { taskRunner.shutdown(); + taskRunner = null; } } @@ -168,7 +185,15 @@ private boolean classBelongsToPackage(List packagesToScan, String classN return false; } - public void addBean(Object bean) { + /** + * Registers every {@link WorkerTask}-annotated method on the bean as a worker. + * + *

Synchronized because it is the public entry point that mutates the worker set and the + * {@code workersChanged} flag {@link #startPolling()} reads to decide whether a restart is + * needed. Without a common lock, a worker added on another thread could be missed and never + * polled. + */ + public synchronized void addBean(Object bean) { Class clazz = bean.getClass(); for (Method method : clazz.getMethods()) { WorkerTask annotation = method.getAnnotation(WorkerTask.class); @@ -222,6 +247,7 @@ private void addMethod(WorkerTask annotation, Method method, Object bean) { for (int i = 0; i < pollerCount; i++) { workers.add(executor); } + workersChanged = true; LOGGER.info( "Adding worker for task {}, method {} with threadCount {} and polling interval set to {} ms", @@ -231,11 +257,28 @@ private void addMethod(WorkerTask annotation, Method method, Object bean) { pollingInterval); } - public void startPolling() { + /** + * Builds a {@link TaskRunnerConfigurer} over the currently registered workers and starts polling. + * + *

Idempotent: if a task runner is already polling and no worker has been added since it was + * built, this returns without doing anything. Restarting unnecessarily would stand up a second + * runner polling the same task types and only shut the first one down afterwards, so a task + * already leased by the outgoing runner could be left in-progress until its response timeout + * expired. Callers that add workers and call this again still get the intended restart. + */ + public synchronized void startPolling() { if (workers.isEmpty()) { return; } + if (taskRunner != null && !workersChanged) { + LOGGER.debug( + "Task runner is already polling {} workers and the worker set is unchanged; " + + "skipping redundant restart.", + workers.size()); + return; + } + LOGGER.info("Starting {} with threadCount {}", workers.stream().map(Worker::getTaskDefName).toList(), workerToThreadCount); LOGGER.info("Worker domains {}", workerDomains); LOGGER.info("Worker workerToPollTimeout (in millis) {}", workerToPollTimeout); @@ -253,6 +296,8 @@ public void startPolling() { taskRunner = builder.build(); taskRunner.init(); + workersChanged = false; + oldTaskRunner.ifPresent(taskRunner -> { LOGGER.trace("Shutting down previous task runner with {} workers.", taskRunner.getWorkerCount()); taskRunner.shutdown(); diff --git a/conductor-client/src/test/java/com/netflix/conductor/sdk/workflow/executor/WorkflowExecutorMonitorTests.java b/conductor-client/src/test/java/com/netflix/conductor/sdk/workflow/executor/WorkflowExecutorMonitorTests.java new file mode 100644 index 000000000..b28f847ec --- /dev/null +++ b/conductor-client/src/test/java/com/netflix/conductor/sdk/workflow/executor/WorkflowExecutorMonitorTests.java @@ -0,0 +1,160 @@ +/* + * Copyright 2026 Conductor Authors. + *

+ * 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.netflix.conductor.sdk.workflow.executor; + +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import com.netflix.conductor.client.http.MetadataClient; +import com.netflix.conductor.client.http.TaskClient; +import com.netflix.conductor.client.http.WorkflowClient; +import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest; +import com.netflix.conductor.common.run.Workflow; +import com.netflix.conductor.sdk.workflow.executor.task.AnnotatedWorkerExecutor; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * Covers the completion-tracking monitor started by {@link WorkflowExecutor}'s constructors. The + * monitor runs under {@code scheduleAtFixedRate}, which cancels all future ticks on any uncaught + * exception, so a single failed {@code getWorkflow} call must not be allowed to escape. + */ +public class WorkflowExecutorMonitorTests { + + private static final String WORKFLOW_ID = "test-workflow-id"; + + private static final String OTHER_WORKFLOW_ID = "other-test-workflow-id"; + + // Stands in for the one-minute default so the tests need not wait it out. + private static final long TEST_POLL_FAILURE_TIMEOUT_MILLIS = 1000; + + private WorkflowExecutor executorFor(WorkflowClient workflowClient) { + WorkflowExecutor executor = new WorkflowExecutor( + mock(TaskClient.class), + workflowClient, + mock(MetadataClient.class), + mock(AnnotatedWorkerExecutor.class)); + executor.setPollFailureTimeoutMillis(TEST_POLL_FAILURE_TIMEOUT_MILLIS); + return executor; + } + + @Test + @DisplayName("polls failing for the whole timeout should complete that workflow's future exceptionally") + void monitorFailsTheFutureOnPersistentPollFailure() throws Exception { + AtomicInteger polls = new AtomicInteger(); + WorkflowClient workflowClient = mock(WorkflowClient.class); + when(workflowClient.startWorkflow(any(StartWorkflowRequest.class))).thenReturn(WORKFLOW_ID); + when(workflowClient.getWorkflow(anyString(), anyBoolean())).thenAnswer(invocation -> { + polls.incrementAndGet(); + throw new RuntimeException("poll failure"); + }); + + WorkflowExecutor executor = executorFor(workflowClient); + try { + long start = System.nanoTime(); + CompletableFuture future = executor.executeWorkflow("wf", 1, Map.of()); + + ExecutionException thrown = assertThrows( + ExecutionException.class, () -> future.get(5, TimeUnit.SECONDS)); + long elapsedMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start); + + assertInstanceOf(RuntimeException.class, thrown.getCause()); + assertEquals("poll failure", thrown.getCause().getMessage()); + assertTrue(elapsedMillis >= TEST_POLL_FAILURE_TIMEOUT_MILLIS, + "future failed after " + elapsedMillis + " ms, before the timeout"); + // The workflow is untracked before its future fails, so no further polls can follow. + int pollsAtFailure = polls.get(); + Thread.sleep(300); + assertEquals(pollsAtFailure, polls.get()); + } finally { + executor.shutdown(); + } + } + + @Test + @DisplayName("poll failures shorter than the timeout should not fail the future, and a success resets it") + void monitorToleratesTransientPollFailures() throws Exception { + Workflow running = new Workflow(); + running.setStatus(Workflow.WorkflowStatus.RUNNING); + Workflow completed = new Workflow(); + completed.setStatus(Workflow.WorkflowStatus.COMPLETED); + + // Two runs of failures, each spanning ~600 ms of 100 ms ticks (short of the 1 s timeout), + // separated by a single successful poll. Together they span ~1.4 s, past the timeout, so + // the future completes only if that success reset the clock. + int burst = 7; + AtomicInteger calls = new AtomicInteger(); + WorkflowClient workflowClient = mock(WorkflowClient.class); + when(workflowClient.startWorkflow(any(StartWorkflowRequest.class))).thenReturn(WORKFLOW_ID); + when(workflowClient.getWorkflow(anyString(), anyBoolean())).thenAnswer(invocation -> { + int call = calls.incrementAndGet(); + if (call <= burst || (call > burst + 1 && call <= 2 * burst + 1)) { + throw new RuntimeException("transient poll failure"); + } + return call == burst + 1 ? running : completed; + }); + + WorkflowExecutor executor = executorFor(workflowClient); + try { + CompletableFuture future = executor.executeWorkflow("wf", 1, Map.of()); + assertEquals(Workflow.WorkflowStatus.COMPLETED, future.get(10, TimeUnit.SECONDS).getStatus()); + } finally { + executor.shutdown(); + } + } + + @Test + @DisplayName("one workflow's poll failure should not stop the monitor tracking the rest") + void monitorKeepsTrackingOtherWorkflowsAfterAFailure() throws Exception { + Workflow completed = new Workflow(); + completed.setStatus(Workflow.WorkflowStatus.COMPLETED); + + WorkflowClient workflowClient = mock(WorkflowClient.class); + when(workflowClient.startWorkflow(any(StartWorkflowRequest.class))) + .thenReturn(WORKFLOW_ID) + .thenReturn(OTHER_WORKFLOW_ID); + when(workflowClient.getWorkflow(eq(WORKFLOW_ID), anyBoolean())) + .thenThrow(new RuntimeException("poll failure")); + when(workflowClient.getWorkflow(eq(OTHER_WORKFLOW_ID), anyBoolean())) + .thenReturn(completed); + + WorkflowExecutor executor = executorFor(workflowClient); + try { + CompletableFuture failing = executor.executeWorkflow("wf", 1, Map.of()); + assertThrows(ExecutionException.class, () -> failing.get(5, TimeUnit.SECONDS)); + + // Registered only after the failure has already happened, so it can complete at all + // only if the tick loop survived it -- scheduleAtFixedRate would have cancelled every + // future tick had the exception been allowed to escape. + CompletableFuture healthy = executor.executeWorkflow("wf", 1, Map.of()); + assertEquals(Workflow.WorkflowStatus.COMPLETED, healthy.get(5, TimeUnit.SECONDS).getStatus()); + } finally { + executor.shutdown(); + } + } +} diff --git a/conductor-client/src/test/java/com/netflix/conductor/sdk/workflow/executor/task/AnnotatedWorkerTests.java b/conductor-client/src/test/java/com/netflix/conductor/sdk/workflow/executor/task/AnnotatedWorkerTests.java index abc4a19fd..a0c529199 100644 --- a/conductor-client/src/test/java/com/netflix/conductor/sdk/workflow/executor/task/AnnotatedWorkerTests.java +++ b/conductor-client/src/test/java/com/netflix/conductor/sdk/workflow/executor/task/AnnotatedWorkerTests.java @@ -19,13 +19,21 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import com.netflix.conductor.client.automator.TaskRunnerConfigurer; +import com.netflix.conductor.client.events.taskrunner.TaskAckFailure; +import com.netflix.conductor.client.http.ConductorClient; +import com.netflix.conductor.client.http.ConductorClientRequest; +import com.netflix.conductor.client.http.ConductorClientResponse; import com.netflix.conductor.client.http.TaskClient; +import com.netflix.conductor.client.metrics.MetricsCollector; import com.netflix.conductor.client.worker.Worker; import com.netflix.conductor.common.metadata.tasks.Task; import com.netflix.conductor.sdk.workflow.executor.task.workers1.CarWorker1; @@ -37,9 +45,14 @@ import com.netflix.conductor.sdk.workflow.task.WorkerTask; import com.netflix.conductor.sdk.workflow.task.WorkflowInstanceIdInputParam; +import com.fasterxml.jackson.core.type.TypeReference; + import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class AnnotatedWorkerTests { private void testAnnotatedWorkersExecutor(Consumer test) { @@ -84,6 +97,125 @@ void directInstanceSupply() { ))); } + @Test + @DisplayName("initWorkers should leave exactly one task runner polling") + void initWorkersStartsASingleTaskRunner() { + var executor = new AnnotatedWorkerExecutor(mock(TaskClient.class)); + executor.initWorkers("com.netflix.conductor.sdk.workflow.executor.task.workers1"); + + var runner = executor.getTaskRunner(); + assertNotNull(runner); + + // The shape used by examples/old/.../taskdomains/Main.java and by callers following the + // docs: initWorkers() followed by an explicit startPolling(). This must not stand up a + // replacement runner alongside the live one. + executor.startPolling(); + assertSame(runner, executor.getTaskRunner()); + + executor.shutdown(); + } + + @Test + @DisplayName("startPolling should be a no-op while the worker set is unchanged") + void startPollingIsIdempotent() { + var executor = new AnnotatedWorkerExecutor(mock(TaskClient.class)); + executor.addBean(new MultipleInputParams()); + + executor.startPolling(); + var first = executor.getTaskRunner(); + assertNotNull(first); + + executor.startPolling(); + executor.startPolling(); + assertSame(first, executor.getTaskRunner()); + + executor.shutdown(); + } + + @Test + @DisplayName("startPolling should still rebuild the task runner once new workers are added") + void startPollingRebuildsWhenWorkersAreAdded() { + var executor = new AnnotatedWorkerExecutor(mock(TaskClient.class)); + executor.addBean(new MultipleInputParams()); + executor.startPolling(); + var first = executor.getTaskRunner(); + assertEquals(1, first.getWorkerCount()); + + executor.addBean(new AnotherAnnotationInput()); + executor.startPolling(); + var second = executor.getTaskRunner(); + + assertNotSame(first, second); + assertEquals(2, second.getWorkerCount()); + + executor.shutdown(); + } + + @Test + @DisplayName("startPolling should build a fresh task runner after a shutdown") + void startPollingRestartsAfterShutdown() { + var executor = new AnnotatedWorkerExecutor(mock(TaskClient.class)); + executor.addBean(new MultipleInputParams()); + executor.startPolling(); + var first = executor.getTaskRunner(); + assertNotNull(first); + + // A TaskRunnerConfigurer is single-use, so shutdown() has to clear the field as well as + // shut the runner down. Otherwise startPolling()'s idempotence check sees a non-null + // runner with an unchanged worker set and silently declines to poll ever again. + executor.shutdown(); + assertNull(executor.getTaskRunner()); + + executor.startPolling(); + var second = executor.getTaskRunner(); + assertNotNull(second); + assertNotSame(first, second); + assertEquals(1, second.getWorkerCount()); + + executor.shutdown(); + } + + @Test + @DisplayName("TaskClient metrics should keep flowing after a restart and after adding a worker") + @SuppressWarnings("unchecked") + void taskClientMetricsSurviveRunnerReplacement() throws InterruptedException { + var collector = mock(MetricsCollector.class); + // Delivery is asynchronous, so record ack failures and wait on them. Only this overload is + // stubbed: the collector also receives poll events through its other consume() overloads. + BlockingQueue ackFailures = new LinkedBlockingQueue<>(); + doAnswer(invocation -> ackFailures.add(invocation.getArgument(0).getTaskId())) + .when(collector).consume(any(TaskAckFailure.class)); + var conductorClient = mock(ConductorClient.class); + when(conductorClient.getMetricsCollector()).thenReturn(collector); + // Polls get no tasks; acks are declined, so TaskClient publishes a TaskAckFailure to its + // auto-wired collector -- the listener a TaskRunnerConfigurer shutdown used to remove. + when(conductorClient.execute(any(ConductorClientRequest.class), any(TypeReference.class))) + .thenAnswer(invocation -> { + ConductorClientRequest request = invocation.getArgument(0); + Object data = request.getPath().endsWith("/ack") ? Boolean.FALSE : List.of(); + return new ConductorClientResponse<>(200, Map.of(), data); + }); + + var taskClient = new TaskClient(conductorClient); + var executor = new AnnotatedWorkerExecutor(taskClient); + executor.addBean(new MultipleInputParams()); + executor.startPolling(); + + executor.shutdown(); + executor.startPolling(); + taskClient.ack("multiple_input_params", "after-restart", "worker"); + assertEquals("after-restart", ackFailures.poll(5, TimeUnit.SECONDS)); + + // Builds the new runner before shutting the old one down, which is the order that + // detached the listeners out from under the live runner. + executor.addBean(new AnotherAnnotationInput()); + executor.startPolling(); + taskClient.ack("multiple_input_params", "after-add", "worker"); + assertEquals("after-add", ackFailures.poll(5, TimeUnit.SECONDS)); + + executor.shutdown(); + } + @Test @DisplayName("it should handle null values when InputParam is a List") void nullListAsInputParam() throws NoSuchMethodException { diff --git a/examples/basics/hello-world/docker-compose.yml b/examples/basics/hello-world/docker-compose.yml index 61b7c07d9..2b92c8f73 100644 --- a/examples/basics/hello-world/docker-compose.yml +++ b/examples/basics/hello-world/docker-compose.yml @@ -1,11 +1,16 @@ services: conductor: image: conductoross/conductor:latest + # Always re-pull so a stale local `latest` doesn't run an older release. + pull_policy: always ports: - "${CONDUCTOR_PORT:-8080}:8080" - "${CONDUCTOR_UI_PORT:-1234}:5000" healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8080/health"] + # Images up to 3.34.0-rc2 ship curl but not wget; from rc3 on they ship + # busybox wget but not curl. Try both. 127.0.0.1 for wget: busybox wget + # tries ::1 first and does not fall back to the IPv4-bound server. + test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:8080/health || curl -sf http://localhost:8080/health"] interval: 5s timeout: 5s retries: 12 diff --git a/scripts/docker-compose-oss.yaml b/scripts/docker-compose-oss.yaml new file mode 100644 index 000000000..48fc06988 --- /dev/null +++ b/scripts/docker-compose-oss.yaml @@ -0,0 +1,45 @@ +# Conductor OSS stack used to run the SDK integration tests against open-source Conductor. +# Shared by scripts/run-integration-oss.sh and the integration-tests-oss job in +# .github/workflows/integration-tests-oss.yml. +# +# The `image:` default below is the SINGLE place the Conductor OSS image tag is written. +# Everything that does not override OSS_CONDUCTOR_VERSION lands on it: a plain +# scripts/run-integration-oss.sh run, and the integration-tests-oss job on a fork PR (where +# GitHub withholds org variables). Overrides are the script's --version flag and, in CI, the +# E2E_TEST_OSS_CONDUCTOR_VERSION org variable or a workflow_dispatch input. Bump the tag here +# and both follow. +# +# The org variable is set independently of this default, so a normal CI run can be on a +# different tag than a local run. The "Pull Conductor OSS image" CI step prints the tag in use. + +services: + conductor-server: + image: conductoross/conductor:${OSS_CONDUCTOR_VERSION:-3.34.0} + environment: + - CONFIG_PROP=config-postgres.properties + ports: + - "8080:8080" + healthcheck: + # Images up to 3.34.0-rc2 ship curl but not wget; from rc3 on they ship busybox wget but not + # curl. Try both so the status is right on any tag. 127.0.0.1 for wget: busybox wget tries + # ::1 first and does not fall back to the IPv4-bound server. + test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:8080/health || curl -sf http://localhost:8080/health"] + interval: 10s + timeout: 10s + retries: 20 + links: + - conductor-postgres:postgresdb + depends_on: + conductor-postgres: + condition: service_healthy + + conductor-postgres: + image: postgres:16 + environment: + - POSTGRES_USER=conductor + - POSTGRES_PASSWORD=conductor + healthcheck: + test: timeout 5 bash -c 'cat < /dev/null > /dev/tcp/localhost/5432' + interval: 5s + timeout: 5s + retries: 12 diff --git a/scripts/run-integration-oss.sh b/scripts/run-integration-oss.sh new file mode 100755 index 000000000..f1c26fab2 --- /dev/null +++ b/scripts/run-integration-oss.sh @@ -0,0 +1,133 @@ +#!/usr/bin/env bash +# +# Spin up a local Conductor OSS stack and run the `tests` module's +# integration suite against it, mirroring the `integration-tests-oss` job in +# .github/workflows/integration-tests-oss.yml. Orkes-Enterprise-only test +# classes are annotated with @DisabledOnOss, so they skip themselves when +# CONDUCTOR_SERVER_TYPE=oss is set (see the individual test files for +# the empirically-confirmed gaps). +# +# The stack (Conductor OSS + Postgres) is defined in +# scripts/docker-compose-oss.yaml and is torn down automatically on exit. That +# file's `image:` line is also where the default tag lives -- this script +# applies no default of its own, so a plain run and a fork-PR CI run land on +# the identical image. The image is always pulled before starting, since a tag +# can be mutable and a cached copy would otherwise go stale silently. +# +# Usage: +# scripts/run-integration-oss.sh [--keep-up] [--version ] [--include-gated] [-- gradle args] +# Examples: +# scripts/run-integration-oss.sh # default tag from the compose file +# scripts/run-integration-oss.sh --version 3.33.0-rc1 +# scripts/run-integration-oss.sh --keep-up +# scripts/run-integration-oss.sh --include-gated # also run tests normally skipped as Orkes-only +# scripts/run-integration-oss.sh -- --tests "*WorkflowClientTests" +set -euo pipefail + +KEEP_UP=0 +INCLUDE_GATED=0 +extra=() + +while [[ $# -gt 0 ]]; do + case "$1" in + --keep-up) KEEP_UP=1; shift ;; + --version) OSS_CONDUCTOR_VERSION="${2:?--version needs a tag}"; shift 2 ;; + --include-gated) INCLUDE_GATED=1; shift ;; + -h|--help) + echo "Usage: $0 [--keep-up] [--version ] [--include-gated] [-- gradle args]" + exit 0 + ;; + --) shift; extra=("$@"); break ;; + *) echo "Unknown argument: $1" >&2; exit 1 ;; + esac +done + +# No default is applied here on purpose. The default tag is written once, in the +# `image:` line of scripts/docker-compose-oss.yaml, so leaving OSS_CONDUCTOR_VERSION +# unset lets compose supply it -- the same path a fork PR takes in CI. Only export +# it when the caller actually asked for a specific tag, otherwise a value set but +# not exported in the caller's shell would never reach compose anyway. +if [[ -n "${OSS_CONDUCTOR_VERSION:-}" ]]; then + export OSS_CONDUCTOR_VERSION +fi + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" +COMPOSE_FILE="${SCRIPT_DIR}/docker-compose-oss.yaml" +cd "${REPO_ROOT}" + +compose() { docker compose -f "${COMPOSE_FILE}" "$@"; } + +LOG_FILE="${REPO_ROOT}/tests/build/oss-conductor-server.log" + +cleanup() { + local status=$? + if [[ "${status}" -ne 0 ]]; then + mkdir -p "$(dirname "${LOG_FILE}")" + compose logs --no-color conductor-server > "${LOG_FILE}" 2>&1 || true + echo "Tests run exited with code ${status}, container logs saved to ${LOG_FILE}" >&2 + fi + if [[ "${KEEP_UP}" == "1" ]]; then + echo "--keep-up set: leaving the OSS stack running. Tear down with:" + echo " docker compose -f ${COMPOSE_FILE} down -v" + return + fi + echo "Tearing down Conductor OSS stack..." + compose down -v || true +} +trap cleanup EXIT + +# Ask compose what it resolved rather than reconstructing the tag here, so this +# stays correct whether the tag came from --version or from the compose default. +# `--images` lists every service's image and does not reliably honour a service +# filter, so select the server's by name rather than by position. +SERVER_IMAGE="$(compose config --images | grep -m1 '^conductoross/conductor:')" +echo "Using ${SERVER_IMAGE}" + +# `docker compose up` only pulls an image when it is missing locally, so a +# previously-cached mutable tag (a re-pushed rc, or `latest` if that is what was +# asked for) would silently be reused instead of getting the current version. +# Pull unconditionally so the stack always reflects the tag we just printed. +echo "Pulling ${SERVER_IMAGE} to ensure it's current..." +compose pull conductor-server + +echo "Starting Conductor OSS stack..." +compose up -d + +echo "Waiting for Conductor to be healthy..." +HEALTH_TIMEOUT="${HEALTH_TIMEOUT:-180}" +deadline=$(( SECONDS + HEALTH_TIMEOUT )) +until curl -sf http://localhost:8080/health >/dev/null 2>&1; do + if (( SECONDS >= deadline )); then + echo "Error: Conductor did not become healthy within ${HEALTH_TIMEOUT}s." >&2 + exit 1 + fi + sleep 5 +done +echo "Conductor is up." + +export CONDUCTOR_SERVER_URL="http://localhost:8080/api" + +# Plain OSS Conductor has no authentication layer and no /token endpoint. ClientTestUtil builds +# its client with useEnvVariables(true), and ApiClient.applyEnvVariables() attaches credentials +# whenever both of these are present -- so a shell that still has them exported for the Orkes +# suite would send the whole run through an auth flow the local server cannot serve. +unset CONDUCTOR_AUTH_KEY CONDUCTOR_AUTH_SECRET +unset CONDUCTOR_SERVER_AUTH_KEY CONDUCTOR_SERVER_AUTH_SECRET + +if [[ "${INCLUDE_GATED}" == "1" ]]; then + echo "--include-gated set: leaving CONDUCTOR_SERVER_TYPE unset, so tests normally" \ + "skipped as Orkes-only will run against OSS too." + unset CONDUCTOR_SERVER_TYPE || true +else + export CONDUCTOR_SERVER_TYPE="oss" +fi + + +# --rerun-tasks: the `test` task's up-to-date check only considers the compiled +# test classpath, not env vars like CONDUCTOR_SERVER_URL/CONDUCTOR_SERVER_TYPE +# or the state of the live server underneath. Without this, Gradle can report +# BUILD SUCCESSFUL while silently reusing a stale cached result from a +# previous run against a different server/tag/gating state instead of +# actually executing anything. +./gradlew :tests:test -PIntegrationTests --rerun-tasks ${extra[@]+"${extra[@]}"} diff --git a/tests/src/test/java/io/orkes/conductor/client/ServiceRegistryClientTest.java b/tests/src/test/java/io/orkes/conductor/client/ServiceRegistryClientTest.java index 76922097e..e4bf2f9e9 100644 --- a/tests/src/test/java/io/orkes/conductor/client/ServiceRegistryClientTest.java +++ b/tests/src/test/java/io/orkes/conductor/client/ServiceRegistryClientTest.java @@ -25,11 +25,13 @@ import com.netflix.conductor.common.model.ServiceRegistry; import io.orkes.conductor.client.util.ClientTestUtil; +import io.orkes.conductor.client.util.DisabledOnOss; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@DisabledOnOss("the Service Registry API (/registry/service) is not implemented by plain OSS Conductor, confirmed empirically (404 'No static resource api/registry/service')") public class ServiceRegistryClientTest { private static final String PROTO_FILENAME = "compiled.bin"; diff --git a/tests/src/test/java/io/orkes/conductor/client/WorkflowRetryTest.java b/tests/src/test/java/io/orkes/conductor/client/WorkflowRetryTest.java index e3793c077..d5869a23e 100644 --- a/tests/src/test/java/io/orkes/conductor/client/WorkflowRetryTest.java +++ b/tests/src/test/java/io/orkes/conductor/client/WorkflowRetryTest.java @@ -31,11 +31,13 @@ import io.orkes.conductor.client.http.OrkesWorkflowClient; import io.orkes.conductor.client.util.ClientTestUtil; import io.orkes.conductor.client.util.Commons; +import io.orkes.conductor.client.util.DisabledOnOss; import com.google.common.util.concurrent.Uninterruptibles; import lombok.extern.slf4j.Slf4j; @Slf4j +@DisabledOnOss("workflowClient.uploadCompletedWorkflows() (/workflow/document-store/upload) is not implemented by plain OSS Conductor, confirmed empirically (404 'No static resource api/workflow/document-store/upload')") public class WorkflowRetryTest { private final OrkesMetadataClient metadataClient; private final OrkesWorkflowClient workflowClient; diff --git a/tests/src/test/java/io/orkes/conductor/client/http/AuthorizationClientTests.java b/tests/src/test/java/io/orkes/conductor/client/http/AuthorizationClientTests.java index d40e829bc..6a3bd1aa7 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/AuthorizationClientTests.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/AuthorizationClientTests.java @@ -48,7 +48,9 @@ import io.orkes.conductor.client.model.UpsertUserRequest; import io.orkes.conductor.client.util.ClientTestUtil; import io.orkes.conductor.client.util.Commons; +import io.orkes.conductor.client.util.DisabledOnOss; +@DisabledOnOss("the Authorization APIs (applications/users/groups/roles/permissions) are not implemented by plain OSS Conductor, confirmed empirically (404 'No static resource api/applications|users|groups|...')") public class AuthorizationClientTests { private static AuthorizationClient authorizationClient; private static String applicationId; diff --git a/tests/src/test/java/io/orkes/conductor/client/http/EnvironmentClientTests.java b/tests/src/test/java/io/orkes/conductor/client/http/EnvironmentClientTests.java index 6dd0e3359..f581760e0 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/EnvironmentClientTests.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/EnvironmentClientTests.java @@ -12,18 +12,21 @@ */ package io.orkes.conductor.client.http; -import io.orkes.conductor.client.EnvironmentClient; -import io.orkes.conductor.client.model.Tag; -import io.orkes.conductor.client.model.environment.EnvironmentVariable; -import io.orkes.conductor.client.util.ClientTestUtil; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import io.orkes.conductor.client.EnvironmentClient; +import io.orkes.conductor.client.model.Tag; +import io.orkes.conductor.client.model.environment.EnvironmentVariable; +import io.orkes.conductor.client.util.ClientTestUtil; +import io.orkes.conductor.client.util.DisabledOnOss; +@DisabledOnOss("environment variable writes are not supported by plain OSS Conductor, confirmed empirically: OSS added read-only GET /environment in 3.32.0-rc.9 but PUT /environment/{key} still 405s ('Request method 'PUT' is not supported')") public class EnvironmentClientTests { private static EnvironmentClient envClient; diff --git a/tests/src/test/java/io/orkes/conductor/client/http/MetadataClientTests.java b/tests/src/test/java/io/orkes/conductor/client/http/MetadataClientTests.java index 836dfd110..9b4052725 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/MetadataClientTests.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/MetadataClientTests.java @@ -24,6 +24,7 @@ import io.orkes.conductor.client.model.TagObject; import io.orkes.conductor.client.util.ClientTestUtil; import io.orkes.conductor.client.util.Commons; +import io.orkes.conductor.client.util.DisabledOnOss; import io.orkes.conductor.client.util.TestUtil; import io.orkes.conductor.client.util.WorkflowUtil; @@ -73,6 +74,7 @@ void workflow() { } @Test + @DisabledOnOss("task tagging (/metadata/task/{name}/tags) is not implemented by plain OSS Conductor, confirmed empirically (404 'No static resource api/metadata/task/{name}/tags')") void tagTask() throws Exception { metadataClient.registerTaskDefs(List.of(Commons.getTaskDef())); try { @@ -98,6 +100,7 @@ void tagTask() throws Exception { } @Test + @DisabledOnOss("workflow tagging (/metadata/workflow/{name}/tags) is not implemented by OSS Conductor; the path falls through to DELETE /metadata/workflow/{name}/{version} with version=\"tags\", so other methods 405") void tagWorkflow() { TagObject tagObject = Commons.getTagObject(); try { diff --git a/tests/src/test/java/io/orkes/conductor/client/http/PromptClientTests.java b/tests/src/test/java/io/orkes/conductor/client/http/PromptClientTests.java index 53d427232..7162691d3 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/PromptClientTests.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/PromptClientTests.java @@ -16,6 +16,7 @@ import java.util.List; import java.util.Map; +import org.conductoross.conductor.client.model.ai.PromptTemplate; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -29,9 +30,10 @@ import io.orkes.conductor.client.model.integration.Category; import io.orkes.conductor.client.model.integration.IntegrationApiUpdate; import io.orkes.conductor.client.model.integration.IntegrationUpdate; -import org.conductoross.conductor.client.model.ai.PromptTemplate; import io.orkes.conductor.client.util.ClientTestUtil; +import io.orkes.conductor.client.util.DisabledOnOss; +@DisabledOnOss("the Prompts and Integrations APIs (/prompts, /integrations) are not implemented by plain OSS Conductor, confirmed empirically (404 'No static resource api/prompts|integrations/...')") public class PromptClientTests { private static final String PROMPT_NAME = "test-sdk-java-prompt"; private static final String PROMPT_DESCRIPTION = "Test prompt for Java SDK"; diff --git a/tests/src/test/java/io/orkes/conductor/client/http/SchedulerClientTests.java b/tests/src/test/java/io/orkes/conductor/client/http/SchedulerClientTests.java index f86c332d2..1fc0c83ef 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/SchedulerClientTests.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/SchedulerClientTests.java @@ -12,6 +12,7 @@ */ package io.orkes.conductor.client.http; +import java.time.Duration; import java.util.List; import java.util.UUID; @@ -23,9 +24,12 @@ import io.orkes.conductor.client.model.SaveScheduleRequest; import io.orkes.conductor.client.model.TagObject; import io.orkes.conductor.client.model.WorkflowSchedule; +import io.orkes.conductor.client.model.WorkflowScheduleExecutionModel; import io.orkes.conductor.client.util.ClientTestUtil; import io.orkes.conductor.client.util.Commons; +import io.orkes.conductor.client.util.DisabledOnOss; +import static org.awaitility.Awaitility.await; import static org.junit.jupiter.api.Assertions.assertEquals; public class SchedulerClientTests { @@ -37,6 +41,7 @@ public class SchedulerClientTests { private static final String CRON_EXPRESSION_1 = "0 * * * * *"; private static final String CRON_EXPRESSION_2 = "0 0 */2 * * *"; // Every 2 hours private static final String CRON_EXPRESSION_3 = "0 0 0 * * *"; // Daily at midnight + private static final String CRON_EVERY_SECOND = "* * * * * *"; private final SchedulerClient schedulerClient = ClientTestUtil.getOrkesClients().getSchedulerClient(); @@ -59,11 +64,6 @@ void testMethods() { WorkflowSchedule workflowSchedule = schedulerClient.getSchedule(SCHEDULE_1); assertEquals(SCHEDULE_1, workflowSchedule.getName()); assertEquals(CRON_EXPRESSION_1, workflowSchedule.getCronExpression()); - Assertions.assertFalse(schedulerClient.search(0, 10, "ASC", "*", "").getResults().isEmpty()); - schedulerClient.setSchedulerTags(getTagObject(), SCHEDULE_1); - assertEquals(getTagObject(), schedulerClient.getSchedulerTags(SCHEDULE_1)); - schedulerClient.deleteSchedulerTags(getTagObject(), SCHEDULE_1); - assertEquals(0, schedulerClient.getSchedulerTags(SCHEDULE_1).size()); schedulerClient.pauseSchedule(SCHEDULE_1); workflowSchedule = schedulerClient.getSchedule(SCHEDULE_1); Assertions.assertTrue(workflowSchedule.isPaused()); @@ -73,6 +73,36 @@ void testMethods() { schedulerClient.deleteSchedule(SCHEDULE_1); } + @Test + @DisplayName("search should find the executions of a schedule once it has fired") + void testSearchExecutions() { + // search() covers executions, not schedules, so fire our own schedule every second rather + // than relying on whatever execution history the server already has. + schedulerClient.saveSchedule(new SaveScheduleRequest() + .name(SCHEDULE_1) + .cronExpression(CRON_EVERY_SECOND) + .startWorkflowRequest(Commons.getStartWorkflowRequest())); + + List executions = await() + .atMost(Duration.ofSeconds(60)) + .pollInterval(Duration.ofSeconds(2)) + .until(() -> schedulerClient.search(0, 10, "ASC", "*", "scheduleName IN (" + SCHEDULE_1 + ")") + .getResults(), results -> results != null && !results.isEmpty()); + schedulerClient.pauseSchedule(SCHEDULE_1); + + executions.forEach(execution -> assertEquals(SCHEDULE_1, execution.getScheduleName())); + } + + @Test + @DisabledOnOss("schedule tagging (/scheduler/schedules/{name}/tags) is not implemented by OSS Conductor") + void testSchedulerTags() { + schedulerClient.saveSchedule(getSaveScheduleRequest()); + schedulerClient.setSchedulerTags(getTagObject(), SCHEDULE_1); + assertEquals(getTagObject(), schedulerClient.getSchedulerTags(SCHEDULE_1)); + schedulerClient.deleteSchedulerTags(getTagObject(), SCHEDULE_1); + assertEquals(0, schedulerClient.getSchedulerTags(SCHEDULE_1).size()); + } + @Test void testDebugMethods() { schedulerClient.pauseAllSchedules(); diff --git a/tests/src/test/java/io/orkes/conductor/client/http/SchemaClientTests.java b/tests/src/test/java/io/orkes/conductor/client/http/SchemaClientTests.java index b74b318fc..b116d5258 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/SchemaClientTests.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/SchemaClientTests.java @@ -23,7 +23,9 @@ import io.orkes.conductor.client.SchemaClient; import io.orkes.conductor.client.util.ClientTestUtil; +import io.orkes.conductor.client.util.DisabledOnOss; +@DisabledOnOss("the Schema API (/schema) is not implemented by plain OSS Conductor, confirmed empirically (404 'No static resource api/schema')") public class SchemaClientTests { private static final String SCHEMA_NAME = "test-sdk-java-schema"; diff --git a/tests/src/test/java/io/orkes/conductor/client/http/SecretClientTests.java b/tests/src/test/java/io/orkes/conductor/client/http/SecretClientTests.java index 1a8daecf8..c316ab347 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/SecretClientTests.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/SecretClientTests.java @@ -22,8 +22,10 @@ import io.orkes.conductor.client.SecretClient; import io.orkes.conductor.client.model.TagObject; import io.orkes.conductor.client.util.ClientTestUtil; +import io.orkes.conductor.client.util.DisabledOnOss; +@DisabledOnOss("secret writes are not supported by plain OSS Conductor, confirmed empirically: its env-var-backed secrets DAO is read-only, so putSecret() 501s ('env-backed secrets are read-only')") public class SecretClientTests { private final String SECRET_NAME = "test-sdk-java-secret_name"; private final String SECRET_KEY = "test-sdk-java-secret_key"; diff --git a/tests/src/test/java/io/orkes/conductor/client/http/ServiceRegistryClientTests.java b/tests/src/test/java/io/orkes/conductor/client/http/ServiceRegistryClientTests.java index d5253fd8a..575939e26 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/ServiceRegistryClientTests.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/ServiceRegistryClientTests.java @@ -27,11 +27,13 @@ import io.orkes.conductor.client.ServiceRegistryClient; import io.orkes.conductor.client.util.ClientTestUtil; +import io.orkes.conductor.client.util.DisabledOnOss; import lombok.SneakyThrows; import static org.junit.jupiter.api.Assertions.assertNull; +@DisabledOnOss("the Service Registry API (/registry/service) is not implemented by plain OSS Conductor, confirmed empirically (404 'No static resource api/registry/service')") public class ServiceRegistryClientTests { private static final String SERVICE_NAME = "test-sdk-java-service"; private static final String SERVICE_URI = "localhost:50051"; diff --git a/tests/src/test/java/io/orkes/conductor/client/http/TaskClientTests.java b/tests/src/test/java/io/orkes/conductor/client/http/TaskClientTests.java index 22f9098e7..b453e0ed6 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/TaskClientTests.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/TaskClientTests.java @@ -47,6 +47,7 @@ import com.netflix.conductor.sdk.workflow.executor.WorkflowExecutor; import io.orkes.conductor.client.util.ClientTestUtil; +import io.orkes.conductor.client.util.DisabledOnOss; import io.orkes.conductor.client.util.TestUtil; import com.fasterxml.jackson.databind.ObjectMapper; @@ -54,6 +55,8 @@ import static org.junit.jupiter.api.Assertions.*; public class TaskClientTests { + private static final String SIGNAL_SYNC_NOT_ON_OSS = + "the SYNCHRONOUS/REGION_DURABLE consistency + BLOCKING_* return-strategy signal API (POST /tasks/{workflowId}/{status}/signal/sync) is not implemented by plain OSS Conductor, confirmed empirically"; private static final String COMPLEX_WF_NAME = "complex_wf_signal_test"; private static final String SUB_WF_1_NAME = "complex_wf_signal_test_subworkflow_1"; @@ -161,7 +164,9 @@ public void testUpdateByRefNameSync() { while (!workflow.getStatus().isTerminal() && count < maxLoop) { workflow = workflowClient.getWorkflow(workflowId, true); List runningTasks = workflow.getTasks().stream() - .filter(task -> !task.getStatus().isTerminal() && task.getTaskType().equals("there_is_no_worker")) + // Every SIMPLE task, not just the there_is_no_worker ones: nothing else completes the + // workflow's first task (x_test_worker_0), so the fork tasks would never be scheduled. + .filter(task -> !task.getStatus().isTerminal() && task.getWorkflowTask().getType().equals("SIMPLE")) .map(Task::getReferenceTaskName) .collect(Collectors.toList()); System.out.println("Running tasks: " + runningTasks); @@ -332,6 +337,7 @@ private void completeWorkflow(String workflowId) throws Exception { } @Test + @DisabledOnOss(SIGNAL_SYNC_NOT_ON_OSS) void testSyncTargetWorkflow() throws Exception { String workflowId = startComplexWorkflow(Consistency.SYNCHRONOUS, ReturnStrategy.TARGET_WORKFLOW); @@ -346,6 +352,7 @@ void testSyncTargetWorkflow() throws Exception { } @Test + @DisabledOnOss(SIGNAL_SYNC_NOT_ON_OSS) void testSyncBlockingWorkflow() throws Exception { String workflowId = startComplexWorkflow(Consistency.SYNCHRONOUS, ReturnStrategy.BLOCKING_WORKFLOW); @@ -360,6 +367,7 @@ void testSyncBlockingWorkflow() throws Exception { } @Test + @DisabledOnOss(SIGNAL_SYNC_NOT_ON_OSS) void testSyncBlockingTask() throws Exception { String workflowId = startComplexWorkflow(Consistency.SYNCHRONOUS, ReturnStrategy.BLOCKING_TASK); @@ -374,6 +382,7 @@ void testSyncBlockingTask() throws Exception { } @Test + @DisabledOnOss("BLOCKING_TASK_LIST is not a value of the server-side WorkflowSignalReturnStrategy enum in any OSS Conductor release, so OSS rejects the returnStrategy parameter outright, on top of not implementing the signal/sync API the other BLOCKING_* tests are skipped for") void testSyncBlockingTaskList() throws Exception { String workflowId = startComplexWorkflow(Consistency.SYNCHRONOUS, ReturnStrategy.BLOCKING_TASK_LIST); @@ -391,6 +400,7 @@ void testSyncBlockingTaskList() throws Exception { } @Test + @DisabledOnOss(SIGNAL_SYNC_NOT_ON_OSS) void testSyncBlockingTaskInput() throws Exception { String workflowId = startComplexWorkflow(Consistency.SYNCHRONOUS, ReturnStrategy.BLOCKING_TASK_INPUT); @@ -408,7 +418,9 @@ void testSyncBlockingTaskInput() throws Exception { private static final String REGION_DURABLE_ENABLED = "CONDUCTOR_REGION_DURABLE_ENABLED"; @Test - @EnabledIfEnvironmentVariable(named = REGION_DURABLE_ENABLED, matches = "true") + @EnabledIfEnvironmentVariable(named = REGION_DURABLE_ENABLED, matches = "true", + disabledReason = "target server has no region replication configured") + @DisabledOnOss(SIGNAL_SYNC_NOT_ON_OSS) void testDurableTargetWorkflow() throws Exception { String workflowId = startComplexWorkflow(Consistency.REGION_DURABLE, ReturnStrategy.TARGET_WORKFLOW); @@ -423,7 +435,9 @@ void testDurableTargetWorkflow() throws Exception { } @Test - @EnabledIfEnvironmentVariable(named = REGION_DURABLE_ENABLED, matches = "true") + @EnabledIfEnvironmentVariable(named = REGION_DURABLE_ENABLED, matches = "true", + disabledReason = "target server has no region replication configured") + @DisabledOnOss(SIGNAL_SYNC_NOT_ON_OSS) void testDurableBlockingWorkflow() throws Exception { String workflowId = startComplexWorkflow(Consistency.REGION_DURABLE, ReturnStrategy.BLOCKING_WORKFLOW); @@ -438,6 +452,7 @@ void testDurableBlockingWorkflow() throws Exception { } @Test + @DisabledOnOss(SIGNAL_SYNC_NOT_ON_OSS) void testDurableBlockingTask() throws Exception { String workflowId = startComplexWorkflow(Consistency.DURABLE, ReturnStrategy.BLOCKING_TASK); @@ -452,7 +467,9 @@ void testDurableBlockingTask() throws Exception { } @Test - @EnabledIfEnvironmentVariable(named = REGION_DURABLE_ENABLED, matches = "true") + @EnabledIfEnvironmentVariable(named = REGION_DURABLE_ENABLED, matches = "true", + disabledReason = "target server has no region replication configured") + @DisabledOnOss(SIGNAL_SYNC_NOT_ON_OSS) void testDurableBlockingTaskInput() throws Exception { String workflowId = startComplexWorkflow(Consistency.REGION_DURABLE, ReturnStrategy.BLOCKING_TASK_INPUT); @@ -467,6 +484,7 @@ void testDurableBlockingTaskInput() throws Exception { } @Test + @DisabledOnOss(SIGNAL_SYNC_NOT_ON_OSS) void testDefaultReturnStrategy() throws Exception { String workflowId = startComplexWorkflow(Consistency.SYNCHRONOUS, ReturnStrategy.TARGET_WORKFLOW); @@ -744,6 +762,15 @@ void testRequeuePendingTasksByTaskType() { // ==================== Search Tests ==================== + // OSS Conductor's Postgres task_index has no workflow_id column, so a workflowId query fails there. + // On the shared Orkes cluster a workflowType query covers every past run of this workflow and can + // time out, so only OSS searches by workflowType. + private String taskSearchQuery(String workflowId) { + return TestUtil.isOssServer() + ? "workflowType='" + workflowName + "'" + : "workflowId='" + workflowId + "'"; + } + @Test void testSearchTasks() { StartWorkflowRequest request = new StartWorkflowRequest(); @@ -754,7 +781,7 @@ void testSearchTasks() { try { var result = TestUtil.retryUntil( - () -> taskClient.search("workflowId='" + workflowId + "'"), 30_000, 2_000); + () -> taskClient.search(taskSearchQuery(workflowId)), 30_000, 2_000); assertNotNull(result); } finally { workflowClient.terminateWorkflow(workflowId, "cleanup"); @@ -792,7 +819,7 @@ void testPaginatedSearchTasks() { Uninterruptibles.sleepUninterruptibly(5, TimeUnit.SECONDS); var result = taskClient.search( - 0, 10, "startTime:DESC", "*", "workflowId='" + workflowId + "'"); + 0, 10, "startTime:DESC", "*", taskSearchQuery(workflowId)); assertNotNull(result); } finally { workflowClient.terminateWorkflow(workflowId, "cleanup"); diff --git a/tests/src/test/java/io/orkes/conductor/client/http/TokenClientTest.java b/tests/src/test/java/io/orkes/conductor/client/http/TokenClientTest.java index 06b2f25dc..7b3df523c 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/TokenClientTest.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/TokenClientTest.java @@ -20,7 +20,9 @@ import io.orkes.conductor.client.model.GenerateTokenRequest; import io.orkes.conductor.client.model.TokenResponse; import io.orkes.conductor.client.util.ClientTestUtil; +import io.orkes.conductor.client.util.DisabledOnOss; +@DisabledOnOss("the auth Token API (/token) is not implemented by plain OSS Conductor (which has no authentication layer), confirmed empirically (404 'No static resource api/token')") public class TokenClientTest { public static OrkesTokenClient tokenClient; diff --git a/tests/src/test/java/io/orkes/conductor/client/http/WorkflowClientTests.java b/tests/src/test/java/io/orkes/conductor/client/http/WorkflowClientTests.java index a8d906940..85f36dbdc 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/WorkflowClientTests.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/WorkflowClientTests.java @@ -41,6 +41,7 @@ import io.orkes.conductor.client.util.ClientTestUtil; import io.orkes.conductor.client.util.Commons; +import io.orkes.conductor.client.util.DisabledOnOss; import io.orkes.conductor.client.util.TestUtil; import com.google.common.util.concurrent.Uninterruptibles; @@ -102,6 +103,7 @@ public void startWorkflow() { } @Test + @DisabledOnOss("batch correlation-id search (POST /workflow/correlated/batch) is not implemented by plain OSS Conductor, confirmed empirically (404 'No static resource api/workflow/correlated/batch')") public void testSearchByCorrelationIds() { List correlationIds = new ArrayList<>(); Set workflowNames = new HashSet<>(); @@ -188,6 +190,7 @@ public void testSkipTaskFromWorkflow() throws Exception { } @Test + @DisabledOnOss("POST /workflow/{workflowId}/variables is not implemented by plain OSS Conductor, confirmed empirically (404 'No static resource api/workflow/{id}/variables')") public void testUpdateVariables() { ConductorWorkflow workflow = new ConductorWorkflow<>(workflowExecutor); workflow.add(new SimpleTask("simple_task", "simple_task_ref")); diff --git a/tests/src/test/java/io/orkes/conductor/client/http/WorkflowStateUpdateTests.java b/tests/src/test/java/io/orkes/conductor/client/http/WorkflowStateUpdateTests.java index 286d428a5..c8dfc1dbf 100644 --- a/tests/src/test/java/io/orkes/conductor/client/http/WorkflowStateUpdateTests.java +++ b/tests/src/test/java/io/orkes/conductor/client/http/WorkflowStateUpdateTests.java @@ -35,6 +35,7 @@ import io.orkes.conductor.client.model.WorkflowStateUpdate; import io.orkes.conductor.client.util.ClientTestUtil; +import io.orkes.conductor.client.util.DisabledOnOss; import lombok.SneakyThrows; @@ -91,6 +92,7 @@ public String startWorkflow() { } @Test + @DisabledOnOss("POST /workflow/{workflowId}/state (updateWorkflow) is not implemented by plain OSS Conductor, confirmed empirically (404 'No static resource api/workflow/{id}/state')") public void test() { String workflowId = startWorkflow(); System.out.println(workflowId); @@ -135,6 +137,7 @@ public void test() { } @Test + @DisabledOnOss("OSS Conductor ignores start-workflow idempotency keys (RETURN_EXISTING starts a new run instead of returning the original workflowId); see conductor-oss/conductor#1527") public void testIdempotency() { StartWorkflowRequest startWorkflowRequest = new StartWorkflowRequest(); startWorkflowRequest.setName("sync_task_variable_updates"); diff --git a/tests/src/test/java/io/orkes/conductor/client/util/DisabledOnOss.java b/tests/src/test/java/io/orkes/conductor/client/util/DisabledOnOss.java new file mode 100644 index 000000000..d1decf8d9 --- /dev/null +++ b/tests/src/test/java/io/orkes/conductor/client/util/DisabledOnOss.java @@ -0,0 +1,36 @@ +/* + * Copyright 2026 Conductor Authors. + *

+ * 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 io.orkes.conductor.client.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * Skips the annotated test class or method when the suite runs against plain Conductor OSS, i.e. + * when {@code CONDUCTOR_SERVER_TYPE=oss}. For Orkes-only features that OSS does not implement. + * + *

Not a composed {@code @DisabledIfEnvironmentVariable}: a meta-annotation cannot pass a + * per-use reason through, and the reason is the record of each gap. + */ +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@ExtendWith(DisabledOnOssCondition.class) +public @interface DisabledOnOss { + + /** The specific, empirically-confirmed OSS gap, reported as the skip reason. */ + String value(); +} diff --git a/tests/src/test/java/io/orkes/conductor/client/util/DisabledOnOssCondition.java b/tests/src/test/java/io/orkes/conductor/client/util/DisabledOnOssCondition.java new file mode 100644 index 000000000..d3c74ae34 --- /dev/null +++ b/tests/src/test/java/io/orkes/conductor/client/util/DisabledOnOssCondition.java @@ -0,0 +1,36 @@ +/* + * Copyright 2026 Conductor Authors. + *

+ * 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 io.orkes.conductor.client.util; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.platform.commons.support.AnnotationSupport; + +/** Evaluates {@link DisabledOnOss}. */ +public final class DisabledOnOssCondition implements ExecutionCondition { + + /** Set by scripts/run-integration-oss.sh and the OSS CI workflow; unset for Orkes. */ + static final String SERVER_TYPE_ENV = "CONDUCTOR_SERVER_TYPE"; + + static final String OSS = "oss"; + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + return AnnotationSupport.findAnnotation(context.getElement(), DisabledOnOss.class) + .filter(annotation -> TestUtil.isOssServer()) + .map(annotation -> ConditionEvaluationResult.disabled( + SERVER_TYPE_ENV + "=" + OSS, annotation.value())) + .orElseGet(() -> ConditionEvaluationResult.enabled("not running against Conductor OSS")); + } +} diff --git a/tests/src/test/java/io/orkes/conductor/client/util/TestUtil.java b/tests/src/test/java/io/orkes/conductor/client/util/TestUtil.java index 65b13f72e..d3378c035 100644 --- a/tests/src/test/java/io/orkes/conductor/client/util/TestUtil.java +++ b/tests/src/test/java/io/orkes/conductor/client/util/TestUtil.java @@ -156,6 +156,11 @@ public static T retryUntil(Callable call, long maxWaitTimeMs, long pollIn .until(call, result -> true); } + /** True when the suite runs against plain Conductor OSS, i.e. {@code CONDUCTOR_SERVER_TYPE=oss}. */ + public static boolean isOssServer() { + return DisabledOnOssCondition.OSS.equals(System.getenv(DisabledOnOssCondition.SERVER_TYPE_ENV)); + } + private static boolean isTerminalFailure(Workflow workflow) { return workflow.getStatus() == Workflow.WorkflowStatus.FAILED || workflow.getStatus() == Workflow.WorkflowStatus.TERMINATED; diff --git a/tests/src/test/java/io/orkes/conductor/sdk/WorkflowSDKTests.java b/tests/src/test/java/io/orkes/conductor/sdk/WorkflowSDKTests.java index 452da6872..391cfd926 100644 --- a/tests/src/test/java/io/orkes/conductor/sdk/WorkflowSDKTests.java +++ b/tests/src/test/java/io/orkes/conductor/sdk/WorkflowSDKTests.java @@ -14,9 +14,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -38,11 +36,15 @@ public class WorkflowSDKTests { @Test - public void testCreateWorkflow() { + public void testCreateWorkflow() throws Exception { ConductorClient client = ClientTestUtil.getClient(); AnnotatedWorkerExecutor workerExecutor = new AnnotatedWorkerExecutor(new TaskClient(client), new WorkerConfiguration()); workerExecutor.initWorkers("io.orkes.conductor.sdk"); + // Redundant -- initWorkers() already reaches startPolling() -- but kept deliberately: this is + // the shape the docs and examples use, and startPolling() is now idempotent, so it must not + // restart the runner out from under an in-flight poll. See + // AnnotatedWorkerTests#initWorkersStartsASingleTaskRunner. workerExecutor.startPolling(); WorkflowExecutor executor = new WorkflowExecutor(client, workerExecutor); @@ -57,11 +59,14 @@ public void testCreateWorkflow() { CompletableFuture result = workflow.execute(Map.of("name", "orkes")); Assertions.assertNotNull(result); try { - Workflow executedWorkflow = result.get(3, TimeUnit.SECONDS); + // WorkflowExecutor's monitor thread polls every 100ms (see initMonitor()), so 10s is a generous margin. + Workflow executedWorkflow = result.get(10, TimeUnit.SECONDS); Assertions.assertNotNull(executedWorkflow); Assertions.assertEquals(Workflow.WorkflowStatus.COMPLETED, executedWorkflow.getStatus()); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assertions.fail(e.getMessage()); + } catch (Exception e) { + // fail(e), not fail(e.getMessage()): a TimeoutException carries a null message, which + // previously surfaced in CI as a bare AssertionFailedError with nothing to diagnose. + Assertions.fail(e); } }