diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2d9fc98c..d509c2d0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,4 +46,5 @@ jobs: with: skip-test: ${{ github.event.inputs.skip-test == 'true' }} kestra-version: ${{ github.event.inputs.kestra-version }} + java-version: '25' secrets: inherit diff --git a/build.gradle b/build.gradle index 5e83a5c0..01f3edee 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ tasks.withType(JavaCompile) { options.compilerArgs.add("-parameters") } -final targetJavaVersion = JavaVersion.VERSION_21 +final targetJavaVersion = JavaVersion.VERSION_25 group "io.kestra.plugin" @@ -122,6 +122,9 @@ subprojects { testImplementation group: "io.kestra", name: "repository-memory", version: kestraVersion testImplementation group: "io.kestra", name: "runner-memory", version: kestraVersion testImplementation group: "io.kestra", name: "storage-local", version: kestraVersion + testImplementation group: "io.kestra", name: "worker", version: kestraVersion + testImplementation group: "io.kestra", name: "worker-controller", version: kestraVersion + testImplementation group: "io.kestra", name: "scheduler", version: kestraVersion // test testImplementation "org.junit.jupiter:junit-jupiter-engine" @@ -133,30 +136,6 @@ subprojects { } } -/**********************************************************************************************************************\ - * Allure Reports - **********************************************************************************************************************/ -subprojects { - dependencies { - testImplementation enforcedPlatform("io.kestra:platform:$kestraVersion") - testImplementation "io.qameta.allure:allure-junit5" - } - - configurations { - agent { - canBeResolved = true - canBeConsumed = true - } - } - - dependencies { - agent "org.aspectj:aspectjweaver:1.9.25.1" - } - - test { - jvmArgs = [ "-javaagent:${configurations.agent.singleFile}" ] - } -} /**********************************************************************************************************************\ * Jacoco diff --git a/gradle.properties b/gradle.properties index 22225564..ca694087 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ version=1.9.6-SNAPSHOT -kestraVersion=1.3.19 +kestraVersion=2.0.0-SNAPSHOT org.gradle.parallel=true org.gradle.caching=true diff --git a/gradlew.bat b/gradlew.bat index 8508ef68..a51ec4f5 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,82 +1,82 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem gradlew startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables, and ensure extensions are enabled -setlocal EnableExtensions - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -"%COMSPEC%" /c exit 1 - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -"%COMSPEC%" /c exit 1 - -:execute -@rem Setup the command line - - - -@rem Execute gradlew -@rem endlocal doesn't take effect until after the line is parsed and variables are expanded -@rem which allows us to clear the local environment before executing the java command -endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel - -:exitWithErrorLevel -@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts -"%COMSPEC%" /c exit %ERRORLEVEL% +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem gradlew startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:execute +@rem Setup the command line + + + +@rem Execute gradlew +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel + +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/plugin-script-bun/src/main/java/io/kestra/plugin/scripts/bun/Commands.java b/plugin-script-bun/src/main/java/io/kestra/plugin/scripts/bun/Commands.java index c5f0def5..e8b7013e 100644 --- a/plugin-script-bun/src/main/java/io/kestra/plugin/scripts/bun/Commands.java +++ b/plugin-script-bun/src/main/java/io/kestra/plugin/scripts/bun/Commands.java @@ -81,6 +81,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-bun/src/main/java/io/kestra/plugin/scripts/bun/Script.java b/plugin-script-bun/src/main/java/io/kestra/plugin/scripts/bun/Script.java index 2a062034..a7804b4a 100644 --- a/plugin-script-bun/src/main/java/io/kestra/plugin/scripts/bun/Script.java +++ b/plugin-script-bun/src/main/java/io/kestra/plugin/scripts/bun/Script.java @@ -88,6 +88,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-bun/src/test/java/io/kestra/plugins/scripts/bun/ScriptTest.java b/plugin-script-bun/src/test/java/io/kestra/plugins/scripts/bun/ScriptTest.java index 3c2094de..b0cca99d 100644 --- a/plugin-script-bun/src/test/java/io/kestra/plugins/scripts/bun/ScriptTest.java +++ b/plugin-script-bun/src/test/java/io/kestra/plugins/scripts/bun/ScriptTest.java @@ -11,8 +11,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; @@ -20,8 +19,6 @@ import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -33,13 +30,12 @@ public class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script bunScript = Script.builder() .id("bun-script-" + UUID.randomUUID()) @@ -54,7 +50,6 @@ void script() throws Exception { assertThat(run.getStdOutLineCount(), is(1)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Kestra is amazing!")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains("Kestra is amazing!")), is(true)); } } \ No newline at end of file diff --git a/plugin-script-bun/src/test/resources/allure.properties b/plugin-script-bun/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-bun/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-bun/src/test/resources/application.yml b/plugin-script-bun/src/test/resources/application.yml index ffbcc1b0..3cc46a48 100644 --- a/plugin-script-bun/src/test/resources/application.yml +++ b/plugin-script-bun/src/test/resources/application.yml @@ -7,3 +7,16 @@ kestra: type: memory repository: type: memory + controller: + port: ${random.port} + worker: + controllers: + type: STATIC + static: + endpoints: + - host: localhost + port: ${kestra.controller.port} + +grpc: + server: + enabled: false diff --git a/plugin-script-deno/src/main/java/io/kestra/plugin/scripts/deno/Commands.java b/plugin-script-deno/src/main/java/io/kestra/plugin/scripts/deno/Commands.java index 5e6c8240..deb0cd02 100644 --- a/plugin-script-deno/src/main/java/io/kestra/plugin/scripts/deno/Commands.java +++ b/plugin-script-deno/src/main/java/io/kestra/plugin/scripts/deno/Commands.java @@ -66,6 +66,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override public ScriptOutput run(RunContext runContext) throws Exception { TargetOS os = runContext.render(this.targetOS).as(TargetOS.class).orElse(null); diff --git a/plugin-script-deno/src/main/java/io/kestra/plugin/scripts/deno/Script.java b/plugin-script-deno/src/main/java/io/kestra/plugin/scripts/deno/Script.java index e9ee7522..f57ed84f 100644 --- a/plugin-script-deno/src/main/java/io/kestra/plugin/scripts/deno/Script.java +++ b/plugin-script-deno/src/main/java/io/kestra/plugin/scripts/deno/Script.java @@ -69,6 +69,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-deno/src/test/java/io/kestra/plugins/scripts/deno/CommandsTest.java b/plugin-script-deno/src/test/java/io/kestra/plugins/scripts/deno/CommandsTest.java index 49cc28a4..75359598 100644 --- a/plugin-script-deno/src/test/java/io/kestra/plugins/scripts/deno/CommandsTest.java +++ b/plugin-script-deno/src/test/java/io/kestra/plugins/scripts/deno/CommandsTest.java @@ -11,8 +11,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; @@ -20,8 +19,6 @@ import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -33,13 +30,12 @@ public class CommandsTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Commands commands = Commands.builder() .id("deno-commands-" + UUID.randomUUID()) @@ -53,7 +49,6 @@ void task() throws Exception { assertThat(run.getExitCode(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Hello from Deno Command")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains("Hello from Deno Command")), is(true)); } } \ No newline at end of file diff --git a/plugin-script-deno/src/test/java/io/kestra/plugins/scripts/deno/ScriptTest.java b/plugin-script-deno/src/test/java/io/kestra/plugins/scripts/deno/ScriptTest.java index 8b3cce1b..59bb82a8 100644 --- a/plugin-script-deno/src/test/java/io/kestra/plugins/scripts/deno/ScriptTest.java +++ b/plugin-script-deno/src/test/java/io/kestra/plugins/scripts/deno/ScriptTest.java @@ -11,8 +11,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; @@ -20,8 +19,6 @@ import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -33,13 +30,12 @@ public class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script script = Script.builder() .id("deno-script-" + UUID.randomUUID()) @@ -54,7 +50,6 @@ void script() throws Exception { String expectedLog = "Hello from deno script."; TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains(expectedLog)); - receive.blockLast(); assertThat(List.copyOf(logs).stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains(expectedLog)), is(true)); } } \ No newline at end of file diff --git a/plugin-script-deno/src/test/resources/allure.properties b/plugin-script-deno/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-deno/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-deno/src/test/resources/application.yml b/plugin-script-deno/src/test/resources/application.yml index ffbcc1b0..3cc46a48 100644 --- a/plugin-script-deno/src/test/resources/application.yml +++ b/plugin-script-deno/src/test/resources/application.yml @@ -7,3 +7,16 @@ kestra: type: memory repository: type: memory + controller: + port: ${random.port} + worker: + controllers: + type: STATIC + static: + endpoints: + - host: localhost + port: ${kestra.controller.port} + +grpc: + server: + enabled: false diff --git a/plugin-script-dotnet/src/test/java/io/kestra/plugin/scripts/dotnet/CommandsTest.java b/plugin-script-dotnet/src/test/java/io/kestra/plugin/scripts/dotnet/CommandsTest.java index cb44703d..5731eda3 100644 --- a/plugin-script-dotnet/src/test/java/io/kestra/plugin/scripts/dotnet/CommandsTest.java +++ b/plugin-script-dotnet/src/test/java/io/kestra/plugin/scripts/dotnet/CommandsTest.java @@ -13,16 +13,13 @@ import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTaskException; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -33,13 +30,12 @@ class CommandsTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Commands dotnetCommands = Commands.builder() .id("dotnet-commands-" + UUID.randomUUID()) @@ -54,7 +50,6 @@ void task() throws Exception { assertThat(run.getStdOutLineCount(), greaterThanOrEqualTo(1)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().matches("\\d+\\.\\d+\\.\\d+.*")); - receive.blockLast(); } @Test diff --git a/plugin-script-dotnet/src/test/java/io/kestra/plugin/scripts/dotnet/ScriptTest.java b/plugin-script-dotnet/src/test/java/io/kestra/plugin/scripts/dotnet/ScriptTest.java index 56ce2cbe..27b05224 100644 --- a/plugin-script-dotnet/src/test/java/io/kestra/plugin/scripts/dotnet/ScriptTest.java +++ b/plugin-script-dotnet/src/test/java/io/kestra/plugin/scripts/dotnet/ScriptTest.java @@ -13,16 +13,13 @@ import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTaskException; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -34,13 +31,12 @@ class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script dotnetScript = Script.builder() .id("dotnet-script-" + UUID.randomUUID()) @@ -54,7 +50,6 @@ void script() throws Exception { assertThat(run.getExitCode(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Hello from Kestra!")); - receive.blockLast(); assertThat( List.copyOf(logs).stream() .filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("Hello from Kestra!")) @@ -66,7 +61,7 @@ void script() throws Exception { @Test void scriptWithNugetDependency() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script dotnetScript = Script.builder() .id("dotnet-nuget-" + UUID.randomUUID()) @@ -85,7 +80,6 @@ void scriptWithNugetDependency() throws Exception { assertThat(run.getExitCode(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Hello from NuGet")); - receive.blockLast(); assertThat( List.copyOf(logs).stream() .filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("Hello from NuGet")) diff --git a/plugin-script-go/src/main/java/io/kestra/plugin/scripts/go/Commands.java b/plugin-script-go/src/main/java/io/kestra/plugin/scripts/go/Commands.java index 908fc67e..4c4e151f 100644 --- a/plugin-script-go/src/main/java/io/kestra/plugin/scripts/go/Commands.java +++ b/plugin-script-go/src/main/java/io/kestra/plugin/scripts/go/Commands.java @@ -88,6 +88,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, @NotNull DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-go/src/main/java/io/kestra/plugin/scripts/go/Script.java b/plugin-script-go/src/main/java/io/kestra/plugin/scripts/go/Script.java index aefb60fc..49bc662b 100644 --- a/plugin-script-go/src/main/java/io/kestra/plugin/scripts/go/Script.java +++ b/plugin-script-go/src/main/java/io/kestra/plugin/scripts/go/Script.java @@ -87,6 +87,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, @NotNull DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-go/src/test/java/io/kestra/plugin/scripts/go/CommandsTriggerTest.java b/plugin-script-go/src/test/java/io/kestra/plugin/scripts/go/CommandsTriggerTest.java index 40aeb572..dbd4c78a 100644 --- a/plugin-script-go/src/test/java/io/kestra/plugin/scripts/go/CommandsTriggerTest.java +++ b/plugin-script-go/src/test/java/io/kestra/plugin/scripts/go/CommandsTriggerTest.java @@ -35,7 +35,7 @@ void commandsTrigger_shouldTriggerOnImplicitFailureExit1() throws Exception { .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); @@ -58,7 +58,7 @@ void commandsTrigger_shouldTriggerOnStdoutMatchUsingStructuredOutputs() throws E .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); @@ -82,12 +82,12 @@ void commandsTrigger_edgeModeShouldSuppressSecondEmission() throws Exception { .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional first = trigger.evaluate(context.getKey(), context.getValue()); + Optional first = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat("First evaluation should fire", first.isPresent(), is(true)); // Second evaluation with edge=true should suppress context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional second = trigger.evaluate(context.getKey(), context.getValue()); + Optional second = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat("Edge mode should suppress repeated emission", second.isPresent(), is(false)); } @@ -103,7 +103,7 @@ void commandsTrigger_shouldMatchRegexAgainstStructuredOutputs() throws Exception .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat("Regex condition should match", execution.isPresent(), is(true)); diff --git a/plugin-script-go/src/test/java/io/kestra/plugins/scripts/go/CommandsTest.java b/plugin-script-go/src/test/java/io/kestra/plugins/scripts/go/CommandsTest.java index 11b35de7..a0ec3bfa 100644 --- a/plugin-script-go/src/test/java/io/kestra/plugins/scripts/go/CommandsTest.java +++ b/plugin-script-go/src/test/java/io/kestra/plugins/scripts/go/CommandsTest.java @@ -17,8 +17,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; import io.kestra.core.tenant.TenantService; @@ -26,7 +25,6 @@ import io.kestra.plugin.scripts.go.Commands; import jakarta.inject.Inject; -import jakarta.inject.Named; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -37,8 +35,7 @@ public class CommandsTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Inject StorageInterface storageInterface; @@ -46,7 +43,7 @@ public class CommandsTest { @Test void should_print_hello_there() throws Exception { List logs = new CopyOnWriteArrayList<>(); - var receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); var goScript = storageInterface.put( TenantService.MAIN_TENANT, @@ -91,7 +88,6 @@ func main() { assertThat(run.getStdErrLineCount(), is(3)); // go logs everything to stderr TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("hello there!")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("hello there!")).count(), is(1L)); } diff --git a/plugin-script-go/src/test/java/io/kestra/plugins/scripts/go/ScriptTest.java b/plugin-script-go/src/test/java/io/kestra/plugins/scripts/go/ScriptTest.java index 3911e59f..9aeaa003 100644 --- a/plugin-script-go/src/test/java/io/kestra/plugins/scripts/go/ScriptTest.java +++ b/plugin-script-go/src/test/java/io/kestra/plugins/scripts/go/ScriptTest.java @@ -13,8 +13,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; import io.kestra.core.tenant.TenantService; @@ -22,7 +21,6 @@ import io.kestra.plugin.scripts.go.Script; import jakarta.inject.Inject; -import jakarta.inject.Named; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -33,8 +31,7 @@ public class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Inject StorageInterface storageInterface; @@ -42,7 +39,7 @@ public class ScriptTest { @Test void should_print_hello_there() throws Exception { List logs = new CopyOnWriteArrayList<>(); - var receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); var script = Script.builder() .id("go-script-" + UUID.randomUUID()) @@ -65,7 +62,6 @@ func main() { assertThat(run.getStdErrLineCount(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("hello there!")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("hello there!")).count(), is(1L)); } diff --git a/plugin-script-go/src/test/resources/allure.properties b/plugin-script-go/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-go/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-go/src/test/resources/application.yml b/plugin-script-go/src/test/resources/application.yml index ffbcc1b0..3cc46a48 100644 --- a/plugin-script-go/src/test/resources/application.yml +++ b/plugin-script-go/src/test/resources/application.yml @@ -7,3 +7,16 @@ kestra: type: memory repository: type: memory + controller: + port: ${random.port} + worker: + controllers: + type: STATIC + static: + endpoints: + - host: localhost + port: ${kestra.controller.port} + +grpc: + server: + enabled: false diff --git a/plugin-script-groovy/src/main/java/io/kestra/plugin/scripts/groovy/Commands.java b/plugin-script-groovy/src/main/java/io/kestra/plugin/scripts/groovy/Commands.java index 4edfa872..5fe61d25 100644 --- a/plugin-script-groovy/src/main/java/io/kestra/plugin/scripts/groovy/Commands.java +++ b/plugin-script-groovy/src/main/java/io/kestra/plugin/scripts/groovy/Commands.java @@ -88,6 +88,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-groovy/src/main/java/io/kestra/plugin/scripts/groovy/Script.java b/plugin-script-groovy/src/main/java/io/kestra/plugin/scripts/groovy/Script.java index e545f191..ec44fb14 100644 --- a/plugin-script-groovy/src/main/java/io/kestra/plugin/scripts/groovy/Script.java +++ b/plugin-script-groovy/src/main/java/io/kestra/plugin/scripts/groovy/Script.java @@ -87,6 +87,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-groovy/src/test/java/io/kestra/plugin/scripts/groovy/CommandsTest.java b/plugin-script-groovy/src/test/java/io/kestra/plugin/scripts/groovy/CommandsTest.java index d0332034..04b5c96d 100644 --- a/plugin-script-groovy/src/test/java/io/kestra/plugin/scripts/groovy/CommandsTest.java +++ b/plugin-script-groovy/src/test/java/io/kestra/plugin/scripts/groovy/CommandsTest.java @@ -11,15 +11,12 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -31,13 +28,12 @@ public class CommandsTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); var groovyCommands = Commands.builder() .id("groovy-commands-" + UUID.randomUUID()) @@ -52,7 +48,6 @@ void task() throws Exception { assertThat(run.getExitCode(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("I love Kestra!")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains("I love Kestra!")), is(true)); } } \ No newline at end of file diff --git a/plugin-script-groovy/src/test/java/io/kestra/plugin/scripts/groovy/ScriptTest.java b/plugin-script-groovy/src/test/java/io/kestra/plugin/scripts/groovy/ScriptTest.java index 11048008..11b1e8bb 100644 --- a/plugin-script-groovy/src/test/java/io/kestra/plugin/scripts/groovy/ScriptTest.java +++ b/plugin-script-groovy/src/test/java/io/kestra/plugin/scripts/groovy/ScriptTest.java @@ -11,15 +11,12 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -31,13 +28,12 @@ public class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); var groovyScript = Script.builder() .id("groovy-script-" + UUID.randomUUID()) @@ -52,7 +48,6 @@ void script() throws Exception { assertThat(run.getExitCode(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Kestra is amazing!")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains("Kestra is amazing!")), is(true)); } } \ No newline at end of file diff --git a/plugin-script-groovy/src/test/resources/allure.properties b/plugin-script-groovy/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-groovy/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-groovy/src/test/resources/application.yml b/plugin-script-groovy/src/test/resources/application.yml index ffbcc1b0..3cc46a48 100644 --- a/plugin-script-groovy/src/test/resources/application.yml +++ b/plugin-script-groovy/src/test/resources/application.yml @@ -7,3 +7,16 @@ kestra: type: memory repository: type: memory + controller: + port: ${random.port} + worker: + controllers: + type: STATIC + static: + endpoints: + - host: localhost + port: ${kestra.controller.port} + +grpc: + server: + enabled: false diff --git a/plugin-script-jbang/src/main/java/io/kestra/plugin/scripts/jbang/Commands.java b/plugin-script-jbang/src/main/java/io/kestra/plugin/scripts/jbang/Commands.java index 92a74db3..b93358b6 100644 --- a/plugin-script-jbang/src/main/java/io/kestra/plugin/scripts/jbang/Commands.java +++ b/plugin-script-jbang/src/main/java/io/kestra/plugin/scripts/jbang/Commands.java @@ -65,6 +65,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-jbang/src/main/java/io/kestra/plugin/scripts/jbang/Script.java b/plugin-script-jbang/src/main/java/io/kestra/plugin/scripts/jbang/Script.java index a179b334..bb4f8e6b 100644 --- a/plugin-script-jbang/src/main/java/io/kestra/plugin/scripts/jbang/Script.java +++ b/plugin-script-jbang/src/main/java/io/kestra/plugin/scripts/jbang/Script.java @@ -140,6 +140,15 @@ public class Script extends AbstractExecScript implements RunnableTask quiet = Property.ofValue(true); + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-jbang/src/test/java/io/kestra/plugin/scripts/jbang/CommandsTest.java b/plugin-script-jbang/src/test/java/io/kestra/plugin/scripts/jbang/CommandsTest.java index 89aa704d..f36414bd 100644 --- a/plugin-script-jbang/src/test/java/io/kestra/plugin/scripts/jbang/CommandsTest.java +++ b/plugin-script-jbang/src/test/java/io/kestra/plugin/scripts/jbang/CommandsTest.java @@ -14,8 +14,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; @@ -24,8 +23,6 @@ import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -39,13 +36,12 @@ class CommandsTest { StorageInterface storageInterface; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); URI put = storageInterface.put( TenantService.MAIN_TENANT, @@ -80,7 +76,6 @@ public static void main(String[] args) { assertThat(run.getStdErrLineCount(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Hello World")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("World!")).count(), is(1L)); } } diff --git a/plugin-script-jbang/src/test/java/io/kestra/plugin/scripts/jbang/ScriptTest.java b/plugin-script-jbang/src/test/java/io/kestra/plugin/scripts/jbang/ScriptTest.java index 7f33ab28..153259d8 100644 --- a/plugin-script-jbang/src/test/java/io/kestra/plugin/scripts/jbang/ScriptTest.java +++ b/plugin-script-jbang/src/test/java/io/kestra/plugin/scripts/jbang/ScriptTest.java @@ -11,16 +11,13 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -31,13 +28,12 @@ class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script jbangScript = Script.builder() .id("jbang-script-" + UUID.randomUUID()) @@ -65,7 +61,6 @@ public static void main(String[] args) { assertThat(run.getStdOutLineCount(), is(1)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Hello World")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("World!")).count(), is(1L)); } } diff --git a/plugin-script-jbang/src/test/resources/allure.properties b/plugin-script-jbang/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-jbang/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-julia/src/main/java/io/kestra/plugin/scripts/julia/Commands.java b/plugin-script-julia/src/main/java/io/kestra/plugin/scripts/julia/Commands.java index 38db0d40..2f469233 100644 --- a/plugin-script-julia/src/main/java/io/kestra/plugin/scripts/julia/Commands.java +++ b/plugin-script-julia/src/main/java/io/kestra/plugin/scripts/julia/Commands.java @@ -74,6 +74,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-julia/src/main/java/io/kestra/plugin/scripts/julia/Script.java b/plugin-script-julia/src/main/java/io/kestra/plugin/scripts/julia/Script.java index 2197ab81..0119e382 100644 --- a/plugin-script-julia/src/main/java/io/kestra/plugin/scripts/julia/Script.java +++ b/plugin-script-julia/src/main/java/io/kestra/plugin/scripts/julia/Script.java @@ -76,6 +76,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-julia/src/test/java/io/kestra/plugin/scripts/julia/CommandsTest.java b/plugin-script-julia/src/test/java/io/kestra/plugin/scripts/julia/CommandsTest.java index 4b193127..89a6b9d2 100644 --- a/plugin-script-julia/src/test/java/io/kestra/plugin/scripts/julia/CommandsTest.java +++ b/plugin-script-julia/src/test/java/io/kestra/plugin/scripts/julia/CommandsTest.java @@ -14,8 +14,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; @@ -24,8 +23,6 @@ import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -39,13 +36,12 @@ class CommandsTest { StorageInterface storageInterface; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); URI put = storageInterface.put( TenantService.MAIN_TENANT, @@ -71,7 +67,6 @@ void task() throws Exception { assertThat(run.getStdErrLineCount(), is(1)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains(put.getPath())); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("hello there!")).count(), is(1L)); } } diff --git a/plugin-script-julia/src/test/java/io/kestra/plugin/scripts/julia/ScriptTest.java b/plugin-script-julia/src/test/java/io/kestra/plugin/scripts/julia/ScriptTest.java index e44d785c..48fb4ee2 100644 --- a/plugin-script-julia/src/test/java/io/kestra/plugin/scripts/julia/ScriptTest.java +++ b/plugin-script-julia/src/test/java/io/kestra/plugin/scripts/julia/ScriptTest.java @@ -11,16 +11,13 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -31,13 +28,12 @@ class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script juliaScript = Script.builder() .id("julia-script-" + UUID.randomUUID()) @@ -53,7 +49,6 @@ void script() throws Exception { assertThat(run.getStdErrLineCount(), is(1)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("hello there!")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("hello there!")).count(), is(1L)); } } diff --git a/plugin-script-julia/src/test/resources/allure.properties b/plugin-script-julia/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-julia/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-jython/src/test/resources/allure.properties b/plugin-script-jython/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-jython/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-lua/src/main/java/io/kestra/plugin/scripts/lua/Commands.java b/plugin-script-lua/src/main/java/io/kestra/plugin/scripts/lua/Commands.java index 84e823ef..3218b8fc 100644 --- a/plugin-script-lua/src/main/java/io/kestra/plugin/scripts/lua/Commands.java +++ b/plugin-script-lua/src/main/java/io/kestra/plugin/scripts/lua/Commands.java @@ -60,6 +60,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override public ScriptOutput run(RunContext runContext) throws Exception { TargetOS os = runContext.render(this.targetOS).as(TargetOS.class).orElse(null); diff --git a/plugin-script-lua/src/main/java/io/kestra/plugin/scripts/lua/Script.java b/plugin-script-lua/src/main/java/io/kestra/plugin/scripts/lua/Script.java index c987a313..cdcae2da 100644 --- a/plugin-script-lua/src/main/java/io/kestra/plugin/scripts/lua/Script.java +++ b/plugin-script-lua/src/main/java/io/kestra/plugin/scripts/lua/Script.java @@ -70,6 +70,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-lua/src/test/java/io/kestra/plugins/scripts/lua/CommandsTest.java b/plugin-script-lua/src/test/java/io/kestra/plugins/scripts/lua/CommandsTest.java index 814f64d6..14c7487e 100644 --- a/plugin-script-lua/src/test/java/io/kestra/plugins/scripts/lua/CommandsTest.java +++ b/plugin-script-lua/src/test/java/io/kestra/plugins/scripts/lua/CommandsTest.java @@ -12,8 +12,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; @@ -21,8 +20,6 @@ import io.kestra.plugin.scripts.lua.Commands; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -33,13 +30,12 @@ public class CommandsTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Commands luaCommands = Commands.builder() .id("lua-commands-" + UUID.randomUUID()) @@ -59,7 +55,6 @@ void task() throws Exception { String expectedLog = "Hello from kestra!"; TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains(expectedLog)); - receive.blockLast(); assertThat(List.copyOf(logs).stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains(expectedLog)), is(true)); } } \ No newline at end of file diff --git a/plugin-script-lua/src/test/java/io/kestra/plugins/scripts/lua/ScriptTest.java b/plugin-script-lua/src/test/java/io/kestra/plugins/scripts/lua/ScriptTest.java index 726f6932..18f8617d 100644 --- a/plugin-script-lua/src/test/java/io/kestra/plugins/scripts/lua/ScriptTest.java +++ b/plugin-script-lua/src/test/java/io/kestra/plugins/scripts/lua/ScriptTest.java @@ -11,8 +11,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; @@ -20,8 +19,6 @@ import io.kestra.plugin.scripts.lua.Script; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -32,13 +29,12 @@ public class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script luaScript = Script.builder() .id("lua-script-" + UUID.randomUUID()) @@ -53,7 +49,6 @@ void script() throws Exception { String expectedLog = "kestra task ran successfully."; TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains(expectedLog)); - receive.blockLast(); assertThat(List.copyOf(logs).stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains(expectedLog)), is(true)); } } \ No newline at end of file diff --git a/plugin-script-lua/src/test/resources/allure.properties b/plugin-script-lua/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-lua/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-lua/src/test/resources/application.yml b/plugin-script-lua/src/test/resources/application.yml index ffbcc1b0..3cc46a48 100644 --- a/plugin-script-lua/src/test/resources/application.yml +++ b/plugin-script-lua/src/test/resources/application.yml @@ -7,3 +7,16 @@ kestra: type: memory repository: type: memory + controller: + port: ${random.port} + worker: + controllers: + type: STATIC + static: + endpoints: + - host: localhost + port: ${kestra.controller.port} + +grpc: + server: + enabled: false diff --git a/plugin-script-nashorn/src/test/resources/allure.properties b/plugin-script-nashorn/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-nashorn/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-nashorn/src/test/resources/application.yml b/plugin-script-nashorn/src/test/resources/application.yml index ffbcc1b0..3cc46a48 100644 --- a/plugin-script-nashorn/src/test/resources/application.yml +++ b/plugin-script-nashorn/src/test/resources/application.yml @@ -7,3 +7,16 @@ kestra: type: memory repository: type: memory + controller: + port: ${random.port} + worker: + controllers: + type: STATIC + static: + endpoints: + - host: localhost + port: ${kestra.controller.port} + +grpc: + server: + enabled: false diff --git a/plugin-script-node/src/main/java/io/kestra/plugin/scripts/node/Commands.java b/plugin-script-node/src/main/java/io/kestra/plugin/scripts/node/Commands.java index 2638d7e9..2115a38e 100644 --- a/plugin-script-node/src/main/java/io/kestra/plugin/scripts/node/Commands.java +++ b/plugin-script-node/src/main/java/io/kestra/plugin/scripts/node/Commands.java @@ -71,6 +71,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-node/src/main/java/io/kestra/plugin/scripts/node/Script.java b/plugin-script-node/src/main/java/io/kestra/plugin/scripts/node/Script.java index a50d59b1..993014bd 100644 --- a/plugin-script-node/src/main/java/io/kestra/plugin/scripts/node/Script.java +++ b/plugin-script-node/src/main/java/io/kestra/plugin/scripts/node/Script.java @@ -188,6 +188,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/CommandsTest.java b/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/CommandsTest.java index 9c4bd7d8..34416aef 100644 --- a/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/CommandsTest.java +++ b/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/CommandsTest.java @@ -14,8 +14,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; @@ -24,8 +23,6 @@ import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -39,13 +36,12 @@ class CommandsTest { StorageInterface storageInterface; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); URI put = storageInterface.put( TenantService.MAIN_TENANT, @@ -71,7 +67,6 @@ void task() throws Exception { assertThat(run.getStdErrLineCount(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains(put.getPath())); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("hello there!")).count(), is(1L)); } } diff --git a/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/CommandsTriggerTest.java b/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/CommandsTriggerTest.java index d2292b3d..e45f82de 100644 --- a/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/CommandsTriggerTest.java +++ b/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/CommandsTriggerTest.java @@ -35,7 +35,7 @@ void commandsTrigger_shouldTriggerOnImplicitFailureExit1() throws Exception { .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); @@ -58,7 +58,7 @@ void commandsTrigger_shouldTriggerOnStdoutMatchUsingStructuredOutputs() throws E .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); diff --git a/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/ScriptTest.java b/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/ScriptTest.java index 33b1fd17..7a6b749d 100644 --- a/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/ScriptTest.java +++ b/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/ScriptTest.java @@ -11,16 +11,13 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -31,13 +28,12 @@ class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script nodeScript = Script.builder() .id("node-script-" + UUID.randomUUID()) @@ -53,7 +49,6 @@ void script() throws Exception { assertThat(run.getStdErrLineCount(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("hello there!")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("hello there!")).count(), is(1L)); } } diff --git a/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/ScriptTriggerTest.java b/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/ScriptTriggerTest.java index a3285262..f671c212 100644 --- a/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/ScriptTriggerTest.java +++ b/plugin-script-node/src/test/java/io/kestra/plugin/scripts/node/ScriptTriggerTest.java @@ -34,7 +34,7 @@ void scriptTrigger_shouldTriggerOnImplicitFailureExit1() throws Exception { .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); @@ -57,7 +57,7 @@ void scriptTrigger_shouldTriggerOnStdoutMatchViaOutputsConvention() throws Excep .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); diff --git a/plugin-script-node/src/test/resources/allure.properties b/plugin-script-node/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-node/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-perl/src/main/java/io/kestra/plugin/scripts/perl/Commands.java b/plugin-script-perl/src/main/java/io/kestra/plugin/scripts/perl/Commands.java index 9f7d227e..8d261b6f 100644 --- a/plugin-script-perl/src/main/java/io/kestra/plugin/scripts/perl/Commands.java +++ b/plugin-script-perl/src/main/java/io/kestra/plugin/scripts/perl/Commands.java @@ -60,6 +60,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override public ScriptOutput run(RunContext runContext) throws Exception { TargetOS os = runContext.render(this.targetOS).as(TargetOS.class).orElse(null); diff --git a/plugin-script-perl/src/main/java/io/kestra/plugin/scripts/perl/Script.java b/plugin-script-perl/src/main/java/io/kestra/plugin/scripts/perl/Script.java index 0fd5699a..8befaefe 100644 --- a/plugin-script-perl/src/main/java/io/kestra/plugin/scripts/perl/Script.java +++ b/plugin-script-perl/src/main/java/io/kestra/plugin/scripts/perl/Script.java @@ -70,6 +70,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-perl/src/test/java/io/kestra/plugins/scripts/perl/CommandsTest.java b/plugin-script-perl/src/test/java/io/kestra/plugins/scripts/perl/CommandsTest.java index a57e1810..52148b01 100644 --- a/plugin-script-perl/src/test/java/io/kestra/plugins/scripts/perl/CommandsTest.java +++ b/plugin-script-perl/src/test/java/io/kestra/plugins/scripts/perl/CommandsTest.java @@ -11,8 +11,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; @@ -20,8 +19,6 @@ import io.kestra.plugin.scripts.perl.Commands; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -32,13 +29,12 @@ public class CommandsTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Commands commands = Commands.builder() .id("perl-commands-" + UUID.randomUUID()) @@ -52,7 +48,6 @@ void task() throws Exception { String expectedLog = "Test OK"; TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains(expectedLog)); - receive.blockLast(); assertThat(List.copyOf(logs).stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains(expectedLog)), is(true)); } } \ No newline at end of file diff --git a/plugin-script-perl/src/test/java/io/kestra/plugins/scripts/perl/ScriptTest.java b/plugin-script-perl/src/test/java/io/kestra/plugins/scripts/perl/ScriptTest.java index 71abf204..3d5f93a1 100644 --- a/plugin-script-perl/src/test/java/io/kestra/plugins/scripts/perl/ScriptTest.java +++ b/plugin-script-perl/src/test/java/io/kestra/plugins/scripts/perl/ScriptTest.java @@ -11,20 +11,14 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; -import io.kestra.core.utils.Await; import io.kestra.core.utils.TestsUtils; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import io.kestra.plugin.scripts.perl.Script; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; - -import java.time.Duration; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -35,13 +29,12 @@ public class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script script = Script.builder() .id("perl-script-" + UUID.randomUUID()) @@ -54,8 +47,7 @@ void script() throws Exception { assertThat(run.getExitCode(), is(0)); String expectedLog = "Hello from kestra!"; - Await.until(() -> logs.stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains(expectedLog)), Duration.ofMillis(100), Duration.ofSeconds(30)); - receive.blockLast(); + TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains(expectedLog)); assertThat(List.copyOf(logs).stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains(expectedLog)), is(true)); } } \ No newline at end of file diff --git a/plugin-script-perl/src/test/resources/allure.properties b/plugin-script-perl/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-perl/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-perl/src/test/resources/application.yml b/plugin-script-perl/src/test/resources/application.yml index ffbcc1b0..3cc46a48 100644 --- a/plugin-script-perl/src/test/resources/application.yml +++ b/plugin-script-perl/src/test/resources/application.yml @@ -7,3 +7,16 @@ kestra: type: memory repository: type: memory + controller: + port: ${random.port} + worker: + controllers: + type: STATIC + static: + endpoints: + - host: localhost + port: ${kestra.controller.port} + +grpc: + server: + enabled: false diff --git a/plugin-script-php/src/main/java/io/kestra/plugin/scripts/php/Commands.java b/plugin-script-php/src/main/java/io/kestra/plugin/scripts/php/Commands.java index bf718dfb..1d19a857 100644 --- a/plugin-script-php/src/main/java/io/kestra/plugin/scripts/php/Commands.java +++ b/plugin-script-php/src/main/java/io/kestra/plugin/scripts/php/Commands.java @@ -71,6 +71,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-php/src/main/java/io/kestra/plugin/scripts/php/Script.java b/plugin-script-php/src/main/java/io/kestra/plugin/scripts/php/Script.java index f094c1c7..caab3f38 100644 --- a/plugin-script-php/src/main/java/io/kestra/plugin/scripts/php/Script.java +++ b/plugin-script-php/src/main/java/io/kestra/plugin/scripts/php/Script.java @@ -73,6 +73,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-php/src/test/java/io/kestra/plugin/scripts/php/CommandsTest.java b/plugin-script-php/src/test/java/io/kestra/plugin/scripts/php/CommandsTest.java index f6a784ea..c97210bd 100644 --- a/plugin-script-php/src/test/java/io/kestra/plugin/scripts/php/CommandsTest.java +++ b/plugin-script-php/src/test/java/io/kestra/plugin/scripts/php/CommandsTest.java @@ -14,8 +14,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; @@ -24,8 +23,6 @@ import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -40,13 +37,12 @@ public class CommandsTest { StorageInterface storageInterface; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); var phpScript = storageInterface.put( TenantService.MAIN_TENANT, @@ -76,7 +72,6 @@ void task() throws Exception { assertThat(run.getStdErrLineCount(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains(phpScript.getPath())); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("Hello, World!")).count(), is(1L)); } } diff --git a/plugin-script-php/src/test/java/io/kestra/plugin/scripts/php/ScriptTest.java b/plugin-script-php/src/test/java/io/kestra/plugin/scripts/php/ScriptTest.java index 13f7227e..3ab568f9 100644 --- a/plugin-script-php/src/test/java/io/kestra/plugin/scripts/php/ScriptTest.java +++ b/plugin-script-php/src/test/java/io/kestra/plugin/scripts/php/ScriptTest.java @@ -11,16 +11,13 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -32,13 +29,12 @@ public class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script phpScript = Script.builder() .id("php-script-" + UUID.randomUUID()) @@ -58,7 +54,6 @@ void script() throws Exception { assertThat(run.getStdErrLineCount(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Hello, World!")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("Hello, World!")).count(), is(1L)); } } diff --git a/plugin-script-php/src/test/resources/allure.properties b/plugin-script-php/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-php/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-php/src/test/resources/application.yml b/plugin-script-php/src/test/resources/application.yml index ffbcc1b0..3cc46a48 100644 --- a/plugin-script-php/src/test/resources/application.yml +++ b/plugin-script-php/src/test/resources/application.yml @@ -7,3 +7,16 @@ kestra: type: memory repository: type: memory + controller: + port: ${random.port} + worker: + controllers: + type: STATIC + static: + endpoints: + - host: localhost + port: ${kestra.controller.port} + +grpc: + server: + enabled: false diff --git a/plugin-script-powershell/src/main/java/io/kestra/plugin/scripts/powershell/Commands.java b/plugin-script-powershell/src/main/java/io/kestra/plugin/scripts/powershell/Commands.java index bba83a09..ef152066 100644 --- a/plugin-script-powershell/src/main/java/io/kestra/plugin/scripts/powershell/Commands.java +++ b/plugin-script-powershell/src/main/java/io/kestra/plugin/scripts/powershell/Commands.java @@ -76,6 +76,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> interpreter = Property.ofValue(List.of("pwsh", "-NoProfile", "-NonInteractive", "-Command")); + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-powershell/src/main/java/io/kestra/plugin/scripts/powershell/Script.java b/plugin-script-powershell/src/main/java/io/kestra/plugin/scripts/powershell/Script.java index 432ceab5..c643b469 100644 --- a/plugin-script-powershell/src/main/java/io/kestra/plugin/scripts/powershell/Script.java +++ b/plugin-script-powershell/src/main/java/io/kestra/plugin/scripts/powershell/Script.java @@ -93,6 +93,15 @@ public class Script extends AbstractExecScript implements RunnableTask> interpreter = Property.ofValue(List.of("pwsh", "-NoProfile", "-NonInteractive", "-Command")); + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-powershell/src/test/java/io/kestra/plugin/scripts/powershell/CommandsTest.java b/plugin-script-powershell/src/test/java/io/kestra/plugin/scripts/powershell/CommandsTest.java index 9725274a..c65fd6e5 100644 --- a/plugin-script-powershell/src/test/java/io/kestra/plugin/scripts/powershell/CommandsTest.java +++ b/plugin-script-powershell/src/test/java/io/kestra/plugin/scripts/powershell/CommandsTest.java @@ -17,8 +17,7 @@ import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTaskException; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; @@ -27,8 +26,6 @@ import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -42,13 +39,12 @@ class CommandsTest { StorageInterface storageInterface; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); URI put = storageInterface.put( TenantService.MAIN_TENANT, diff --git a/plugin-script-powershell/src/test/java/io/kestra/plugin/scripts/powershell/ScriptTest.java b/plugin-script-powershell/src/test/java/io/kestra/plugin/scripts/powershell/ScriptTest.java index 5d2d7be5..b1d05739 100644 --- a/plugin-script-powershell/src/test/java/io/kestra/plugin/scripts/powershell/ScriptTest.java +++ b/plugin-script-powershell/src/test/java/io/kestra/plugin/scripts/powershell/ScriptTest.java @@ -11,16 +11,13 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -31,13 +28,12 @@ class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script powershellScript = Script.builder() .id("powershell-script-" + UUID.randomUUID()) @@ -53,7 +49,6 @@ void script() throws Exception { assertThat(run.getStdErrLineCount(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Hello, World!")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("World!")).count(), is(1L)); } } diff --git a/plugin-script-powershell/src/test/resources/allure.properties b/plugin-script-powershell/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-powershell/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-python/src/main/java/io/kestra/plugin/scripts/python/AbstractPythonExecScript.java b/plugin-script-python/src/main/java/io/kestra/plugin/scripts/python/AbstractPythonExecScript.java index e764ce7e..5da2c25e 100644 --- a/plugin-script-python/src/main/java/io/kestra/plugin/scripts/python/AbstractPythonExecScript.java +++ b/plugin-script-python/src/main/java/io/kestra/plugin/scripts/python/AbstractPythonExecScript.java @@ -4,6 +4,7 @@ import io.kestra.core.models.property.Property; import io.kestra.plugin.scripts.exec.AbstractExecScript; +import io.kestra.plugin.scripts.exec.scripts.models.DockerOptions; import io.kestra.plugin.scripts.python.internals.PackageManagerType; import io.kestra.plugin.scripts.python.internals.PythonBasedPlugin; @@ -41,6 +42,13 @@ public abstract class AbstractPythonExecScript extends AbstractExecScript implem @Builder.Default protected Property packageManager = Property.ofValue(PackageManagerType.UV); + @Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected DockerOptions docker; @Builder.Default protected Property uvAutoInstallEnabled = Property.ofValue(true); diff --git a/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/CommandsTest.java b/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/CommandsTest.java index d59bdd0c..72deb2b8 100644 --- a/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/CommandsTest.java +++ b/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/CommandsTest.java @@ -14,8 +14,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; @@ -25,8 +24,6 @@ import io.kestra.plugin.scripts.python.internals.PackageManagerType; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -40,13 +37,12 @@ class CommandsTest { StorageInterface storageInterface; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); URI put = storageInterface.put( TenantService.MAIN_TENANT, @@ -72,14 +68,13 @@ void task() throws Exception { assertThat(run.getStdErrLineCount(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("hello there!")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("hello there!")).count(), is(1L)); } @Test void testPipPackageManager() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); String script = "import requests, idna; print(f'requests: {requests.__version__}, idna: {idna.__version__}')"; URI put = storageInterface.put(TenantService.MAIN_TENANT, null, new URI("/file/storage/pip_test.py"), IOUtils.toInputStream(script, StandardCharsets.UTF_8)); @@ -97,13 +92,12 @@ void testPipPackageManager() throws Exception { assertThat(run.getExitCode(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("requests:")); - receive.blockLast(); } @Test void testUvPackageManager() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); String script = "import requests; print(f'requests (UV): {requests.__version__}')"; URI put = storageInterface.put(TenantService.MAIN_TENANT, null, new URI("/file/storage/uv_test.py"), IOUtils.toInputStream(script, StandardCharsets.UTF_8)); @@ -121,13 +115,12 @@ void testUvPackageManager() throws Exception { assertThat(run.getExitCode(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("uv test worked")); - receive.blockLast(); } @Test void testBackwardCompatibility() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); String script = "import requests; print('backward compatibility works', requests.__version__)"; URI put = storageInterface.put(TenantService.MAIN_TENANT, null, new URI("/file/storage/compat_test.py"), IOUtils.toInputStream(script, StandardCharsets.UTF_8)); @@ -145,7 +138,6 @@ void testBackwardCompatibility() throws Exception { assertThat(run.getExitCode(), is(0)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("backward compatibility works")); - receive.blockLast(); assertThat(logs.stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains("backward compatibility works")), is(true)); } diff --git a/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/CommandsTriggerTest.java b/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/CommandsTriggerTest.java index 87e6e6f6..c92716eb 100644 --- a/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/CommandsTriggerTest.java +++ b/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/CommandsTriggerTest.java @@ -35,7 +35,7 @@ void commandsTrigger_shouldTriggerOnImplicitFailureExit1() throws Exception { .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); @@ -58,7 +58,7 @@ void commandsTrigger_shouldTriggerOnStdoutMatchUsingStructuredOutputs() throws E .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); diff --git a/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTest.java b/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTest.java index 53f44692..99f0e69f 100644 --- a/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTest.java +++ b/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTest.java @@ -26,6 +26,8 @@ import io.kestra.plugin.scripts.exec.scripts.models.DockerOptions; import io.kestra.plugin.scripts.exec.scripts.models.RunnerType; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; +import io.kestra.plugin.scripts.runner.docker.Docker; +import org.junit.jupiter.api.Test; import jakarta.inject.Inject; import jakarta.validation.ConstraintViolationException; @@ -121,14 +123,12 @@ void requirements(RunnerType runner, DockerOptions dockerOptions) throws Excepti assertThat(run.getVars().get("extract"), is("200")); } - @ParameterizedTest - @MethodSource("source") - void shouldExecScriptGivenDependency(RunnerType runner, DockerOptions dockerOptions) throws Exception { + @Test + void shouldExecScriptGivenDependency() throws Exception { Script python = Script.builder() .id("python-script-deps-" + UUID.randomUUID()) .type(Script.class.getName()) - .docker(dockerOptions) - .runner(runner) + .taskRunner(Docker.builder().type(Docker.class.getName()).image("python:3.13").build()) .dependencies(Property.ofValue(List.of("kestra", "pandas"))) .dependencyCacheEnabled(Property.ofValue(false)) .pythonVersion(Property.ofValue("3.13")) diff --git a/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTriggerTest.java b/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTriggerTest.java index b636e38f..99c57bd2 100644 --- a/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTriggerTest.java +++ b/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTriggerTest.java @@ -34,7 +34,7 @@ void scriptTrigger_shouldTriggerOnImplicitFailureExit1() throws Exception { .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); @@ -57,7 +57,7 @@ void scriptTrigger_shouldTriggerOnStdoutMatchViaOutputsConvention() throws Excep .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); diff --git a/plugin-script-python/src/test/resources/allure.properties b/plugin-script-python/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-python/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-python/src/test/resources/application.yml b/plugin-script-python/src/test/resources/application.yml index ffbcc1b0..3cc46a48 100644 --- a/plugin-script-python/src/test/resources/application.yml +++ b/plugin-script-python/src/test/resources/application.yml @@ -7,3 +7,16 @@ kestra: type: memory repository: type: memory + controller: + port: ${random.port} + worker: + controllers: + type: STATIC + static: + endpoints: + - host: localhost + port: ${kestra.controller.port} + +grpc: + server: + enabled: false diff --git a/plugin-script-r/src/main/java/io/kestra/plugin/scripts/r/Commands.java b/plugin-script-r/src/main/java/io/kestra/plugin/scripts/r/Commands.java index 5bf94646..d562e971 100644 --- a/plugin-script-r/src/main/java/io/kestra/plugin/scripts/r/Commands.java +++ b/plugin-script-r/src/main/java/io/kestra/plugin/scripts/r/Commands.java @@ -73,6 +73,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-r/src/main/java/io/kestra/plugin/scripts/r/Script.java b/plugin-script-r/src/main/java/io/kestra/plugin/scripts/r/Script.java index 97fcbdfe..8ffae7d4 100644 --- a/plugin-script-r/src/main/java/io/kestra/plugin/scripts/r/Script.java +++ b/plugin-script-r/src/main/java/io/kestra/plugin/scripts/r/Script.java @@ -172,6 +172,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-r/src/test/java/io/kestra/plugin/scripts/r/CommandsTest.java b/plugin-script-r/src/test/java/io/kestra/plugin/scripts/r/CommandsTest.java index fb7163bc..8fc2e43c 100644 --- a/plugin-script-r/src/test/java/io/kestra/plugin/scripts/r/CommandsTest.java +++ b/plugin-script-r/src/test/java/io/kestra/plugin/scripts/r/CommandsTest.java @@ -14,8 +14,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; @@ -24,8 +23,6 @@ import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -39,13 +36,12 @@ class CommandsTest { StorageInterface storageInterface; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); URI put = storageInterface.put( TenantService.MAIN_TENANT, @@ -74,7 +70,6 @@ void task() throws Exception { synchronized (logs) { TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Hello World")); } - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("[1]")).count(), is(1L)); } } diff --git a/plugin-script-r/src/test/java/io/kestra/plugin/scripts/r/ScriptTest.java b/plugin-script-r/src/test/java/io/kestra/plugin/scripts/r/ScriptTest.java index f074d132..57ee7951 100644 --- a/plugin-script-r/src/test/java/io/kestra/plugin/scripts/r/ScriptTest.java +++ b/plugin-script-r/src/test/java/io/kestra/plugin/scripts/r/ScriptTest.java @@ -11,19 +11,13 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; -import io.kestra.core.utils.Await; import io.kestra.core.utils.TestsUtils; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; - -import java.time.Duration; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; @@ -35,13 +29,12 @@ class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script rScript = Script.builder() .id("r-script-" + UUID.randomUUID()) @@ -71,13 +64,7 @@ void script() throws Exception { assertThat(run.getStdOutLineCount(), greaterThan(1)); assertThat(run.getStdErrLineCount(), greaterThan(1)); - Await.until(() -> - logs.stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains("2010-06-04")) && - logs.stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains("2011-06-04")) && - logs.stream().anyMatch(log -> log.getMessage() != null && log.getMessage().contains("2012-06-04")), - Duration.ofMillis(100), Duration.ofSeconds(30) - ); - receive.blockLast(); + TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("2012-06-04")); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("2010-06-04")).count(), is(1L)); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("2011-06-04")).count(), is(1L)); } diff --git a/plugin-script-r/src/test/resources/allure.properties b/plugin-script-r/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-r/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-ruby/src/main/java/io/kestra/plugin/scripts/ruby/Commands.java b/plugin-script-ruby/src/main/java/io/kestra/plugin/scripts/ruby/Commands.java index 545f0db1..8ad24249 100644 --- a/plugin-script-ruby/src/main/java/io/kestra/plugin/scripts/ruby/Commands.java +++ b/plugin-script-ruby/src/main/java/io/kestra/plugin/scripts/ruby/Commands.java @@ -110,6 +110,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-ruby/src/main/java/io/kestra/plugin/scripts/ruby/Script.java b/plugin-script-ruby/src/main/java/io/kestra/plugin/scripts/ruby/Script.java index cc8962f5..6c28d2af 100644 --- a/plugin-script-ruby/src/main/java/io/kestra/plugin/scripts/ruby/Script.java +++ b/plugin-script-ruby/src/main/java/io/kestra/plugin/scripts/ruby/Script.java @@ -110,6 +110,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/CommandsTest.java b/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/CommandsTest.java index c5060f69..023c1c27 100644 --- a/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/CommandsTest.java +++ b/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/CommandsTest.java @@ -14,8 +14,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; @@ -24,8 +23,6 @@ import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -39,13 +36,12 @@ class CommandsTest { StorageInterface storageInterface; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void task() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); URI put = storageInterface.put( TenantService.MAIN_TENANT, @@ -72,7 +68,6 @@ void task() throws Exception { assertThat(run.getStdErrLineCount(), is(1)); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Hello World")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("done")).count(), is(1L)); } } diff --git a/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/CommandsTriggerTest.java b/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/CommandsTriggerTest.java index 56d40f1a..8f554fe6 100644 --- a/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/CommandsTriggerTest.java +++ b/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/CommandsTriggerTest.java @@ -35,7 +35,7 @@ void commandsTrigger_shouldTriggerOnImplicitFailureExit1() throws Exception { .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); @@ -58,7 +58,7 @@ void commandsTrigger_shouldTriggerOnStdoutMatchUsingStructuredOutputs() throws E .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); diff --git a/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/ScriptTest.java b/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/ScriptTest.java index 0110c4c9..b6ddfa80 100644 --- a/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/ScriptTest.java +++ b/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/ScriptTest.java @@ -11,16 +11,13 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; @@ -32,13 +29,12 @@ class ScriptTest { RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; @Test void script() throws Exception { List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); + logQueue.addListener(logs::add); Script rubyScript = Script.builder() .id("ruby-script-" + UUID.randomUUID()) @@ -70,7 +66,6 @@ void script() throws Exception { TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("2012-12-25")); TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("2001-02-03")); - receive.blockLast(); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("2012-12-25")).count(), is(1L)); assertThat(List.copyOf(logs).stream().filter(logEntry -> logEntry.getMessage() != null && logEntry.getMessage().contains("2001-02-03")).count(), is(1L)); } diff --git a/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/ScriptTriggerTest.java b/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/ScriptTriggerTest.java index 4970a406..8b0ee061 100644 --- a/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/ScriptTriggerTest.java +++ b/plugin-script-ruby/src/test/java/io/kestra/plugin/scripts/ruby/ScriptTriggerTest.java @@ -1,95 +1,104 @@ package io.kestra.plugin.scripts.ruby; +import java.util.Map; +import java.util.Optional; + import org.junit.jupiter.api.Test; -import java.time.Instant; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; +import io.kestra.core.junit.annotations.KestraTest; +import io.kestra.core.models.executions.Execution; +import io.kestra.core.models.property.Property; +import io.kestra.core.runners.RunContextFactory; +import io.kestra.core.utils.TestsUtils; + +import jakarta.inject.Inject; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; -/** - * Unit tests for ScriptTrigger's condition-matching logic and edge mode. - * - * These tests exercise matchesCondition via the Output model without requiring a Ruby - * runtime, which may not be available on all CI machines. - * Integration tests against an actual Ruby runtime are covered by the sanity checks. - */ +@KestraTest class ScriptTriggerTest { - - private final ScriptTrigger trigger = ScriptTrigger.builder().build(); - - private ScriptTrigger.Output output(String condition, Integer exitCode, Map vars) { - return new ScriptTrigger.Output(Instant.now(), condition, exitCode, vars); - } - - @Test - void exitCodeCondition_shouldMatchWhenExitCodeEquals() { - assertThat(trigger.matchesCondition(output("exit 1", 1, null)), is(true)); - } - - @Test - void exitCodeCondition_shouldNotMatchWhenExitCodeDiffers() { - assertThat(trigger.matchesCondition(output("exit 1", 127, null)), is(false)); - } - - @Test - void exitCodeCondition_shouldNotMatchWhenExitCodeIsNull() { - assertThat(trigger.matchesCondition(output("exit 1", null, null)), is(false)); - } - - @Test - void substringCondition_shouldMatchAgainstVars() { - assertThat(trigger.matchesCondition(output("toto", 0, Map.of("listing", "toto"))), is(true)); - } - - @Test - void substringCondition_shouldNotMatchWhenAbsent() { - assertThat(trigger.matchesCondition(output("toto", 0, Map.of("listing", "something_else"))), is(false)); - } - - @Test - void regexCondition_shouldMatchAgainstVars() { - assertThat(trigger.matchesCondition(output("status=\\w+", 0, Map.of("status", "status=ready"))), is(true)); - } - - @Test - void emptyCondition_shouldNotMatch() { - assertThat(trigger.matchesCondition(output("", 0, null)), is(false)); - } - - @Test - void nullCondition_shouldNotMatch() { - assertThat(trigger.matchesCondition(output(null, 0, null)), is(false)); - } - - @Test - void exitZeroCondition_shouldMatchSuccessfulExecution() { - assertThat(trigger.matchesCondition(output("exit 0", 0, null)), is(true)); - } + @Inject + private RunContextFactory runContextFactory; @Test - void edgeMode_shouldEmitOnFirstMatch() { - var lastMatched = new AtomicBoolean(false); - boolean matched = true; - boolean emit = !lastMatched.getAndSet(matched) && matched; - assertThat("first match should emit", emit, is(true)); + void scriptTrigger_shouldTriggerOnImplicitFailureExit1() throws Exception { + ScriptTrigger trigger = ScriptTrigger.builder() + .id("script-trigger") + .type(ScriptTrigger.class.getName()) + .exitCondition(Property.ofValue("exit 1")) + .edge(Property.ofValue(true)) + .containerImage(Property.ofValue("ruby:latest")) + .script(Property.ofValue("exit 1")) + .build(); + + var context = TestsUtils.mockTrigger(runContextFactory, trigger); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); + + assertThat(execution.isPresent(), is(true)); + + Map triggerVars = execution.get().getTrigger().getVariables(); + assertThat("condition should be present", triggerVars.get("condition"), is("exit 1")); + assertThat("exitCode should be present", triggerVars.get("exitCode"), notNullValue()); + assertThat("exitCode should be 1", triggerVars.get("exitCode"), is(1)); + assertThat("timestamp should be present", triggerVars.get("timestamp"), notNullValue()); } @Test - void edgeMode_shouldSuppressConsecutiveMatches() { - var lastMatched = new AtomicBoolean(true); - boolean matched = true; - boolean emit = !lastMatched.getAndSet(matched) && matched; - assertThat("consecutive match should not emit in edge mode", emit, is(false)); + void scriptTrigger_shouldTriggerOnStdoutMatchViaOutputsConvention() throws Exception { + ScriptTrigger trigger = ScriptTrigger.builder() + .id("script-stdout-match-trigger") + .type(ScriptTrigger.class.getName()) + .exitCondition(Property.ofValue("toto")) + .edge(Property.ofValue(true)) + .containerImage(Property.ofValue("ruby:latest")) + .script(Property.ofValue("puts '::{\"outputs\":{\"listing\":\"toto\"}}::'")) + .build(); + + var context = TestsUtils.mockTrigger(runContextFactory, trigger); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); + + assertThat(execution.isPresent(), is(true)); + + Map triggerVars = execution.get().getTrigger().getVariables(); + assertThat("condition should be present", triggerVars.get("condition"), is("toto")); + assertThat("exitCode should be present", triggerVars.get("exitCode"), notNullValue()); + assertThat("exitCode should be 0", triggerVars.get("exitCode"), is(0)); + assertThat("timestamp should be present", triggerVars.get("timestamp"), notNullValue()); + assertThat("vars should be present", triggerVars.get("vars"), notNullValue()); } @Test - void edgeMode_shouldEmitAgainAfterNonMatch() { - var lastMatched = new AtomicBoolean(false); - boolean matched = true; - boolean emit = !lastMatched.getAndSet(matched) && matched; - assertThat("match after non-match should emit", emit, is(true)); + void edgeMode_preventsConsecutiveEmit() { + ScriptTrigger trigger = ScriptTrigger.builder() + .id("edge-test") + .type(ScriptTrigger.class.getName()) + .exitCondition(Property.ofValue("exit 1")) + .script(Property.ofValue("raise 'boom'")) + .edge(Property.ofValue(true)) + .build(); + + java.util.concurrent.atomic.AtomicBoolean lastMatched = new java.util.concurrent.atomic.AtomicBoolean(false); + + // First match: transition false->true => should emit + boolean matched1 = true; + boolean emit1 = !lastMatched.getAndSet(matched1) && matched1; + assertThat("first match should emit", emit1, is(true)); + + // Second consecutive match: true->true => should NOT emit + boolean matched2 = true; + boolean emit2 = !lastMatched.getAndSet(matched2) && matched2; + assertThat("consecutive match should NOT emit in edge mode", emit2, is(false)); + + // Non-match: true->false => should not emit + boolean matched3 = false; + boolean emit3 = !lastMatched.getAndSet(matched3) && matched3; + assertThat("non-match should not emit", emit3, is(false)); + + // Match again after non-match: false->true => should emit + boolean matched4 = true; + boolean emit4 = !lastMatched.getAndSet(matched4) && matched4; + assertThat("match after non-match should emit", emit4, is(true)); } } diff --git a/plugin-script-ruby/src/test/resources/allure.properties b/plugin-script-ruby/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-ruby/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Commands.java b/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Commands.java index 8fb777e4..5de38905 100644 --- a/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Commands.java +++ b/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Commands.java @@ -310,6 +310,15 @@ public class Commands extends AbstractExecScript implements RunnableTask> commands; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Script.java b/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Script.java index dc7152d6..da077016 100644 --- a/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Script.java +++ b/plugin-script-shell/src/main/java/io/kestra/plugin/scripts/shell/Script.java @@ -114,6 +114,15 @@ public class Script extends AbstractExecScript implements RunnableTask script; + @io.swagger.v3.oas.annotations.media.Schema( + title = "Deprecated - use the 'taskRunner' property instead.", + description = "Only used if the `taskRunner` property is not set", + deprecated = true + ) + @Deprecated + protected io.kestra.plugin.scripts.exec.scripts.models.DockerOptions docker; + + @Override protected DockerOptions injectDefaults(RunContext runContext, DockerOptions original) throws IllegalVariableEvaluationException { var builder = original.toBuilder(); diff --git a/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/CommandsTest.java b/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/CommandsTest.java index ed0fd89f..91ce1d6e 100644 --- a/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/CommandsTest.java +++ b/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/CommandsTest.java @@ -22,8 +22,7 @@ import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTaskException; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; @@ -32,11 +31,10 @@ import io.kestra.plugin.scripts.exec.scripts.models.DockerOptions; import io.kestra.plugin.scripts.exec.scripts.models.RunnerType; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; +import io.kestra.plugin.scripts.runner.docker.Docker; import io.kestra.plugin.scripts.runner.docker.PullPolicy; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -51,8 +49,7 @@ class CommandsTest { StorageInterface storageInterface; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; static Stream source() { return Stream.of( @@ -160,6 +157,7 @@ void files(RunnerType runner, DockerOptions dockerOptions) throws Exception { .type(Commands.class.getName()) .docker(dockerOptions) .runner(runner) + .outputDirectory(Property.ofValue(true)) .commands( TestsUtils.propertyFromList( List.of( @@ -228,10 +226,8 @@ void nullOutputs(RunnerType runner, DockerOptions dockerOptions) throws Exceptio @Test void pull() throws Exception { - List logs = new CopyOnWriteArrayList<>(); - Flux receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft())); - - Commands bash = Commands.builder() + // Build a fresh Commands per run; Docker runner's isKilled flag persists across run() calls. + java.util.function.Supplier builder = () -> Commands.builder() .id("shell-commands-pull-" + UUID.randomUUID()) .type(Commands.class.getName()) .docker( @@ -244,16 +240,13 @@ void pull() throws Exception { .commands(Property.ofValue(List.of("pwd"))) .build(); - RunContext runContext = TestsUtils.mockRunContext(runContextFactory, bash, ImmutableMap.of()); - ScriptOutput run = bash.run(runContext); + Commands first = builder.get(); + ScriptOutput run = first.run(TestsUtils.mockRunContext(runContextFactory, first, ImmutableMap.of())); assertThat(run.getExitCode(), is(0)); - run = bash.run(runContext); + Commands second = builder.get(); + run = second.run(TestsUtils.mockRunContext(runContextFactory, second, ImmutableMap.of())); assertThat(run.getExitCode(), is(0)); - - TestsUtils.awaitLog(logs, log -> log.getMessage() != null && log.getMessage().contains("Image pulled")); - receive.blockLast(); - assertThat(List.copyOf(logs).stream().filter(m -> m.getMessage().contains("pulled")).count(), greaterThan(1L)); } @Test @@ -261,13 +254,13 @@ void invalidImage() { Commands bash = Commands.builder() .id("shell-commands-invalid-image-" + UUID.randomUUID()) .type(Commands.class.getName()) - .docker( - DockerOptions.builder() + .taskRunner( + Docker.builder() + .type(Docker.class.getName()) .pullPolicy(Property.ofValue(PullPolicy.IF_NOT_PRESENT)) .image("alpine:999.15.6") .build() ) - .runner(RunnerType.DOCKER) .commands(Property.ofValue(List.of("pwd"))) .build(); diff --git a/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/CommandsTriggerTest.java b/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/CommandsTriggerTest.java index caac7357..7ea1ad7a 100644 --- a/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/CommandsTriggerTest.java +++ b/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/CommandsTriggerTest.java @@ -35,7 +35,7 @@ void commandsTrigger_shouldTriggerOnImplicitFailureExit1() throws Exception { .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); @@ -58,7 +58,7 @@ void commandsTrigger_shouldTriggerOnStdoutMatchUsingStructuredOutputs() throws E .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); diff --git a/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/ScriptTest.java b/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/ScriptTest.java index a3492f6b..703bca3f 100644 --- a/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/ScriptTest.java +++ b/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/ScriptTest.java @@ -21,8 +21,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.LogEntry; import io.kestra.core.models.property.Property; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.storages.StorageInterface; @@ -32,9 +31,9 @@ import io.kestra.plugin.scripts.exec.scripts.models.RunnerType; import io.kestra.plugin.scripts.exec.scripts.models.ScriptOutput; import io.kestra.plugin.scripts.runner.docker.Credentials; +import io.kestra.plugin.scripts.runner.docker.Docker; import jakarta.inject.Inject; -import jakarta.inject.Named; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -48,8 +47,7 @@ class ScriptTest { private StorageInterface storageInterface; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface logQueue; + private DispatchQueueInterface logQueue; static Stream source() { return Stream.of( @@ -113,8 +111,9 @@ void overwrite() throws Exception { Function function = (String username) -> Script.builder() .id("shell-script-overwrite-" + UUID.randomUUID()) .type(Script.class.getName()) - .docker( - DockerOptions.builder() + .taskRunner( + Docker.builder() + .type(Docker.class.getName()) .image("ubuntu") .credentials( Credentials.builder() diff --git a/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/ScriptTriggerTest.java b/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/ScriptTriggerTest.java index 5908b4f7..dc5fca3b 100644 --- a/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/ScriptTriggerTest.java +++ b/plugin-script-shell/src/test/java/io/kestra/plugin/scripts/shell/ScriptTriggerTest.java @@ -34,7 +34,7 @@ void scriptTrigger_shouldTriggerOnImplicitFailureExit1() throws Exception { .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); @@ -57,7 +57,7 @@ void scriptTrigger_shouldTriggerOnStdoutMatchViaOutputsConvention() throws Excep .build(); var context = TestsUtils.mockTrigger(runContextFactory, trigger); - Optional execution = trigger.evaluate(context.getKey(), context.getValue()); + Optional execution = trigger.evaluate(context.getKey(), context.getValue().context()); assertThat(execution.isPresent(), is(true)); diff --git a/plugin-script-shell/src/test/resources/allure.properties b/plugin-script-shell/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script-shell/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results diff --git a/plugin-script-shell/src/test/resources/application.yml b/plugin-script-shell/src/test/resources/application.yml index ffbcc1b0..d6023034 100644 --- a/plugin-script-shell/src/test/resources/application.yml +++ b/plugin-script-shell/src/test/resources/application.yml @@ -7,3 +7,21 @@ kestra: type: memory repository: type: memory + controller: + port: ${random.port} + worker: + controllers: + type: STATIC + static: + endpoints: + - host: localhost + port: ${kestra.controller.port} + plugins: + configurations: + - type: io.kestra.plugin.scripts.runner.docker.Docker + values: + volume-enabled: true + +grpc: + server: + enabled: false diff --git a/plugin-script/src/test/java/io/kestra/plugin/scripts/jvm/EvalTest.java b/plugin-script/src/test/java/io/kestra/plugin/scripts/jvm/EvalTest.java index ddf43033..6f8e59b6 100644 --- a/plugin-script/src/test/java/io/kestra/plugin/scripts/jvm/EvalTest.java +++ b/plugin-script/src/test/java/io/kestra/plugin/scripts/jvm/EvalTest.java @@ -1,7 +1,9 @@ package io.kestra.plugin.scripts.jvm; import java.net.URI; +import java.util.List; import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; import org.junit.jupiter.api.Test; import org.slf4j.event.Level; @@ -11,15 +13,12 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.executions.AbstractMetricEntry; import io.kestra.core.models.executions.LogEntry; -import io.kestra.core.queues.QueueFactoryInterface; -import io.kestra.core.queues.QueueInterface; +import io.kestra.core.queues.DispatchQueueInterface; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.utils.TestsUtils; import jakarta.inject.Inject; -import jakarta.inject.Named; -import reactor.core.publisher.Flux; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -31,15 +30,15 @@ abstract public class EvalTest { private RunContextFactory runContextFactory; @Inject - @Named(QueueFactoryInterface.WORKERTASKLOG_NAMED) - private QueueInterface workerTaskLogQueue; + private DispatchQueueInterface workerTaskLogQueue; abstract protected Eval task(); @SuppressWarnings("unchecked") @Test void run() throws Exception { - Flux receive = TestsUtils.receive(workerTaskLogQueue); + List logs = new CopyOnWriteArrayList<>(); + workerTaskLogQueue.addListener(logs::add); Eval task = this.task(); @@ -48,7 +47,7 @@ void run() throws Exception { Eval.Output runOutput = task.run(runContext); Thread.sleep(500); - LogEntry firstLog = receive.blockFirst(); + LogEntry firstLog = logs.get(0); assertThat(firstLog.getLevel(), is(Level.INFO)); assertThat(firstLog.getMessage(), is("executionId: " + ((Map) runContext.getVariables().get("execution")).get("id"))); diff --git a/plugin-script/src/test/resources/allure.properties b/plugin-script/src/test/resources/allure.properties deleted file mode 100644 index 4873f6d0..00000000 --- a/plugin-script/src/test/resources/allure.properties +++ /dev/null @@ -1 +0,0 @@ -allure.results.directory=build/allure-results