mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-19 18:05:41 -05:00
feat(core)!: make tenant id required (#8460)
* feat(core)!: WIP make tenant id required * feat(core)!: WIP make tenant id required * test(core)!: WIP fix storage unit test * build(deps): bump com.google.guava:guava from 33.4.7-jre to 33.4.8-jre Bumps [com.google.guava:guava](https://github.com/google/guava) from 33.4.7-jre to 33.4.8-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-version: 33.4.8-jre dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump io.micronaut.platform:micronaut-platform Bumps [io.micronaut.platform:micronaut-platform](https://github.com/micronaut-projects/micronaut-platform) from 4.8.0 to 4.8.2. - [Release notes](https://github.com/micronaut-projects/micronaut-platform/releases) - [Commits](https://github.com/micronaut-projects/micronaut-platform/compare/v4.8.0...v4.8.2) --- updated-dependencies: - dependency-name: io.micronaut.platform:micronaut-platform dependency-version: 4.8.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump flyingSaucerVersion from 9.11.6 to 9.12.0 Bumps `flyingSaucerVersion` from 9.11.6 to 9.12.0. Updates `org.xhtmlrenderer:flying-saucer-core` from 9.11.6 to 9.12.0 - [Release notes](https://github.com/flyingsaucerproject/flyingsaucer/releases) - [Changelog](https://github.com/flyingsaucerproject/flyingsaucer/blob/main/CHANGELOG.md) - [Commits](https://github.com/flyingsaucerproject/flyingsaucer/compare/v9.11.6...v9.12.0) Updates `org.xhtmlrenderer:flying-saucer-pdf` from 9.11.6 to 9.12.0 - [Release notes](https://github.com/flyingsaucerproject/flyingsaucer/releases) - [Changelog](https://github.com/flyingsaucerproject/flyingsaucer/blob/main/CHANGELOG.md) - [Commits](https://github.com/flyingsaucerproject/flyingsaucer/compare/v9.11.6...v9.12.0) --- updated-dependencies: - dependency-name: org.xhtmlrenderer:flying-saucer-core dependency-version: 9.12.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.xhtmlrenderer:flying-saucer-pdf dependency-version: 9.12.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump software.amazon.awssdk:bom from 2.31.21 to 2.31.25 Bumps software.amazon.awssdk:bom from 2.31.21 to 2.31.25. --- updated-dependencies: - dependency-name: software.amazon.awssdk:bom dependency-version: 2.31.25 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump com.github.oshi:oshi-core from 6.8.0 to 6.8.1 Bumps [com.github.oshi:oshi-core](https://github.com/oshi/oshi) from 6.8.0 to 6.8.1. - [Release notes](https://github.com/oshi/oshi/releases) - [Changelog](https://github.com/oshi/oshi/blob/master/CHANGELOG.md) - [Commits](https://github.com/oshi/oshi/compare/oshi-parent-6.8.0...oshi-parent-6.8.1) --- updated-dependencies: - dependency-name: com.github.oshi:oshi-core dependency-version: 6.8.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump org.opensearch.client:opensearch-java Bumps [org.opensearch.client:opensearch-java](https://github.com/opensearch-project/opensearch-java) from 2.22.0 to 2.23.0. - [Release notes](https://github.com/opensearch-project/opensearch-java/releases) - [Changelog](https://github.com/opensearch-project/opensearch-java/blob/v2.23.0/CHANGELOG.md) - [Commits](https://github.com/opensearch-project/opensearch-java/compare/v2.22.0...v2.23.0) --- updated-dependencies: - dependency-name: org.opensearch.client:opensearch-java dependency-version: 2.23.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump co.elastic.logging:logback-ecs-encoder Bumps [co.elastic.logging:logback-ecs-encoder](https://github.com/elastic/ecs-logging-java) from 1.6.0 to 1.7.0. - [Release notes](https://github.com/elastic/ecs-logging-java/releases) - [Commits](https://github.com/elastic/ecs-logging-java/compare/v1.6.0...v1.7.0) --- updated-dependencies: - dependency-name: co.elastic.logging:logback-ecs-encoder dependency-version: 1.7.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * tests(system): isolate SchedulerScheduleTest tests with tenantId * Feat/storage outputs (#8361) * feat(executions): Store outputs inside the internal storage (1/2) * feat(executions): Store outputs inside the internal storage (2/2) * feat(test): allow passing tenantId to tests --------- Co-authored-by: Ludovic DEHON <tchiot.ludo@gmail.com> * chore(deps): regular dependency update (#8484) Performing a weekly round of dependency updates in the NPM ecosystem to keep everything up to date. * fix(ui): full view height for single task logs (#8042) Co-authored-by: Miloš Paunović <paun992@hotmail.com> * feat: synchronize task edition with editor (#8433) * fix(controls): adjust bottom position of contorls in multiPanelsEditor (#8465) * fix(executions): unqueing execution must remove the execution queued When an execution is queued in the JDBC backend, a record is inserted inside the execution_queued table, we must remove this record when we unqeue an execution. Fixes #8448 * chore(core): localize to languages other than english (#8485) Extended localization support by adding translations for multiple languages using English as the base. This enhances accessibility and usability for non-English-speaking users while keeping English as the source reference. Co-authored-by: GitHub Action <actions@github.com> * tests(webserver): fix flaky test which could query previous tests tasks * tests(system): debug flaky error of shouldPauseExecutionByQueryRunningFlows * tests(system): debug flaky error of shouldPauseExecutionByQueryRunningFlows * tests(system): try with different task id * tests(system): bump sleep-short sleep time to 10s * fix(execution)*: decode and hide nested inputs of type SECRET Fixes #7964 * refactor(core): pass the dynamic concurrency schema to no code editor (#8488) There was an issue with passing hard-coded concurrency schema to be rendered in No Code editor, which is now amended and we're passing down the previously fetched one * chore(deps): update gradle version * doc(basic.md): add link to configuration for kestra property variables (#8490) * fix(flows): properly check average duration for dashboard graphs (#8457) There was a problem on flows view with the main chart not showing proper data until user clicks on duration toggle. Closes https://github.com/kestra-io/kestra/issues/8435. Closes https://github.com/kestra-io/kestra-ee/issues/3499. * docs(core-pause): update pauseDuration properties, titles, descriptions (#8495) * fix(system): restrict the JdbcConcurrencyLimitService to the JDBC runner * fix(core): fix indexer metric description (#8500) * Add examples with expression and trimmed values (#6154) * chore(ui): improvement to drilldown for Default and Custom Charts. (#7885) * chore(ui): improvement to drilldown for Default and Custom Charts. * minor tweak * test: fix the Barchart stories to test drilldown --------- Co-authored-by: Bart Ledoux <bledoux@kestra.io> * fix(ui): restart trigger position for backfill column (#8246) Co-authored-by: Miloš Paunović <paun992@hotmail.com> Co-authored-by: Barthélémy Ledoux <ledouxb@me.com> Co-authored-by: Bart Ledoux <bledoux@kestra.io> * feat(plugin): add a way to provide additional type of plugins Provide a way for plugins to define a new type of plugins. To do that, a plugin must provide both an abstract base class that extends AdditionalPlugin and a set of concret classes. Both the abstract base class and the concrete classes mut be inside the same plugin. This is a limitation that we may work on later by providing, for example, an SPI to add base classes to the application classloader. * fix(ui): save existing flow after making changes (#8378) Co-authored-by: Barthélémy Ledoux <ledouxb@me.com> * fix(core): failing DocumentationGeneratorTest.returnDoc() * chore(core): refactor component to composition API structure and with some styling (#8504) * feat(flows): add validation for use of inputs and outputs with '-' in the name (#8379) * test(core): fix breaking change in local flow repository (#8517) Co-authored-by: nKwiatkowski <nkwiatkowski@kestra.io> * feat(system)!: remove the SQLServer runner Part-of: https://github.com/kestra-io/kestra-ee/issues/3504 * chore(build): add Postgres stat extension * feat(plugins): add Langchain4J plugins * chore(system): add warn log when emit logQueue failed (#8432) * feat(plugins): add Go Script plugin * fix(jdbc): add service_id index on service_instance table * chore(flows): improve the blueprints view within the flow editing panels (#7983) Changes here consist of removing the tags from blueprint view on Multi Panel flow editor, along with couple of other UI improvements. Closes https://github.com/kestra-io/kestra/issues/7881. Co-authored-by: Miloš Paunović <paun992@hotmail.com> * fix(flows): properly load blueprints in multi panel view (#8524) While using the new Multi Panel view blueprints were not loading properly due to wrong paramtere being sent to action. now that's sorted. Closes https://github.com/kestra-io/kestra/issues/8523. * feat(flows): improve the display of array inputs when running an execution (#7953) This PR is introducing a change of how the `array` inputs are displayed inside the flow run dialog, to be more user-friendly. Closes https://github.com/kestra-io/kestra/issues/6947. --------- Co-authored-by: Miloš Paunović <paun992@hotmail.com> * fix(system): change default config values for liveness Change kestra.server.liveness.interval from 5s to 10s to be less agressive on liveness check. Align other default liveness configs with kafka implementation. * fix(ui): amend Absolute date filter's looks (#8501) * chore(core): localize to languages other than english (#8528) Extended localization support by adding translations for multiple languages using English as the base. This enhances accessibility and usability for non-English-speaking users while keeping English as the source reference. Co-authored-by: GitHub Action <actions@github.com> * docs(flow-trigger): add note about no Pebble in conditions * fix(ui): remove parts of filter using backspace (#8105) Co-authored-by: Miloš Paunović <paun992@hotmail.com> Co-authored-by: Barthélémy Ledoux <ledouxb@me.com> * fix(ui): open link in markdown in other tab. (#8258) * fix(ui): open link in markdown in other tab. * chore(core): restrict attribute to external links. Co-authored-by: Barthélémy Ledoux <ledouxb@me.com> --------- Co-authored-by: Barthélémy Ledoux <ledouxb@me.com> * fix(system): load OpenTelemetry lib in the app classloader Without that, as we have it here, plugins may have class loading issue if they use OpenTelemetry internally (like in the Elasticsearch client). * feat(ui): Add search in internal docs (#8458) Co-authored-by: Barthélémy Ledoux <ledouxb@me.com> * fix(triggers): inject default later inside the Scheduler Today, as they are injected eagerly, they are done even if no trigger exists. This is counter-performant, and in case the flow is an error will log each seconds. Doing it a little later will be better. * build(deps): bump software.amazon.awssdk:bom from 2.31.25 to 2.31.30 Bumps software.amazon.awssdk:bom from 2.31.25 to 2.31.30. --- updated-dependencies: - dependency-name: software.amazon.awssdk:bom dependency-version: 2.31.30 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump org.wiremock:wiremock-jetty12 from 3.12.1 to 3.13.0 Bumps [org.wiremock:wiremock-jetty12](https://github.com/wiremock/wiremock) from 3.12.1 to 3.13.0. - [Release notes](https://github.com/wiremock/wiremock/releases) - [Commits](https://github.com/wiremock/wiremock/compare/3.12.1...3.13.0) --- updated-dependencies: - dependency-name: org.wiremock:wiremock-jetty12 dependency-version: 3.13.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump jacksonVersion from 2.18.3 to 2.19.0 Bumps `jacksonVersion` from 2.18.3 to 2.19.0. Updates `com.fasterxml.jackson:jackson-bom` from 2.18.3 to 2.19.0 - [Commits](https://github.com/FasterXML/jackson-bom/compare/jackson-bom-2.18.3...jackson-bom-2.19.0) Updates `com.fasterxml.jackson.core:jackson-core` from 2.18.3 to 2.19.0 - [Commits](https://github.com/FasterXML/jackson-core/compare/jackson-core-2.18.3...jackson-core-2.19.0) Updates `com.fasterxml.jackson.core:jackson-databind` from 2.18.3 to 2.19.0 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.core:jackson-annotations` from 2.18.3 to 2.19.0 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `com.fasterxml.jackson.module:jackson-module-parameter-names` from 2.18.3 to 2.19.0 - [Commits](https://github.com/FasterXML/jackson-modules-java8/compare/jackson-modules-java8-2.18.3...jackson-modules-java8-2.19.0) Updates `com.fasterxml.jackson.dataformat:jackson-dataformat-yaml` from 2.18.3 to 2.19.0 - [Commits](https://github.com/FasterXML/jackson-dataformats-text/compare/jackson-dataformats-text-2.18.3...jackson-dataformats-text-2.19.0) Updates `com.fasterxml.jackson.dataformat:jackson-dataformat-smile` from 2.18.3 to 2.19.0 - [Commits](https://github.com/FasterXML/jackson-dataformats-binary/compare/jackson-dataformats-binary-2.18.3...jackson-dataformats-binary-2.19.0) Updates `com.fasterxml.jackson.dataformat:jackson-dataformat-cbor` from 2.18.3 to 2.19.0 - [Commits](https://github.com/FasterXML/jackson-dataformats-binary/compare/jackson-dataformats-binary-2.18.3...jackson-dataformats-binary-2.19.0) Updates `com.fasterxml.jackson.dataformat:jackson-dataformat-ion` from 2.18.3 to 2.19.0 - [Commits](https://github.com/FasterXML/jackson-dataformat-ion/commits) Updates `com.fasterxml.jackson.dataformat:jackson-dataformat-xml` from 2.18.3 to 2.19.0 - [Commits](https://github.com/FasterXML/jackson-dataformat-xml/compare/jackson-dataformat-xml-2.18.3...jackson-dataformat-xml-2.19.0) Updates `com.fasterxml.jackson.datatype:jackson-datatype-guava` from 2.18.3 to 2.19.0 - [Commits](https://github.com/FasterXML/jackson-datatypes-collections/compare/jackson-datatypes-collections-2.18.3...jackson-datatypes-collections-2.19.0) Updates `com.fasterxml.jackson.datatype:jackson-datatype-jsr310` from 2.18.3 to 2.19.0 Updates `com.fasterxml.jackson.datatype:jackson-datatype-jdk8` from 2.18.3 to 2.19.0 --- updated-dependencies: - dependency-name: com.fasterxml.jackson:jackson-bom dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.core:jackson-core dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.core:jackson-annotations dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.module:jackson-module-parameter-names dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-smile dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-cbor dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-ion dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-xml dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.datatype:jackson-datatype-guava dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.datatype:jackson-datatype-jsr310 dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.fasterxml.jackson.datatype:jackson-datatype-jdk8 dependency-version: 2.19.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * chore(execution): update display names for executions. (#8527) * fix(core): change incorrectly used search parameter (#8534) Co-authored-by: nKwiatkowski <nkwiatkowski@kestra.io> * fix(ui): set isCreating to false when opening flow edit mode (#8549) * fix(core): safely access section and identifier query params (#8542) Co-authored-by: Barthélémy Ledoux <ledouxb@me.com> * fix(ui): update storybook editor tests with provided keys (#8550) Co-authored-by: Piyush Bhaskar <102078527+Piyush-r-bhaskar@users.noreply.github.com> * chore(core): localize to languages other than english (#8554) Extended localization support by adding translations for multiple languages using English as the base. This enhances accessibility and usability for non-English-speaking users while keeping English as the source reference. Co-authored-by: GitHub Action <actions@github.com> * fix(triggers): amend broken filtering on triggers tab (#8553) There was a problem with both namespace and state filters on Triggers page which is now properly sorted. Closes https://github.com/kestra-io/kestra/issues/8529. * chore: attempt to fix flaky tests (#8537) SingleFlowCommandsTest: The flow Delete -> Create -> Update sequence is weird - delete got HTTP 404. Reworked to Create -> Update -> Delete sequence. PurgeLogsTest: The log repository contained the prepared single entry but also might contain additional entries from previously logged messages. * fix(namespaces): namespaceFiles with same name are wrongly overwritten (#8562) Co-authored-by: nKwiatkowski <nkwiatkowski@kestra.io> * feat(core): forward execution labels in Flow Trigger * chore(triggers)*: properly handle switches for triggers disabled from within flow source (#8106) It was not clear as to which trigger can not be enabled and why. Now, that is much more clear with the proper tooltips and disabling of switch toggling. Closes https://github.com/kestra-io/kestra/issues/8011. Closes https://github.com/kestra-io/kestra/issues/5736. * fix(executions): fix execution failure due to UnsupportedOperationException (#8563) Fix: #8563 * chore(core): localize to languages other than english (#8568) Extended localization support by adding translations for multiple languages using English as the base. This enhances accessibility and usability for non-English-speaking users while keeping English as the source reference. Co-authored-by: GitHub Action <actions@github.com> * feat(system): add TestSuite model,taskFixture impl * fix: redirect to edit when saving new flow (#8560) Co-authored-by: Piyush Bhaskar <102078527+Piyush-r-bhaskar@users.noreply.github.com> * feat(system)*: decrease defaut JDBC queue poll size Decreasing it from 100 to 50 didn't show any performance hit but should lower the memory consumption now that we process the queue concurrently in the executor. ## BEFORE - pollSize=100 - 10 tx/s: 150ms - 25 tx/s: 200ms - 50 tx/s: 300ms - 75 tx/s: 5.2s - 100 tx/s: 15s ## AFTER - pollSize=50 - 10 tx/s: 150ms - 25 tx/s: 200ms - 50 tx/s: 300ms - 75 tx/s: 4.8s - 100 tx/s: 14s * feat(flows): Allow to define an onPause task on the Pause task The onPause task will be executed immediatly when the execution is paused. Part-of: #3601 * feat(core)!: WIP make tenant id required * feat(core)!: WIP make tenant id required * Feat/storage outputs (#8361) * feat(executions): Store outputs inside the internal storage (1/2) * feat(executions): Store outputs inside the internal storage (2/2) * feat(test): allow passing tenantId to tests --------- Co-authored-by: Ludovic DEHON <tchiot.ludo@gmail.com> * tests(webserver): fix flaky test which could query previous tests tasks * feat(executions): Add workerId to each worker task attemps Closes #7799 * Feat/storage outputs (#8361) * feat(executions): Store outputs inside the internal storage (1/2) * feat(executions): Store outputs inside the internal storage (2/2) * feat(test): allow passing tenantId to tests --------- Co-authored-by: Ludovic DEHON <tchiot.ludo@gmail.com> * wip(core): fix unit tests * test(core): fix unit tests * test(core): fix unit tests * test(core): fix unit tests * feat(core): make tenant id required everywhere * feat(core): make tenant required in create user command * feat(core): clean the PR * feat(core): add tenant id to dashboard controller * fix(core): tests after merging * clean(core): fixes after review --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: nKwiatkowski <nkwiatkowski@kestra.io> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Roman Acevedo <roman.acevedo62@gmail.com> Co-authored-by: Loïc Mathieu <loikeseke@gmail.com> Co-authored-by: Ludovic DEHON <tchiot.ludo@gmail.com> Co-authored-by: Miloš Paunović <paun992@hotmail.com> Co-authored-by: Piyush Bhaskar <102078527+Piyush-r-bhaskar@users.noreply.github.com> Co-authored-by: Barthélémy Ledoux <ledouxb@me.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: GitHub Action <actions@github.com> Co-authored-by: AJ Emerich <aemerich@kestra.io> Co-authored-by: ben8t <46634684+Ben8t@users.noreply.github.com> Co-authored-by: Bart Ledoux <bledoux@kestra.io> Co-authored-by: Satvik Kushwaha <59243339+satvik2131@users.noreply.github.com> Co-authored-by: Karuna Tata <karuna.tata@devrev.ai> Co-authored-by: Hashim Khalifa <105060840+hashimzs@users.noreply.github.com> Co-authored-by: lwyang <1670906161@qq.com> Co-authored-by: 杨利伟 <yangliwei@xiaomi.com> Co-authored-by: Florian Hussonnois <fhussonnois@kestra.io> Co-authored-by: yuri <1969yuri1969@gmail.com> Co-authored-by: AJ Emerich <aj-emerich@proton.me> Co-authored-by: rajatsingh23 <48049052+rajatsingh23@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package io.kestra.cli;
|
package io.kestra.cli;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
|
|
||||||
import io.micronaut.core.annotation.Nullable;
|
import io.micronaut.core.annotation.Nullable;
|
||||||
import io.micronaut.http.HttpHeaders;
|
import io.micronaut.http.HttpHeaders;
|
||||||
import io.micronaut.http.HttpRequest;
|
import io.micronaut.http.HttpRequest;
|
||||||
@@ -90,7 +92,7 @@ public abstract class AbstractApiCommand extends AbstractCommand {
|
|||||||
throw new IllegalArgumentException("'path' must be non-null and start with '/'");
|
throw new IllegalArgumentException("'path' must be non-null and start with '/'");
|
||||||
}
|
}
|
||||||
|
|
||||||
return tenantId == null ? "/api/v1" + path : "/api/v1/" + tenantId + path;
|
return tenantId == null ? "/api/v1/" + MAIN_TENANT + path : "/api/v1/" + tenantId + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class FlowTestCommand extends AbstractCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
runner.run();
|
runner.run();
|
||||||
repositoryLoader.load(null, file.toFile());
|
repositoryLoader.load(file.toFile());
|
||||||
|
|
||||||
List<Flow> all = flowRepository.findAllForAllTenants();
|
List<Flow> all = flowRepository.findAllForAllTenants();
|
||||||
if (all.size() != 1) {
|
if (all.size() != 1) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class LocalFlowFileWatcher implements FlowFilesManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FlowWithSource createOrUpdateFlow(final GenericFlow flow) {
|
public FlowWithSource createOrUpdateFlow(final GenericFlow flow) {
|
||||||
return flowRepository.findById(null, flow.getNamespace(), flow.getId())
|
return flowRepository.findById(flow.getTenantId(), flow.getNamespace(), flow.getId())
|
||||||
.map(previous -> flowRepository.update(flow, previous))
|
.map(previous -> flowRepository.update(flow, previous))
|
||||||
.orElseGet(() -> flowRepository.create(flow));
|
.orElseGet(() -> flowRepository.create(flow));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ class FlowUpdatesCommandTest {
|
|||||||
};
|
};
|
||||||
PicocliRunner.call(FlowUpdatesCommand.class, ctx, args);
|
PicocliRunner.call(FlowUpdatesCommand.class, ctx, args);
|
||||||
|
|
||||||
assertThat(out.toString()).contains("Invalid entity: flow.namespace: io.kestra.outsider_quattro_-1 - flow namespace is invalid");
|
assertThat(out.toString()).contains("Invalid entity: flow.namespace: main_io.kestra.outsider_quattro_-1 - flow namespace is invalid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
class KvUpdateCommandTest {
|
class KvUpdateCommandTest {
|
||||||
@@ -40,7 +41,7 @@ class KvUpdateCommandTest {
|
|||||||
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
||||||
|
|
||||||
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
||||||
KVStore kvStore = kvStoreService.get(null, "io.kestra.cli", null);
|
KVStore kvStore = kvStoreService.get(MAIN_TENANT, "io.kestra.cli", null);
|
||||||
|
|
||||||
assertThat(kvStore.getValue("string").get()).isEqualTo(new KVValue("stringValue"));
|
assertThat(kvStore.getValue("string").get()).isEqualTo(new KVValue("stringValue"));
|
||||||
assertThat(((InternalKVStore) kvStore).getRawValue("string").get()).isEqualTo("\"stringValue\"");
|
assertThat(((InternalKVStore) kvStore).getRawValue("string").get()).isEqualTo("\"stringValue\"");
|
||||||
@@ -68,7 +69,7 @@ class KvUpdateCommandTest {
|
|||||||
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
||||||
|
|
||||||
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
||||||
KVStore kvStore = kvStoreService.get(null, "io.kestra.cli", null);
|
KVStore kvStore = kvStoreService.get(MAIN_TENANT, "io.kestra.cli", null);
|
||||||
|
|
||||||
assertThat(kvStore.getValue("int").get()).isEqualTo(new KVValue(1));
|
assertThat(kvStore.getValue("int").get()).isEqualTo(new KVValue(1));
|
||||||
assertThat(((InternalKVStore) kvStore).getRawValue("int").get()).isEqualTo("1");
|
assertThat(((InternalKVStore) kvStore).getRawValue("int").get()).isEqualTo("1");
|
||||||
@@ -98,7 +99,7 @@ class KvUpdateCommandTest {
|
|||||||
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
||||||
|
|
||||||
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
||||||
KVStore kvStore = kvStoreService.get(null, "io.kestra.cli", null);
|
KVStore kvStore = kvStoreService.get(MAIN_TENANT, "io.kestra.cli", null);
|
||||||
|
|
||||||
assertThat(kvStore.getValue("intStr").get()).isEqualTo(new KVValue("1"));
|
assertThat(kvStore.getValue("intStr").get()).isEqualTo(new KVValue("1"));
|
||||||
assertThat(((InternalKVStore) kvStore).getRawValue("intStr").get()).isEqualTo("\"1\"");
|
assertThat(((InternalKVStore) kvStore).getRawValue("intStr").get()).isEqualTo("\"1\"");
|
||||||
@@ -126,7 +127,7 @@ class KvUpdateCommandTest {
|
|||||||
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
||||||
|
|
||||||
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
||||||
KVStore kvStore = kvStoreService.get(null, "io.kestra.cli", null);
|
KVStore kvStore = kvStoreService.get(MAIN_TENANT, "io.kestra.cli", null);
|
||||||
|
|
||||||
assertThat(kvStore.getValue("object").get()).isEqualTo(new KVValue(Map.of("some", "json")));
|
assertThat(kvStore.getValue("object").get()).isEqualTo(new KVValue(Map.of("some", "json")));
|
||||||
assertThat(((InternalKVStore) kvStore).getRawValue("object").get()).isEqualTo("{some:\"json\"}");
|
assertThat(((InternalKVStore) kvStore).getRawValue("object").get()).isEqualTo("{some:\"json\"}");
|
||||||
@@ -156,7 +157,7 @@ class KvUpdateCommandTest {
|
|||||||
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
||||||
|
|
||||||
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
||||||
KVStore kvStore = kvStoreService.get(null, "io.kestra.cli", null);
|
KVStore kvStore = kvStoreService.get(MAIN_TENANT, "io.kestra.cli", null);
|
||||||
|
|
||||||
assertThat(kvStore.getValue("objectStr").get()).isEqualTo(new KVValue("{\"some\":\"json\"}"));
|
assertThat(kvStore.getValue("objectStr").get()).isEqualTo(new KVValue("{\"some\":\"json\"}"));
|
||||||
assertThat(((InternalKVStore) kvStore).getRawValue("objectStr").get()).isEqualTo("\"{\\\"some\\\":\\\"json\\\"}\"");
|
assertThat(((InternalKVStore) kvStore).getRawValue("objectStr").get()).isEqualTo("\"{\\\"some\\\":\\\"json\\\"}\"");
|
||||||
@@ -190,7 +191,7 @@ class KvUpdateCommandTest {
|
|||||||
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
|
||||||
|
|
||||||
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
KVStoreService kvStoreService = ctx.getBean(KVStoreService.class);
|
||||||
KVStore kvStore = kvStoreService.get(null, "io.kestra.cli", null);
|
KVStore kvStore = kvStoreService.get(MAIN_TENANT, "io.kestra.cli", null);
|
||||||
|
|
||||||
assertThat(kvStore.getValue("objectFromFile").get()).isEqualTo(new KVValue(Map.of("some", "json", "from", "file")));
|
assertThat(kvStore.getValue("objectFromFile").get()).isEqualTo(new KVValue(Map.of("some", "json", "from", "file")));
|
||||||
assertThat(((InternalKVStore) kvStore).getRawValue("objectFromFile").get()).isEqualTo("{some:\"json\",from:\"file\"}");
|
assertThat(((InternalKVStore) kvStore).getRawValue("objectFromFile").get()).isEqualTo("{some:\"json\",from:\"file\"}");
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static io.kestra.core.utils.Rethrow.throwRunnable;
|
import static io.kestra.core.utils.Rethrow.throwRunnable;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ class FileChangedEventListenerTest {
|
|||||||
@RetryingTest(5) // Flaky on CI but always pass locally
|
@RetryingTest(5) // Flaky on CI but always pass locally
|
||||||
void test() throws IOException, TimeoutException {
|
void test() throws IOException, TimeoutException {
|
||||||
// remove the flow if it already exists
|
// remove the flow if it already exists
|
||||||
flowRepository.findByIdWithSource(null, "io.kestra.tests.watch", "myflow").ifPresent(flow -> flowRepository.delete(flow));
|
flowRepository.findByIdWithSource(MAIN_TENANT, "io.kestra.tests.watch", "myflow").ifPresent(flow -> flowRepository.delete(flow));
|
||||||
|
|
||||||
// create a basic flow
|
// create a basic flow
|
||||||
String flow = """
|
String flow = """
|
||||||
@@ -71,11 +72,11 @@ class FileChangedEventListenerTest {
|
|||||||
""";
|
""";
|
||||||
Files.write(Path.of(FILE_WATCH + "/myflow.yaml"), flow.getBytes());
|
Files.write(Path.of(FILE_WATCH + "/myflow.yaml"), flow.getBytes());
|
||||||
Await.until(
|
Await.until(
|
||||||
() -> flowRepository.findById(null, "io.kestra.tests.watch", "myflow").isPresent(),
|
() -> flowRepository.findById(MAIN_TENANT, "io.kestra.tests.watch", "myflow").isPresent(),
|
||||||
Duration.ofMillis(100),
|
Duration.ofMillis(100),
|
||||||
Duration.ofSeconds(10)
|
Duration.ofSeconds(10)
|
||||||
);
|
);
|
||||||
Flow myflow = flowRepository.findById(null, "io.kestra.tests.watch", "myflow").orElseThrow();
|
Flow myflow = flowRepository.findById(MAIN_TENANT, "io.kestra.tests.watch", "myflow").orElseThrow();
|
||||||
assertThat(myflow.getTasks()).hasSize(1);
|
assertThat(myflow.getTasks()).hasSize(1);
|
||||||
assertThat(myflow.getTasks().getFirst().getId()).isEqualTo("hello");
|
assertThat(myflow.getTasks().getFirst().getId()).isEqualTo("hello");
|
||||||
assertThat(myflow.getTasks().getFirst().getType()).isEqualTo("io.kestra.plugin.core.log.Log");
|
assertThat(myflow.getTasks().getFirst().getType()).isEqualTo("io.kestra.plugin.core.log.Log");
|
||||||
@@ -83,7 +84,7 @@ class FileChangedEventListenerTest {
|
|||||||
// delete the flow
|
// delete the flow
|
||||||
Files.delete(Path.of(FILE_WATCH + "/myflow.yaml"));
|
Files.delete(Path.of(FILE_WATCH + "/myflow.yaml"));
|
||||||
Await.until(
|
Await.until(
|
||||||
() -> flowRepository.findById(null, "io.kestra.tests.watch", "myflow").isEmpty(),
|
() -> flowRepository.findById(MAIN_TENANT, "io.kestra.tests.watch", "myflow").isEmpty(),
|
||||||
Duration.ofMillis(100),
|
Duration.ofMillis(100),
|
||||||
Duration.ofSeconds(10)
|
Duration.ofSeconds(10)
|
||||||
);
|
);
|
||||||
@@ -92,7 +93,7 @@ class FileChangedEventListenerTest {
|
|||||||
@RetryingTest(5) // Flaky on CI but always pass locally
|
@RetryingTest(5) // Flaky on CI but always pass locally
|
||||||
void testWithPluginDefault() throws IOException, TimeoutException {
|
void testWithPluginDefault() throws IOException, TimeoutException {
|
||||||
// remove the flow if it already exists
|
// remove the flow if it already exists
|
||||||
flowRepository.findByIdWithSource(null, "io.kestra.tests.watch", "pluginDefault").ifPresent(flow -> flowRepository.delete(flow));
|
flowRepository.findByIdWithSource(MAIN_TENANT, "io.kestra.tests.watch", "pluginDefault").ifPresent(flow -> flowRepository.delete(flow));
|
||||||
|
|
||||||
// create a flow with plugin default
|
// create a flow with plugin default
|
||||||
String pluginDefault = """
|
String pluginDefault = """
|
||||||
@@ -110,11 +111,11 @@ class FileChangedEventListenerTest {
|
|||||||
""";
|
""";
|
||||||
Files.write(Path.of(FILE_WATCH + "/plugin-default.yaml"), pluginDefault.getBytes());
|
Files.write(Path.of(FILE_WATCH + "/plugin-default.yaml"), pluginDefault.getBytes());
|
||||||
Await.until(
|
Await.until(
|
||||||
() -> flowRepository.findById(null, "io.kestra.tests.watch", "pluginDefault").isPresent(),
|
() -> flowRepository.findById(MAIN_TENANT, "io.kestra.tests.watch", "pluginDefault").isPresent(),
|
||||||
Duration.ofMillis(100),
|
Duration.ofMillis(100),
|
||||||
Duration.ofSeconds(10)
|
Duration.ofSeconds(10)
|
||||||
);
|
);
|
||||||
Flow pluginDefaultFlow = flowRepository.findById(null, "io.kestra.tests.watch", "pluginDefault").orElseThrow();
|
Flow pluginDefaultFlow = flowRepository.findById(MAIN_TENANT, "io.kestra.tests.watch", "pluginDefault").orElseThrow();
|
||||||
assertThat(pluginDefaultFlow.getTasks()).hasSize(1);
|
assertThat(pluginDefaultFlow.getTasks()).hasSize(1);
|
||||||
assertThat(pluginDefaultFlow.getTasks().getFirst().getId()).isEqualTo("helloWithDefault");
|
assertThat(pluginDefaultFlow.getTasks().getFirst().getId()).isEqualTo("helloWithDefault");
|
||||||
assertThat(pluginDefaultFlow.getTasks().getFirst().getType()).isEqualTo("io.kestra.plugin.core.log.Log");
|
assertThat(pluginDefaultFlow.getTasks().getFirst().getType()).isEqualTo("io.kestra.plugin.core.log.Log");
|
||||||
@@ -122,7 +123,7 @@ class FileChangedEventListenerTest {
|
|||||||
// delete both files
|
// delete both files
|
||||||
Files.delete(Path.of(FILE_WATCH + "/plugin-default.yaml"));
|
Files.delete(Path.of(FILE_WATCH + "/plugin-default.yaml"));
|
||||||
Await.until(
|
Await.until(
|
||||||
() -> flowRepository.findById(null, "io.kestra.tests.watch", "pluginDefault").isEmpty(),
|
() -> flowRepository.findById(MAIN_TENANT, "io.kestra.tests.watch", "pluginDefault").isEmpty(),
|
||||||
Duration.ofMillis(100),
|
Duration.ofMillis(100),
|
||||||
Duration.ofSeconds(10)
|
Duration.ofSeconds(10)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ micronaut:
|
|||||||
io:
|
io:
|
||||||
watch:
|
watch:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
tenantId: main
|
||||||
paths:
|
paths:
|
||||||
- build/file-watch
|
- build/file-watch
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class FlowWithPath {
|
|||||||
|
|
||||||
public static FlowWithPath of(FlowInterface flow, String path) {
|
public static FlowWithPath of(FlowInterface flow, String path) {
|
||||||
return FlowWithPath.builder()
|
return FlowWithPath.builder()
|
||||||
|
.tenantId(flow.getTenantId())
|
||||||
.id(flow.getId())
|
.id(flow.getId())
|
||||||
.namespace(flow.getNamespace())
|
.namespace(flow.getNamespace())
|
||||||
.path(path)
|
.path(path)
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public class Template implements DeletedInterface, TenantInterface, HasUID {
|
|||||||
})
|
})
|
||||||
.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
|
.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
|
||||||
|
|
||||||
|
@Setter
|
||||||
@Hidden
|
@Hidden
|
||||||
@Pattern(regexp = "^[a-z0-9][a-z0-9_-]*")
|
@Pattern(regexp = "^[a-z0-9][a-z0-9_-]*")
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static io.kestra.core.utils.Rethrow.throwConsumer;
|
import static io.kestra.core.utils.Rethrow.throwConsumer;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -48,7 +49,7 @@ public class LocalFlowRepositoryLoader {
|
|||||||
private PluginDefaultService pluginDefaultService;
|
private PluginDefaultService pluginDefaultService;
|
||||||
|
|
||||||
public void load(URL basePath) throws IOException, URISyntaxException {
|
public void load(URL basePath) throws IOException, URISyntaxException {
|
||||||
load(null, basePath);
|
load(MAIN_TENANT, basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(String tenantId, URL basePath) throws IOException, URISyntaxException {
|
public void load(String tenantId, URL basePath) throws IOException, URISyntaxException {
|
||||||
@@ -78,7 +79,7 @@ public class LocalFlowRepositoryLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void load(File basePath) throws IOException {
|
public void load(File basePath) throws IOException {
|
||||||
load(null, basePath);
|
load(MAIN_TENANT, basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(String tenantId, File basePath) throws IOException {
|
public void load(String tenantId, File basePath) throws IOException {
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import java.net.URI;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package io.kestra.core.runners;
|
package io.kestra.core.runners;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import io.kestra.core.metrics.MetricRegistry;
|
import io.kestra.core.metrics.MetricRegistry;
|
||||||
import io.kestra.core.models.executions.Execution;
|
import io.kestra.core.models.executions.Execution;
|
||||||
@@ -180,7 +182,7 @@ public class RunContextFactory {
|
|||||||
@Override
|
@Override
|
||||||
public String getTenantId() {
|
public String getTenantId() {
|
||||||
var tenantId = ((Map<String, Object>)variables.getOrDefault("flow", Map.of())).get("tenantId");
|
var tenantId = ((Map<String, Object>)variables.getOrDefault("flow", Map.of())).get("tenantId");
|
||||||
return Optional.ofNullable(tenantId).map(Object::toString).orElse(null);
|
return Optional.ofNullable(tenantId).map(Object::toString).orElse(MAIN_TENANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -5,13 +5,15 @@ import jakarta.inject.Singleton;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class TenantService {
|
public class TenantService {
|
||||||
|
|
||||||
|
public static final String MAIN_TENANT = "main";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve the current tenant and return its identifier.
|
* Resolve the current tenant and return its identifier.
|
||||||
* If the tenant is the default tenant, it returns null, which is always the case on OSS as Tenant is an EE feature.
|
* If the tenant is the default tenant, it returns main, which is always the case on OSS as Tenant is an EE feature.
|
||||||
*
|
*
|
||||||
* @return the current tenant identifier
|
* @return the current tenant identifier
|
||||||
*/
|
*/
|
||||||
public String resolveTenant() {
|
public String resolveTenant() {
|
||||||
return null;
|
return MAIN_TENANT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.kestra.core.http.client;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.google.common.net.HttpHeaders;
|
import com.google.common.net.HttpHeaders;
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
||||||
import io.kestra.core.http.HttpRequest;
|
import io.kestra.core.http.HttpRequest;
|
||||||
import io.kestra.core.http.HttpResponse;
|
import io.kestra.core.http.HttpResponse;
|
||||||
@@ -15,7 +16,6 @@ import io.kestra.core.models.property.Property;
|
|||||||
import io.kestra.core.queues.QueueFactoryInterface;
|
import io.kestra.core.queues.QueueFactoryInterface;
|
||||||
import io.kestra.core.queues.QueueInterface;
|
import io.kestra.core.queues.QueueInterface;
|
||||||
import io.kestra.core.runners.RunContext;
|
import io.kestra.core.runners.RunContext;
|
||||||
import io.kestra.core.runners.RunContextFactory;
|
|
||||||
import io.kestra.core.serializers.JacksonMapper;
|
import io.kestra.core.serializers.JacksonMapper;
|
||||||
import io.kestra.core.utils.IdUtils;
|
import io.kestra.core.utils.IdUtils;
|
||||||
import io.kestra.core.utils.TestsUtils;
|
import io.kestra.core.utils.TestsUtils;
|
||||||
@@ -71,7 +71,7 @@ class HttpClientTest {
|
|||||||
private ApplicationContext applicationContext;
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
private URI embeddedServerUri;
|
private URI embeddedServerUri;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.models.flows.sla.types;
|
package io.kestra.core.models.flows.sla.types;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.exceptions.InternalException;
|
import io.kestra.core.exceptions.InternalException;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
import io.kestra.core.models.flows.sla.Violation;
|
import io.kestra.core.models.flows.sla.Violation;
|
||||||
@@ -18,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
@KestraTest
|
@KestraTest
|
||||||
class ExecutionAssertionSLATest {
|
class ExecutionAssertionSLATest {
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldEvaluateToAViolation() throws InternalException {
|
void shouldEvaluateToAViolation() throws InternalException {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
@@ -300,7 +301,7 @@ class FlowGraphTest {
|
|||||||
IllegalArgumentException illegalArgumentException = Assertions.assertThrows(IllegalArgumentException.class, () -> graphService.flowGraph(flow, Collections.singletonList("root.launch")));
|
IllegalArgumentException illegalArgumentException = Assertions.assertThrows(IllegalArgumentException.class, () -> graphService.flowGraph(flow, Collections.singletonList("root.launch")));
|
||||||
assertThat(illegalArgumentException.getMessage()).isEqualTo("Can't expand subflow task 'launch' because namespace and/or flowId contains dynamic values. This can only be viewed on an execution.");
|
assertThat(illegalArgumentException.getMessage()).isEqualTo("Can't expand subflow task 'launch' because namespace and/or flowId contains dynamic values. This can only be viewed on an execution.");
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "task-flow-dynamic", 1, (f, e) -> Map.of(
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "task-flow-dynamic", 1, (f, e) -> Map.of(
|
||||||
"namespace", f.getNamespace(),
|
"namespace", f.getNamespace(),
|
||||||
"flowId", "switch"
|
"flowId", "switch"
|
||||||
));
|
));
|
||||||
@@ -377,7 +378,10 @@ class FlowGraphTest {
|
|||||||
|
|
||||||
File file = new File(resource.getFile());
|
File file = new File(resource.getFile());
|
||||||
|
|
||||||
return YamlParser.parse(file, FlowWithSource.class).toBuilder().source(Files.readString(file.toPath())).build();
|
return YamlParser.parse(file, FlowWithSource.class).toBuilder()
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
|
.source(Files.readString(file.toPath()))
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AbstractGraph node(FlowGraph flowGraph, String taskId) {
|
private static AbstractGraph node(FlowGraph flowGraph, String taskId) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.models.property;
|
package io.kestra.core.models.property;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
import io.kestra.core.runners.RunContextFactory;
|
import io.kestra.core.runners.RunContextFactory;
|
||||||
@@ -20,6 +21,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static java.util.Map.entry;
|
import static java.util.Map.entry;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
@@ -28,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||||||
class PropertyTest {
|
class PropertyTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private StorageInterface storage;
|
private StorageInterface storage;
|
||||||
@@ -155,7 +157,7 @@ class PropertyTest {
|
|||||||
FileSerde.writeAll(Files.newBufferedWriter(messages), Flux.fromIterable(inputValues)).block();
|
FileSerde.writeAll(Files.newBufferedWriter(messages), Flux.fromIterable(inputValues)).block();
|
||||||
URI uri;
|
URI uri;
|
||||||
try (var input = new FileInputStream(messages.toFile())) {
|
try (var input = new FileInputStream(messages.toFile())) {
|
||||||
uri = storage.put(null, null, URI.create("/messages.ion"), input);
|
uri = storage.put(MAIN_TENANT, null, URI.create("/messages.ion"), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
var task = DynamicPropertyExampleTask.builder()
|
var task = DynamicPropertyExampleTask.builder()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.models.tasks.runners;
|
package io.kestra.core.models.tasks.runners;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
||||||
import io.kestra.core.models.executions.Execution;
|
import io.kestra.core.models.executions.Execution;
|
||||||
import io.kestra.core.models.executions.TaskRun;
|
import io.kestra.core.models.executions.TaskRun;
|
||||||
@@ -28,7 +29,7 @@ import static org.hamcrest.Matchers.*;
|
|||||||
@KestraTest
|
@KestraTest
|
||||||
class ScriptServiceTest {
|
class ScriptServiceTest {
|
||||||
public static final Pattern COMMAND_PATTERN_CAPTURE_LOCAL_PATH = Pattern.compile("my command with an internal storage file: (.*)");
|
public static final Pattern COMMAND_PATTERN_CAPTURE_LOCAL_PATH = Pattern.compile("my command with an internal storage file: (.*)");
|
||||||
@Inject private RunContextFactory runContextFactory;
|
@Inject private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void replaceInternalStorage() throws IOException {
|
void replaceInternalStorage() throws IOException {
|
||||||
@@ -39,7 +40,7 @@ class ScriptServiceTest {
|
|||||||
command = ScriptService.replaceInternalStorage(runContext, "my command", false);
|
command = ScriptService.replaceInternalStorage(runContext, "my command", false);
|
||||||
assertThat(command).isEqualTo("my command");
|
assertThat(command).isEqualTo("my command");
|
||||||
|
|
||||||
Path path = Path.of("/tmp/unittest/file.txt");
|
Path path = Path.of("/tmp/unittest/main/file.txt");
|
||||||
if (!path.toFile().exists()) {
|
if (!path.toFile().exists()) {
|
||||||
Files.createFile(path);
|
Files.createFile(path);
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,7 @@ class ScriptServiceTest {
|
|||||||
void uploadInputFiles() throws IOException {
|
void uploadInputFiles() throws IOException {
|
||||||
var runContext = runContextFactory.of();
|
var runContext = runContextFactory.of();
|
||||||
|
|
||||||
Path path = Path.of("/tmp/unittest/file.txt");
|
Path path = Path.of("/tmp/unittest/main/file.txt");
|
||||||
if (!path.toFile().exists()) {
|
if (!path.toFile().exists()) {
|
||||||
Files.createFile(path);
|
Files.createFile(path);
|
||||||
}
|
}
|
||||||
@@ -118,12 +119,12 @@ class ScriptServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
void uploadOutputFiles() throws IOException {
|
void uploadOutputFiles() throws IOException {
|
||||||
var runContext = runContextFactory.of();
|
var runContext = runContextFactory.of();
|
||||||
Path path = Path.of("/tmp/unittest/file.txt");
|
Path path = Path.of("/tmp/unittest/main/file.txt");
|
||||||
if (!path.toFile().exists()) {
|
if (!path.toFile().exists()) {
|
||||||
Files.createFile(path);
|
Files.createFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
var outputFiles = ScriptService.uploadOutputFiles(runContext, Path.of("/tmp/unittest"));
|
var outputFiles = ScriptService.uploadOutputFiles(runContext, Path.of("/tmp/unittest/main"));
|
||||||
assertThat(outputFiles, not(anEmptyMap()));
|
assertThat(outputFiles, not(anEmptyMap()));
|
||||||
assertThat(outputFiles.get("file.txt")).isEqualTo(URI.create("kestra:///file.txt"));
|
assertThat(outputFiles.get("file.txt")).isEqualTo(URI.create("kestra:///file.txt"));
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.groups.Tuple.tuple;
|
import static org.assertj.core.groups.Tuple.tuple;
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
@@ -60,6 +61,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
Execution.ExecutionBuilder execution = Execution.builder()
|
Execution.ExecutionBuilder execution = Execution.builder()
|
||||||
.id(FriendlyId.createFriendlyId())
|
.id(FriendlyId.createFriendlyId())
|
||||||
.namespace(namespace)
|
.namespace(namespace)
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.flowId(flowId == null ? FLOW : flowId)
|
.flowId(flowId == null ? FLOW : flowId)
|
||||||
.flowRevision(1)
|
.flowRevision(1)
|
||||||
.state(finalState);
|
.state(finalState);
|
||||||
@@ -155,7 +157,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
protected void find() {
|
protected void find() {
|
||||||
inject();
|
inject();
|
||||||
|
|
||||||
ArrayListTotal<Execution> executions = executionRepository.find(Pageable.from(1, 10), null, null);
|
ArrayListTotal<Execution> executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, null);
|
||||||
assertThat(executions.getTotal()).isEqualTo(28L);
|
assertThat(executions.getTotal()).isEqualTo(28L);
|
||||||
assertThat(executions.size()).isEqualTo(10);
|
assertThat(executions.size()).isEqualTo(10);
|
||||||
|
|
||||||
@@ -164,7 +166,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.operation(QueryFilter.Op.EQUALS)
|
.operation(QueryFilter.Op.EQUALS)
|
||||||
.value( List.of(State.Type.RUNNING, State.Type.FAILED))
|
.value( List.of(State.Type.RUNNING, State.Type.FAILED))
|
||||||
.build());
|
.build());
|
||||||
executions = executionRepository.find(Pageable.from(1, 10), null, filters);
|
executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(executions.getTotal()).isEqualTo(8L);
|
assertThat(executions.getTotal()).isEqualTo(8L);
|
||||||
|
|
||||||
filters = List.of(QueryFilter.builder()
|
filters = List.of(QueryFilter.builder()
|
||||||
@@ -172,7 +174,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.operation(QueryFilter.Op.EQUALS)
|
.operation(QueryFilter.Op.EQUALS)
|
||||||
.value(Map.of("key", "value"))
|
.value(Map.of("key", "value"))
|
||||||
.build());
|
.build());
|
||||||
executions = executionRepository.find(Pageable.from(1, 10), null, filters);
|
executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(executions.getTotal()).isEqualTo(1L);
|
assertThat(executions.getTotal()).isEqualTo(1L);
|
||||||
|
|
||||||
filters = List.of(QueryFilter.builder()
|
filters = List.of(QueryFilter.builder()
|
||||||
@@ -180,7 +182,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.operation(QueryFilter.Op.EQUALS)
|
.operation(QueryFilter.Op.EQUALS)
|
||||||
.value(Map.of("key", "value2"))
|
.value(Map.of("key", "value2"))
|
||||||
.build());
|
.build());
|
||||||
executions = executionRepository.find(Pageable.from(1, 10), null, filters);
|
executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(executions.getTotal()).isEqualTo(0L);
|
assertThat(executions.getTotal()).isEqualTo(0L);
|
||||||
|
|
||||||
filters = List.of(QueryFilter.builder()
|
filters = List.of(QueryFilter.builder()
|
||||||
@@ -189,7 +191,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.value(Map.of("key", "value", "keyTest", "valueTest"))
|
.value(Map.of("key", "value", "keyTest", "valueTest"))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
executions = executionRepository.find(Pageable.from(1, 10), null, filters);
|
executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(executions.getTotal()).isEqualTo(1L);
|
assertThat(executions.getTotal()).isEqualTo(1L);
|
||||||
|
|
||||||
filters = List.of(QueryFilter.builder()
|
filters = List.of(QueryFilter.builder()
|
||||||
@@ -197,7 +199,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.operation(QueryFilter.Op.EQUALS)
|
.operation(QueryFilter.Op.EQUALS)
|
||||||
.value("second")
|
.value("second")
|
||||||
.build());
|
.build());
|
||||||
executions = executionRepository.find(Pageable.from(1, 10), null, filters);
|
executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(executions.getTotal()).isEqualTo(13L);
|
assertThat(executions.getTotal()).isEqualTo(13L);
|
||||||
|
|
||||||
filters = List.of(QueryFilter.builder()
|
filters = List.of(QueryFilter.builder()
|
||||||
@@ -211,7 +213,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.value(NAMESPACE)
|
.value(NAMESPACE)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
executions = executionRepository.find(Pageable.from(1, 10), null, filters);
|
executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(executions.getTotal()).isEqualTo(13L);
|
assertThat(executions.getTotal()).isEqualTo(13L);
|
||||||
|
|
||||||
filters = List.of(QueryFilter.builder()
|
filters = List.of(QueryFilter.builder()
|
||||||
@@ -219,7 +221,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.operation(QueryFilter.Op.STARTS_WITH)
|
.operation(QueryFilter.Op.STARTS_WITH)
|
||||||
.value("io.kestra")
|
.value("io.kestra")
|
||||||
.build());
|
.build());
|
||||||
executions = executionRepository.find(Pageable.from(1, 10), null, filters);
|
executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(executions.getTotal()).isEqualTo(28L);
|
assertThat(executions.getTotal()).isEqualTo(28L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +237,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.operation(QueryFilter.Op.EQUALS)
|
.operation(QueryFilter.Op.EQUALS)
|
||||||
.value(executionTriggerId)
|
.value(executionTriggerId)
|
||||||
.build());
|
.build());
|
||||||
ArrayListTotal<Execution> executions = executionRepository.find(Pageable.from(1, 10), null, filters);
|
ArrayListTotal<Execution> executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(executions.getTotal()).isEqualTo(28L);
|
assertThat(executions.getTotal()).isEqualTo(28L);
|
||||||
assertThat(executions.size()).isEqualTo(10);
|
assertThat(executions.size()).isEqualTo(10);
|
||||||
assertThat(executions.getFirst().getTrigger().getVariables().get("executionId")).isEqualTo(executionTriggerId);
|
assertThat(executions.getFirst().getTrigger().getVariables().get("executionId")).isEqualTo(executionTriggerId);
|
||||||
@@ -245,7 +247,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.value(ExecutionRepositoryInterface.ChildFilter.CHILD)
|
.value(ExecutionRepositoryInterface.ChildFilter.CHILD)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
executions = executionRepository.find(Pageable.from(1, 10), null, filters);
|
executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(executions.getTotal()).isEqualTo(28L);
|
assertThat(executions.getTotal()).isEqualTo(28L);
|
||||||
assertThat(executions.size()).isEqualTo(10);
|
assertThat(executions.size()).isEqualTo(10);
|
||||||
assertThat(executions.getFirst().getTrigger().getVariables().get("executionId")).isEqualTo(executionTriggerId);
|
assertThat(executions.getFirst().getTrigger().getVariables().get("executionId")).isEqualTo(executionTriggerId);
|
||||||
@@ -256,12 +258,12 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.value(ExecutionRepositoryInterface.ChildFilter.MAIN)
|
.value(ExecutionRepositoryInterface.ChildFilter.MAIN)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
executions = executionRepository.find(Pageable.from(1, 10), null, filters );
|
executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters );
|
||||||
assertThat(executions.getTotal()).isEqualTo(28L);
|
assertThat(executions.getTotal()).isEqualTo(28L);
|
||||||
assertThat(executions.size()).isEqualTo(10);
|
assertThat(executions.size()).isEqualTo(10);
|
||||||
assertThat(executions.getFirst().getTrigger()).isNull();
|
assertThat(executions.getFirst().getTrigger()).isNull();
|
||||||
|
|
||||||
executions = executionRepository.find(Pageable.from(1, 10), null,null);
|
executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, null);
|
||||||
assertThat(executions.getTotal()).isEqualTo(56L);
|
assertThat(executions.getTotal()).isEqualTo(56L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,7 +271,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
protected void findWithSort() {
|
protected void findWithSort() {
|
||||||
inject();
|
inject();
|
||||||
|
|
||||||
ArrayListTotal<Execution> executions = executionRepository.find(Pageable.from(1, 10, Sort.of(Sort.Order.desc("id"))), null, null);
|
ArrayListTotal<Execution> executions = executionRepository.find(Pageable.from(1, 10, Sort.of(Sort.Order.desc("id"))), MAIN_TENANT, null);
|
||||||
assertThat(executions.getTotal()).isEqualTo(28L);
|
assertThat(executions.getTotal()).isEqualTo(28L);
|
||||||
assertThat(executions.size()).isEqualTo(10);
|
assertThat(executions.size()).isEqualTo(10);
|
||||||
|
|
||||||
@@ -278,7 +280,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.operation(QueryFilter.Op.EQUALS)
|
.operation(QueryFilter.Op.EQUALS)
|
||||||
.value(List.of(State.Type.RUNNING, State.Type.FAILED))
|
.value(List.of(State.Type.RUNNING, State.Type.FAILED))
|
||||||
.build());
|
.build());
|
||||||
executions = executionRepository.find(Pageable.from(1, 10), null, filters);
|
executions = executionRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(executions.getTotal()).isEqualTo(8L);
|
assertThat(executions.getTotal()).isEqualTo(8L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,7 +288,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
protected void findTaskRun() {
|
protected void findTaskRun() {
|
||||||
inject();
|
inject();
|
||||||
|
|
||||||
ArrayListTotal<TaskRun> taskRuns = executionRepository.findTaskRun(Pageable.from(1, 10), null, null);
|
ArrayListTotal<TaskRun> taskRuns = executionRepository.findTaskRun(Pageable.from(1, 10), MAIN_TENANT, null);
|
||||||
assertThat(taskRuns.getTotal()).isEqualTo(74L);
|
assertThat(taskRuns.getTotal()).isEqualTo(74L);
|
||||||
assertThat(taskRuns.size()).isEqualTo(10);
|
assertThat(taskRuns.size()).isEqualTo(10);
|
||||||
|
|
||||||
@@ -296,7 +298,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
.value(Map.of("key", "value"))
|
.value(Map.of("key", "value"))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
taskRuns = executionRepository.findTaskRun(Pageable.from(1, 10), null, filters);
|
taskRuns = executionRepository.findTaskRun(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(taskRuns.getTotal()).isEqualTo(1L);
|
assertThat(taskRuns.getTotal()).isEqualTo(1L);
|
||||||
assertThat(taskRuns.size()).isEqualTo(1);
|
assertThat(taskRuns.size()).isEqualTo(1);
|
||||||
}
|
}
|
||||||
@@ -306,7 +308,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
protected void findById() {
|
protected void findById() {
|
||||||
executionRepository.save(ExecutionFixture.EXECUTION_1);
|
executionRepository.save(ExecutionFixture.EXECUTION_1);
|
||||||
|
|
||||||
Optional<Execution> full = executionRepository.findById(null, ExecutionFixture.EXECUTION_1.getId());
|
Optional<Execution> full = executionRepository.findById(MAIN_TENANT, ExecutionFixture.EXECUTION_1.getId());
|
||||||
assertThat(full.isPresent()).isTrue();
|
assertThat(full.isPresent()).isTrue();
|
||||||
|
|
||||||
full.ifPresent(current -> {
|
full.ifPresent(current -> {
|
||||||
@@ -330,7 +332,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
protected void purge() {
|
protected void purge() {
|
||||||
executionRepository.save(ExecutionFixture.EXECUTION_1);
|
executionRepository.save(ExecutionFixture.EXECUTION_1);
|
||||||
|
|
||||||
Optional<Execution> full = executionRepository.findById(null, ExecutionFixture.EXECUTION_1.getId());
|
Optional<Execution> full = executionRepository.findById(MAIN_TENANT, ExecutionFixture.EXECUTION_1.getId());
|
||||||
assertThat(full.isPresent()).isTrue();
|
assertThat(full.isPresent()).isTrue();
|
||||||
|
|
||||||
executionRepository.purge(ExecutionFixture.EXECUTION_1);
|
executionRepository.purge(ExecutionFixture.EXECUTION_1);
|
||||||
@@ -343,12 +345,12 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
protected void delete() {
|
protected void delete() {
|
||||||
executionRepository.save(ExecutionFixture.EXECUTION_1);
|
executionRepository.save(ExecutionFixture.EXECUTION_1);
|
||||||
|
|
||||||
Optional<Execution> full = executionRepository.findById(null, ExecutionFixture.EXECUTION_1.getId());
|
Optional<Execution> full = executionRepository.findById(MAIN_TENANT, ExecutionFixture.EXECUTION_1.getId());
|
||||||
assertThat(full.isPresent()).isTrue();
|
assertThat(full.isPresent()).isTrue();
|
||||||
|
|
||||||
executionRepository.delete(ExecutionFixture.EXECUTION_1);
|
executionRepository.delete(ExecutionFixture.EXECUTION_1);
|
||||||
|
|
||||||
full = executionRepository.findById(null, ExecutionFixture.EXECUTION_1.getId());
|
full = executionRepository.findById(MAIN_TENANT, ExecutionFixture.EXECUTION_1.getId());
|
||||||
assertThat(full.isPresent()).isFalse();
|
assertThat(full.isPresent()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,7 +359,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
executionRepository.save(ExecutionFixture.EXECUTION_2);
|
executionRepository.save(ExecutionFixture.EXECUTION_2);
|
||||||
executionRepository.save(ExecutionFixture.EXECUTION_1);
|
executionRepository.save(ExecutionFixture.EXECUTION_1);
|
||||||
|
|
||||||
ArrayListTotal<Execution> page1 = executionRepository.findByFlowId(null, NAMESPACE, FLOW, Pageable.from(1, 10));
|
ArrayListTotal<Execution> page1 = executionRepository.findByFlowId(MAIN_TENANT, NAMESPACE, FLOW, Pageable.from(1, 10));
|
||||||
|
|
||||||
assertThat(page1.size()).isEqualTo(2);
|
assertThat(page1.size()).isEqualTo(2);
|
||||||
}
|
}
|
||||||
@@ -376,7 +378,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
|
|
||||||
Map<String, Map<String, List<DailyExecutionStatistics>>> result = executionRepository.dailyGroupByFlowStatistics(
|
Map<String, Map<String, List<DailyExecutionStatistics>>> result = executionRepository.dailyGroupByFlowStatistics(
|
||||||
null,
|
null,
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -405,7 +407,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
|
|
||||||
result = executionRepository.dailyGroupByFlowStatistics(
|
result = executionRepository.dailyGroupByFlowStatistics(
|
||||||
null,
|
null,
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -426,7 +428,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
|
|
||||||
result = executionRepository.dailyGroupByFlowStatistics(
|
result = executionRepository.dailyGroupByFlowStatistics(
|
||||||
null,
|
null,
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
List.of(ExecutionRepositoryInterface.FlowFilter.builder().namespace("io.kestra.unittest").id(FLOW).build()),
|
List.of(ExecutionRepositoryInterface.FlowFilter.builder().namespace("io.kestra.unittest").id(FLOW).build()),
|
||||||
@@ -489,7 +491,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
List<Execution> result = executionRepository.lastExecutions(
|
List<Execution> result = executionRepository.lastExecutions(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
List.of(
|
List.of(
|
||||||
ExecutionRepositoryInterface.FlowFilter.builder()
|
ExecutionRepositoryInterface.FlowFilter.builder()
|
||||||
.id(FLOW)
|
.id(FLOW)
|
||||||
@@ -531,7 +533,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
|
|
||||||
List<DailyExecutionStatistics> result = executionRepository.dailyStatistics(
|
List<DailyExecutionStatistics> result = executionRepository.dailyStatistics(
|
||||||
null,
|
null,
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -551,7 +553,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
|
|
||||||
result = executionRepository.dailyStatistics(
|
result = executionRepository.dailyStatistics(
|
||||||
null,
|
null,
|
||||||
null,
|
MAIN_TENANT,
|
||||||
List.of(FlowScope.USER, FlowScope.SYSTEM),
|
List.of(FlowScope.USER, FlowScope.SYSTEM),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -566,7 +568,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
|
|
||||||
result = executionRepository.dailyStatistics(
|
result = executionRepository.dailyStatistics(
|
||||||
null,
|
null,
|
||||||
null,
|
MAIN_TENANT,
|
||||||
List.of(FlowScope.USER),
|
List.of(FlowScope.USER),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -580,7 +582,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
|
|
||||||
result = executionRepository.dailyStatistics(
|
result = executionRepository.dailyStatistics(
|
||||||
null,
|
null,
|
||||||
null,
|
MAIN_TENANT,
|
||||||
List.of(FlowScope.SYSTEM),
|
List.of(FlowScope.SYSTEM),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -609,7 +611,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
|
|
||||||
List<DailyExecutionStatistics> result = executionRepository.dailyStatistics(
|
List<DailyExecutionStatistics> result = executionRepository.dailyStatistics(
|
||||||
null,
|
null,
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -629,7 +631,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
|
|
||||||
result = executionRepository.dailyStatistics(
|
result = executionRepository.dailyStatistics(
|
||||||
null,
|
null,
|
||||||
null,
|
MAIN_TENANT,
|
||||||
List.of(FlowScope.USER, FlowScope.SYSTEM),
|
List.of(FlowScope.USER, FlowScope.SYSTEM),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -644,7 +646,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
|
|
||||||
result = executionRepository.dailyStatistics(
|
result = executionRepository.dailyStatistics(
|
||||||
null,
|
null,
|
||||||
null,
|
MAIN_TENANT,
|
||||||
List.of(FlowScope.USER),
|
List.of(FlowScope.USER),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -658,7 +660,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
|
|
||||||
result = executionRepository.dailyStatistics(
|
result = executionRepository.dailyStatistics(
|
||||||
null,
|
null,
|
||||||
null,
|
MAIN_TENANT,
|
||||||
List.of(FlowScope.SYSTEM),
|
List.of(FlowScope.SYSTEM),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -685,7 +687,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
List<ExecutionCount> result = executionRepository.executionCounts(
|
List<ExecutionCount> result = executionRepository.executionCounts(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
List.of(
|
List.of(
|
||||||
new Flow(NAMESPACE, "first"),
|
new Flow(NAMESPACE, "first"),
|
||||||
new Flow(NAMESPACE, "second"),
|
new Flow(NAMESPACE, "second"),
|
||||||
@@ -704,7 +706,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
assertThat(result.stream().filter(executionCount -> executionCount.getFlowId().equals("missing")).findFirst().get().getCount()).isEqualTo(0L);
|
assertThat(result.stream().filter(executionCount -> executionCount.getFlowId().equals("missing")).findFirst().get().getCount()).isEqualTo(0L);
|
||||||
|
|
||||||
result = executionRepository.executionCounts(
|
result = executionRepository.executionCounts(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
List.of(
|
List.of(
|
||||||
new Flow(NAMESPACE, "first"),
|
new Flow(NAMESPACE, "first"),
|
||||||
new Flow(NAMESPACE, "second"),
|
new Flow(NAMESPACE, "second"),
|
||||||
@@ -721,7 +723,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
assertThat(result.stream().filter(executionCount -> executionCount.getFlowId().equals("third")).findFirst().get().getCount()).isEqualTo(9L);
|
assertThat(result.stream().filter(executionCount -> executionCount.getFlowId().equals("third")).findFirst().get().getCount()).isEqualTo(9L);
|
||||||
|
|
||||||
result = executionRepository.executionCounts(
|
result = executionRepository.executionCounts(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -741,7 +743,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
Execution updated = execution.toBuilder().labels(List.of(label)).build();
|
Execution updated = execution.toBuilder().labels(List.of(label)).build();
|
||||||
executionRepository.update(updated);
|
executionRepository.update(updated);
|
||||||
|
|
||||||
Optional<Execution> validation = executionRepository.findById(null, updated.getId());
|
Optional<Execution> validation = executionRepository.findById(MAIN_TENANT, updated.getId());
|
||||||
assertThat(validation.isPresent()).isTrue();
|
assertThat(validation.isPresent()).isTrue();
|
||||||
assertThat(validation.get().getLabels().size()).isEqualTo(1);
|
assertThat(validation.get().getLabels().size()).isEqualTo(1);
|
||||||
assertThat(validation.get().getLabels().getFirst()).isEqualTo(label);
|
assertThat(validation.get().getLabels().getFirst()).isEqualTo(label);
|
||||||
@@ -755,7 +757,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
executionRepository.save(earliest);
|
executionRepository.save(earliest);
|
||||||
executionRepository.save(latest);
|
executionRepository.save(latest);
|
||||||
|
|
||||||
Optional<Execution> result = executionRepository.findLatestForStates(null, "io.kestra.unittest", "full", List.of(State.Type.CREATED));
|
Optional<Execution> result = executionRepository.findLatestForStates(MAIN_TENANT, "io.kestra.unittest", "full", List.of(State.Type.CREATED));
|
||||||
assertThat(result.isPresent()).isTrue();
|
assertThat(result.isPresent()).isTrue();
|
||||||
assertThat(result.get().getId()).isEqualTo(latest.getId());
|
assertThat(result.get().getId()).isEqualTo(latest.getId());
|
||||||
}
|
}
|
||||||
@@ -799,6 +801,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
return Execution.builder()
|
return Execution.builder()
|
||||||
.id(IdUtils.create())
|
.id(IdUtils.create())
|
||||||
.namespace("io.kestra.unittest")
|
.namespace("io.kestra.unittest")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.flowId("full")
|
.flowId("full")
|
||||||
.flowRevision(1)
|
.flowRevision(1)
|
||||||
.state(new State(State.Type.CREATED, List.of(new State.History(State.Type.CREATED, instant))))
|
.state(new State(State.Type.CREATED, List.of(new State.History(State.Type.CREATED, instant))))
|
||||||
@@ -811,7 +814,7 @@ public abstract class AbstractExecutionRepositoryTest {
|
|||||||
protected void findAllAsync() {
|
protected void findAllAsync() {
|
||||||
inject();
|
inject();
|
||||||
|
|
||||||
List<Execution> executions = executionRepository.findAllAsync(null).collectList().block();
|
List<Execution> executions = executionRepository.findAllAsync(MAIN_TENANT).collectList().block();
|
||||||
assertThat(executions).hasSize(29); // used by the backup so it contains TEST executions
|
assertThat(executions).hasSize(29); // used by the backup so it contains TEST executions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import jakarta.validation.ConstraintViolationException;
|
import jakarta.validation.ConstraintViolationException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
@@ -59,7 +60,7 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
protected void init() throws IOException, URISyntaxException {
|
protected void init() throws IOException, URISyntaxException {
|
||||||
TestsUtils.loads(null, repositoryLoader);
|
TestsUtils.loads(MAIN_TENANT, repositoryLoader);
|
||||||
FlowListener.reset();
|
FlowListener.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,15 +78,16 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
@Test
|
@Test
|
||||||
void findById() {
|
void findById() {
|
||||||
FlowWithSource flow = builder()
|
FlowWithSource flow = builder()
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.revision(3)
|
.revision(3)
|
||||||
.build();
|
.build();
|
||||||
flow = flowRepository.create(GenericFlow.of(flow));
|
flow = flowRepository.create(GenericFlow.of(flow));
|
||||||
try {
|
try {
|
||||||
Optional<Flow> full = flowRepository.findById(null, flow.getNamespace(), flow.getId());
|
Optional<Flow> full = flowRepository.findById(MAIN_TENANT, flow.getNamespace(), flow.getId());
|
||||||
assertThat(full.isPresent()).isTrue();
|
assertThat(full.isPresent()).isTrue();
|
||||||
assertThat(full.get().getRevision()).isEqualTo(1);
|
assertThat(full.get().getRevision()).isEqualTo(1);
|
||||||
|
|
||||||
full = flowRepository.findById(null, flow.getNamespace(), flow.getId(), Optional.empty());
|
full = flowRepository.findById(MAIN_TENANT, flow.getNamespace(), flow.getId(), Optional.empty());
|
||||||
assertThat(full.isPresent()).isTrue();
|
assertThat(full.isPresent()).isTrue();
|
||||||
} finally {
|
} finally {
|
||||||
deleteFlow(flow);
|
deleteFlow(flow);
|
||||||
@@ -95,15 +97,16 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
@Test
|
@Test
|
||||||
void findByIdWithoutAcl() {
|
void findByIdWithoutAcl() {
|
||||||
FlowWithSource flow = builder()
|
FlowWithSource flow = builder()
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.revision(3)
|
.revision(3)
|
||||||
.build();
|
.build();
|
||||||
flow = flowRepository.create(GenericFlow.of(flow));
|
flow = flowRepository.create(GenericFlow.of(flow));
|
||||||
try {
|
try {
|
||||||
Optional<Flow> full = flowRepository.findByIdWithoutAcl(null, flow.getNamespace(), flow.getId(), Optional.empty());
|
Optional<Flow> full = flowRepository.findByIdWithoutAcl(MAIN_TENANT, flow.getNamespace(), flow.getId(), Optional.empty());
|
||||||
assertThat(full.isPresent()).isTrue();
|
assertThat(full.isPresent()).isTrue();
|
||||||
assertThat(full.get().getRevision()).isEqualTo(1);
|
assertThat(full.get().getRevision()).isEqualTo(1);
|
||||||
|
|
||||||
full = flowRepository.findByIdWithoutAcl(null, flow.getNamespace(), flow.getId(), Optional.empty());
|
full = flowRepository.findByIdWithoutAcl(MAIN_TENANT, flow.getNamespace(), flow.getId(), Optional.empty());
|
||||||
assertThat(full.isPresent()).isTrue();
|
assertThat(full.isPresent()).isTrue();
|
||||||
} finally {
|
} finally {
|
||||||
deleteFlow(flow);
|
deleteFlow(flow);
|
||||||
@@ -113,13 +116,14 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
@Test
|
@Test
|
||||||
void findByIdWithSource() {
|
void findByIdWithSource() {
|
||||||
FlowWithSource flow = builder()
|
FlowWithSource flow = builder()
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.revision(3)
|
.revision(3)
|
||||||
.build();
|
.build();
|
||||||
String source = "# comment\n" + flow.sourceOrGenerateIfNull();
|
String source = "# comment\n" + flow.sourceOrGenerateIfNull();
|
||||||
flow = flowRepository.create(GenericFlow.fromYaml(null, source));
|
flow = flowRepository.create(GenericFlow.fromYaml(MAIN_TENANT, source));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Optional<FlowWithSource> full = flowRepository.findByIdWithSource(null, flow.getNamespace(), flow.getId());
|
Optional<FlowWithSource> full = flowRepository.findByIdWithSource(MAIN_TENANT, flow.getNamespace(), flow.getId());
|
||||||
assertThat(full.isPresent()).isTrue();
|
assertThat(full.isPresent()).isTrue();
|
||||||
|
|
||||||
full.ifPresent(current -> {
|
full.ifPresent(current -> {
|
||||||
@@ -159,14 +163,14 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void findAll() {
|
void findAll() {
|
||||||
List<Flow> save = flowRepository.findAll(null);
|
List<Flow> save = flowRepository.findAll(MAIN_TENANT);
|
||||||
|
|
||||||
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT);
|
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void findAllWithSource() {
|
void findAllWithSource() {
|
||||||
List<FlowWithSource> save = flowRepository.findAllWithSource(null);
|
List<FlowWithSource> save = flowRepository.findAllWithSource(MAIN_TENANT);
|
||||||
|
|
||||||
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT);
|
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT);
|
||||||
}
|
}
|
||||||
@@ -187,25 +191,25 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void findByNamespace() {
|
void findByNamespace() {
|
||||||
List<Flow> save = flowRepository.findByNamespace(null, "io.kestra.tests");
|
List<Flow> save = flowRepository.findByNamespace(MAIN_TENANT, "io.kestra.tests");
|
||||||
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT - 22);
|
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT - 22);
|
||||||
|
|
||||||
save = flowRepository.findByNamespace(null, "io.kestra.tests2");
|
save = flowRepository.findByNamespace(MAIN_TENANT, "io.kestra.tests2");
|
||||||
assertThat((long) save.size()).isEqualTo(1L);
|
assertThat((long) save.size()).isEqualTo(1L);
|
||||||
|
|
||||||
save = flowRepository.findByNamespace(null, "io.kestra.tests.minimal.bis");
|
save = flowRepository.findByNamespace(MAIN_TENANT, "io.kestra.tests.minimal.bis");
|
||||||
assertThat((long) save.size()).isEqualTo(1L);
|
assertThat((long) save.size()).isEqualTo(1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void findByNamespacePrefix() {
|
void findByNamespacePrefix() {
|
||||||
List<Flow> save = flowRepository.findByNamespacePrefix(null, "io.kestra.tests");
|
List<Flow> save = flowRepository.findByNamespacePrefix(MAIN_TENANT, "io.kestra.tests");
|
||||||
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT - 1);
|
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT - 1);
|
||||||
|
|
||||||
save = flowRepository.findByNamespace(null, "io.kestra.tests2");
|
save = flowRepository.findByNamespace(MAIN_TENANT, "io.kestra.tests2");
|
||||||
assertThat((long) save.size()).isEqualTo(1L);
|
assertThat((long) save.size()).isEqualTo(1L);
|
||||||
|
|
||||||
save = flowRepository.findByNamespace(null, "io.kestra.tests.minimal.bis");
|
save = flowRepository.findByNamespace(MAIN_TENANT, "io.kestra.tests.minimal.bis");
|
||||||
assertThat((long) save.size()).isEqualTo(1L);
|
assertThat((long) save.size()).isEqualTo(1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,10 +219,10 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
.revision(3)
|
.revision(3)
|
||||||
.build();
|
.build();
|
||||||
String flowSource = "# comment\n" + flow.sourceOrGenerateIfNull();
|
String flowSource = "# comment\n" + flow.sourceOrGenerateIfNull();
|
||||||
flow = flowRepository.create(GenericFlow.fromYaml(null, flowSource));
|
flow = flowRepository.create(GenericFlow.fromYaml(MAIN_TENANT, flowSource));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<FlowWithSource> save = flowRepository.findByNamespaceWithSource(null, flow.getNamespace());
|
List<FlowWithSource> save = flowRepository.findByNamespaceWithSource(MAIN_TENANT, flow.getNamespace());
|
||||||
assertThat((long) save.size()).isEqualTo(1L);
|
assertThat((long) save.size()).isEqualTo(1L);
|
||||||
|
|
||||||
assertThat(save.getFirst().getSource()).isEqualTo(FlowService.cleanupSource(flowSource));
|
assertThat(save.getFirst().getSource()).isEqualTo(FlowService.cleanupSource(flowSource));
|
||||||
@@ -229,51 +233,51 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
protected void find() {
|
protected void find() {
|
||||||
List<Flow> save = flowRepository.find(Pageable.from(1, (int) Helpers.FLOWS_COUNT - 1, Sort.UNSORTED), null, null, null, null, null);
|
List<Flow> save = flowRepository.find(Pageable.from(1, (int) Helpers.FLOWS_COUNT - 1, Sort.UNSORTED), null, MAIN_TENANT, null, null, null);
|
||||||
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT - 1);
|
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT - 1);
|
||||||
|
|
||||||
save = flowRepository.find(Pageable.from(1, (int) Helpers.FLOWS_COUNT + 1, Sort.UNSORTED), null, null, null, null, null);
|
save = flowRepository.find(Pageable.from(1, (int) Helpers.FLOWS_COUNT + 1, Sort.UNSORTED), null, MAIN_TENANT, null, null, null);
|
||||||
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT);
|
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT);
|
||||||
|
|
||||||
save = flowRepository.find(Pageable.from(1), null, null, null, "io.kestra.tests.minimal.bis", Collections.emptyMap());
|
save = flowRepository.find(Pageable.from(1), null, MAIN_TENANT, null, "io.kestra.tests.minimal.bis", Collections.emptyMap());
|
||||||
assertThat((long) save.size()).isEqualTo(1L);
|
assertThat((long) save.size()).isEqualTo(1L);
|
||||||
|
|
||||||
save = flowRepository.find(Pageable.from(1, 100, Sort.UNSORTED), null, null, null, null, Map.of("country", "FR"));
|
save = flowRepository.find(Pageable.from(1, 100, Sort.UNSORTED), null, MAIN_TENANT, null, null, Map.of("country", "FR"));
|
||||||
assertThat(save.size()).isEqualTo(1);
|
assertThat(save.size()).isEqualTo(1);
|
||||||
|
|
||||||
save = flowRepository.find(Pageable.from(1), null, null, null, "io.kestra.tests", Map.of("key2", "value2"));
|
save = flowRepository.find(Pageable.from(1), null, MAIN_TENANT, null, "io.kestra.tests", Map.of("key2", "value2"));
|
||||||
assertThat((long) save.size()).isEqualTo(1L);
|
assertThat((long) save.size()).isEqualTo(1L);
|
||||||
|
|
||||||
save = flowRepository.find(Pageable.from(1), null, null, null, "io.kestra.tests", Map.of("key1", "value2"));
|
save = flowRepository.find(Pageable.from(1), null, MAIN_TENANT, null, "io.kestra.tests", Map.of("key1", "value2"));
|
||||||
assertThat((long) save.size()).isEqualTo(0L);
|
assertThat((long) save.size()).isEqualTo(0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
protected void findSpecialChars() {
|
protected void findSpecialChars() {
|
||||||
ArrayListTotal<SearchResult<Flow>> save = flowRepository.findSourceCode(Pageable.unpaged(), "https://api.chucknorris.io", null, null);
|
ArrayListTotal<SearchResult<Flow>> save = flowRepository.findSourceCode(Pageable.unpaged(), "https://api.chucknorris.io", MAIN_TENANT, null);
|
||||||
assertThat((long) save.size()).isEqualTo(2L);
|
assertThat((long) save.size()).isEqualTo(2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void findWithSource() {
|
void findWithSource() {
|
||||||
List<FlowWithSource> save = flowRepository.findWithSource(null, null, null, "io.kestra.tests", Collections.emptyMap());
|
List<FlowWithSource> save = flowRepository.findWithSource(null, MAIN_TENANT, null, "io.kestra.tests", Collections.emptyMap());
|
||||||
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT - 1);
|
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT - 1);
|
||||||
|
|
||||||
save = flowRepository.findWithSource(null, null, null, "io.kestra.tests2", Collections.emptyMap());
|
save = flowRepository.findWithSource(null, MAIN_TENANT, null, "io.kestra.tests2", Collections.emptyMap());
|
||||||
assertThat((long) save.size()).isEqualTo(1L);
|
assertThat((long) save.size()).isEqualTo(1L);
|
||||||
|
|
||||||
save = flowRepository.findWithSource(null, null, null, "io.kestra.tests.minimal.bis", Collections.emptyMap());
|
save = flowRepository.findWithSource(null, MAIN_TENANT, null, "io.kestra.tests.minimal.bis", Collections.emptyMap());
|
||||||
assertThat((long) save.size()).isEqualTo(1L);
|
assertThat((long) save.size()).isEqualTo(1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void delete() {
|
void delete() {
|
||||||
Flow flow = builder().build();
|
Flow flow = builder().tenantId(MAIN_TENANT).build();
|
||||||
|
|
||||||
FlowWithSource save = flowRepository.create(GenericFlow.of(flow));
|
FlowWithSource save = flowRepository.create(GenericFlow.of(flow));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assertThat(flowRepository.findById(null, save.getNamespace(), save.getId()).isPresent()).isTrue();
|
assertThat(flowRepository.findById(MAIN_TENANT, save.getNamespace(), save.getId()).isPresent()).isTrue();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
deleteFlow(save);
|
deleteFlow(save);
|
||||||
throw e;
|
throw e;
|
||||||
@@ -281,10 +285,10 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
|
|
||||||
Flow delete = flowRepository.delete(save);
|
Flow delete = flowRepository.delete(save);
|
||||||
|
|
||||||
assertThat(flowRepository.findById(null, flow.getNamespace(), flow.getId()).isPresent()).isFalse();
|
assertThat(flowRepository.findById(MAIN_TENANT, flow.getNamespace(), flow.getId()).isPresent()).isFalse();
|
||||||
assertThat(flowRepository.findById(null, flow.getNamespace(), flow.getId(), Optional.of(save.getRevision())).isPresent()).isTrue();
|
assertThat(flowRepository.findById(MAIN_TENANT, flow.getNamespace(), flow.getId(), Optional.of(save.getRevision())).isPresent()).isTrue();
|
||||||
|
|
||||||
List<FlowWithSource> revisions = flowRepository.findRevisions(null, flow.getNamespace(), flow.getId());
|
List<FlowWithSource> revisions = flowRepository.findRevisions(MAIN_TENANT, flow.getNamespace(), flow.getId());
|
||||||
assertThat(revisions.getLast().getRevision()).isEqualTo(delete.getRevision());
|
assertThat(revisions.getLast().getRevision()).isEqualTo(delete.getRevision());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,6 +299,7 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
Flow flow = Flow.builder()
|
Flow flow = Flow.builder()
|
||||||
.id(flowId)
|
.id(flowId)
|
||||||
.namespace(TEST_NAMESPACE)
|
.namespace(TEST_NAMESPACE)
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.inputs(List.of(StringInput.builder().type(Type.STRING).id("a").build()))
|
.inputs(List.of(StringInput.builder().type(Type.STRING).id("a").build()))
|
||||||
.tasks(Collections.singletonList(Return.builder().id(TEST_FLOW_ID).type(Return.class.getName()).format(Property.of(TEST_FLOW_ID)).build()))
|
.tasks(Collections.singletonList(Return.builder().id(TEST_FLOW_ID).type(Return.class.getName()).format(Property.of(TEST_FLOW_ID)).build()))
|
||||||
.build();
|
.build();
|
||||||
@@ -302,11 +307,12 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
Flow save = flowRepository.create(GenericFlow.of(flow));
|
Flow save = flowRepository.create(GenericFlow.of(flow));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assertThat(flowRepository.findById(null, flow.getNamespace(), flow.getId()).isPresent()).isTrue();
|
assertThat(flowRepository.findById(MAIN_TENANT, flow.getNamespace(), flow.getId()).isPresent()).isTrue();
|
||||||
|
|
||||||
Flow update = Flow.builder()
|
Flow update = Flow.builder()
|
||||||
.id(IdUtils.create())
|
.id(IdUtils.create())
|
||||||
.namespace("io.kestra.unittest2")
|
.namespace("io.kestra.unittest2")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.inputs(List.of(StringInput.builder().type(Type.STRING).id("b").build()))
|
.inputs(List.of(StringInput.builder().type(Type.STRING).id("b").build()))
|
||||||
.tasks(Collections.singletonList(Return.builder().id(TEST_FLOW_ID).type(Return.class.getName()).format(Property.of(TEST_FLOW_ID)).build()))
|
.tasks(Collections.singletonList(Return.builder().id(TEST_FLOW_ID).type(Return.class.getName()).format(Property.of(TEST_FLOW_ID)).build()))
|
||||||
.build();
|
.build();
|
||||||
@@ -330,6 +336,7 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
Flow flow = Flow.builder()
|
Flow flow = Flow.builder()
|
||||||
.id(flowId)
|
.id(flowId)
|
||||||
.namespace(TEST_NAMESPACE)
|
.namespace(TEST_NAMESPACE)
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.triggers(Collections.singletonList(AbstractSchedulerTest.UnitTest.builder()
|
.triggers(Collections.singletonList(AbstractSchedulerTest.UnitTest.builder()
|
||||||
.id("sleep")
|
.id("sleep")
|
||||||
.type(AbstractSchedulerTest.UnitTest.class.getName())
|
.type(AbstractSchedulerTest.UnitTest.class.getName())
|
||||||
@@ -339,11 +346,12 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
|
|
||||||
flow = flowRepository.create(GenericFlow.of(flow));
|
flow = flowRepository.create(GenericFlow.of(flow));
|
||||||
try {
|
try {
|
||||||
assertThat(flowRepository.findById(null, flow.getNamespace(), flow.getId()).isPresent()).isTrue();
|
assertThat(flowRepository.findById(MAIN_TENANT, flow.getNamespace(), flow.getId()).isPresent()).isTrue();
|
||||||
|
|
||||||
Flow update = Flow.builder()
|
Flow update = Flow.builder()
|
||||||
.id(flowId)
|
.id(flowId)
|
||||||
.namespace(TEST_NAMESPACE)
|
.namespace(TEST_NAMESPACE)
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.tasks(Collections.singletonList(Return.builder().id(TEST_FLOW_ID).type(Return.class.getName()).format(Property.of(TEST_FLOW_ID)).build()))
|
.tasks(Collections.singletonList(Return.builder().id(TEST_FLOW_ID).type(Return.class.getName()).format(Property.of(TEST_FLOW_ID)).build()))
|
||||||
.build();
|
.build();
|
||||||
;
|
;
|
||||||
@@ -362,12 +370,13 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void removeTriggerDelete() throws TimeoutException, QueueException {
|
void removeTriggerDelete() throws TimeoutException {
|
||||||
String flowId = IdUtils.create();
|
String flowId = IdUtils.create();
|
||||||
|
|
||||||
Flow flow = Flow.builder()
|
Flow flow = Flow.builder()
|
||||||
.id(flowId)
|
.id(flowId)
|
||||||
.namespace(TEST_NAMESPACE)
|
.namespace(TEST_NAMESPACE)
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.triggers(Collections.singletonList(AbstractSchedulerTest.UnitTest.builder()
|
.triggers(Collections.singletonList(AbstractSchedulerTest.UnitTest.builder()
|
||||||
.id("sleep")
|
.id("sleep")
|
||||||
.type(AbstractSchedulerTest.UnitTest.class.getName())
|
.type(AbstractSchedulerTest.UnitTest.class.getName())
|
||||||
@@ -377,7 +386,7 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
|
|
||||||
Flow save = flowRepository.create(GenericFlow.of(flow));
|
Flow save = flowRepository.create(GenericFlow.of(flow));
|
||||||
try {
|
try {
|
||||||
assertThat(flowRepository.findById(null, flow.getNamespace(), flow.getId()).isPresent()).isTrue();
|
assertThat(flowRepository.findById(MAIN_TENANT, flow.getNamespace(), flow.getId()).isPresent()).isTrue();
|
||||||
} finally {
|
} finally {
|
||||||
deleteFlow(save);
|
deleteFlow(save);
|
||||||
}
|
}
|
||||||
@@ -389,45 +398,10 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void findDistinctNamespace() {
|
void findDistinctNamespace() {
|
||||||
List<String> distinctNamespace = flowRepository.findDistinctNamespace(null);
|
List<String> distinctNamespace = flowRepository.findDistinctNamespace(MAIN_TENANT);
|
||||||
assertThat((long) distinctNamespace.size()).isEqualTo(8L);
|
assertThat((long) distinctNamespace.size()).isEqualTo(8L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Test
|
|
||||||
void templateDisabled() {
|
|
||||||
Template template = Template.builder()
|
|
||||||
.id(IdUtils.create())
|
|
||||||
.type(Template.class.getName())
|
|
||||||
.namespace(TEST_FLOW_ID)
|
|
||||||
.templateId("testTemplate")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Template templateSpy = spy(template);
|
|
||||||
|
|
||||||
doReturn(Collections.emptyList())
|
|
||||||
.when(templateSpy)
|
|
||||||
.allChildTasks();
|
|
||||||
|
|
||||||
Flow flow = Flow.builder()
|
|
||||||
.id(IdUtils.create())
|
|
||||||
.namespace(TEST_NAMESPACE)
|
|
||||||
.tasks(Collections.singletonList(templateSpy))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
flow = flowRepository.create(GenericFlow.of(flow));
|
|
||||||
|
|
||||||
try {
|
|
||||||
Optional<Flow> found = flowRepository.findById(null, flow.getNamespace(), flow.getId());
|
|
||||||
|
|
||||||
assertThat(found.isPresent()).isTrue();
|
|
||||||
assertThat(found.get() instanceof FlowWithException).isTrue();
|
|
||||||
assertThat(((FlowWithException) found.get()).getException()).contains("Templates are disabled");
|
|
||||||
} finally {
|
|
||||||
deleteFlow(flow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
protected void shouldReturnNullRevisionForNonExistingFlow() {
|
protected void shouldReturnNullRevisionForNonExistingFlow() {
|
||||||
assertThat(flowRepository.lastRevision(TEST_TENANT_ID, TEST_NAMESPACE, IdUtils.create())).isNull();
|
assertThat(flowRepository.lastRevision(TEST_TENANT_ID, TEST_NAMESPACE, IdUtils.create())).isNull();
|
||||||
@@ -583,7 +557,7 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldReturnForFindGivenQueryWildcard() {
|
void shouldReturnForFindGivenQueryWildcard() {
|
||||||
ArrayListTotal<Flow> flows = flowRepository.find(Pageable.from(1, 10), "*", null, null, null, Map.of());
|
ArrayListTotal<Flow> flows = flowRepository.find(Pageable.from(1, 10), "*", MAIN_TENANT, null, null, Map.of());
|
||||||
assertThat(flows.size()).isEqualTo(10);
|
assertThat(flows.size()).isEqualTo(10);
|
||||||
assertThat(flows.getTotal()).isEqualTo(Helpers.FLOWS_COUNT);
|
assertThat(flows.getTotal()).isEqualTo(Helpers.FLOWS_COUNT);
|
||||||
}
|
}
|
||||||
@@ -593,7 +567,7 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
List<QueryFilter> filters = List.of(
|
List<QueryFilter> filters = List.of(
|
||||||
QueryFilter.builder().field(QueryFilter.Field.QUERY).operation(QueryFilter.Op.EQUALS).value("*").build()
|
QueryFilter.builder().field(QueryFilter.Field.QUERY).operation(QueryFilter.Op.EQUALS).value("*").build()
|
||||||
);
|
);
|
||||||
ArrayListTotal<Flow> flows = flowRepository.find(Pageable.from(1, 10), null, filters);
|
ArrayListTotal<Flow> flows = flowRepository.find(Pageable.from(1, 10), MAIN_TENANT, filters);
|
||||||
assertThat(flows.size()).isEqualTo(10);
|
assertThat(flows.size()).isEqualTo(10);
|
||||||
assertThat(flows.getTotal()).isEqualTo(Helpers.FLOWS_COUNT);
|
assertThat(flows.getTotal()).isEqualTo(Helpers.FLOWS_COUNT);
|
||||||
}
|
}
|
||||||
@@ -601,12 +575,14 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
@Test
|
@Test
|
||||||
void findByExecution() {
|
void findByExecution() {
|
||||||
Flow flow = builder()
|
Flow flow = builder()
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.revision(1)
|
.revision(1)
|
||||||
.build();
|
.build();
|
||||||
flowRepository.create(GenericFlow.of(flow));
|
flowRepository.create(GenericFlow.of(flow));
|
||||||
Execution execution = Execution.builder()
|
Execution execution = Execution.builder()
|
||||||
.id(IdUtils.create())
|
.id(IdUtils.create())
|
||||||
.namespace(flow.getNamespace())
|
.namespace(flow.getNamespace())
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.flowId(flow.getId())
|
.flowId(flow.getId())
|
||||||
.flowRevision(flow.getRevision())
|
.flowRevision(flow.getRevision())
|
||||||
.state(new State())
|
.state(new State())
|
||||||
@@ -667,7 +643,7 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
Flow flow = createTestFlowForNamespace(TEST_NAMESPACE);
|
Flow flow = createTestFlowForNamespace(TEST_NAMESPACE);
|
||||||
toDelete = flowRepository.create(GenericFlow.of(flow));
|
toDelete = flowRepository.create(GenericFlow.of(flow));
|
||||||
// When
|
// When
|
||||||
int count = flowRepository.count(null);
|
int count = flowRepository.count(MAIN_TENANT);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
Assertions.assertTrue(count > 0);
|
Assertions.assertTrue(count > 0);
|
||||||
@@ -686,10 +662,10 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
toDelete.add(flowRepository.create(GenericFlow.of(createTestFlowForNamespace("io.kestra.unittest.shouldcountbynamespacefornulltenant"))));
|
toDelete.add(flowRepository.create(GenericFlow.of(createTestFlowForNamespace("io.kestra.unittest.shouldcountbynamespacefornulltenant"))));
|
||||||
toDelete.add(flowRepository.create(GenericFlow.of(createTestFlowForNamespace("com.kestra.unittest"))));
|
toDelete.add(flowRepository.create(GenericFlow.of(createTestFlowForNamespace("com.kestra.unittest"))));
|
||||||
|
|
||||||
int count = flowRepository.countForNamespace(null, "io.kestra.unittest.shouldcountbynamespacefornulltenant");
|
int count = flowRepository.countForNamespace(MAIN_TENANT, "io.kestra.unittest.shouldcountbynamespacefornulltenant");
|
||||||
assertThat(count).isEqualTo(1);
|
assertThat(count).isEqualTo(1);
|
||||||
|
|
||||||
count = flowRepository.countForNamespace(null, TEST_NAMESPACE);
|
count = flowRepository.countForNamespace(MAIN_TENANT, TEST_NAMESPACE);
|
||||||
assertThat(count).isEqualTo(2);
|
assertThat(count).isEqualTo(2);
|
||||||
} finally {
|
} finally {
|
||||||
for (FlowWithSource flow : toDelete) {
|
for (FlowWithSource flow : toDelete) {
|
||||||
@@ -702,6 +678,7 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
return Flow.builder()
|
return Flow.builder()
|
||||||
.id(IdUtils.create())
|
.id(IdUtils.create())
|
||||||
.namespace(namespace)
|
.namespace(namespace)
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.tasks(List.of(Return.builder()
|
.tasks(List.of(Return.builder()
|
||||||
.id(IdUtils.create())
|
.id(IdUtils.create())
|
||||||
.type(Return.class.getName())
|
.type(Return.class.getName())
|
||||||
@@ -710,7 +687,7 @@ public abstract class AbstractFlowRepositoryTest {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteFlow(Flow flow) {
|
protected void deleteFlow(Flow flow) {
|
||||||
if (flow == null) {
|
if (flow == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package io.kestra.core.repositories;
|
package io.kestra.core.repositories;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import io.kestra.core.models.executions.*;
|
import io.kestra.core.models.executions.*;
|
||||||
import io.kestra.core.models.flows.State;
|
import io.kestra.core.models.flows.State;
|
||||||
@@ -12,6 +14,7 @@ class ExecutionFixture {
|
|||||||
public static final Execution EXECUTION_1 = Execution.builder()
|
public static final Execution EXECUTION_1 = Execution.builder()
|
||||||
.id(IdUtils.create())
|
.id(IdUtils.create())
|
||||||
.namespace("io.kestra.unittest")
|
.namespace("io.kestra.unittest")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.flowId("full")
|
.flowId("full")
|
||||||
.flowRevision(1)
|
.flowRevision(1)
|
||||||
.state(new State())
|
.state(new State())
|
||||||
@@ -36,6 +39,7 @@ class ExecutionFixture {
|
|||||||
public static final Execution EXECUTION_2 = Execution.builder()
|
public static final Execution EXECUTION_2 = Execution.builder()
|
||||||
.id(IdUtils.create())
|
.id(IdUtils.create())
|
||||||
.namespace("io.kestra.unittest")
|
.namespace("io.kestra.unittest")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.flowId("full")
|
.flowId("full")
|
||||||
.flowRevision(1)
|
.flowRevision(1)
|
||||||
.state(new State())
|
.state(new State())
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.runners;
|
package io.kestra.core.runners;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import io.kestra.core.junit.annotations.ExecuteFlow;
|
import io.kestra.core.junit.annotations.ExecuteFlow;
|
||||||
@@ -42,7 +43,7 @@ public abstract class AbstractRunnerTest {
|
|||||||
private RestartCaseTest restartCaseTest;
|
private RestartCaseTest restartCaseTest;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private FlowTriggerCaseTest flowTriggerCaseTest;
|
protected FlowTriggerCaseTest flowTriggerCaseTest;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected MultipleConditionTriggerCaseTest multipleConditionTriggerCaseTest;
|
protected MultipleConditionTriggerCaseTest multipleConditionTriggerCaseTest;
|
||||||
@@ -494,7 +495,7 @@ public abstract class AbstractRunnerTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/if.yaml"})
|
@LoadFlows({"flows/valids/if.yaml"})
|
||||||
void multipleIf() throws TimeoutException, QueueException {
|
void multipleIf() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "if", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "if", null,
|
||||||
(f, e) -> Map.of("if1", true, "if2", false, "if3", true));
|
(f, e) -> Map.of("if1", true, "if2", false, "if3", true));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(12);
|
assertThat(execution.getTaskRunList()).hasSize(12);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import java.util.concurrent.CountDownLatch;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -74,7 +75,7 @@ public class ChangeStateTestCase {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// run the parent flow
|
// run the parent flow
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "subflow-parent-of-failed");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "subflow-parent-of-failed");
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
assertThat(execution.getTaskRunList().getFirst().getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getTaskRunList().getFirst().getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.runners;
|
package io.kestra.core.runners;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.encryption.EncryptionService;
|
import io.kestra.core.encryption.EncryptionService;
|
||||||
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
||||||
import io.kestra.core.models.tasks.common.EncryptedString;
|
import io.kestra.core.models.tasks.common.EncryptedString;
|
||||||
@@ -25,7 +26,7 @@ class DefaultRunContextTest {
|
|||||||
private String secretKey;
|
private String secretKey;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldGetKestraVersion() {
|
void shouldGetKestraVersion() {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
@@ -25,7 +26,7 @@ public class EmptyVariablesTest {
|
|||||||
@LoadFlows({"flows/valids/empty-variables.yml"})
|
@LoadFlows({"flows/valids/empty-variables.yml"})
|
||||||
void emptyVariables() throws TimeoutException, QueueException {
|
void emptyVariables() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"empty-variables",
|
"empty-variables",
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
@@ -56,7 +57,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/restart_last_failed.yaml"})
|
@LoadFlows({"flows/valids/restart_last_failed.yaml"})
|
||||||
void restartSimple() throws Exception {
|
void restartSimple() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "restart_last_failed");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "restart_last_failed");
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
|
|
||||||
@@ -75,11 +76,11 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/restart_last_failed.yaml"})
|
@LoadFlows({"flows/valids/restart_last_failed.yaml"})
|
||||||
void restartSimpleRevision() throws Exception {
|
void restartSimpleRevision() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "restart_last_failed");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "restart_last_failed");
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
|
|
||||||
FlowWithSource flow = flowRepository.findByIdWithSource(null, "io.kestra.tests", "restart_last_failed").orElseThrow();
|
FlowWithSource flow = flowRepository.findByIdWithSource(MAIN_TENANT, "io.kestra.tests", "restart_last_failed").orElseThrow();
|
||||||
flowRepository.update(
|
flowRepository.update(
|
||||||
GenericFlow.of(flow),
|
GenericFlow.of(flow),
|
||||||
flow.updateTask(
|
flow.updateTask(
|
||||||
@@ -108,7 +109,7 @@ class ExecutionServiceTest {
|
|||||||
@RetryingTest(5)
|
@RetryingTest(5)
|
||||||
@LoadFlows({"flows/valids/restart-each.yaml"})
|
@LoadFlows({"flows/valids/restart-each.yaml"})
|
||||||
void restartFlowable() throws Exception {
|
void restartFlowable() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "restart-each", null, (f, e) -> ImmutableMap.of("failed", "FIRST"));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "restart-each", null, (f, e) -> ImmutableMap.of("failed", "FIRST"));
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
|
|
||||||
Execution restart = executionService.restart(execution, null);
|
Execution restart = executionService.restart(execution, null);
|
||||||
@@ -124,7 +125,7 @@ class ExecutionServiceTest {
|
|||||||
@RetryingTest(5)
|
@RetryingTest(5)
|
||||||
@LoadFlows({"flows/valids/restart-each.yaml"})
|
@LoadFlows({"flows/valids/restart-each.yaml"})
|
||||||
void restartFlowable2() throws Exception {
|
void restartFlowable2() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "restart-each", null, (f, e) -> ImmutableMap.of("failed", "SECOND"));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "restart-each", null, (f, e) -> ImmutableMap.of("failed", "SECOND"));
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
|
|
||||||
Execution restart = executionService.restart(execution, null);
|
Execution restart = executionService.restart(execution, null);
|
||||||
@@ -140,7 +141,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/working-directory.yaml"})
|
@LoadFlows({"flows/valids/working-directory.yaml"})
|
||||||
void restartDynamic() throws Exception {
|
void restartDynamic() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory", null, (f, e) -> ImmutableMap.of("failed", "true"));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory", null, (f, e) -> ImmutableMap.of("failed", "true"));
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
|
|
||||||
@@ -156,7 +157,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/logs.yaml"})
|
@LoadFlows({"flows/valids/logs.yaml"})
|
||||||
void replayFromBeginning() throws Exception {
|
void replayFromBeginning() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "logs");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "logs");
|
||||||
assertThat(execution.getTaskRunList()).hasSize(5);
|
assertThat(execution.getTaskRunList()).hasSize(5);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
@@ -177,7 +178,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/logs.yaml"})
|
@LoadFlows({"flows/valids/logs.yaml"})
|
||||||
void replaySimple() throws Exception {
|
void replaySimple() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "logs");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "logs");
|
||||||
assertThat(execution.getTaskRunList()).hasSize(5);
|
assertThat(execution.getTaskRunList()).hasSize(5);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
@@ -196,7 +197,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/restart-each.yaml"})
|
@LoadFlows({"flows/valids/restart-each.yaml"})
|
||||||
void replayFlowable() throws Exception {
|
void replayFlowable() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "restart-each", null, (f, e) -> ImmutableMap.of("failed", "NO"));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "restart-each", null, (f, e) -> ImmutableMap.of("failed", "NO"));
|
||||||
assertThat(execution.getTaskRunList()).hasSize(20);
|
assertThat(execution.getTaskRunList()).hasSize(20);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
@@ -214,7 +215,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/parallel-nested.yaml"})
|
@LoadFlows({"flows/valids/parallel-nested.yaml"})
|
||||||
void replayParallel() throws Exception {
|
void replayParallel() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "parallel-nested");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "parallel-nested");
|
||||||
assertThat(execution.getTaskRunList()).hasSize(11);
|
assertThat(execution.getTaskRunList()).hasSize(11);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
@@ -272,7 +273,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/dynamic-task.yaml"})
|
@LoadFlows({"flows/valids/dynamic-task.yaml"})
|
||||||
void replayWithADynamicTask() throws Exception {
|
void replayWithADynamicTask() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "dynamic-task");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "dynamic-task");
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
@@ -292,7 +293,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/each-parallel-nested.yaml"})
|
@LoadFlows({"flows/valids/each-parallel-nested.yaml"})
|
||||||
void replayEachPara() throws Exception {
|
void replayEachPara() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "each-parallel-nested");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "each-parallel-nested");
|
||||||
assertThat(execution.getTaskRunList()).hasSize(11);
|
assertThat(execution.getTaskRunList()).hasSize(11);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
@@ -312,7 +313,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/each-parallel-nested.yaml"})
|
@LoadFlows({"flows/valids/each-parallel-nested.yaml"})
|
||||||
void markAsEachPara() throws Exception {
|
void markAsEachPara() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "each-parallel-nested");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "each-parallel-nested");
|
||||||
Flow flow = flowRepository.findByExecution(execution);
|
Flow flow = flowRepository.findByExecution(execution);
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(11);
|
assertThat(execution.getTaskRunList()).hasSize(11);
|
||||||
@@ -344,7 +345,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/pause.yaml"})
|
@LoadFlows({"flows/valids/pause.yaml"})
|
||||||
void resumePausedToRunning() throws Exception {
|
void resumePausedToRunning() throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause");
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause");
|
||||||
Flow flow = flowRepository.findByExecution(execution);
|
Flow flow = flowRepository.findByExecution(execution);
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
@@ -364,7 +365,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/pause.yaml"})
|
@LoadFlows({"flows/valids/pause.yaml"})
|
||||||
void resumePausedToKilling() throws Exception {
|
void resumePausedToKilling() throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause");
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause");
|
||||||
Flow flow = flowRepository.findByExecution(execution);
|
Flow flow = flowRepository.findByExecution(execution);
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
@@ -403,7 +404,7 @@ class ExecutionServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/pause_no_tasks.yaml"})
|
@LoadFlows({"flows/valids/pause_no_tasks.yaml"})
|
||||||
void shouldKillPausedExecutions() throws Exception {
|
void shouldKillPausedExecutions() throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause_no_tasks");
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause_no_tasks");
|
||||||
Flow flow = flowRepository.findByExecution(execution);
|
Flow flow = flowRepository.findByExecution(execution);
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.runners;
|
package io.kestra.core.runners;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
@@ -14,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@KestraTest
|
@KestraTest
|
||||||
class FilesServiceTest {
|
class FilesServiceTest {
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void overrideExistingInputFile() throws Exception {
|
void overrideExistingInputFile() throws Exception {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@@ -37,8 +38,8 @@ public class FlowConcurrencyCaseTest {
|
|||||||
protected QueueInterface<Execution> executionQueue;
|
protected QueueInterface<Execution> executionQueue;
|
||||||
|
|
||||||
public void flowConcurrencyCancel() throws TimeoutException, QueueException, InterruptedException {
|
public void flowConcurrencyCancel() throws TimeoutException, QueueException, InterruptedException {
|
||||||
Execution execution1 = runnerUtils.runOneUntilRunning(null, "io.kestra.tests", "flow-concurrency-cancel", null, null, Duration.ofSeconds(30));
|
Execution execution1 = runnerUtils.runOneUntilRunning(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-cancel", null, null, Duration.ofSeconds(30));
|
||||||
Execution execution2 = runnerUtils.runOne(null, "io.kestra.tests", "flow-concurrency-cancel");
|
Execution execution2 = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-cancel");
|
||||||
|
|
||||||
assertThat(execution1.getState().isRunning()).isTrue();
|
assertThat(execution1.getState().isRunning()).isTrue();
|
||||||
assertThat(execution2.getState().getCurrent()).isEqualTo(State.Type.CANCELLED);
|
assertThat(execution2.getState().getCurrent()).isEqualTo(State.Type.CANCELLED);
|
||||||
@@ -60,8 +61,8 @@ public class FlowConcurrencyCaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void flowConcurrencyFail() throws TimeoutException, QueueException, InterruptedException {
|
public void flowConcurrencyFail() throws TimeoutException, QueueException, InterruptedException {
|
||||||
Execution execution1 = runnerUtils.runOneUntilRunning(null, "io.kestra.tests", "flow-concurrency-fail", null, null, Duration.ofSeconds(30));
|
Execution execution1 = runnerUtils.runOneUntilRunning(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-fail", null, null, Duration.ofSeconds(30));
|
||||||
Execution execution2 = runnerUtils.runOne(null, "io.kestra.tests", "flow-concurrency-fail");
|
Execution execution2 = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-fail");
|
||||||
|
|
||||||
assertThat(execution1.getState().isRunning()).isTrue();
|
assertThat(execution1.getState().isRunning()).isTrue();
|
||||||
assertThat(execution2.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution2.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
@@ -83,9 +84,9 @@ public class FlowConcurrencyCaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void flowConcurrencyQueue() throws TimeoutException, QueueException, InterruptedException {
|
public void flowConcurrencyQueue() throws TimeoutException, QueueException, InterruptedException {
|
||||||
Execution execution1 = runnerUtils.runOneUntilRunning(null, "io.kestra.tests", "flow-concurrency-queue", null, null, Duration.ofSeconds(30));
|
Execution execution1 = runnerUtils.runOneUntilRunning(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-queue", null, null, Duration.ofSeconds(30));
|
||||||
Flow flow = flowRepository
|
Flow flow = flowRepository
|
||||||
.findById(null, "io.kestra.tests", "flow-concurrency-queue", Optional.empty())
|
.findById(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-queue", Optional.empty())
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
Execution execution2 = Execution.newExecution(flow, null, null, Optional.empty());
|
Execution execution2 = Execution.newExecution(flow, null, null, Optional.empty());
|
||||||
executionQueue.emit(execution2);
|
executionQueue.emit(execution2);
|
||||||
@@ -163,9 +164,9 @@ public class FlowConcurrencyCaseTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Execution execution1 = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "flow-concurrency-queue-pause");
|
Execution execution1 = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-queue-pause");
|
||||||
Flow flow = flowRepository
|
Flow flow = flowRepository
|
||||||
.findById(null, "io.kestra.tests", "flow-concurrency-queue-pause", Optional.empty())
|
.findById(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-queue-pause", Optional.empty())
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
Execution execution2 = Execution.newExecution(flow, null, null, Optional.empty());
|
Execution execution2 = Execution.newExecution(flow, null, null, Optional.empty());
|
||||||
executionQueue.emit(execution2);
|
executionQueue.emit(execution2);
|
||||||
@@ -215,9 +216,9 @@ public class FlowConcurrencyCaseTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Execution execution1 = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "flow-concurrency-cancel-pause");
|
Execution execution1 = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-cancel-pause");
|
||||||
Flow flow = flowRepository
|
Flow flow = flowRepository
|
||||||
.findById(null, "io.kestra.tests", "flow-concurrency-cancel-pause", Optional.empty())
|
.findById(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-cancel-pause", Optional.empty())
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
Execution execution2 = Execution.newExecution(flow, null, null, Optional.empty());
|
Execution execution2 = Execution.newExecution(flow, null, null, Optional.empty());
|
||||||
executionQueue.emit(execution2);
|
executionQueue.emit(execution2);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.kestra.core.runners;
|
package io.kestra.core.runners;
|
||||||
|
|
||||||
import io.kestra.core.models.flows.FlowInterface;
|
|
||||||
import io.kestra.core.models.flows.FlowWithSource;
|
import io.kestra.core.models.flows.FlowWithSource;
|
||||||
import io.kestra.core.models.flows.GenericFlow;
|
import io.kestra.core.models.flows.GenericFlow;
|
||||||
import io.kestra.core.models.property.Property;
|
import io.kestra.core.models.property.Property;
|
||||||
@@ -17,6 +16,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest
|
@KestraTest
|
||||||
@@ -28,6 +28,7 @@ abstract public class FlowListenersTest {
|
|||||||
FlowWithSource flow = FlowWithSource.builder()
|
FlowWithSource flow = FlowWithSource.builder()
|
||||||
.id(flowId)
|
.id(flowId)
|
||||||
.namespace("io.kestra.unittest")
|
.namespace("io.kestra.unittest")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.revision(1)
|
.revision(1)
|
||||||
.tasks(Collections.singletonList(Return.builder()
|
.tasks(Collections.singletonList(Return.builder()
|
||||||
.id(taskId)
|
.id(taskId)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.kestra.core.runners;
|
package io.kestra.core.runners;
|
||||||
|
|
||||||
import io.kestra.core.models.executions.Execution;
|
import io.kestra.core.models.executions.Execution;
|
||||||
import io.kestra.core.models.executions.LogEntry;
|
|
||||||
import io.kestra.core.models.flows.State;
|
import io.kestra.core.models.flows.State;
|
||||||
import io.kestra.core.queues.QueueException;
|
import io.kestra.core.queues.QueueException;
|
||||||
import io.kestra.core.queues.QueueFactoryInterface;
|
import io.kestra.core.queues.QueueFactoryInterface;
|
||||||
@@ -19,6 +18,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public class FlowTriggerCaseTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests.trigger", "trigger-flow");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger", "trigger-flow");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
@@ -97,7 +97,7 @@ public class FlowTriggerCaseTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests.trigger.pause", "trigger-flow-with-pause");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger.pause", "trigger-flow-with-pause");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(3);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(3);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import java.time.LocalTime;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ public class InputsTest {
|
|||||||
private FlowInputOutput flowInputOutput;
|
private FlowInputOutput flowInputOutput;
|
||||||
|
|
||||||
private Map<String, Object> typedInputs(Map<String, Object> map) {
|
private Map<String, Object> typedInputs(Map<String, Object> map) {
|
||||||
return typedInputs(map, flowRepository.findById(null, "io.kestra.tests", "inputs").get());
|
return typedInputs(map, flowRepository.findById(MAIN_TENANT, "io.kestra.tests", "inputs").get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> typedInputs(Map<String, Object> map, Flow flow) {
|
private Map<String, Object> typedInputs(Map<String, Object> map, Flow flow) {
|
||||||
@@ -100,6 +101,7 @@ public class InputsTest {
|
|||||||
Execution.builder()
|
Execution.builder()
|
||||||
.id("test")
|
.id("test")
|
||||||
.namespace(flow.getNamespace())
|
.namespace(flow.getNamespace())
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.flowRevision(1)
|
.flowRevision(1)
|
||||||
.flowId(flow.getId())
|
.flowId(flow.getId())
|
||||||
.build(),
|
.build(),
|
||||||
@@ -142,7 +144,7 @@ public class InputsTest {
|
|||||||
assertThat(typeds.get("time")).isEqualTo(LocalTime.parse("18:27:49"));
|
assertThat(typeds.get("time")).isEqualTo(LocalTime.parse("18:27:49"));
|
||||||
assertThat(typeds.get("duration")).isEqualTo(Duration.parse("PT5M6S"));
|
assertThat(typeds.get("duration")).isEqualTo(Duration.parse("PT5M6S"));
|
||||||
assertThat((URI) typeds.get("file")).isEqualTo(new URI("kestra:///io/kestra/tests/inputs/executions/test/inputs/file/application-test.yml"));
|
assertThat((URI) typeds.get("file")).isEqualTo(new URI("kestra:///io/kestra/tests/inputs/executions/test/inputs/file/application-test.yml"));
|
||||||
assertThat(CharStreams.toString(new InputStreamReader(storageInterface.get(null, null, (URI) typeds.get("file"))))).isEqualTo(CharStreams.toString(new InputStreamReader(new FileInputStream((String) inputs.get("file")))));
|
assertThat(CharStreams.toString(new InputStreamReader(storageInterface.get(MAIN_TENANT, null, (URI) typeds.get("file"))))).isEqualTo(CharStreams.toString(new InputStreamReader(new FileInputStream((String) inputs.get("file")))));
|
||||||
assertThat(typeds.get("json")).isEqualTo(Map.of("a", "b"));
|
assertThat(typeds.get("json")).isEqualTo(Map.of("a", "b"));
|
||||||
assertThat(typeds.get("uri")).isEqualTo("https://www.google.com");
|
assertThat(typeds.get("uri")).isEqualTo("https://www.google.com");
|
||||||
assertThat(((Map<String, Object>) typeds.get("nested")).get("string")).isEqualTo("a string");
|
assertThat(((Map<String, Object>) typeds.get("nested")).get("string")).isEqualTo("a string");
|
||||||
@@ -183,7 +185,7 @@ public class InputsTest {
|
|||||||
@LoadFlows({"flows/valids/inputs.yaml"})
|
@LoadFlows({"flows/valids/inputs.yaml"})
|
||||||
void inputFlow() throws TimeoutException, QueueException {
|
void inputFlow() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"inputs",
|
"inputs",
|
||||||
null,
|
null,
|
||||||
@@ -358,7 +360,7 @@ public class InputsTest {
|
|||||||
map.put("json", "{}");
|
map.put("json", "{}");
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"inputs",
|
"inputs",
|
||||||
null,
|
null,
|
||||||
@@ -379,7 +381,7 @@ public class InputsTest {
|
|||||||
Flux<LogEntry> receive = TestsUtils.receive(logQueue, l -> {});
|
Flux<LogEntry> receive = TestsUtils.receive(logQueue, l -> {});
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"input-log-secret",
|
"input-log-secret",
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import java.net.URISyntaxException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
@@ -28,17 +29,17 @@ class ListenersTest {
|
|||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void initListeners() throws IOException, URISyntaxException {
|
void initListeners() throws IOException, URISyntaxException {
|
||||||
repositoryLoader.load(null, Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners.yaml")));
|
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners.yaml")));
|
||||||
repositoryLoader.load(null, Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-flowable.yaml")));
|
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-flowable.yaml")));
|
||||||
repositoryLoader.load(null, Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-multiple.yaml")));
|
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-multiple.yaml")));
|
||||||
repositoryLoader.load(null, Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-multiple-failed.yaml")));
|
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-multiple-failed.yaml")));
|
||||||
repositoryLoader.load(null, Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-failed.yaml")));
|
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-failed.yaml")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void success() throws TimeoutException, QueueException {
|
void success() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"listeners",
|
"listeners",
|
||||||
null,
|
null,
|
||||||
@@ -53,7 +54,7 @@ class ListenersTest {
|
|||||||
@Test
|
@Test
|
||||||
void failed() throws TimeoutException, QueueException {
|
void failed() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"listeners",
|
"listeners",
|
||||||
null,
|
null,
|
||||||
@@ -68,7 +69,7 @@ class ListenersTest {
|
|||||||
@Test
|
@Test
|
||||||
void flowableExecution() throws TimeoutException, QueueException{
|
void flowableExecution() throws TimeoutException, QueueException{
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"listeners-flowable",
|
"listeners-flowable",
|
||||||
null,
|
null,
|
||||||
@@ -84,7 +85,7 @@ class ListenersTest {
|
|||||||
@Test
|
@Test
|
||||||
void multipleListeners() throws TimeoutException, QueueException {
|
void multipleListeners() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"listeners-multiple"
|
"listeners-multiple"
|
||||||
);
|
);
|
||||||
@@ -97,7 +98,7 @@ class ListenersTest {
|
|||||||
@Test
|
@Test
|
||||||
void failedListeners() throws TimeoutException, QueueException {
|
void failedListeners() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"listeners-failed"
|
"listeners-failed"
|
||||||
);
|
);
|
||||||
@@ -111,7 +112,7 @@ class ListenersTest {
|
|||||||
@Test
|
@Test
|
||||||
void failedMultipleListeners() throws TimeoutException, QueueException{
|
void failedMultipleListeners() throws TimeoutException, QueueException{
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"listeners-multiple-failed"
|
"listeners-multiple-failed"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package io.kestra.core.runners;
|
package io.kestra.core.runners;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
|
|
||||||
import io.kestra.core.models.tasks.retrys.Exponential;
|
import io.kestra.core.models.tasks.retrys.Exponential;
|
||||||
import io.kestra.core.repositories.ExecutionRepositoryInterface;
|
import io.kestra.core.repositories.ExecutionRepositoryInterface;
|
||||||
import io.kestra.core.utils.RetryUtils;
|
import io.kestra.core.utils.RetryUtils;
|
||||||
@@ -37,7 +39,7 @@ public class ListenersTestTask extends Task implements RunnableTask<ListenersTes
|
|||||||
|
|
||||||
Execution execution = retryInstance.run(
|
Execution execution = retryInstance.run(
|
||||||
NoSuchElementException.class,
|
NoSuchElementException.class,
|
||||||
() -> executionRepository.findById(null, executionRendererId)
|
() -> executionRepository.findById(MAIN_TENANT, executionRendererId)
|
||||||
.filter(e -> e.getState().getCurrent().isTerminated())
|
.filter(e -> e.getState().getCurrent().isTerminated())
|
||||||
.orElseThrow(() -> new NoSuchElementException("Unable to find execution '" + executionRendererId + "'"))
|
.orElseThrow(() -> new NoSuchElementException("Unable to find execution '" + executionRendererId + "'"))
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
@@ -32,7 +33,7 @@ public class LogToFileTest {
|
|||||||
TaskRunAttempt attempt = taskRun.getAttempts().getFirst();
|
TaskRunAttempt attempt = taskRun.getAttempts().getFirst();
|
||||||
assertThat(attempt.getLogFile()).isNotNull();
|
assertThat(attempt.getLogFile()).isNotNull();
|
||||||
|
|
||||||
InputStream inputStream = storage.get(null, "io.kestra.tests", attempt.getLogFile());
|
InputStream inputStream = storage.get(MAIN_TENANT, "io.kestra.tests", attempt.getLogFile());
|
||||||
List<String> strings = IOUtils.readLines(inputStream, StandardCharsets.UTF_8);
|
List<String> strings = IOUtils.readLines(inputStream, StandardCharsets.UTF_8);
|
||||||
assertThat(strings).isNotNull();
|
assertThat(strings).isNotNull();
|
||||||
assertThat(strings.size()).isEqualTo(1);
|
assertThat(strings.size()).isEqualTo(1);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import jakarta.inject.Named;
|
|||||||
import jakarta.inject.Singleton;
|
import jakarta.inject.Singleton;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@ public class MultipleConditionTriggerCaseTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// first one
|
// first one
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests.trigger",
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger",
|
||||||
"trigger-multiplecondition-flow-a", Duration.ofSeconds(60));
|
"trigger-multiplecondition-flow-a", Duration.ofSeconds(60));
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
@@ -70,7 +71,7 @@ public class MultipleConditionTriggerCaseTest {
|
|||||||
assertThat(ended.size()).isEqualTo(1);
|
assertThat(ended.size()).isEqualTo(1);
|
||||||
|
|
||||||
// second one
|
// second one
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests.trigger",
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger",
|
||||||
"trigger-multiplecondition-flow-b", Duration.ofSeconds(60));
|
"trigger-multiplecondition-flow-b", Duration.ofSeconds(60));
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
@@ -80,7 +81,7 @@ public class MultipleConditionTriggerCaseTest {
|
|||||||
receive.blockLast();
|
receive.blockLast();
|
||||||
assertThat(ended.size()).isEqualTo(3);
|
assertThat(ended.size()).isEqualTo(3);
|
||||||
|
|
||||||
Flow flow = flowRepository.findById(null, "io.kestra.tests.trigger",
|
Flow flow = flowRepository.findById(MAIN_TENANT, "io.kestra.tests.trigger",
|
||||||
"trigger-multiplecondition-listener").orElseThrow();
|
"trigger-multiplecondition-listener").orElseThrow();
|
||||||
Execution triggerExecution = ended.entrySet()
|
Execution triggerExecution = ended.entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
@@ -110,7 +111,7 @@ public class MultipleConditionTriggerCaseTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// first one
|
// first one
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests.trigger",
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger",
|
||||||
"trigger-multiplecondition-flow-c", Duration.ofSeconds(60));
|
"trigger-multiplecondition-flow-c", Duration.ofSeconds(60));
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
@@ -120,7 +121,7 @@ public class MultipleConditionTriggerCaseTest {
|
|||||||
assertThat(listener.get()).isNull();
|
assertThat(listener.get()).isNull();
|
||||||
|
|
||||||
// second one
|
// second one
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests.trigger",
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger",
|
||||||
"trigger-multiplecondition-flow-d", Duration.ofSeconds(60));
|
"trigger-multiplecondition-flow-d", Duration.ofSeconds(60));
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
@@ -147,17 +148,17 @@ public class MultipleConditionTriggerCaseTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// flowA
|
// flowA
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests.trigger.preconditions",
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger.preconditions",
|
||||||
"flow-trigger-preconditions-flow-a", Duration.ofSeconds(60));
|
"flow-trigger-preconditions-flow-a", Duration.ofSeconds(60));
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
// flowB: we trigger it two times, as flow-trigger-flow-preconditions-flow-listen is configured with resetOnSuccess: false it should be triggered two times
|
// flowB: we trigger it two times, as flow-trigger-flow-preconditions-flow-listen is configured with resetOnSuccess: false it should be triggered two times
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests.trigger.preconditions",
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger.preconditions",
|
||||||
"flow-trigger-preconditions-flow-a", Duration.ofSeconds(60));
|
"flow-trigger-preconditions-flow-a", Duration.ofSeconds(60));
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests.trigger.preconditions",
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger.preconditions",
|
||||||
"flow-trigger-preconditions-flow-b", Duration.ofSeconds(60));
|
"flow-trigger-preconditions-flow-b", Duration.ofSeconds(60));
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
@@ -189,13 +190,13 @@ public class MultipleConditionTriggerCaseTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// flowB
|
// flowB
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests.trigger.preconditions",
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger.preconditions",
|
||||||
"flow-trigger-preconditions-flow-b", Duration.ofSeconds(60));
|
"flow-trigger-preconditions-flow-b", Duration.ofSeconds(60));
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
// flowA
|
// flowA
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests.trigger.preconditions",
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger.preconditions",
|
||||||
"flow-trigger-preconditions-flow-a", Duration.ofSeconds(60));
|
"flow-trigger-preconditions-flow-a", Duration.ofSeconds(60));
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
@@ -226,7 +227,7 @@ public class MultipleConditionTriggerCaseTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests.trigger.paused",
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger.paused",
|
||||||
"flow-trigger-paused-flow", Duration.ofSeconds(60));
|
"flow-trigger-paused-flow", Duration.ofSeconds(60));
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(2);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(2);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import org.junit.jupiter.api.TestInstance;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
@@ -59,12 +60,13 @@ public class NoEncryptionConfiguredTest implements TestPropertyProvider {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/inputs.yaml"})
|
@LoadFlows({"flows/valids/inputs.yaml"})
|
||||||
void secretInput() {
|
void secretInput() {
|
||||||
assertThat(flowRepository.findById(null, "io.kestra.tests", "inputs").isPresent()).isTrue();
|
assertThat(flowRepository.findById(MAIN_TENANT, "io.kestra.tests", "inputs").isPresent()).isTrue();
|
||||||
|
|
||||||
Flow flow = flowRepository.findById(null, "io.kestra.tests", "inputs").get();
|
Flow flow = flowRepository.findById(MAIN_TENANT, "io.kestra.tests", "inputs").get();
|
||||||
Execution execution = Execution.builder()
|
Execution execution = Execution.builder()
|
||||||
.id("test")
|
.id("test")
|
||||||
.namespace(flow.getNamespace())
|
.namespace(flow.getNamespace())
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.flowRevision(1)
|
.flowRevision(1)
|
||||||
.flowId(flow.getId())
|
.flowId(flow.getId())
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package io.kestra.core.runners;
|
package io.kestra.core.runners;
|
||||||
|
|
||||||
|
import io.kestra.core.junit.annotations.ExecuteFlow;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
import io.kestra.core.junit.annotations.LoadFlows;
|
|
||||||
import io.kestra.core.models.executions.Execution;
|
import io.kestra.core.models.executions.Execution;
|
||||||
import io.kestra.core.models.flows.State;
|
import io.kestra.core.models.flows.State;
|
||||||
import io.kestra.core.queues.QueueException;
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@@ -20,9 +18,6 @@ public class NullOutputTest {
|
|||||||
@Inject
|
@Inject
|
||||||
protected StandAloneRunner runner;
|
protected StandAloneRunner runner;
|
||||||
|
|
||||||
@Inject
|
|
||||||
protected RunnerUtils runnerUtils;
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
protected void init() throws IOException, URISyntaxException {
|
protected void init() throws IOException, URISyntaxException {
|
||||||
if (!runner.isRunning()) {
|
if (!runner.isRunning()) {
|
||||||
@@ -31,10 +26,8 @@ public class NullOutputTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@LoadFlows("flows/valids/null-output.yaml")
|
@ExecuteFlow("flows/valids/null-output.yaml")
|
||||||
void shouldIncludeNullOutput() throws QueueException, TimeoutException {
|
void shouldIncludeNullOutput(Execution execution){
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "null-output");
|
|
||||||
|
|
||||||
assertThat(execution).isNotNull();
|
assertThat(execution).isNotNull();
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -32,7 +33,7 @@ public class PluginDefaultsCaseTest {
|
|||||||
private RunnerUtils runnerUtils;
|
private RunnerUtils runnerUtils;
|
||||||
|
|
||||||
public void taskDefaults() throws TimeoutException, QueueException {
|
public void taskDefaults() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "plugin-defaults", Duration.ofSeconds(60));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "plugin-defaults", Duration.ofSeconds(60));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(8);
|
assertThat(execution.getTaskRunList()).hasSize(8);
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import jakarta.inject.Inject;
|
|||||||
import jakarta.inject.Named;
|
import jakarta.inject.Named;
|
||||||
import jakarta.inject.Singleton;
|
import jakarta.inject.Singleton;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static io.kestra.core.utils.Rethrow.throwRunnable;
|
import static io.kestra.core.utils.Rethrow.throwRunnable;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@@ -43,9 +45,9 @@ public class RestartCaseTest {
|
|||||||
private QueueInterface<Execution> executionQueue;
|
private QueueInterface<Execution> executionQueue;
|
||||||
|
|
||||||
public void restartFailedThenSuccess() throws Exception {
|
public void restartFailedThenSuccess() throws Exception {
|
||||||
Flow flow = flowRepository.findById(null, "io.kestra.tests", "restart_last_failed").orElseThrow();
|
Flow flow = flowRepository.findById(MAIN_TENANT, "io.kestra.tests", "restart_last_failed").orElseThrow();
|
||||||
|
|
||||||
Execution firstExecution = runnerUtils.runOne(null, flow.getNamespace(), flow.getId(), Duration.ofSeconds(60));
|
Execution firstExecution = runnerUtils.runOne(MAIN_TENANT, flow.getNamespace(), flow.getId(), Duration.ofSeconds(60));
|
||||||
|
|
||||||
assertThat(firstExecution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(firstExecution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
assertThat(firstExecution.getTaskRunList()).hasSize(3);
|
assertThat(firstExecution.getTaskRunList()).hasSize(3);
|
||||||
@@ -82,9 +84,9 @@ public class RestartCaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void restartFailedThenFailureWithGlobalErrors() throws Exception {
|
public void restartFailedThenFailureWithGlobalErrors() throws Exception {
|
||||||
Flow flow = flowRepository.findById(null, "io.kestra.tests", "restart_always_failed").orElseThrow();
|
Flow flow = flowRepository.findById(MAIN_TENANT, "io.kestra.tests", "restart_always_failed").orElseThrow();
|
||||||
|
|
||||||
Execution firstExecution = runnerUtils.runOne(null, flow.getNamespace(), flow.getId(), Duration.ofSeconds(60));
|
Execution firstExecution = runnerUtils.runOne(MAIN_TENANT, flow.getNamespace(), flow.getId(), Duration.ofSeconds(60));
|
||||||
|
|
||||||
assertThat(firstExecution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(firstExecution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
assertThat(firstExecution.getTaskRunList()).hasSize(2);
|
assertThat(firstExecution.getTaskRunList()).hasSize(2);
|
||||||
@@ -117,9 +119,9 @@ public class RestartCaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void restartFailedThenFailureWithLocalErrors() throws Exception {
|
public void restartFailedThenFailureWithLocalErrors() throws Exception {
|
||||||
Flow flow = flowRepository.findById(null, "io.kestra.tests", "restart_local_errors").orElseThrow();
|
Flow flow = flowRepository.findById(MAIN_TENANT, "io.kestra.tests", "restart_local_errors").orElseThrow();
|
||||||
|
|
||||||
Execution firstExecution = runnerUtils.runOne(null, flow.getNamespace(), flow.getId(), Duration.ofSeconds(60));
|
Execution firstExecution = runnerUtils.runOne(MAIN_TENANT, flow.getNamespace(), flow.getId(), Duration.ofSeconds(60));
|
||||||
|
|
||||||
assertThat(firstExecution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(firstExecution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
assertThat(firstExecution.getTaskRunList()).hasSize(5);
|
assertThat(firstExecution.getTaskRunList()).hasSize(5);
|
||||||
@@ -154,9 +156,9 @@ public class RestartCaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void replay() throws Exception {
|
public void replay() throws Exception {
|
||||||
Flow flow = flowRepository.findById(null, "io.kestra.tests", "restart-each").orElseThrow();
|
Flow flow = flowRepository.findById(MAIN_TENANT, "io.kestra.tests", "restart-each").orElseThrow();
|
||||||
|
|
||||||
Execution firstExecution = runnerUtils.runOne(null, flow.getNamespace(), flow.getId(), Duration.ofSeconds(60));
|
Execution firstExecution = runnerUtils.runOne(MAIN_TENANT, flow.getNamespace(), flow.getId(), Duration.ofSeconds(60));
|
||||||
|
|
||||||
assertThat(firstExecution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(firstExecution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
@@ -186,7 +188,7 @@ public class RestartCaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void restartMultiple() throws Exception {
|
public void restartMultiple() throws Exception {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "failed-first");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "failed-first");
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
|
|
||||||
@@ -221,7 +223,7 @@ public class RestartCaseTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "restart-parent");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "restart-parent");
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.runners;
|
package io.kestra.core.runners;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
import io.kestra.core.models.property.Property;
|
import io.kestra.core.models.property.Property;
|
||||||
@@ -15,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@KestraTest
|
@KestraTest
|
||||||
class RunContextPropertyTest {
|
class RunContextPropertyTest {
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void asShouldReturnEmptyForNullProperty() throws IllegalVariableEvaluationException {
|
void asShouldReturnEmptyForNullProperty() throws IllegalVariableEvaluationException {
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.within;
|
import static org.assertj.core.api.Assertions.within;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
@@ -110,7 +111,7 @@ class RunContextTest {
|
|||||||
LogEntry matchingLog;
|
LogEntry matchingLog;
|
||||||
Flux<LogEntry> receive = TestsUtils.receive(workerTaskLogQueue, either -> logs.add(either.getLeft()));
|
Flux<LogEntry> receive = TestsUtils.receive(workerTaskLogQueue, either -> logs.add(either.getLeft()));
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "logs");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "logs");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(5);
|
assertThat(execution.getTaskRunList()).hasSize(5);
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ class RunContextTest {
|
|||||||
inputs.put("string", new String(chars));
|
inputs.put("string", new String(chars));
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"inputs-large",
|
"inputs-large",
|
||||||
null,
|
null,
|
||||||
@@ -179,7 +180,7 @@ class RunContextTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void taskDefaults() throws TimeoutException, QueueException, IOException, URISyntaxException {
|
void taskDefaults() throws TimeoutException, QueueException, IOException, URISyntaxException {
|
||||||
repositoryLoader.load(null, Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/plugin-defaults.yaml")));
|
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/plugin-defaults.yaml")));
|
||||||
pluginDefaultsCaseTest.taskDefaults();
|
pluginDefaultsCaseTest.taskDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +196,7 @@ class RunContextTest {
|
|||||||
p.destroy();
|
p.destroy();
|
||||||
|
|
||||||
URI uri = runContext.storage().putFile(path.toFile());
|
URI uri = runContext.storage().putFile(path.toFile());
|
||||||
assertThat(storageInterface.getAttributes(null, null, uri).getSize()).isEqualTo(size + 1);
|
assertThat(storageInterface.getAttributes(MAIN_TENANT, null, uri).getSize()).isEqualTo(size + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import jakarta.inject.Singleton;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -18,31 +19,31 @@ public class SLATestCase {
|
|||||||
private RunnerUtils runnerUtils;
|
private RunnerUtils runnerUtils;
|
||||||
|
|
||||||
public void maxDurationSLAShouldFail() throws QueueException, TimeoutException {
|
public void maxDurationSLAShouldFail() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "sla-max-duration-fail");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "sla-max-duration-fail");
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void maxDurationSLAShouldPass() throws QueueException, TimeoutException {
|
public void maxDurationSLAShouldPass() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "sla-max-duration-ok");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "sla-max-duration-ok");
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executionConditionSLAShouldPass() throws QueueException, TimeoutException {
|
public void executionConditionSLAShouldPass() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "sla-execution-condition");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "sla-execution-condition");
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executionConditionSLAShouldCancel() throws QueueException, TimeoutException {
|
public void executionConditionSLAShouldCancel() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "sla-execution-condition", null, (f, e) -> Map.of("string", "CANCEL"));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "sla-execution-condition", null, (f, e) -> Map.of("string", "CANCEL"));
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.CANCELLED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.CANCELLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executionConditionSLAShouldLabel() throws QueueException, TimeoutException {
|
public void executionConditionSLAShouldLabel() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "sla-execution-condition", null, (f, e) -> Map.of("string", "LABEL"));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "sla-execution-condition", null, (f, e) -> Map.of("string", "LABEL"));
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getLabels()).contains(new Label("sla", "violated"));
|
assertThat(execution.getLabels()).contains(new Label("sla", "violated"));
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ public class ScheduleDateCaseTest {
|
|||||||
|
|
||||||
public void shouldScheduleOnDate() throws QueueException, InterruptedException {
|
public void shouldScheduleOnDate() throws QueueException, InterruptedException {
|
||||||
ZonedDateTime scheduleOn = ZonedDateTime.now().plusSeconds(1);
|
ZonedDateTime scheduleOn = ZonedDateTime.now().plusSeconds(1);
|
||||||
Flow flow = flowRepository.findById(null, "io.kestra.tests", "minimal").orElseThrow();
|
Flow flow = flowRepository.findById(MAIN_TENANT, "io.kestra.tests", "minimal").orElseThrow();
|
||||||
Execution execution = Execution.newExecution(flow, null, null, Optional.of(scheduleOn));
|
Execution execution = Execution.newExecution(flow, null, null, Optional.of(scheduleOn));
|
||||||
this.executionQueue.emit(execution);
|
this.executionQueue.emit(execution);
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -46,17 +47,18 @@ public class SkipExecutionCaseTest {
|
|||||||
skipExecutionService.setSkipExecutions(List.of(execution1Id));
|
skipExecutionService.setSkipExecutions(List.of(execution1Id));
|
||||||
|
|
||||||
executionQueue.emit(execution1);
|
executionQueue.emit(execution1);
|
||||||
Execution execution2 = runnerUtils.runOne(null, "io.kestra.tests", "minimal");
|
Execution execution2 = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "minimal");
|
||||||
|
|
||||||
// the execution 2 should be in success and the 1 still created
|
// the execution 2 should be in success and the 1 still created
|
||||||
assertThat(execution2.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution2.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
execution1 = Await.until(() -> executionRepository.findById(null, execution1Id).orElse(null), Duration.ofMillis(100), Duration.ofSeconds(1));
|
execution1 = Await.until(() -> executionRepository.findById(MAIN_TENANT, execution1Id).orElse(null), Duration.ofMillis(100), Duration.ofSeconds(1));
|
||||||
assertThat(execution1.getState().getCurrent()).isEqualTo(State.Type.CREATED);
|
assertThat(execution1.getState().getCurrent()).isEqualTo(State.Type.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Flow createFlow() {
|
private Flow createFlow() {
|
||||||
return Flow.builder()
|
return Flow.builder()
|
||||||
.id(IdUtils.create())
|
.id(IdUtils.create())
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.namespace("io.kestra.unittest")
|
.namespace("io.kestra.unittest")
|
||||||
.revision(1)
|
.revision(1)
|
||||||
.tasks(Collections.singletonList(Return.builder()
|
.tasks(Collections.singletonList(Return.builder()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.runners;
|
package io.kestra.core.runners;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import io.kestra.core.junit.annotations.ExecuteFlow;
|
import io.kestra.core.junit.annotations.ExecuteFlow;
|
||||||
@@ -46,7 +47,7 @@ public class TaskWithAllowFailureTest {
|
|||||||
@LoadFlows({"flows/valids/task-allow-failure-executable-flow.yml",
|
@LoadFlows({"flows/valids/task-allow-failure-executable-flow.yml",
|
||||||
"flows/valids/for-each-item-subflow-failed.yaml"})
|
"flows/valids/for-each-item-subflow-failed.yaml"})
|
||||||
void executableTask_Flow() throws QueueException, TimeoutException {
|
void executableTask_Flow() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "task-allow-failure-executable-flow");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "task-allow-failure-executable-flow");
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.WARNING);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.WARNING);
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
}
|
}
|
||||||
@@ -57,7 +58,7 @@ public class TaskWithAllowFailureTest {
|
|||||||
void executableTask_ForEachItem() throws TimeoutException, QueueException, URISyntaxException, IOException {
|
void executableTask_ForEachItem() throws TimeoutException, QueueException, URISyntaxException, IOException {
|
||||||
URI file = storageUpload();
|
URI file = storageUpload();
|
||||||
Map<String, Object> inputs = Map.of("file", file.toString());
|
Map<String, Object> inputs = Map.of("file", file.toString());
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "task-allow-failure-executable-foreachitem", null, (flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "task-allow-failure-executable-foreachitem", null, (flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs));
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.WARNING);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.WARNING);
|
||||||
assertThat(execution.getTaskRunList()).hasSize(4);
|
assertThat(execution.getTaskRunList()).hasSize(4);
|
||||||
@@ -76,7 +77,7 @@ public class TaskWithAllowFailureTest {
|
|||||||
Files.write(tempFile.toPath(), content());
|
Files.write(tempFile.toPath(), content());
|
||||||
|
|
||||||
return storageInterface.put(
|
return storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/file/storage/file.txt"),
|
new URI("/file/storage/file.txt"),
|
||||||
new FileInputStream(tempFile)
|
new FileInputStream(tempFile)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
@@ -47,7 +48,7 @@ public class TaskWithAllowWarningTest {
|
|||||||
@LoadFlows({"flows/valids/task-allow-warning-executable-flow.yml",
|
@LoadFlows({"flows/valids/task-allow-warning-executable-flow.yml",
|
||||||
"flows/valids/for-each-item-subflow-failed.yaml"})
|
"flows/valids/for-each-item-subflow-failed.yaml"})
|
||||||
void executableTask_Flow() throws QueueException, TimeoutException {
|
void executableTask_Flow() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "task-allow-warning-executable-flow");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "task-allow-warning-executable-flow");
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
}
|
}
|
||||||
@@ -57,7 +58,7 @@ public class TaskWithAllowWarningTest {
|
|||||||
void executableTask_ForEachItem() throws TimeoutException, QueueException, URISyntaxException, IOException {
|
void executableTask_ForEachItem() throws TimeoutException, QueueException, URISyntaxException, IOException {
|
||||||
URI file = storageUpload();
|
URI file = storageUpload();
|
||||||
Map<String, Object> inputs = Map.of("file", file.toString());
|
Map<String, Object> inputs = Map.of("file", file.toString());
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "task-allow-warning-executable-foreachitem", null, (flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "task-allow-warning-executable-foreachitem", null, (flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs));
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getTaskRunList()).hasSize(4);
|
assertThat(execution.getTaskRunList()).hasSize(4);
|
||||||
@@ -76,7 +77,7 @@ public class TaskWithAllowWarningTest {
|
|||||||
Files.write(tempFile.toPath(), content());
|
Files.write(tempFile.toPath(), content());
|
||||||
|
|
||||||
return storageInterface.put(
|
return storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/file/storage/file.txt"),
|
new URI("/file/storage/file.txt"),
|
||||||
new FileInputStream(tempFile)
|
new FileInputStream(tempFile)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.within;
|
import static org.assertj.core.api.Assertions.within;
|
||||||
|
|
||||||
@@ -133,7 +134,7 @@ class TestSuiteTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Execution runReturnFlow(List<TaskFixture> fixtures) throws TimeoutException, QueueException {
|
private Execution runReturnFlow(List<TaskFixture> fixtures) throws TimeoutException, QueueException {
|
||||||
var flow = flowRepository.findById(null, "io.kestra.tests", "return", Optional.empty()).orElseThrow();
|
var flow = flowRepository.findById(MAIN_TENANT, "io.kestra.tests", "return", Optional.empty()).orElseThrow();
|
||||||
|
|
||||||
var execution = Execution.builder()
|
var execution = Execution.builder()
|
||||||
.id(IdUtils.create())
|
.id(IdUtils.create())
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.io.IOException;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
@KestraTest
|
@KestraTest
|
||||||
@@ -33,7 +34,7 @@ class FileExistsFunctionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private URI getInternalStorageFile(URI internalStorageURI, String text) throws IOException {
|
private URI getInternalStorageFile(URI internalStorageURI, String text) throws IOException {
|
||||||
return storageInterface.put(null, NAMESPACE, internalStorageURI, new ByteArrayInputStream(text.getBytes()));
|
return storageInterface.put(MAIN_TENANT, NAMESPACE, internalStorageURI, new ByteArrayInputStream(text.getBytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -46,7 +47,8 @@ class FileExistsFunctionTest {
|
|||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", FLOW,
|
"id", FLOW,
|
||||||
"namespace", NAMESPACE),
|
"namespace", NAMESPACE,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", executionId)
|
"execution", Map.of("id", executionId)
|
||||||
);
|
);
|
||||||
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ fileExists('" + internalStorageFile + "') }}", variables));
|
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ fileExists('" + internalStorageFile + "') }}", variables));
|
||||||
@@ -57,12 +59,12 @@ class FileExistsFunctionTest {
|
|||||||
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
|
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
|
||||||
String namespace = "io.kestra.tests";
|
String namespace = "io.kestra.tests";
|
||||||
String filePath = "file.txt";
|
String filePath = "file.txt";
|
||||||
storageInterface.createDirectory(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
|
storageInterface.createDirectory(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
|
||||||
storageInterface.put(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("NOT AN EMPTY FILE".getBytes()));
|
storageInterface.put(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("NOT AN EMPTY FILE".getBytes()));
|
||||||
|
|
||||||
boolean render = Boolean.parseBoolean(
|
boolean render = Boolean.parseBoolean(
|
||||||
variableRenderer.render("{{ fileExists('" + filePath + "', namespace='" + namespace + "') }}",
|
variableRenderer.render("{{ fileExists('" + filePath + "', namespace='" + namespace + "') }}",
|
||||||
Map.of("flow", Map.of("namespace", "flow.namespace"))));
|
Map.of("flow", Map.of("namespace", "flow.namespace", "tenantId", MAIN_TENANT))));
|
||||||
assertTrue(render);
|
assertTrue(render);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +78,8 @@ class FileExistsFunctionTest {
|
|||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", FLOW,
|
"id", FLOW,
|
||||||
"namespace", NAMESPACE),
|
"namespace", NAMESPACE,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", executionId)
|
"execution", Map.of("id", executionId)
|
||||||
);
|
);
|
||||||
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ fileExists('" + internalStorageFile + "') }}", variables));
|
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ fileExists('" + internalStorageFile + "') }}", variables));
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.io.IOException;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.hibernate.validator.internal.util.Contracts.assertTrue;
|
import static org.hibernate.validator.internal.util.Contracts.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
@@ -42,7 +43,8 @@ public class FileSizeFunctionTest {
|
|||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", FLOW,
|
"id", FLOW,
|
||||||
"namespace", NAMESPACE),
|
"namespace", NAMESPACE,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", executionId)
|
"execution", Map.of("id", executionId)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -54,10 +56,10 @@ public class FileSizeFunctionTest {
|
|||||||
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
|
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
|
||||||
String namespace = "io.kestra.tests";
|
String namespace = "io.kestra.tests";
|
||||||
String filePath = "file.txt";
|
String filePath = "file.txt";
|
||||||
storageInterface.createDirectory(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
|
storageInterface.createDirectory(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
|
||||||
storageInterface.put(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream(FILE_TEXT.getBytes()));
|
storageInterface.put(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream(FILE_TEXT.getBytes()));
|
||||||
|
|
||||||
String render = variableRenderer.render("{{ fileSize('" + filePath + "', namespace='" + namespace + "') }}", Map.of("flow", Map.of("namespace", "flow.namespace")));
|
String render = variableRenderer.render("{{ fileSize('" + filePath + "', namespace='" + namespace + "') }}", Map.of("flow", Map.of("namespace", "flow.namespace", "tenantId", MAIN_TENANT)));
|
||||||
assertThat(render).isEqualTo(FILE_SIZE);
|
assertThat(render).isEqualTo(FILE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,12 +72,14 @@ public class FileSizeFunctionTest {
|
|||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", "subflow",
|
"id", "subflow",
|
||||||
"namespace", NAMESPACE),
|
"namespace", NAMESPACE,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", IdUtils.create()),
|
"execution", Map.of("id", IdUtils.create()),
|
||||||
"trigger", Map.of(
|
"trigger", Map.of(
|
||||||
"flowId", FLOW,
|
"flowId", FLOW,
|
||||||
"namespace", NAMESPACE,
|
"namespace", NAMESPACE,
|
||||||
"executionId", executionId
|
"executionId", executionId,
|
||||||
|
"tenantId", MAIN_TENANT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -92,7 +96,8 @@ public class FileSizeFunctionTest {
|
|||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", "subflow",
|
"id", "subflow",
|
||||||
"namespace", NAMESPACE),
|
"namespace", NAMESPACE,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", IdUtils.create())
|
"execution", Map.of("id", IdUtils.create())
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -109,11 +114,13 @@ public class FileSizeFunctionTest {
|
|||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", "subflow",
|
"id", "subflow",
|
||||||
"namespace", NAMESPACE),
|
"namespace", NAMESPACE,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", IdUtils.create()),
|
"execution", Map.of("id", IdUtils.create()),
|
||||||
"trigger", Map.of(
|
"trigger", Map.of(
|
||||||
"flowId", FLOW,
|
"flowId", FLOW,
|
||||||
"executionId", executionId
|
"executionId", executionId,
|
||||||
|
"tenantId", MAIN_TENANT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -135,7 +142,8 @@ public class FileSizeFunctionTest {
|
|||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", FLOW,
|
"id", FLOW,
|
||||||
"namespace", NAMESPACE),
|
"namespace", NAMESPACE,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", executionId),
|
"execution", Map.of("id", executionId),
|
||||||
"file", internalStorageFile
|
"file", internalStorageFile
|
||||||
);
|
);
|
||||||
@@ -153,12 +161,14 @@ public class FileSizeFunctionTest {
|
|||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", "subflow",
|
"id", "subflow",
|
||||||
"namespace", NAMESPACE),
|
"namespace", NAMESPACE,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", IdUtils.create()),
|
"execution", Map.of("id", IdUtils.create()),
|
||||||
"trigger", Map.of(
|
"trigger", Map.of(
|
||||||
"flowId", FLOW,
|
"flowId", FLOW,
|
||||||
"namespace", NAMESPACE,
|
"namespace", NAMESPACE,
|
||||||
"executionId", executionId
|
"executionId", executionId,
|
||||||
|
"tenantId", MAIN_TENANT
|
||||||
),
|
),
|
||||||
"file", internalStorageFile
|
"file", internalStorageFile
|
||||||
);
|
);
|
||||||
@@ -172,6 +182,6 @@ public class FileSizeFunctionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private URI getInternalStorageFile(URI internalStorageURI) throws IOException {
|
private URI getInternalStorageFile(URI internalStorageURI) throws IOException {
|
||||||
return storageInterface.put(null, null, internalStorageURI, new ByteArrayInputStream(FILE_TEXT.getBytes()));
|
return storageInterface.put(MAIN_TENANT, null, internalStorageURI, new ByteArrayInputStream(FILE_TEXT.getBytes()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.io.*;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
@@ -49,12 +50,12 @@ class FromIonFunctionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of("id", "test", "namespace", "unit"),
|
"flow", Map.of("id", "test", "namespace", "unit", "tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", "id-exec")
|
"execution", Map.of("id", "id-exec")
|
||||||
);
|
);
|
||||||
|
|
||||||
URI internalStorageURI = URI.create("/unit/test/executions/id-exec/" + IdUtils.create() + ".ion");
|
URI internalStorageURI = URI.create("/unit/test/executions/id-exec/" + IdUtils.create() + ".ion");
|
||||||
URI internalStorageFile = storageInterface.put(null, "unit", internalStorageURI, new FileInputStream(tempFile));
|
URI internalStorageFile = storageInterface.put(MAIN_TENANT, "unit", internalStorageURI, new FileInputStream(tempFile));
|
||||||
|
|
||||||
String render = variableRenderer.render("{{ fromIon(read('" + internalStorageFile + "'), allRows=true) }}", variables);
|
String render = variableRenderer.render("{{ fromIon(read('" + internalStorageFile + "'), allRows=true) }}", variables);
|
||||||
assertThat(render).contains("\"id\":0");
|
assertThat(render).contains("\"id\":0");
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.io.IOException;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
@KestraTest
|
@KestraTest
|
||||||
@@ -33,7 +34,7 @@ class IsFileEmptyFunctionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private URI getInternalStorageFile(URI internalStorageURI, String text) throws IOException {
|
private URI getInternalStorageFile(URI internalStorageURI, String text) throws IOException {
|
||||||
return storageInterface.put(null, NAMESPACE, internalStorageURI, new ByteArrayInputStream(text.getBytes()));
|
return storageInterface.put(MAIN_TENANT, NAMESPACE, internalStorageURI, new ByteArrayInputStream(text.getBytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -46,7 +47,8 @@ class IsFileEmptyFunctionTest {
|
|||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", FLOW,
|
"id", FLOW,
|
||||||
"namespace", NAMESPACE),
|
"namespace", NAMESPACE,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", executionId)
|
"execution", Map.of("id", executionId)
|
||||||
);
|
);
|
||||||
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ isFileEmpty('" + internalStorageFile + "') }}", variables));
|
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ isFileEmpty('" + internalStorageFile + "') }}", variables));
|
||||||
@@ -57,12 +59,12 @@ class IsFileEmptyFunctionTest {
|
|||||||
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
|
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
|
||||||
String namespace = "io.kestra.tests";
|
String namespace = "io.kestra.tests";
|
||||||
String filePath = "file.txt";
|
String filePath = "file.txt";
|
||||||
storageInterface.createDirectory(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
|
storageInterface.createDirectory(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
|
||||||
storageInterface.put(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("NOT AN EMPTY FILE".getBytes()));
|
storageInterface.put(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("NOT AN EMPTY FILE".getBytes()));
|
||||||
|
|
||||||
boolean render = Boolean.parseBoolean(
|
boolean render = Boolean.parseBoolean(
|
||||||
variableRenderer.render("{{ isFileEmpty('" + filePath + "', namespace='" + namespace + "') }}",
|
variableRenderer.render("{{ isFileEmpty('" + filePath + "', namespace='" + namespace + "') }}",
|
||||||
Map.of("flow", Map.of("namespace", "flow.namespace"))));
|
Map.of("flow", Map.of("namespace", "flow.namespace", "tenantId", MAIN_TENANT))));
|
||||||
assertFalse(render);
|
assertFalse(render);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +78,8 @@ class IsFileEmptyFunctionTest {
|
|||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", FLOW,
|
"id", FLOW,
|
||||||
"namespace", NAMESPACE),
|
"namespace", NAMESPACE,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", executionId)
|
"execution", Map.of("id", executionId)
|
||||||
);
|
);
|
||||||
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ isFileEmpty('" + internalStorageFile + "') }}", variables));
|
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ isFileEmpty('" + internalStorageFile + "') }}", variables));
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import java.io.IOException;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
@@ -34,10 +35,10 @@ class ReadFileFunctionTest {
|
|||||||
void readNamespaceFile() throws IllegalVariableEvaluationException, IOException {
|
void readNamespaceFile() throws IllegalVariableEvaluationException, IOException {
|
||||||
String namespace = "io.kestra.tests";
|
String namespace = "io.kestra.tests";
|
||||||
String filePath = "file.txt";
|
String filePath = "file.txt";
|
||||||
storageInterface.createDirectory(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
|
storageInterface.createDirectory(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
|
||||||
storageInterface.put(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("Hello from {{ flow.namespace }}".getBytes()));
|
storageInterface.put(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("Hello from {{ flow.namespace }}".getBytes()));
|
||||||
|
|
||||||
String render = variableRenderer.render("{{ render(read('" + filePath + "')) }}", Map.of("flow", Map.of("namespace", namespace)));
|
String render = variableRenderer.render("{{ render(read('" + filePath + "')) }}", Map.of("flow", Map.of("namespace", namespace, "tenantId", MAIN_TENANT)));
|
||||||
assertThat(render).isEqualTo("Hello from " + namespace);
|
assertThat(render).isEqualTo("Hello from " + namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,10 +46,10 @@ class ReadFileFunctionTest {
|
|||||||
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
|
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
|
||||||
String namespace = "io.kestra.tests";
|
String namespace = "io.kestra.tests";
|
||||||
String filePath = "file.txt";
|
String filePath = "file.txt";
|
||||||
storageInterface.createDirectory(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
|
storageInterface.createDirectory(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
|
||||||
storageInterface.put(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("Hello but not from flow.namespace".getBytes()));
|
storageInterface.put(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("Hello but not from flow.namespace".getBytes()));
|
||||||
|
|
||||||
String render = variableRenderer.render("{{ read('" + filePath + "', namespace='" + namespace + "') }}", Map.of("flow", Map.of("namespace", "flow.namespace")));
|
String render = variableRenderer.render("{{ read('" + filePath + "', namespace='" + namespace + "') }}", Map.of("flow", Map.of("namespace", "flow.namespace", "tenantId", MAIN_TENANT)));
|
||||||
assertThat(render).isEqualTo("Hello but not from flow.namespace");
|
assertThat(render).isEqualTo("Hello but not from flow.namespace");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,13 +66,14 @@ class ReadFileFunctionTest {
|
|||||||
String flowId = "flow";
|
String flowId = "flow";
|
||||||
String executionId = IdUtils.create();
|
String executionId = IdUtils.create();
|
||||||
URI internalStorageURI = URI.create("/" + namespace.replace(".", "/") + "/" + flowId + "/executions/" + executionId + "/tasks/task/" + IdUtils.create() + "/123456.ion");
|
URI internalStorageURI = URI.create("/" + namespace.replace(".", "/") + "/" + flowId + "/executions/" + executionId + "/tasks/task/" + IdUtils.create() + "/123456.ion");
|
||||||
URI internalStorageFile = storageInterface.put(null, namespace, internalStorageURI, new ByteArrayInputStream("Hello from a task output".getBytes()));
|
URI internalStorageFile = storageInterface.put(MAIN_TENANT, namespace, internalStorageURI, new ByteArrayInputStream("Hello from a task output".getBytes()));
|
||||||
|
|
||||||
// test for an authorized execution
|
// test for an authorized execution
|
||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", flowId,
|
"id", flowId,
|
||||||
"namespace", namespace),
|
"namespace", namespace,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", executionId)
|
"execution", Map.of("id", executionId)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -82,12 +84,14 @@ class ReadFileFunctionTest {
|
|||||||
variables = Map.of(
|
variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", "subflow",
|
"id", "subflow",
|
||||||
"namespace", namespace),
|
"namespace", namespace,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", IdUtils.create()),
|
"execution", Map.of("id", IdUtils.create()),
|
||||||
"trigger", Map.of(
|
"trigger", Map.of(
|
||||||
"flowId", flowId,
|
"flowId", flowId,
|
||||||
"namespace", namespace,
|
"namespace", namespace,
|
||||||
"executionId", executionId
|
"executionId", executionId,
|
||||||
|
"tenantId", MAIN_TENANT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -102,13 +106,14 @@ class ReadFileFunctionTest {
|
|||||||
String flowId = "flow";
|
String flowId = "flow";
|
||||||
String executionId = IdUtils.create();
|
String executionId = IdUtils.create();
|
||||||
URI internalStorageURI = URI.create("/" + namespace.replace(".", "/") + "/" + flowId + "/executions/" + executionId + "/tasks/task/" + IdUtils.create() + "/123456.ion");
|
URI internalStorageURI = URI.create("/" + namespace.replace(".", "/") + "/" + flowId + "/executions/" + executionId + "/tasks/task/" + IdUtils.create() + "/123456.ion");
|
||||||
URI internalStorageFile = storageInterface.put(null, namespace, internalStorageURI, new ByteArrayInputStream("Hello from a task output".getBytes()));
|
URI internalStorageFile = storageInterface.put(MAIN_TENANT, namespace, internalStorageURI, new ByteArrayInputStream("Hello from a task output".getBytes()));
|
||||||
|
|
||||||
// test for an authorized execution
|
// test for an authorized execution
|
||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", flowId,
|
"id", flowId,
|
||||||
"namespace", namespace),
|
"namespace", namespace,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", executionId),
|
"execution", Map.of("id", executionId),
|
||||||
"file", internalStorageFile
|
"file", internalStorageFile
|
||||||
);
|
);
|
||||||
@@ -120,12 +125,14 @@ class ReadFileFunctionTest {
|
|||||||
variables = Map.of(
|
variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", "subflow",
|
"id", "subflow",
|
||||||
"namespace", namespace),
|
"namespace", namespace,
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", IdUtils.create()),
|
"execution", Map.of("id", IdUtils.create()),
|
||||||
"trigger", Map.of(
|
"trigger", Map.of(
|
||||||
"flowId", flowId,
|
"flowId", flowId,
|
||||||
"namespace", namespace,
|
"namespace", namespace,
|
||||||
"executionId", executionId
|
"executionId", executionId,
|
||||||
|
"tenantId", MAIN_TENANT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -139,12 +146,13 @@ class ReadFileFunctionTest {
|
|||||||
String flowId = "flow";
|
String flowId = "flow";
|
||||||
String executionId = IdUtils.create();
|
String executionId = IdUtils.create();
|
||||||
URI internalStorageURI = URI.create("/" + namespace.replace(".", "/") + "/" + flowId + "/executions/" + executionId + "/tasks/task/" + IdUtils.create() + "/123456.ion");
|
URI internalStorageURI = URI.create("/" + namespace.replace(".", "/") + "/" + flowId + "/executions/" + executionId + "/tasks/task/" + IdUtils.create() + "/123456.ion");
|
||||||
URI internalStorageFile = storageInterface.put(null, namespace, internalStorageURI, new ByteArrayInputStream("Hello from a task output".getBytes()));
|
URI internalStorageFile = storageInterface.put(MAIN_TENANT, namespace, internalStorageURI, new ByteArrayInputStream("Hello from a task output".getBytes()));
|
||||||
|
|
||||||
Map<String, Object> variables = Map.of(
|
Map<String, Object> variables = Map.of(
|
||||||
"flow", Map.of(
|
"flow", Map.of(
|
||||||
"id", "notme",
|
"id", "notme",
|
||||||
"namespace", "notme"),
|
"namespace", "notme",
|
||||||
|
"tenantId", MAIN_TENANT),
|
||||||
"execution", Map.of("id", "notme")
|
"execution", Map.of("id", "notme")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.secret;
|
package io.kestra.core.secret;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
||||||
@@ -56,7 +57,7 @@ public class SecretFunctionTest {
|
|||||||
List<LogEntry> logs = new CopyOnWriteArrayList<>();
|
List<LogEntry> logs = new CopyOnWriteArrayList<>();
|
||||||
Flux<LogEntry> receive = TestsUtils.receive(logQueue, either -> logs.add(either.getLeft()));
|
Flux<LogEntry> receive = TestsUtils.receive(logQueue, either -> logs.add(either.getLeft()));
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "secrets");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "secrets");
|
||||||
assertThat(execution.getTaskRunList().getFirst().getOutputs().get("value")).isEqualTo("secretValue");
|
assertThat(execution.getTaskRunList().getFirst().getOutputs().get("value")).isEqualTo("secretValue");
|
||||||
assertThat(execution.getTaskRunList().get(2).getOutputs().get("value")).isEqualTo("passwordveryveryveyrlongpasswordveryveryveyrlongpasswordveryveryveyrlongpasswordveryveryveyrlongpasswordveryveryveyrlong");
|
assertThat(execution.getTaskRunList().get(2).getOutputs().get("value")).isEqualTo("passwordveryveryveyrlongpasswordveryveryveyrlongpasswordveryveryveyrlongpasswordveryveryveyrlongpasswordveryveryveyrlong");
|
||||||
assertThat(execution.getTaskRunList().get(3).getOutputs().get("value")).isEqualTo("secretValue");
|
assertThat(execution.getTaskRunList().get(3).getOutputs().get("value")).isEqualTo("secretValue");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.services;
|
package io.kestra.core.services;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
import io.kestra.core.models.Label;
|
import io.kestra.core.models.Label;
|
||||||
import io.kestra.core.models.flows.Flow;
|
import io.kestra.core.models.flows.Flow;
|
||||||
@@ -22,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
class LabelServiceTest {
|
class LabelServiceTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldFilterSystemLabels() {
|
void shouldFilterSystemLabels() {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
@@ -70,7 +71,7 @@ class PluginDefaultServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
void shouldInjectGivenFlowWithNullSource() throws FlowProcessingException {
|
void shouldInjectGivenFlowWithNullSource() throws FlowProcessingException {
|
||||||
// Given
|
// Given
|
||||||
FlowInterface flow = GenericFlow.fromYaml(null, TEST_LOG_FLOW_SOURCE);
|
FlowInterface flow = GenericFlow.fromYaml(MAIN_TENANT, TEST_LOG_FLOW_SOURCE);
|
||||||
|
|
||||||
// When
|
// When
|
||||||
FlowWithSource result = pluginDefaultService.injectAllDefaults(flow, true);
|
FlowWithSource result = pluginDefaultService.injectAllDefaults(flow, true);
|
||||||
@@ -308,7 +309,7 @@ class PluginDefaultServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
void shouldInjectFlowDefaultsGivenAlias() throws FlowProcessingException {
|
void shouldInjectFlowDefaultsGivenAlias() throws FlowProcessingException {
|
||||||
// Given
|
// Given
|
||||||
GenericFlow flow = GenericFlow.fromYaml(null, """
|
GenericFlow flow = GenericFlow.fromYaml(MAIN_TENANT, """
|
||||||
id: default-test
|
id: default-test
|
||||||
namespace: io.kestra.tests
|
namespace: io.kestra.tests
|
||||||
|
|
||||||
@@ -332,7 +333,7 @@ class PluginDefaultServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldInjectFlowDefaultsGivenType() throws FlowProcessingException {
|
void shouldInjectFlowDefaultsGivenType() throws FlowProcessingException {
|
||||||
GenericFlow flow = GenericFlow.fromYaml(null, """
|
GenericFlow flow = GenericFlow.fromYaml(MAIN_TENANT, """
|
||||||
id: default-test
|
id: default-test
|
||||||
namespace: io.kestra.tests
|
namespace: io.kestra.tests
|
||||||
|
|
||||||
@@ -355,7 +356,7 @@ class PluginDefaultServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldNotInjectDefaultsGivenExistingTaskValue() throws FlowProcessingException {
|
public void shouldNotInjectDefaultsGivenExistingTaskValue() throws FlowProcessingException {
|
||||||
// Given
|
// Given
|
||||||
GenericFlow flow = GenericFlow.fromYaml(null, """
|
GenericFlow flow = GenericFlow.fromYaml(MAIN_TENANT, """
|
||||||
id: default-test
|
id: default-test
|
||||||
namespace: io.kestra.tests
|
namespace: io.kestra.tests
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.within;
|
||||||
|
|
||||||
class InternalKVStoreTest {
|
class InternalKVStoreTest {
|
||||||
private static final Instant date = Instant.now().truncatedTo(ChronoUnit.MILLIS);
|
private static final Instant date = Instant.now().truncatedTo(ChronoUnit.MILLIS);
|
||||||
@@ -46,7 +47,7 @@ class InternalKVStoreTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void list() throws IOException {
|
void list() throws IOException {
|
||||||
Instant before = Instant.now().minusMillis(100);
|
Instant now = Instant.now();
|
||||||
InternalKVStore kv = kv();
|
InternalKVStore kv = kv();
|
||||||
|
|
||||||
assertThat(kv.list().size()).isZero();
|
assertThat(kv.list().size()).isZero();
|
||||||
@@ -54,14 +55,13 @@ class InternalKVStoreTest {
|
|||||||
kv.put(TEST_KV_KEY, new KVValueAndMetadata(new KVMetadata(Duration.ofMinutes(5)), complexValue));
|
kv.put(TEST_KV_KEY, new KVValueAndMetadata(new KVMetadata(Duration.ofMinutes(5)), complexValue));
|
||||||
kv.put("my-second-key", new KVValueAndMetadata(new KVMetadata(Duration.ofMinutes(10)), complexValue));
|
kv.put("my-second-key", new KVValueAndMetadata(new KVMetadata(Duration.ofMinutes(10)), complexValue));
|
||||||
kv.put("expired-key", new KVValueAndMetadata(new KVMetadata(Duration.ofMillis(1)), complexValue));
|
kv.put("expired-key", new KVValueAndMetadata(new KVMetadata(Duration.ofMillis(1)), complexValue));
|
||||||
Instant after = Instant.now().plusMillis(100);
|
|
||||||
|
|
||||||
List<KVEntry> list = kv.list();
|
List<KVEntry> list = kv.list();
|
||||||
assertThat(list.size()).isEqualTo(2);
|
assertThat(list.size()).isEqualTo(2);
|
||||||
|
|
||||||
list.forEach(kvEntry -> {
|
list.forEach(kvEntry -> {
|
||||||
assertThat(kvEntry.creationDate().isAfter(before) && kvEntry.creationDate().isBefore(after)).isTrue();
|
assertThat(kvEntry.creationDate()).isCloseTo(now, within(1, ChronoUnit. SECONDS));
|
||||||
assertThat(kvEntry.updateDate().isAfter(before) && kvEntry.updateDate().isBefore(after)).isTrue();
|
assertThat(kvEntry.updateDate()).isCloseTo(now, within(1, ChronoUnit. SECONDS));
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<String, KVEntry> map = list.stream().collect(Collectors.toMap(KVEntry::key, Function.identity()));
|
Map<String, KVEntry> map = list.stream().collect(Collectors.toMap(KVEntry::key, Function.identity()));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.storages;
|
package io.kestra.core.storages;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.exceptions.MigrationRequiredException;
|
import io.kestra.core.exceptions.MigrationRequiredException;
|
||||||
import io.kestra.core.exceptions.ResourceExpiredException;
|
import io.kestra.core.exceptions.ResourceExpiredException;
|
||||||
import io.kestra.core.runners.RunContext;
|
import io.kestra.core.runners.RunContext;
|
||||||
@@ -23,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@MicronautTest
|
@MicronautTest
|
||||||
public class StateStoreTest {
|
public class StateStoreTest {
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void all() throws IOException, ResourceExpiredException {
|
void all() throws IOException, ResourceExpiredException {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.core.tasks;
|
package io.kestra.core.tasks;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
|
||||||
import io.kestra.core.models.tasks.runners.PluginUtilsService;
|
import io.kestra.core.models.tasks.runners.PluginUtilsService;
|
||||||
import io.kestra.core.runners.RunContextFactory;
|
import io.kestra.core.runners.RunContextFactory;
|
||||||
@@ -20,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||||||
@KestraTest
|
@KestraTest
|
||||||
public class PluginUtilsServiceTest {
|
public class PluginUtilsServiceTest {
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void outputFiles() throws IOException {
|
void outputFiles() throws IOException {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class TenantServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
void test() {
|
void test() {
|
||||||
var tenant = tenantService.resolveTenant();
|
var tenant = tenantService.resolveTenant();
|
||||||
assertThat(tenant).isNull();
|
assertThat(tenant).isEqualTo("main");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest
|
@KestraTest
|
||||||
@@ -54,7 +55,7 @@ class NamespaceFilesUtilsTest {
|
|||||||
|
|
||||||
ByteArrayInputStream data = new ByteArrayInputStream("a".repeat(1024).getBytes(StandardCharsets.UTF_8));
|
ByteArrayInputStream data = new ByteArrayInputStream("a".repeat(1024).getBytes(StandardCharsets.UTF_8));
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
storageInterface.put(null, namespace, toNamespacedStorageUri(namespace, URI.create("/" + i + ".txt")), data);
|
storageInterface.put(MAIN_TENANT, namespace, toNamespacedStorageUri(namespace, URI.create("/" + i + ".txt")), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespaceFilesUtils.loadNamespaceFiles(runContext, NamespaceFiles.builder().build());
|
namespaceFilesUtils.loadNamespaceFiles(runContext, NamespaceFiles.builder().build());
|
||||||
@@ -78,7 +79,7 @@ class NamespaceFilesUtilsTest {
|
|||||||
|
|
||||||
ByteArrayInputStream data = new ByteArrayInputStream("a".repeat(1024).getBytes(StandardCharsets.UTF_8));
|
ByteArrayInputStream data = new ByteArrayInputStream("a".repeat(1024).getBytes(StandardCharsets.UTF_8));
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
storageInterface.put(null, namespace, toNamespacedStorageUri(namespace, URI.create("/" + i + ".txt")), data);
|
storageInterface.put(MAIN_TENANT, namespace, toNamespacedStorageUri(namespace, URI.create("/" + i + ".txt")), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespaceFilesUtils.loadNamespaceFiles(runContext, NamespaceFiles.builder().namespaces(Property.of(List.of(namespace))).build());
|
namespaceFilesUtils.loadNamespaceFiles(runContext, NamespaceFiles.builder().namespaces(Property.of(List.of(namespace))).build());
|
||||||
@@ -101,9 +102,9 @@ class NamespaceFilesUtilsTest {
|
|||||||
String namespace = IdUtils.create();
|
String namespace = IdUtils.create();
|
||||||
|
|
||||||
ByteArrayInputStream data = new ByteArrayInputStream("a".repeat(1024).getBytes(StandardCharsets.UTF_8));
|
ByteArrayInputStream data = new ByteArrayInputStream("a".repeat(1024).getBytes(StandardCharsets.UTF_8));
|
||||||
storageInterface.put(null, namespace, toNamespacedStorageUri(namespace, URI.create("/folder1/test.txt")), data);
|
storageInterface.put(MAIN_TENANT, namespace, toNamespacedStorageUri(namespace, URI.create("/folder1/test.txt")), data);
|
||||||
storageInterface.put(null, namespace, toNamespacedStorageUri(namespace, URI.create("/folder2/test.txt")), data);
|
storageInterface.put(MAIN_TENANT, namespace, toNamespacedStorageUri(namespace, URI.create("/folder2/test.txt")), data);
|
||||||
storageInterface.put(null, namespace, toNamespacedStorageUri(namespace, URI.create("/test.txt")), data);
|
storageInterface.put(MAIN_TENANT, namespace, toNamespacedStorageUri(namespace, URI.create("/test.txt")), data);
|
||||||
|
|
||||||
namespaceFilesUtils.loadNamespaceFiles(runContext, NamespaceFiles.builder().namespaces(Property.of(List.of(namespace))).build());
|
namespaceFilesUtils.loadNamespaceFiles(runContext, NamespaceFiles.builder().namespaces(Property.of(List.of(namespace))).build());
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import java.util.concurrent.CountDownLatch;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ class ExitTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// we cannot use the runnerUtils as it may not see the RUNNING state before the execution is killed
|
// we cannot use the runnerUtils as it may not see the RUNNING state before the execution is killed
|
||||||
Flow flow = flowRepository.findById(null, "io.kestra.tests", "exit-killed", Optional.empty()).orElseThrow();
|
Flow flow = flowRepository.findById(MAIN_TENANT, "io.kestra.tests", "exit-killed", Optional.empty()).orElseThrow();
|
||||||
Execution execution = Execution.newExecution(flow, null, null, Optional.empty());
|
Execution execution = Execution.newExecution(flow, null, null, Optional.empty());
|
||||||
executionQueue.emit(execution);
|
executionQueue.emit(execution);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.execution;
|
package io.kestra.plugin.core.execution;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
@@ -23,8 +24,8 @@ public class FailTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/fail-on-switch.yaml"})
|
@LoadFlows({"flows/valids/fail-on-switch.yaml"})
|
||||||
void failOnSwitch() throws TimeoutException, QueueException {
|
void failOnSwitch() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "fail-on-switch", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "fail-on-switch", null,
|
||||||
(f, e) -> Map.of("param", "fail") , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", "fail") , Duration.ofSeconds(20));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
assertThat(execution.findTaskRunsByTaskId("switch").getFirst().getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.findTaskRunsByTaskId("switch").getFirst().getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
@@ -34,8 +35,8 @@ public class FailTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/fail-on-condition.yaml"})
|
@LoadFlows({"flows/valids/fail-on-condition.yaml"})
|
||||||
void failOnCondition() throws TimeoutException, QueueException{
|
void failOnCondition() throws TimeoutException, QueueException{
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "fail-on-condition", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "fail-on-condition", null,
|
||||||
(f, e) -> Map.of("param", "fail") , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", "fail") , Duration.ofSeconds(20));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
assertThat(execution.findTaskRunsByTaskId("fail").getFirst().getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.findTaskRunsByTaskId("fail").getFirst().getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
@@ -45,8 +46,8 @@ public class FailTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/fail-on-condition.yaml"})
|
@LoadFlows({"flows/valids/fail-on-condition.yaml"})
|
||||||
void dontFailOnCondition() throws TimeoutException, QueueException{
|
void dontFailOnCondition() throws TimeoutException, QueueException{
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "fail-on-condition", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "fail-on-condition", null,
|
||||||
(f, e) -> Map.of("param", "success") , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", "success") , Duration.ofSeconds(20));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
assertThat(execution.findTaskRunsByTaskId("fail").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.findTaskRunsByTaskId("fail").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.execution;
|
package io.kestra.plugin.core.execution;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
import io.kestra.core.models.executions.Execution;
|
import io.kestra.core.models.executions.Execution;
|
||||||
import io.kestra.core.models.flows.State;
|
import io.kestra.core.models.flows.State;
|
||||||
@@ -20,7 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@KestraTest
|
@KestraTest
|
||||||
class PurgeExecutionsTest {
|
class PurgeExecutionsTest {
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ExecutionRepositoryInterface executionRepository;
|
private ExecutionRepositoryInterface executionRepository;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
@@ -28,14 +29,14 @@ class ResumeTest {
|
|||||||
@LoadFlows({"flows/valids/pause.yaml",
|
@LoadFlows({"flows/valids/pause.yaml",
|
||||||
"flows/valids/resume-execution.yaml"})
|
"flows/valids/resume-execution.yaml"})
|
||||||
void resume() throws Exception {
|
void resume() throws Exception {
|
||||||
Execution pause = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause");
|
Execution pause = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause");
|
||||||
String pauseId = pause.getId();
|
String pauseId = pause.getId();
|
||||||
|
|
||||||
Execution resume = runnerUtils.runOne(null, "io.kestra.tests", "resume-execution", null, (flow, execution) -> Map.of("executionId", pauseId));
|
Execution resume = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "resume-execution", null, (flow, execution) -> Map.of("executionId", pauseId));
|
||||||
assertThat(resume.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(resume.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
Await.until(
|
Await.until(
|
||||||
() -> executionRepository.findById(null, pauseId).orElseThrow().getState().getCurrent().isTerminated(),
|
() -> executionRepository.findById(MAIN_TENANT, pauseId).orElseThrow().getState().getCurrent().isTerminated(),
|
||||||
Duration.ofMillis(100),
|
Duration.ofMillis(100),
|
||||||
Duration.ofSeconds(5)
|
Duration.ofSeconds(5)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import io.kestra.core.models.flows.State;
|
|||||||
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
@@ -37,7 +38,7 @@ class AllowFailureTest {
|
|||||||
@LoadFlows({"flows/valids/allow-failure.yaml"})
|
@LoadFlows({"flows/valids/allow-failure.yaml"})
|
||||||
void failed() throws TimeoutException, QueueException {
|
void failed() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"allow-failure",
|
"allow-failure",
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ class CorrelationIdTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "subflow-parent");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "subflow-parent");
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
assertTrue(countDownLatch.await(1, TimeUnit.MINUTES));
|
assertTrue(countDownLatch.await(1, TimeUnit.MINUTES));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.flow;
|
package io.kestra.plugin.core.flow;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import io.kestra.core.junit.annotations.ExecuteFlow;
|
import io.kestra.core.junit.annotations.ExecuteFlow;
|
||||||
@@ -70,7 +71,7 @@ public class DagTest {
|
|||||||
@LoadFlows({"flows/valids/finally-dag.yaml"})
|
@LoadFlows({"flows/valids/finally-dag.yaml"})
|
||||||
void errors() throws QueueException, TimeoutException {
|
void errors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-dag", null,
|
"io.kestra.tests", "finally-dag", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import jakarta.inject.Inject;
|
|||||||
import jakarta.inject.Named;
|
import jakarta.inject.Named;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
@@ -95,7 +96,7 @@ public class EachSequentialTest {
|
|||||||
List<LogEntry> logs = new CopyOnWriteArrayList<>();
|
List<LogEntry> logs = new CopyOnWriteArrayList<>();
|
||||||
Flux<LogEntry> receive = TestsUtils.receive(logQueue, either -> logs.add(either.getLeft()));
|
Flux<LogEntry> receive = TestsUtils.receive(logQueue, either -> logs.add(either.getLeft()));
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "each-null", Duration.ofSeconds(60));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "each-null", Duration.ofSeconds(60));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
|
|||||||
@@ -15,10 +15,13 @@ import java.time.Duration;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
class FinallyTest {
|
class FinallyTest {
|
||||||
|
|
||||||
|
public static final String NAMESPACE = "io.kestra.tests";
|
||||||
@Inject
|
@Inject
|
||||||
protected RunnerUtils runnerUtils;
|
protected RunnerUtils runnerUtils;
|
||||||
|
|
||||||
@@ -29,8 +32,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-sequential.yaml"})
|
@LoadFlows({"flows/valids/finally-sequential.yaml"})
|
||||||
void sequentialWithoutErrors() throws QueueException, TimeoutException {
|
void sequentialWithoutErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-sequential", null,
|
NAMESPACE, "finally-sequential", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -46,8 +49,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-sequential.yaml"})
|
@LoadFlows({"flows/valids/finally-sequential.yaml"})
|
||||||
void sequentialWithErrors() throws QueueException, TimeoutException {
|
void sequentialWithErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-sequential", null,
|
NAMESPACE, "finally-sequential", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -63,8 +66,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-sequential-error.yaml"})
|
@LoadFlows({"flows/valids/finally-sequential-error.yaml"})
|
||||||
void sequentialErrorBlockWithoutErrors() throws QueueException, TimeoutException {
|
void sequentialErrorBlockWithoutErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-sequential-error", null,
|
NAMESPACE, "finally-sequential-error", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -79,7 +82,7 @@ class FinallyTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/finally-sequential-error-first.yaml"})
|
@LoadFlows({"flows/valids/finally-sequential-error-first.yaml"})
|
||||||
void sequentialErrorFirst() throws QueueException, TimeoutException {
|
void sequentialErrorFirst() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "finally-sequential-error-first");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, NAMESPACE, "finally-sequential-error-first");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
@@ -92,8 +95,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-sequential-error.yaml"})
|
@LoadFlows({"flows/valids/finally-sequential-error.yaml"})
|
||||||
void sequentialErrorBlockWithErrors() throws QueueException, TimeoutException {
|
void sequentialErrorBlockWithErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-sequential-error", null,
|
NAMESPACE, "finally-sequential-error", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -111,8 +114,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-allowfailure.yaml"})
|
@LoadFlows({"flows/valids/finally-allowfailure.yaml"})
|
||||||
void allowFailureWithoutErrors() throws QueueException, TimeoutException {
|
void allowFailureWithoutErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-allowfailure", null,
|
NAMESPACE, "finally-allowfailure", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -128,8 +131,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-allowfailure.yaml"})
|
@LoadFlows({"flows/valids/finally-allowfailure.yaml"})
|
||||||
void allowFailureWithErrors() throws QueueException, TimeoutException {
|
void allowFailureWithErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-allowfailure", null,
|
NAMESPACE, "finally-allowfailure", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -147,8 +150,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-parallel.yaml"})
|
@LoadFlows({"flows/valids/finally-parallel.yaml"})
|
||||||
void parallelWithoutErrors() throws QueueException, TimeoutException {
|
void parallelWithoutErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-parallel", null,
|
NAMESPACE, "finally-parallel", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -164,8 +167,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-parallel.yaml"})
|
@LoadFlows({"flows/valids/finally-parallel.yaml"})
|
||||||
void parallelWithErrors() throws QueueException, TimeoutException {
|
void parallelWithErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-parallel", null,
|
NAMESPACE, "finally-parallel", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -183,8 +186,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-foreach.yaml"})
|
@LoadFlows({"flows/valids/finally-foreach.yaml"})
|
||||||
void forEachWithoutErrors() throws QueueException, TimeoutException {
|
void forEachWithoutErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-foreach", null,
|
NAMESPACE, "finally-foreach", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -200,8 +203,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-foreach.yaml"})
|
@LoadFlows({"flows/valids/finally-foreach.yaml"})
|
||||||
void forEachWithErrors() throws QueueException, TimeoutException {
|
void forEachWithErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-foreach", null,
|
NAMESPACE, "finally-foreach", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -219,8 +222,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-eachparallel.yaml"})
|
@LoadFlows({"flows/valids/finally-eachparallel.yaml"})
|
||||||
void eachParallelWithoutErrors() throws QueueException, TimeoutException {
|
void eachParallelWithoutErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-eachparallel", null,
|
NAMESPACE, "finally-eachparallel", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -236,8 +239,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-eachparallel.yaml"})
|
@LoadFlows({"flows/valids/finally-eachparallel.yaml"})
|
||||||
void eachParallelWithErrors() throws QueueException, TimeoutException {
|
void eachParallelWithErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-eachparallel", null,
|
NAMESPACE, "finally-eachparallel", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -255,8 +258,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-dag.yaml"})
|
@LoadFlows({"flows/valids/finally-dag.yaml"})
|
||||||
void dagWithoutErrors() throws QueueException, TimeoutException {
|
void dagWithoutErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-dag", null,
|
NAMESPACE, "finally-dag", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -272,8 +275,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-dag.yaml"})
|
@LoadFlows({"flows/valids/finally-dag.yaml"})
|
||||||
void dagWithErrors() throws QueueException, TimeoutException {
|
void dagWithErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-dag", null,
|
NAMESPACE, "finally-dag", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -291,8 +294,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-flow.yaml"})
|
@LoadFlows({"flows/valids/finally-flow.yaml"})
|
||||||
void flowWithoutErrors() throws QueueException, TimeoutException {
|
void flowWithoutErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-flow", null,
|
NAMESPACE, "finally-flow", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -308,8 +311,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-flow.yaml"})
|
@LoadFlows({"flows/valids/finally-flow.yaml"})
|
||||||
void flowWithErrors() throws QueueException, TimeoutException {
|
void flowWithErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-flow", null,
|
NAMESPACE, "finally-flow", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -325,8 +328,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-flow-error.yaml"})
|
@LoadFlows({"flows/valids/finally-flow-error.yaml"})
|
||||||
void flowErrorBlockWithoutErrors() throws QueueException, TimeoutException {
|
void flowErrorBlockWithoutErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-flow-error", null,
|
NAMESPACE, "finally-flow-error", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -342,8 +345,8 @@ class FinallyTest {
|
|||||||
@LoadFlows({"flows/valids/finally-flow-error.yaml"})
|
@LoadFlows({"flows/valids/finally-flow-error.yaml"})
|
||||||
void flowErrorBlockWithErrors() throws QueueException, TimeoutException {
|
void flowErrorBlockWithErrors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-flow-error", null,
|
NAMESPACE, "finally-flow-error", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
@@ -360,7 +363,7 @@ class FinallyTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/finally-flow-error-first.yaml"})
|
@LoadFlows({"flows/valids/finally-flow-error-first.yaml"})
|
||||||
void flowErrorFirst() throws QueueException, TimeoutException {
|
void flowErrorFirst() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "finally-flow-error-first");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, NAMESPACE, "finally-flow-error-first");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import jakarta.inject.Named;
|
|||||||
import jakarta.inject.Singleton;
|
import jakarta.inject.Singleton;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -61,7 +62,7 @@ public class FlowCaseTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"subflow-old-task-name"
|
"subflow-old-task-name"
|
||||||
);
|
);
|
||||||
@@ -92,7 +93,7 @@ public class FlowCaseTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
testInherited ? "task-flow" : "task-flow-inherited-labels",
|
testInherited ? "task-flow" : "task-flow-inherited-labels",
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import static io.kestra.core.models.flows.State.Type.FAILED;
|
import static io.kestra.core.models.flows.State.Type.FAILED;
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static io.kestra.core.utils.Rethrow.throwRunnable;
|
import static io.kestra.core.utils.Rethrow.throwRunnable;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@@ -78,7 +79,7 @@ public class ForEachItemCaseTest {
|
|||||||
|
|
||||||
URI file = storageUpload();
|
URI file = storageUpload();
|
||||||
Map<String, Object> inputs = Map.of("file", file.toString(), "batch", 4);
|
Map<String, Object> inputs = Map.of("file", file.toString(), "batch", 4);
|
||||||
Execution execution = runnerUtils.runOne(null, TEST_NAMESPACE, "for-each-item", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, TEST_NAMESPACE, "for-each-item", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
||||||
Duration.ofSeconds(30));
|
Duration.ofSeconds(30));
|
||||||
|
|
||||||
@@ -112,7 +113,7 @@ public class ForEachItemCaseTest {
|
|||||||
public void forEachItemEmptyItems() throws TimeoutException, URISyntaxException, IOException, QueueException {
|
public void forEachItemEmptyItems() throws TimeoutException, URISyntaxException, IOException, QueueException {
|
||||||
URI file = emptyItems();
|
URI file = emptyItems();
|
||||||
Map<String, Object> inputs = Map.of("file", file.toString(), "batch", 4);
|
Map<String, Object> inputs = Map.of("file", file.toString(), "batch", 4);
|
||||||
Execution execution = runnerUtils.runOne(null, TEST_NAMESPACE, "for-each-item", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, TEST_NAMESPACE, "for-each-item", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
||||||
Duration.ofSeconds(30));
|
Duration.ofSeconds(30));
|
||||||
|
|
||||||
@@ -140,7 +141,7 @@ public class ForEachItemCaseTest {
|
|||||||
|
|
||||||
URI file = storageUpload();
|
URI file = storageUpload();
|
||||||
Map<String, Object> inputs = Map.of("file", file.toString());
|
Map<String, Object> inputs = Map.of("file", file.toString());
|
||||||
Execution execution = runnerUtils.runOne(null, TEST_NAMESPACE, "for-each-item-no-wait", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, TEST_NAMESPACE, "for-each-item-no-wait", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
||||||
Duration.ofSeconds(30));
|
Duration.ofSeconds(30));
|
||||||
|
|
||||||
@@ -187,7 +188,7 @@ public class ForEachItemCaseTest {
|
|||||||
|
|
||||||
URI file = storageUpload();
|
URI file = storageUpload();
|
||||||
Map<String, Object> inputs = Map.of("file", file.toString());
|
Map<String, Object> inputs = Map.of("file", file.toString());
|
||||||
Execution execution = runnerUtils.runOne(null, TEST_NAMESPACE, "for-each-item-failed", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, TEST_NAMESPACE, "for-each-item-failed", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
||||||
Duration.ofSeconds(60));
|
Duration.ofSeconds(60));
|
||||||
|
|
||||||
@@ -230,7 +231,7 @@ public class ForEachItemCaseTest {
|
|||||||
|
|
||||||
URI file = storageUpload();
|
URI file = storageUpload();
|
||||||
Map<String, Object> inputs = Map.of("file", file.toString());
|
Map<String, Object> inputs = Map.of("file", file.toString());
|
||||||
Execution execution = runnerUtils.runOne(null, TEST_NAMESPACE, "for-each-item-outputs", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, TEST_NAMESPACE, "for-each-item-outputs", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
||||||
Duration.ofSeconds(30));
|
Duration.ofSeconds(30));
|
||||||
|
|
||||||
@@ -261,7 +262,7 @@ public class ForEachItemCaseTest {
|
|||||||
// asserts for subflow merged outputs
|
// asserts for subflow merged outputs
|
||||||
Map<String, Object> mergeTaskOutputs = execution.getTaskRunList().get(3).getOutputs();
|
Map<String, Object> mergeTaskOutputs = execution.getTaskRunList().get(3).getOutputs();
|
||||||
assertThat(mergeTaskOutputs.get("subflowOutputs")).isNotNull();
|
assertThat(mergeTaskOutputs.get("subflowOutputs")).isNotNull();
|
||||||
InputStream stream = storageInterface.get(null, execution.getNamespace(), URI.create((String) mergeTaskOutputs.get("subflowOutputs")));
|
InputStream stream = storageInterface.get(MAIN_TENANT, execution.getNamespace(), URI.create((String) mergeTaskOutputs.get("subflowOutputs")));
|
||||||
|
|
||||||
try (var br = new BufferedReader(new InputStreamReader(stream))) {
|
try (var br = new BufferedReader(new InputStreamReader(stream))) {
|
||||||
// one line per sub-flows
|
// one line per sub-flows
|
||||||
@@ -280,7 +281,7 @@ public class ForEachItemCaseTest {
|
|||||||
|
|
||||||
URI file = storageUpload();
|
URI file = storageUpload();
|
||||||
Map<String, Object> inputs = Map.of("file", file.toString(), "batch", 20);
|
Map<String, Object> inputs = Map.of("file", file.toString(), "batch", 20);
|
||||||
Execution execution = runnerUtils.runOne(null, TEST_NAMESPACE, "restart-for-each-item", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, TEST_NAMESPACE, "restart-for-each-item", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
||||||
Duration.ofSeconds(30));
|
Duration.ofSeconds(30));
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
@@ -326,7 +327,7 @@ public class ForEachItemCaseTest {
|
|||||||
|
|
||||||
URI file = storageUpload();
|
URI file = storageUpload();
|
||||||
Map<String, Object> inputs = Map.of("file", file.toString(), "batch", 4);
|
Map<String, Object> inputs = Map.of("file", file.toString(), "batch", 4);
|
||||||
Execution execution = runnerUtils.runOne(null, TEST_NAMESPACE, "for-each-item-in-if", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, TEST_NAMESPACE, "for-each-item-in-if", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, inputs),
|
||||||
Duration.ofSeconds(30));
|
Duration.ofSeconds(30));
|
||||||
|
|
||||||
@@ -361,7 +362,7 @@ public class ForEachItemCaseTest {
|
|||||||
Files.write(tempFile.toPath(), content());
|
Files.write(tempFile.toPath(), content());
|
||||||
|
|
||||||
return storageInterface.put(
|
return storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/file/storage/file.txt"),
|
new URI("/file/storage/file.txt"),
|
||||||
new FileInputStream(tempFile)
|
new FileInputStream(tempFile)
|
||||||
@@ -372,7 +373,7 @@ public class ForEachItemCaseTest {
|
|||||||
File tempFile = File.createTempFile("file", ".txt");
|
File tempFile = File.createTempFile("file", ".txt");
|
||||||
|
|
||||||
return storageInterface.put(
|
return storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/file/storage/file.txt"),
|
new URI("/file/storage/file.txt"),
|
||||||
new FileInputStream(tempFile)
|
new FileInputStream(tempFile)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.time.Duration;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
@@ -25,21 +26,21 @@ class IfTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/if-condition.yaml"})
|
@LoadFlows({"flows/valids/if-condition.yaml"})
|
||||||
void ifTruthy() throws TimeoutException, QueueException {
|
void ifTruthy() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "if-condition", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "if-condition", null,
|
||||||
(f, e) -> Map.of("param", true) , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", true) , Duration.ofSeconds(120));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
assertThat(execution.findTaskRunsByTaskId("when-true").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.findTaskRunsByTaskId("when-true").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests", "if-condition", null,
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "if-condition", null,
|
||||||
(f, e) -> Map.of("param", "true") , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", "true") , Duration.ofSeconds(120));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
assertThat(execution.findTaskRunsByTaskId("when-true").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.findTaskRunsByTaskId("when-true").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests", "if-condition", null,
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "if-condition", null,
|
||||||
(f, e) -> Map.of("param", 1) , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", 1) , Duration.ofSeconds(120));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
@@ -50,28 +51,28 @@ class IfTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/if-condition.yaml"})
|
@LoadFlows({"flows/valids/if-condition.yaml"})
|
||||||
void ifFalsy() throws TimeoutException, QueueException {
|
void ifFalsy() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "if-condition", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "if-condition", null,
|
||||||
(f, e) -> Map.of("param", false) , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", false) , Duration.ofSeconds(120));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
assertThat(execution.findTaskRunsByTaskId("when-false").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.findTaskRunsByTaskId("when-false").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests", "if-condition", null,
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "if-condition", null,
|
||||||
(f, e) -> Map.of("param", "false") , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", "false") , Duration.ofSeconds(120));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
assertThat(execution.findTaskRunsByTaskId("when-false").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.findTaskRunsByTaskId("when-false").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests", "if-condition", null,
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "if-condition", null,
|
||||||
(f, e) -> Map.of("param", 0) , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", 0) , Duration.ofSeconds(120));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
assertThat(execution.findTaskRunsByTaskId("when-false").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.findTaskRunsByTaskId("when-false").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests", "if-condition", null,
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "if-condition", null,
|
||||||
(f, e) -> Map.of("param", -0) , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", -0) , Duration.ofSeconds(120));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
@@ -84,14 +85,14 @@ class IfTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/if-without-else.yaml"})
|
@LoadFlows({"flows/valids/if-without-else.yaml"})
|
||||||
void ifWithoutElse() throws TimeoutException, QueueException {
|
void ifWithoutElse() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "if-without-else", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "if-without-else", null,
|
||||||
(f, e) -> Map.of("param", true) , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", true) , Duration.ofSeconds(120));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
assertThat(execution.findTaskRunsByTaskId("when-true").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.findTaskRunsByTaskId("when-true").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests", "if-without-else", null,
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "if-without-else", null,
|
||||||
(f, e) -> Map.of("param", false) , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", false) , Duration.ofSeconds(120));
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
assertThat(execution.findTaskRunsByTaskId("when-true").isEmpty()).isTrue();
|
assertThat(execution.findTaskRunsByTaskId("when-true").isEmpty()).isTrue();
|
||||||
@@ -101,7 +102,7 @@ class IfTest {
|
|||||||
@Test
|
@Test
|
||||||
@LoadFlows({"flows/valids/if-in-flowable.yaml"})
|
@LoadFlows({"flows/valids/if-in-flowable.yaml"})
|
||||||
void ifInFlowable() throws TimeoutException, QueueException {
|
void ifInFlowable() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "if-in-flowable", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "if-in-flowable", null,
|
||||||
(f, e) -> Map.of("param", true) , Duration.ofSeconds(120));
|
(f, e) -> Map.of("param", true) , Duration.ofSeconds(120));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(8);
|
assertThat(execution.getTaskRunList()).hasSize(8);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.flow;
|
package io.kestra.plugin.core.flow;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import io.kestra.core.junit.annotations.ExecuteFlow;
|
import io.kestra.core.junit.annotations.ExecuteFlow;
|
||||||
@@ -41,7 +42,7 @@ class ParallelTest {
|
|||||||
@LoadFlows({"flows/valids/finally-parallel.yaml"})
|
@LoadFlows({"flows/valids/finally-parallel.yaml"})
|
||||||
void errors() throws QueueException, TimeoutException {
|
void errors() throws QueueException, TimeoutException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests", "finally-parallel", null,
|
"io.kestra.tests", "finally-parallel", null,
|
||||||
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
|
||||||
Duration.ofSeconds(60)
|
Duration.ofSeconds(60)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static io.kestra.core.utils.Rethrow.throwRunnable;
|
import static io.kestra.core.utils.Rethrow.throwRunnable;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
@@ -148,7 +149,7 @@ public class PauseTest {
|
|||||||
protected QueueInterface<Execution> executionQueue;
|
protected QueueInterface<Execution> executionQueue;
|
||||||
|
|
||||||
public void run(RunnerUtils runnerUtils) throws Exception {
|
public void run(RunnerUtils runnerUtils) throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause", null, null, Duration.ofSeconds(30));
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause", null, null, Duration.ofSeconds(30));
|
||||||
String executionId = execution.getId();
|
String executionId = execution.getId();
|
||||||
Flow flow = flowRepository.findByExecution(execution);
|
Flow flow = flowRepository.findByExecution(execution);
|
||||||
|
|
||||||
@@ -173,7 +174,7 @@ public class PauseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runDelay(RunnerUtils runnerUtils) throws Exception {
|
public void runDelay(RunnerUtils runnerUtils) throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause-delay", null, null, Duration.ofSeconds(30));
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause-delay", null, null, Duration.ofSeconds(30));
|
||||||
String executionId = execution.getId();
|
String executionId = execution.getId();
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
|
||||||
@@ -191,7 +192,7 @@ public class PauseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runDurationFromInput(RunnerUtils runnerUtils) throws Exception {
|
public void runDurationFromInput(RunnerUtils runnerUtils) throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause-duration-from-input", null, null, Duration.ofSeconds(30));
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause-duration-from-input", null, null, Duration.ofSeconds(30));
|
||||||
String executionId = execution.getId();
|
String executionId = execution.getId();
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
|
||||||
@@ -209,14 +210,14 @@ public class PauseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runParallelDelay(RunnerUtils runnerUtils) throws TimeoutException, QueueException {
|
public void runParallelDelay(RunnerUtils runnerUtils) throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "each-parallel-pause", Duration.ofSeconds(30));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "each-parallel-pause", Duration.ofSeconds(30));
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getTaskRunList()).hasSize(7);
|
assertThat(execution.getTaskRunList()).hasSize(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runTimeout(RunnerUtils runnerUtils) throws Exception {
|
public void runTimeout(RunnerUtils runnerUtils) throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause-timeout", null, null, Duration.ofSeconds(30));
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause-timeout", null, null, Duration.ofSeconds(30));
|
||||||
String executionId = execution.getId();
|
String executionId = execution.getId();
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
|
||||||
@@ -235,7 +236,7 @@ public class PauseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runEmptyTasks(RunnerUtils runnerUtils) throws Exception {
|
public void runEmptyTasks(RunnerUtils runnerUtils) throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause_no_tasks", null, null, Duration.ofSeconds(30));
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause_no_tasks", null, null, Duration.ofSeconds(30));
|
||||||
String executionId = execution.getId();
|
String executionId = execution.getId();
|
||||||
Flow flow = flowRepository.findByExecution(execution);
|
Flow flow = flowRepository.findByExecution(execution);
|
||||||
|
|
||||||
@@ -261,7 +262,7 @@ public class PauseTest {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void runOnResume(RunnerUtils runnerUtils) throws Exception {
|
public void runOnResume(RunnerUtils runnerUtils) throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause_on_resume", null, null, Duration.ofSeconds(30));
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause_on_resume", null, null, Duration.ofSeconds(30));
|
||||||
String executionId = execution.getId();
|
String executionId = execution.getId();
|
||||||
Flow flow = flowRepository.findByExecution(execution);
|
Flow flow = flowRepository.findByExecution(execution);
|
||||||
|
|
||||||
@@ -293,11 +294,11 @@ public class PauseTest {
|
|||||||
Map<String, Object> outputs = (Map<String, Object>) execution.findTaskRunsByTaskId("last").getFirst().getOutputs().get("values");
|
Map<String, Object> outputs = (Map<String, Object>) execution.findTaskRunsByTaskId("last").getFirst().getOutputs().get("values");
|
||||||
assertThat(outputs.get("asked")).isEqualTo("restarted");
|
assertThat(outputs.get("asked")).isEqualTo("restarted");
|
||||||
assertThat((String) outputs.get("data")).startsWith("kestra://");
|
assertThat((String) outputs.get("data")).startsWith("kestra://");
|
||||||
assertThat(CharStreams.toString(new InputStreamReader(storageInterface.get(null, null, URI.create((String) outputs.get("data")))))).isEqualTo(executionId);
|
assertThat(CharStreams.toString(new InputStreamReader(storageInterface.get(MAIN_TENANT, null, URI.create((String) outputs.get("data")))))).isEqualTo(executionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runOnResumeMissingInputs(RunnerUtils runnerUtils) throws Exception {
|
public void runOnResumeMissingInputs(RunnerUtils runnerUtils) throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause_on_resume", null, null, Duration.ofSeconds(30));
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause_on_resume", null, null, Duration.ofSeconds(30));
|
||||||
Flow flow = flowRepository.findByExecution(execution);
|
Flow flow = flowRepository.findByExecution(execution);
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
|
||||||
@@ -312,7 +313,7 @@ public class PauseTest {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void runOnResumeOptionalInputs(RunnerUtils runnerUtils) throws Exception {
|
public void runOnResumeOptionalInputs(RunnerUtils runnerUtils) throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause_on_resume_optional", null, null, Duration.ofSeconds(30));
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause_on_resume_optional", null, null, Duration.ofSeconds(30));
|
||||||
String executionId = execution.getId();
|
String executionId = execution.getId();
|
||||||
Flow flow = flowRepository.findByExecution(execution);
|
Flow flow = flowRepository.findByExecution(execution);
|
||||||
|
|
||||||
@@ -333,7 +334,7 @@ public class PauseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runDurationWithBehavior(RunnerUtils runnerUtils, Pause.Behavior behavior) throws Exception {
|
public void runDurationWithBehavior(RunnerUtils runnerUtils, Pause.Behavior behavior) throws Exception {
|
||||||
Execution execution = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause-behavior", null, (unused, _unused) -> Map.of("behavior", behavior), Duration.ofSeconds(30));
|
Execution execution = runnerUtils.runOneUntilPaused(MAIN_TENANT, "io.kestra.tests", "pause-behavior", null, (unused, _unused) -> Map.of("behavior", behavior), Duration.ofSeconds(30));
|
||||||
String executionId = execution.getId();
|
String executionId = execution.getId();
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import java.util.concurrent.CountDownLatch;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -86,7 +87,7 @@ public class RetryCaseTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
runnerUtils.runOne(
|
runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"retry-new-execution-task-duration",
|
"retry-new-execution-task-duration",
|
||||||
null,
|
null,
|
||||||
@@ -113,7 +114,7 @@ public class RetryCaseTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
runnerUtils.runOne(
|
runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"retry-new-execution-task-attempts",
|
"retry-new-execution-task-attempts",
|
||||||
null,
|
null,
|
||||||
@@ -140,7 +141,7 @@ public class RetryCaseTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
runnerUtils.runOne(
|
runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"retry-new-execution-flow-duration",
|
"retry-new-execution-flow-duration",
|
||||||
null,
|
null,
|
||||||
@@ -167,7 +168,7 @@ public class RetryCaseTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
runnerUtils.runOne(
|
runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"retry-new-execution-flow-attempts",
|
"retry-new-execution-flow-attempts",
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.flow;
|
package io.kestra.plugin.core.flow;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ class RuntimeLabelsTest {
|
|||||||
@LoadFlows({"flows/valids/labels-update-task.yml"})
|
@LoadFlows({"flows/valids/labels-update-task.yml"})
|
||||||
void update() throws TimeoutException, QueueException {
|
void update() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"labels-update-task",
|
"labels-update-task",
|
||||||
null,
|
null,
|
||||||
@@ -75,7 +76,7 @@ class RuntimeLabelsTest {
|
|||||||
@LoadFlows({"flows/valids/primitive-labels-flow.yml"})
|
@LoadFlows({"flows/valids/primitive-labels-flow.yml"})
|
||||||
void primitiveTypeLabels() throws TimeoutException, QueueException {
|
void primitiveTypeLabels() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"primitive-labels-flow",
|
"primitive-labels-flow",
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.flow;
|
package io.kestra.plugin.core.flow;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@@ -29,17 +30,17 @@ class StateTest {
|
|||||||
void set() throws TimeoutException, QueueException {
|
void set() throws TimeoutException, QueueException {
|
||||||
String stateName = IdUtils.create();
|
String stateName = IdUtils.create();
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "state", null, (f, e) -> ImmutableMap.of("state", stateName));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "state", null, (f, e) -> ImmutableMap.of("state", stateName));
|
||||||
assertThat(execution.getTaskRunList()).hasSize(5);
|
assertThat(execution.getTaskRunList()).hasSize(5);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(((Map<String, Integer>) execution.findTaskRunsByTaskId("createGet").getFirst().getOutputs().get("data")).get("value")).isEqualTo(1);
|
assertThat(((Map<String, Integer>) execution.findTaskRunsByTaskId("createGet").getFirst().getOutputs().get("data")).get("value")).isEqualTo(1);
|
||||||
|
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests", "state", null, (f, e) -> ImmutableMap.of("state", stateName));
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "state", null, (f, e) -> ImmutableMap.of("state", stateName));
|
||||||
assertThat(execution.getTaskRunList()).hasSize(5);
|
assertThat(execution.getTaskRunList()).hasSize(5);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(((Map<String, Object>) execution.findTaskRunsByTaskId("updateGet").getFirst().getOutputs().get("data")).get("value")).isEqualTo("2");
|
assertThat(((Map<String, Object>) execution.findTaskRunsByTaskId("updateGet").getFirst().getOutputs().get("data")).get("value")).isEqualTo("2");
|
||||||
|
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests", "state", null, (f, e) -> ImmutableMap.of("state", stateName));
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "state", null, (f, e) -> ImmutableMap.of("state", stateName));
|
||||||
assertThat(execution.getTaskRunList()).hasSize(5);
|
assertThat(execution.getTaskRunList()).hasSize(5);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat((Integer) execution.findTaskRunsByTaskId("deleteGet").getFirst().getOutputs().get("count")).isZero();
|
assertThat((Integer) execution.findTaskRunsByTaskId("deleteGet").getFirst().getOutputs().get("count")).isZero();
|
||||||
@@ -50,7 +51,7 @@ class StateTest {
|
|||||||
@LoadFlows({"flows/valids/state.yaml"})
|
@LoadFlows({"flows/valids/state.yaml"})
|
||||||
void each() throws TimeoutException, InternalException, QueueException {
|
void each() throws TimeoutException, InternalException, QueueException {
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "state", null, (f, e) -> ImmutableMap.of("state", "each"));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "state", null, (f, e) -> ImmutableMap.of("state", "each"));
|
||||||
assertThat(execution.getTaskRunList()).hasSize(17);
|
assertThat(execution.getTaskRunList()).hasSize(17);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(((Map<String, String>) execution.findTaskRunByTaskIdAndValue("regetEach1", List.of("b")).getOutputs().get("data")).get("value")).isEqualTo("null-b");
|
assertThat(((Map<String, String>) execution.findTaskRunByTaskIdAndValue("regetEach1", List.of("b")).getOutputs().get("data")).get("value")).isEqualTo("null-b");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.flow;
|
package io.kestra.plugin.core.flow;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@@ -23,7 +24,7 @@ class SwitchTest {
|
|||||||
@LoadFlows({"flows/valids/switch.yaml"})
|
@LoadFlows({"flows/valids/switch.yaml"})
|
||||||
void switchFirst() throws TimeoutException, QueueException {
|
void switchFirst() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"switch",
|
"switch",
|
||||||
null,
|
null,
|
||||||
@@ -39,7 +40,7 @@ class SwitchTest {
|
|||||||
@LoadFlows({"flows/valids/switch.yaml"})
|
@LoadFlows({"flows/valids/switch.yaml"})
|
||||||
void switchSecond() throws TimeoutException, QueueException {
|
void switchSecond() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"switch",
|
"switch",
|
||||||
null,
|
null,
|
||||||
@@ -56,7 +57,7 @@ class SwitchTest {
|
|||||||
@LoadFlows({"flows/valids/switch.yaml"})
|
@LoadFlows({"flows/valids/switch.yaml"})
|
||||||
void switchThird() throws TimeoutException, QueueException {
|
void switchThird() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"switch",
|
"switch",
|
||||||
null,
|
null,
|
||||||
@@ -74,7 +75,7 @@ class SwitchTest {
|
|||||||
@LoadFlows({"flows/valids/switch.yaml"})
|
@LoadFlows({"flows/valids/switch.yaml"})
|
||||||
void switchDefault() throws TimeoutException, QueueException {
|
void switchDefault() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"switch",
|
"switch",
|
||||||
null,
|
null,
|
||||||
@@ -90,7 +91,7 @@ class SwitchTest {
|
|||||||
@LoadFlows({"flows/valids/switch-impossible.yaml"})
|
@LoadFlows({"flows/valids/switch-impossible.yaml"})
|
||||||
void switchImpossible() throws TimeoutException, QueueException {
|
void switchImpossible() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"switch-impossible",
|
"switch-impossible",
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
@@ -49,6 +50,7 @@ public class TemplateTest {
|
|||||||
public static final io.kestra.core.models.templates.Template TEMPLATE_1 = io.kestra.core.models.templates.Template.builder()
|
public static final io.kestra.core.models.templates.Template TEMPLATE_1 = io.kestra.core.models.templates.Template.builder()
|
||||||
.id("template")
|
.id("template")
|
||||||
.namespace("io.kestra.tests")
|
.namespace("io.kestra.tests")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.tasks(Collections.singletonList(Log.builder().id("test").type(Log.class.getName()).message("{{ parent.outputs.args['my-forward'] }}").build())).build();
|
.tasks(Collections.singletonList(Log.builder().id("test").type(Log.class.getName()).message("{{ parent.outputs.args['my-forward'] }}").build())).build();
|
||||||
|
|
||||||
public static void withTemplate(
|
public static void withTemplate(
|
||||||
@@ -62,7 +64,7 @@ public class TemplateTest {
|
|||||||
Flux<LogEntry> receive = TestsUtils.receive(logQueue, either -> logs.add(either.getLeft()));
|
Flux<LogEntry> receive = TestsUtils.receive(logQueue, either -> logs.add(either.getLeft()));
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(
|
Execution execution = runnerUtils.runOne(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
"io.kestra.tests",
|
"io.kestra.tests",
|
||||||
"with-template",
|
"with-template",
|
||||||
null,
|
null,
|
||||||
@@ -92,7 +94,7 @@ public class TemplateTest {
|
|||||||
List<LogEntry> logs = new CopyOnWriteArrayList<>();
|
List<LogEntry> logs = new CopyOnWriteArrayList<>();
|
||||||
Flux<LogEntry> receive = TestsUtils.receive(logQueue, either -> logs.add(either.getLeft()));
|
Flux<LogEntry> receive = TestsUtils.receive(logQueue, either -> logs.add(either.getLeft()));
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "with-failed-template", Duration.ofSeconds(60));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "with-failed-template", Duration.ofSeconds(60));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.flow;
|
package io.kestra.plugin.core.flow;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import io.kestra.core.junit.annotations.ExecuteFlow;
|
import io.kestra.core.junit.annotations.ExecuteFlow;
|
||||||
@@ -49,7 +50,7 @@ class VariablesTest {
|
|||||||
List<LogEntry> logs = new CopyOnWriteArrayList<>();
|
List<LogEntry> logs = new CopyOnWriteArrayList<>();
|
||||||
Flux<LogEntry> receive = TestsUtils.receive(workerTaskLogQueue, either -> logs.add(either.getLeft()));
|
Flux<LogEntry> receive = TestsUtils.receive(workerTaskLogQueue, either -> logs.add(either.getLeft()));
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "variables-invalid");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "variables-invalid");
|
||||||
|
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
|
|||||||
@@ -3,24 +3,22 @@ package io.kestra.plugin.core.flow;
|
|||||||
import io.kestra.core.models.executions.Execution;
|
import io.kestra.core.models.executions.Execution;
|
||||||
import io.kestra.core.models.flows.State;
|
import io.kestra.core.models.flows.State;
|
||||||
import io.kestra.core.queues.QueueException;
|
import io.kestra.core.queues.QueueException;
|
||||||
import io.kestra.core.repositories.FlowRepositoryInterface;
|
|
||||||
import io.kestra.core.runners.RunnerUtils;
|
import io.kestra.core.runners.RunnerUtils;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
public class WaitForCaseTest {
|
public class WaitForCaseTest {
|
||||||
@Inject
|
|
||||||
FlowRepositoryInterface flowRepository;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected RunnerUtils runnerUtils;
|
protected RunnerUtils runnerUtils;
|
||||||
|
|
||||||
public void waitfor() throws TimeoutException, QueueException {
|
public void waitfor() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "waitfor");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "waitfor");
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getTaskRunList().getFirst().getOutputs()).isNotNull();
|
assertThat(execution.getTaskRunList().getFirst().getOutputs()).isNotNull();
|
||||||
@@ -28,7 +26,7 @@ public class WaitForCaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void waitforMaxIterations() throws TimeoutException, QueueException {
|
public void waitforMaxIterations() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "waitfor-max-iterations");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "waitfor-max-iterations");
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
assertThat(execution.getTaskRunList().getFirst().getOutputs()).isNotNull();
|
assertThat(execution.getTaskRunList().getFirst().getOutputs()).isNotNull();
|
||||||
@@ -36,13 +34,13 @@ public class WaitForCaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void waitforMaxDuration() throws TimeoutException, QueueException {
|
public void waitforMaxDuration() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "waitfor-max-duration");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "waitfor-max-duration");
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitforNoSuccess() throws TimeoutException, QueueException {
|
public void waitforNoSuccess() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "waitfor-no-success");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "waitfor-no-success");
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getTaskRunList().getFirst().getOutputs()).isNotNull();
|
assertThat(execution.getTaskRunList().getFirst().getOutputs()).isNotNull();
|
||||||
@@ -51,7 +49,7 @@ public class WaitForCaseTest {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void waitforMultipleTasks() throws TimeoutException, QueueException {
|
public void waitforMultipleTasks() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "waitfor-multiple-tasks");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "waitfor-multiple-tasks");
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
|
|
||||||
@@ -62,14 +60,14 @@ public class WaitForCaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void waitforMultipleTasksFailed() throws TimeoutException, QueueException {
|
public void waitforMultipleTasksFailed() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "waitfor-multiple-tasks-failed");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "waitfor-multiple-tasks-failed");
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
assertThat(execution.getTaskRunList().getLast().attemptNumber()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().getLast().attemptNumber()).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitForChildTaskWarning() throws TimeoutException, QueueException {
|
public void waitForChildTaskWarning() throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "waitfor-child-task-warning");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "waitfor-child-task-warning");
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
|
||||||
assertThat((Integer) execution.getTaskRunList().getFirst().getOutputs().get("iterationCount")).isGreaterThan(1);
|
assertThat((Integer) execution.getTaskRunList().getFirst().getOutputs().get("iterationCount")).isGreaterThan(1);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.flow;
|
package io.kestra.plugin.core.flow;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@@ -116,7 +117,7 @@ public class WorkingDirectoryTest {
|
|||||||
StorageInterface storageInterface;
|
StorageInterface storageInterface;
|
||||||
|
|
||||||
public void success(RunnerUtils runnerUtils) throws TimeoutException, QueueException {
|
public void success(RunnerUtils runnerUtils) throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory", null,
|
||||||
(f, e) -> ImmutableMap.of("failed", "false"), Duration.ofSeconds(60)
|
(f, e) -> ImmutableMap.of("failed", "false"), Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -126,7 +127,7 @@ public class WorkingDirectoryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void failed(RunnerUtils runnerUtils) throws TimeoutException, QueueException {
|
public void failed(RunnerUtils runnerUtils) throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory", null,
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory", null,
|
||||||
(f, e) -> ImmutableMap.of("failed", "true"), Duration.ofSeconds(60)
|
(f, e) -> ImmutableMap.of("failed", "true"), Duration.ofSeconds(60)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -136,7 +137,7 @@ public class WorkingDirectoryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void each(RunnerUtils runnerUtils) throws TimeoutException, QueueException {
|
public void each(RunnerUtils runnerUtils) throws TimeoutException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory-each", Duration.ofSeconds(60));
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory-each", Duration.ofSeconds(60));
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(8);
|
assertThat(execution.getTaskRunList()).hasSize(8);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
@@ -146,7 +147,7 @@ public class WorkingDirectoryTest {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void outputFiles(RunnerUtils runnerUtils) throws TimeoutException, IOException, QueueException {
|
public void outputFiles(RunnerUtils runnerUtils) throws TimeoutException, IOException, QueueException {
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory-outputs");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory-outputs");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
@@ -173,7 +174,7 @@ public class WorkingDirectoryTest {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void inputFiles(RunnerUtils runnerUtils) throws TimeoutException, IOException, QueueException {
|
public void inputFiles(RunnerUtils runnerUtils) throws TimeoutException, IOException, QueueException {
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory-inputs");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory-inputs");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(2);
|
assertThat(execution.getTaskRunList()).hasSize(2);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
@@ -203,6 +204,7 @@ public class WorkingDirectoryTest {
|
|||||||
.builder()
|
.builder()
|
||||||
.namespace("io.kestra.tests")
|
.namespace("io.kestra.tests")
|
||||||
.id("working-directory-cache")
|
.id("working-directory-cache")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
InternalStorage storage = new InternalStorage(
|
InternalStorage storage = new InternalStorage(
|
||||||
@@ -214,9 +216,9 @@ public class WorkingDirectoryTest {
|
|||||||
storage.deleteCacheFile("workingDir", null);
|
storage.deleteCacheFile("workingDir", null);
|
||||||
|
|
||||||
URI cacheURI = storageContext.getCacheURI("workingdir", null);
|
URI cacheURI = storageContext.getCacheURI("workingdir", null);
|
||||||
assertFalse(storageInterface.exists(null, null, cacheURI));
|
assertFalse(storageInterface.exists(MAIN_TENANT, null, cacheURI));
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory-cache");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory-cache");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
assertThat(execution.getTaskRunList().stream()
|
assertThat(execution.getTaskRunList().stream()
|
||||||
@@ -224,10 +226,10 @@ public class WorkingDirectoryTest {
|
|||||||
.findFirst().get()
|
.findFirst().get()
|
||||||
.getOutputs()).containsAllEntriesOf(Map.of("uris", Collections.emptyMap()));
|
.getOutputs()).containsAllEntriesOf(Map.of("uris", Collections.emptyMap()));
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertTrue(storageInterface.exists(null, null, cacheURI));
|
assertTrue(storageInterface.exists(MAIN_TENANT, null, cacheURI));
|
||||||
|
|
||||||
// a second run should use the cache so the task `exists` should output the cached file
|
// a second run should use the cache so the task `exists` should output the cached file
|
||||||
execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory-cache");
|
execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory-cache");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
assertThat(((Map<String, String>) execution.getTaskRunList().stream()
|
assertThat(((Map<String, String>) execution.getTaskRunList().stream()
|
||||||
@@ -240,7 +242,7 @@ public class WorkingDirectoryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void taskRun(RunnerUtils runnerUtils) throws TimeoutException, InternalException, QueueException {
|
public void taskRun(RunnerUtils runnerUtils) throws TimeoutException, InternalException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory-taskrun");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory-taskrun");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
@@ -248,7 +250,7 @@ public class WorkingDirectoryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void taskRunNested(RunnerUtils runnerUtils) throws TimeoutException, InternalException, QueueException {
|
public void taskRunNested(RunnerUtils runnerUtils) throws TimeoutException, InternalException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory-taskrun-nested");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory-taskrun-nested");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(6);
|
assertThat(execution.getTaskRunList()).hasSize(6);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
@@ -261,7 +263,7 @@ public class WorkingDirectoryTest {
|
|||||||
put("/a/b/3.txt", "third");
|
put("/a/b/3.txt", "third");
|
||||||
put("/ignore/4.txt", "4th");
|
put("/ignore/4.txt", "4th");
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory-namespace-files");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory-namespace-files");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(6);
|
assertThat(execution.getTaskRunList()).hasSize(6);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.WARNING);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.WARNING);
|
||||||
@@ -285,7 +287,7 @@ public class WorkingDirectoryTest {
|
|||||||
//third namespace
|
//third namespace
|
||||||
put("/test/a/b/c/1.txt", "first in third namespace", "io.test.third");
|
put("/test/a/b/c/1.txt", "first in third namespace", "io.test.third");
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory-namespace-files-with-namespaces");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory-namespace-files-with-namespaces");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(6);
|
assertThat(execution.getTaskRunList()).hasSize(6);
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.WARNING);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.WARNING);
|
||||||
@@ -297,7 +299,7 @@ public class WorkingDirectoryTest {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void encryption(RunnerUtils runnerUtils, RunContextFactory runContextFactory) throws TimeoutException, GeneralSecurityException, QueueException {
|
public void encryption(RunnerUtils runnerUtils, RunContextFactory runContextFactory) throws TimeoutException, GeneralSecurityException, QueueException {
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory-taskrun-encrypted");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "working-directory-taskrun-encrypted");
|
||||||
|
|
||||||
assertThat(execution.getTaskRunList()).hasSize(3);
|
assertThat(execution.getTaskRunList()).hasSize(3);
|
||||||
Map<String, Object> encryptedString = (Map<String, Object>) execution.findTaskRunsByTaskId("encrypted").getFirst().getOutputs().get("value");
|
Map<String, Object> encryptedString = (Map<String, Object>) execution.findTaskRunsByTaskId("encrypted").getFirst().getOutputs().get("value");
|
||||||
@@ -314,7 +316,7 @@ public class WorkingDirectoryTest {
|
|||||||
|
|
||||||
private void put(String path, String content, String namespace) throws IOException {
|
private void put(String path, String content, String namespace) throws IOException {
|
||||||
storageInterface.put(
|
storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
URI.create(StorageContext.namespaceFilePrefix(namespace) + path),
|
URI.create(StorageContext.namespaceFilePrefix(namespace) + path),
|
||||||
new ByteArrayInputStream(content.getBytes())
|
new ByteArrayInputStream(content.getBytes())
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.kestra.plugin.core.http;
|
package io.kestra.plugin.core.http;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.http.client.HttpClientResponseException;
|
import io.kestra.core.http.client.HttpClientResponseException;
|
||||||
import io.kestra.core.http.client.configurations.HttpConfiguration;
|
import io.kestra.core.http.client.configurations.HttpConfiguration;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
@@ -26,6 +27,7 @@ import java.net.URI;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
@@ -34,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||||||
class DownloadTest {
|
class DownloadTest {
|
||||||
public static final String FILE = "https://sampletestfile.com/wp-content/uploads/2023/07/500KB-CSV.csv";
|
public static final String FILE = "https://sampletestfile.com/wp-content/uploads/2023/07/500KB-CSV.csv";
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private StorageInterface storageInterface;
|
private StorageInterface storageInterface;
|
||||||
@@ -54,7 +56,7 @@ class DownloadTest {
|
|||||||
|
|
||||||
Download.Output output = task.run(runContext);
|
Download.Output output = task.run(runContext);
|
||||||
|
|
||||||
assertThat(IOUtils.toString(this.storageInterface.get(null, null, output.getUri()), StandardCharsets.UTF_8)).isEqualTo(IOUtils.toString(new URI(FILE).toURL().openStream(), StandardCharsets.UTF_8));
|
assertThat(IOUtils.toString(this.storageInterface.get(MAIN_TENANT, null, output.getUri()), StandardCharsets.UTF_8)).isEqualTo(IOUtils.toString(new URI(FILE).toURL().openStream(), StandardCharsets.UTF_8));
|
||||||
assertThat(output.getUri().toString()).endsWith(".csv");
|
assertThat(output.getUri().toString()).endsWith(".csv");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +97,7 @@ class DownloadTest {
|
|||||||
Download.Output output = assertDoesNotThrow(() -> task.run(runContext));
|
Download.Output output = assertDoesNotThrow(() -> task.run(runContext));
|
||||||
|
|
||||||
assertThat(output.getLength()).isEqualTo(0L);
|
assertThat(output.getLength()).isEqualTo(0L);
|
||||||
assertThat(IOUtils.toString(this.storageInterface.get(null, null, output.getUri()), StandardCharsets.UTF_8)).isEqualTo("");
|
assertThat(IOUtils.toString(this.storageInterface.get(MAIN_TENANT, null, output.getUri()), StandardCharsets.UTF_8)).isEqualTo("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -134,7 +136,7 @@ class DownloadTest {
|
|||||||
|
|
||||||
Download.Output output = task.run(runContext);
|
Download.Output output = task.run(runContext);
|
||||||
|
|
||||||
assertThat(this.storageInterface.get(null, null, output.getUri()).readAllBytes().length).isEqualTo(10000 * 12);
|
assertThat(this.storageInterface.get(MAIN_TENANT, null, output.getUri()).readAllBytes().length).isEqualTo(10000 * 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.kestra.plugin.core.http;
|
|||||||
|
|
||||||
import com.devskiller.friendly_id.FriendlyId;
|
import com.devskiller.friendly_id.FriendlyId;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.http.client.HttpClientRequestException;
|
import io.kestra.core.http.client.HttpClientRequestException;
|
||||||
import io.kestra.core.http.client.HttpClientResponseException;
|
import io.kestra.core.http.client.HttpClientResponseException;
|
||||||
import io.kestra.core.http.client.configurations.*;
|
import io.kestra.core.http.client.configurations.*;
|
||||||
@@ -36,6 +37,7 @@ import java.util.Base64;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static io.kestra.core.utils.Rethrow.throwFunction;
|
import static io.kestra.core.utils.Rethrow.throwFunction;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
@@ -43,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||||||
@KestraTest
|
@KestraTest
|
||||||
class RequestTest {
|
class RequestTest {
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private StorageInterface storageInterface;
|
private StorageInterface storageInterface;
|
||||||
@@ -356,7 +358,7 @@ class RequestTest {
|
|||||||
File file = new File(Objects.requireNonNull(RequestTest.class.getClassLoader().getResource("application-test.yml")).toURI());
|
File file = new File(Objects.requireNonNull(RequestTest.class.getClassLoader().getResource("application-test.yml")).toURI());
|
||||||
|
|
||||||
URI fileStorage = storageInterface.put(
|
URI fileStorage = storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/" + FriendlyId.createFriendlyId()),
|
new URI("/" + FriendlyId.createFriendlyId()),
|
||||||
new FileInputStream(file)
|
new FileInputStream(file)
|
||||||
@@ -390,7 +392,7 @@ class RequestTest {
|
|||||||
File file = new File(Objects.requireNonNull(RequestTest.class.getClassLoader().getResource("application-test.yml")).toURI());
|
File file = new File(Objects.requireNonNull(RequestTest.class.getClassLoader().getResource("application-test.yml")).toURI());
|
||||||
|
|
||||||
URI fileStorage = storageInterface.put(
|
URI fileStorage = storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/" + FriendlyId.createFriendlyId()),
|
new URI("/" + FriendlyId.createFriendlyId()),
|
||||||
new FileInputStream(file)
|
new FileInputStream(file)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class TriggerTest {
|
|||||||
|
|
||||||
worker.run();
|
worker.run();
|
||||||
scheduler.run();
|
scheduler.run();
|
||||||
repositoryLoader.load(null, Objects.requireNonNull(TriggerTest.class.getClassLoader().getResource("flows/valids/http-listen.yaml")));
|
repositoryLoader.load(Objects.requireNonNull(TriggerTest.class.getClassLoader().getResource("flows/valids/http-listen.yaml")));
|
||||||
|
|
||||||
assertTrue(queueCount.await(1, TimeUnit.MINUTES));
|
assertTrue(queueCount.await(1, TimeUnit.MINUTES));
|
||||||
receive.blockLast();
|
receive.blockLast();
|
||||||
@@ -89,7 +89,7 @@ class TriggerTest {
|
|||||||
|
|
||||||
worker.run();
|
worker.run();
|
||||||
scheduler.run();
|
scheduler.run();
|
||||||
repositoryLoader.load(null, Objects.requireNonNull(TriggerTest.class.getClassLoader().getResource("flows/valids/http-listen-encrypted.yaml")));
|
repositoryLoader.load(Objects.requireNonNull(TriggerTest.class.getClassLoader().getResource("flows/valids/http-listen-encrypted.yaml")));
|
||||||
|
|
||||||
assertTrue(queueCount.await(1, TimeUnit.MINUTES));
|
assertTrue(queueCount.await(1, TimeUnit.MINUTES));
|
||||||
worker.shutdown();
|
worker.shutdown();
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import io.kestra.core.junit.annotations.LoadFlows;
|
|||||||
import io.kestra.core.models.executions.Execution;
|
import io.kestra.core.models.executions.Execution;
|
||||||
import io.kestra.core.models.executions.LogEntry;
|
import io.kestra.core.models.executions.LogEntry;
|
||||||
import io.kestra.core.repositories.LogRepositoryInterface;
|
import io.kestra.core.repositories.LogRepositoryInterface;
|
||||||
import io.kestra.core.runners.RunContextFactory;
|
|
||||||
import io.kestra.core.runners.RunnerUtils;
|
import io.kestra.core.runners.RunnerUtils;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
@@ -18,13 +17,12 @@ import org.slf4j.event.Level;
|
|||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@KestraTest(startRunner = true)
|
@KestraTest(startRunner = true)
|
||||||
class PurgeLogsTest {
|
class PurgeLogsTest {
|
||||||
@Inject
|
|
||||||
private RunContextFactory runContextFactory;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private LogRepositoryInterface logRepository;
|
private LogRepositoryInterface logRepository;
|
||||||
@@ -39,13 +37,14 @@ class PurgeLogsTest {
|
|||||||
var logEntry = LogEntry.builder()
|
var logEntry = LogEntry.builder()
|
||||||
.namespace("namespace")
|
.namespace("namespace")
|
||||||
.flowId("flowId")
|
.flowId("flowId")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.timestamp(Instant.now())
|
.timestamp(Instant.now())
|
||||||
.level(Level.INFO)
|
.level(Level.INFO)
|
||||||
.message("Hello World")
|
.message("Hello World")
|
||||||
.build();
|
.build();
|
||||||
logRepository.save(logEntry);
|
logRepository.save(logEntry);
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "purge_logs_no_arguments");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "purge_logs_no_arguments");
|
||||||
|
|
||||||
assertTrue(execution.getState().isSuccess());
|
assertTrue(execution.getState().isSuccess());
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
@@ -59,7 +58,7 @@ class PurgeLogsTest {
|
|||||||
void run_with_full_arguments(LogEntry logEntry, int resultCount, String failingReason) throws Exception {
|
void run_with_full_arguments(LogEntry logEntry, int resultCount, String failingReason) throws Exception {
|
||||||
logRepository.save(logEntry);
|
logRepository.save(logEntry);
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "purge_logs_full_arguments");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "purge_logs_full_arguments");
|
||||||
|
|
||||||
assertTrue(execution.getState().isSuccess());
|
assertTrue(execution.getState().isSuccess());
|
||||||
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
|
||||||
@@ -71,6 +70,7 @@ class PurgeLogsTest {
|
|||||||
Arguments.of(LogEntry.builder()
|
Arguments.of(LogEntry.builder()
|
||||||
.namespace("purge.namespace")
|
.namespace("purge.namespace")
|
||||||
.flowId("purgeFlowId")
|
.flowId("purgeFlowId")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.timestamp(Instant.now().plus(5, ChronoUnit.HOURS))
|
.timestamp(Instant.now().plus(5, ChronoUnit.HOURS))
|
||||||
.level(Level.INFO)
|
.level(Level.INFO)
|
||||||
.message("Hello World")
|
.message("Hello World")
|
||||||
@@ -78,6 +78,7 @@ class PurgeLogsTest {
|
|||||||
Arguments.of(LogEntry.builder()
|
Arguments.of(LogEntry.builder()
|
||||||
.namespace("purge.namespace")
|
.namespace("purge.namespace")
|
||||||
.flowId("purgeFlowId")
|
.flowId("purgeFlowId")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.timestamp(Instant.now().minus(5, ChronoUnit.HOURS))
|
.timestamp(Instant.now().minus(5, ChronoUnit.HOURS))
|
||||||
.level(Level.INFO)
|
.level(Level.INFO)
|
||||||
.message("Hello World")
|
.message("Hello World")
|
||||||
@@ -85,6 +86,7 @@ class PurgeLogsTest {
|
|||||||
Arguments.of(LogEntry.builder()
|
Arguments.of(LogEntry.builder()
|
||||||
.namespace("uncorrect.namespace")
|
.namespace("uncorrect.namespace")
|
||||||
.flowId("purgeFlowId")
|
.flowId("purgeFlowId")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.timestamp(Instant.now().minusSeconds(10))
|
.timestamp(Instant.now().minusSeconds(10))
|
||||||
.level(Level.INFO)
|
.level(Level.INFO)
|
||||||
.message("Hello World")
|
.message("Hello World")
|
||||||
@@ -92,6 +94,7 @@ class PurgeLogsTest {
|
|||||||
Arguments.of(LogEntry.builder()
|
Arguments.of(LogEntry.builder()
|
||||||
.namespace("purge.namespace")
|
.namespace("purge.namespace")
|
||||||
.flowId("wrongFlowId")
|
.flowId("wrongFlowId")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.timestamp(Instant.now().minusSeconds(10))
|
.timestamp(Instant.now().minusSeconds(10))
|
||||||
.level(Level.INFO)
|
.level(Level.INFO)
|
||||||
.message("Hello World")
|
.message("Hello World")
|
||||||
@@ -99,6 +102,7 @@ class PurgeLogsTest {
|
|||||||
Arguments.of(LogEntry.builder()
|
Arguments.of(LogEntry.builder()
|
||||||
.namespace("purge.namespace")
|
.namespace("purge.namespace")
|
||||||
.flowId("purgeFlowId")
|
.flowId("purgeFlowId")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.timestamp(Instant.now().minusSeconds(10))
|
.timestamp(Instant.now().minusSeconds(10))
|
||||||
.level(Level.WARN)
|
.level(Level.WARN)
|
||||||
.message("Hello World")
|
.message("Hello World")
|
||||||
@@ -106,6 +110,7 @@ class PurgeLogsTest {
|
|||||||
Arguments.of(LogEntry.builder()
|
Arguments.of(LogEntry.builder()
|
||||||
.namespace("purge.namespace")
|
.namespace("purge.namespace")
|
||||||
.flowId("purgeFlowId")
|
.flowId("purgeFlowId")
|
||||||
|
.tenantId(MAIN_TENANT)
|
||||||
.timestamp(Instant.now().minusSeconds(10))
|
.timestamp(Instant.now().minusSeconds(10))
|
||||||
.level(Level.INFO)
|
.level(Level.INFO)
|
||||||
.message("Hello World")
|
.message("Hello World")
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.metric;
|
package io.kestra.plugin.core.metric;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
import io.kestra.core.models.property.Property;
|
import io.kestra.core.models.property.Property;
|
||||||
import io.kestra.core.models.tasks.metrics.CounterMetric;
|
import io.kestra.core.models.tasks.metrics.CounterMetric;
|
||||||
@@ -19,7 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@KestraTest
|
@KestraTest
|
||||||
public class PublishTest {
|
public class PublishTest {
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ public class UploadFilesTest {
|
|||||||
File file = new File(Objects.requireNonNull(UploadFilesTest.class.getClassLoader().getResource("application-test.yml")).toURI());
|
File file = new File(Objects.requireNonNull(UploadFilesTest.class.getClassLoader().getResource("application-test.yml")).toURI());
|
||||||
|
|
||||||
URI fileStorage = storageInterface.put(
|
URI fileStorage = storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/" + FriendlyId.createFriendlyId()),
|
new URI("/" + FriendlyId.createFriendlyId()),
|
||||||
new FileInputStream(file)
|
new FileInputStream(file)
|
||||||
@@ -169,7 +170,7 @@ public class UploadFilesTest {
|
|||||||
File file = new File(Objects.requireNonNull(UploadFilesTest.class.getClassLoader().getResource(fileToLoad)).toURI());
|
File file = new File(Objects.requireNonNull(UploadFilesTest.class.getClassLoader().getResource(fileToLoad)).toURI());
|
||||||
|
|
||||||
return storageInterface.put(
|
return storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/" + FriendlyId.createFriendlyId()),
|
new URI("/" + FriendlyId.createFriendlyId()),
|
||||||
new FileInputStream(file)
|
new FileInputStream(file)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest
|
@KestraTest
|
||||||
@@ -38,7 +39,7 @@ class ConcatTest {
|
|||||||
.toURI());
|
.toURI());
|
||||||
|
|
||||||
URI put = storageInterface.put(
|
URI put = storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/file/storage/get.yml"),
|
new URI("/file/storage/get.yml"),
|
||||||
new FileInputStream(Objects.requireNonNull(resource).getFile())
|
new FileInputStream(Objects.requireNonNull(resource).getFile())
|
||||||
@@ -56,7 +57,7 @@ class ConcatTest {
|
|||||||
String s = CharStreams.toString(new InputStreamReader(new FileInputStream(file)));
|
String s = CharStreams.toString(new InputStreamReader(new FileInputStream(file)));
|
||||||
|
|
||||||
|
|
||||||
assertThat(CharStreams.toString(new InputStreamReader(storageInterface.get(null, null, run.getUri())))).isEqualTo(s + "\n" + s + "\n");
|
assertThat(CharStreams.toString(new InputStreamReader(storageInterface.get(MAIN_TENANT, null, run.getUri())))).isEqualTo(s + "\n" + s + "\n");
|
||||||
assertThat(run.getUri().getPath()).endsWith(".yml");
|
assertThat(run.getUri().getPath()).endsWith(".yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package io.kestra.plugin.core.storage;
|
package io.kestra.plugin.core.storage;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
import io.kestra.core.models.property.Property;
|
import io.kestra.core.models.property.Property;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import io.kestra.core.runners.RunContext;
|
import io.kestra.core.runners.RunContext;
|
||||||
import io.kestra.core.runners.RunContextFactory;
|
|
||||||
import io.kestra.core.storages.StorageInterface;
|
import io.kestra.core.storages.StorageInterface;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -14,13 +14,14 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
@KestraTest
|
@KestraTest
|
||||||
class DeleteTest {
|
class DeleteTest {
|
||||||
@Inject
|
@Inject
|
||||||
RunContextFactory runContextFactory;
|
TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
StorageInterface storageInterface;
|
StorageInterface storageInterface;
|
||||||
@@ -31,7 +32,7 @@ class DeleteTest {
|
|||||||
URL resource = DeleteTest.class.getClassLoader().getResource("application-test.yml");
|
URL resource = DeleteTest.class.getClassLoader().getResource("application-test.yml");
|
||||||
|
|
||||||
URI put = storageInterface.put(
|
URI put = storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/file/storage/get.yml"),
|
new URI("/file/storage/get.yml"),
|
||||||
new FileInputStream(Objects.requireNonNull(resource).getFile())
|
new FileInputStream(Objects.requireNonNull(resource).getFile())
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ class LocalFilesTest {
|
|||||||
var resource = ConcatTest.class.getClassLoader().getResource("application-test.yml");
|
var resource = ConcatTest.class.getClassLoader().getResource("application-test.yml");
|
||||||
|
|
||||||
return storageInterface.put(
|
return storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/file/storage/get.yml"),
|
new URI("/file/storage/get.yml"),
|
||||||
new FileInputStream(Objects.requireNonNull(resource).getFile())
|
new FileInputStream(Objects.requireNonNull(resource).getFile())
|
||||||
@@ -63,10 +64,10 @@ class LocalFilesTest {
|
|||||||
assertThat(outputs).isNotNull();
|
assertThat(outputs).isNotNull();
|
||||||
assertThat(outputs.getUris()).isNotNull();
|
assertThat(outputs.getUris()).isNotNull();
|
||||||
assertThat(outputs.getUris().size()).isEqualTo(1);
|
assertThat(outputs.getUris().size()).isEqualTo(1);
|
||||||
assertThat(new String(storageInterface.get(null, null, outputs.getUris().get("hello-input.txt")).readAllBytes())).isEqualTo("Hello Input");
|
assertThat(new String(storageInterface.get(MAIN_TENANT, null, outputs.getUris().get("hello-input.txt")).readAllBytes())).isEqualTo("Hello Input");
|
||||||
assertThat(runContext.workingDir().path().toFile().list().length).isEqualTo(2);
|
assertThat(runContext.workingDir().path().toFile().list().length).isEqualTo(2);
|
||||||
assertThat(Files.readString(runContext.workingDir().path().resolve("execution.txt"))).isEqualTo("tata");
|
assertThat(Files.readString(runContext.workingDir().path().resolve("execution.txt"))).isEqualTo("tata");
|
||||||
assertThat(Files.readString(runContext.workingDir().path().resolve("application-test.yml"))).isEqualTo(new String(storageInterface.get(null, null, storageFile).readAllBytes()));
|
assertThat(Files.readString(runContext.workingDir().path().resolve("application-test.yml"))).isEqualTo(new String(storageInterface.get(MAIN_TENANT, null, storageFile).readAllBytes()));
|
||||||
|
|
||||||
runContext.cleanup();
|
runContext.cleanup();
|
||||||
}
|
}
|
||||||
@@ -91,11 +92,11 @@ class LocalFilesTest {
|
|||||||
assertThat(outputs).isNotNull();
|
assertThat(outputs).isNotNull();
|
||||||
assertThat(outputs.getUris()).isNotNull();
|
assertThat(outputs.getUris()).isNotNull();
|
||||||
assertThat(outputs.getUris().size()).isEqualTo(3);
|
assertThat(outputs.getUris().size()).isEqualTo(3);
|
||||||
assertThat(new String(storageInterface.get(null, null, outputs.getUris().get("test/hello-input.txt")).readAllBytes())).isEqualTo("Hello Input");
|
assertThat(new String(storageInterface.get(MAIN_TENANT, null, outputs.getUris().get("test/hello-input.txt")).readAllBytes())).isEqualTo("Hello Input");
|
||||||
assertThat(new String(storageInterface.get(null, null, outputs.getUris().get("test/sub/dir/2/execution.txt"))
|
assertThat(new String(storageInterface.get(MAIN_TENANT, null, outputs.getUris().get("test/sub/dir/2/execution.txt"))
|
||||||
.readAllBytes())).isEqualTo("tata");
|
.readAllBytes())).isEqualTo("tata");
|
||||||
assertThat(new String(storageInterface.get(null, null, outputs.getUris().get("test/sub/dir/3/application-test.yml"))
|
assertThat(new String(storageInterface.get(MAIN_TENANT, null, outputs.getUris().get("test/sub/dir/3/application-test.yml"))
|
||||||
.readAllBytes())).isEqualTo(new String(storageInterface.get(null, null, storageFile).readAllBytes()));
|
.readAllBytes())).isEqualTo(new String(storageInterface.get(MAIN_TENANT, null, storageFile).readAllBytes()));
|
||||||
runContext.cleanup();
|
runContext.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.storage;
|
package io.kestra.plugin.core.storage;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
import io.kestra.core.models.flows.Flow;
|
import io.kestra.core.models.flows.Flow;
|
||||||
import io.kestra.core.runners.RunContextFactory;
|
import io.kestra.core.runners.RunContextFactory;
|
||||||
@@ -13,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@KestraTest
|
@KestraTest
|
||||||
class PurgeCurrentExecutionFilesTest {
|
class PurgeCurrentExecutionFilesTest {
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest
|
@KestraTest
|
||||||
@@ -28,7 +29,7 @@ class ReverseTest {
|
|||||||
RunContext runContext = runContextFactory.of();
|
RunContext runContext = runContextFactory.of();
|
||||||
|
|
||||||
URI put = storageInterface.put(
|
URI put = storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/file/storage/get.yml"),
|
new URI("/file/storage/get.yml"),
|
||||||
new ByteArrayInputStream("1\n2\n3\n".getBytes())
|
new ByteArrayInputStream("1\n2\n3\n".getBytes())
|
||||||
@@ -42,6 +43,6 @@ class ReverseTest {
|
|||||||
Reverse.Output run = result.run(runContext);
|
Reverse.Output run = result.run(runContext);
|
||||||
|
|
||||||
assertThat(run.getUri().getPath()).endsWith(".yml");
|
assertThat(run.getUri().getPath()).endsWith(".yml");
|
||||||
assertThat(CharStreams.toString(new InputStreamReader(storageInterface.get(null, null, run.getUri())))).isEqualTo("3\n2\n1\n");
|
assertThat(CharStreams.toString(new InputStreamReader(storageInterface.get(MAIN_TENANT, null, run.getUri())))).isEqualTo("3\n2\n1\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package io.kestra.plugin.core.storage;
|
package io.kestra.plugin.core.storage;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.models.property.Property;
|
import io.kestra.core.models.property.Property;
|
||||||
import io.kestra.core.runners.RunContext;
|
import io.kestra.core.runners.RunContext;
|
||||||
import io.kestra.core.runners.RunContextFactory;
|
|
||||||
import io.kestra.core.storages.StorageInterface;
|
import io.kestra.core.storages.StorageInterface;
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -13,12 +13,13 @@ import java.util.Random;
|
|||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest
|
@KestraTest
|
||||||
class SizeTest {
|
class SizeTest {
|
||||||
@Inject
|
@Inject
|
||||||
RunContextFactory runContextFactory;
|
TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
StorageInterface storageInterface;
|
StorageInterface storageInterface;
|
||||||
@@ -32,7 +33,7 @@ class SizeTest {
|
|||||||
new Random().nextBytes(randomBytes);
|
new Random().nextBytes(randomBytes);
|
||||||
|
|
||||||
URI put = storageInterface.put(
|
URI put = storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/file/storage/get.yml"),
|
new URI("/file/storage/get.yml"),
|
||||||
new ByteArrayInputStream(randomBytes)
|
new ByteArrayInputStream(randomBytes)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest
|
@KestraTest
|
||||||
@@ -91,7 +92,7 @@ class SplitTest {
|
|||||||
private String readAll(List<URI> uris) throws IOException {
|
private String readAll(List<URI> uris) throws IOException {
|
||||||
return uris
|
return uris
|
||||||
.stream()
|
.stream()
|
||||||
.map(Rethrow.throwFunction(uri -> CharStreams.toString(new InputStreamReader(storageInterface.get(null, null, uri)))))
|
.map(Rethrow.throwFunction(uri -> CharStreams.toString(new InputStreamReader(storageInterface.get(MAIN_TENANT, null, uri)))))
|
||||||
.collect(Collectors.joining());
|
.collect(Collectors.joining());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +103,7 @@ class SplitTest {
|
|||||||
Files.write(tempFile.toPath(), content(count));
|
Files.write(tempFile.toPath(), content(count));
|
||||||
|
|
||||||
return storageInterface.put(
|
return storageInterface.put(
|
||||||
null,
|
MAIN_TENANT,
|
||||||
null,
|
null,
|
||||||
new URI("/file/storage/get.yml"),
|
new URI("/file/storage/get.yml"),
|
||||||
new FileInputStream(tempFile)
|
new FileInputStream(tempFile)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@KestraTest
|
@KestraTest
|
||||||
@@ -33,7 +34,7 @@ class WriteTest {
|
|||||||
assertThat(output).isNotNull();
|
assertThat(output).isNotNull();
|
||||||
assertThat(output.getUri()).isNotNull();
|
assertThat(output.getUri()).isNotNull();
|
||||||
|
|
||||||
InputStream inputStream = storageInterface.get(null, null, output.getUri());
|
InputStream inputStream = storageInterface.get(MAIN_TENANT, null, output.getUri());
|
||||||
assertThat(inputStream).isNotNull();
|
assertThat(inputStream).isNotNull();
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.templating;
|
package io.kestra.plugin.core.templating;
|
||||||
|
|
||||||
|
import io.kestra.core.context.TestRunContextFactory;
|
||||||
import io.kestra.core.models.property.Property;
|
import io.kestra.core.models.property.Property;
|
||||||
import io.kestra.core.models.tasks.Output;
|
import io.kestra.core.models.tasks.Output;
|
||||||
import io.kestra.core.runners.RunContext;
|
import io.kestra.core.runners.RunContext;
|
||||||
@@ -18,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||||||
class TemplatedTaskTest {
|
class TemplatedTaskTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RunContextFactory runContextFactory;
|
private TestRunContextFactory runContextFactory;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void templatedType() throws Exception {
|
void templatedType() throws Exception {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.kestra.plugin.core.trigger;
|
package io.kestra.plugin.core.trigger;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import io.kestra.core.junit.annotations.KestraTest;
|
import io.kestra.core.junit.annotations.KestraTest;
|
||||||
@@ -60,7 +61,7 @@ class ToggleTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests.trigger", "trigger-toggle");
|
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests.trigger", "trigger-toggle");
|
||||||
|
|
||||||
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
|
||||||
assertThat(execution.getTaskRunList()).hasSize(1);
|
assertThat(execution.getTaskRunList()).hasSize(1);
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ namespace: io.kestra.tests
|
|||||||
tasks:
|
tasks:
|
||||||
- id: sleep-short
|
- id: sleep-short
|
||||||
type: io.kestra.plugin.core.flow.Sleep
|
type: io.kestra.plugin.core.flow.Sleep
|
||||||
duration: PT10S
|
duration: PT3S
|
||||||
@@ -2,9 +2,15 @@ package io.kestra.repository.h2;
|
|||||||
|
|
||||||
import io.kestra.core.models.SearchResult;
|
import io.kestra.core.models.SearchResult;
|
||||||
import io.kestra.core.models.flows.Flow;
|
import io.kestra.core.models.flows.Flow;
|
||||||
|
import io.kestra.core.models.flows.FlowWithException;
|
||||||
|
import io.kestra.core.models.flows.GenericFlow;
|
||||||
|
import io.kestra.core.utils.IdUtils;
|
||||||
import io.kestra.jdbc.repository.AbstractJdbcFlowRepositoryTest;
|
import io.kestra.jdbc.repository.AbstractJdbcFlowRepositoryTest;
|
||||||
|
import io.kestra.plugin.core.flow.Template;
|
||||||
import io.micronaut.data.model.Pageable;
|
import io.micronaut.data.model.Pageable;
|
||||||
import io.micronaut.data.model.Sort;
|
import io.micronaut.data.model.Sort;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Optional;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@@ -12,7 +18,10 @@ import java.io.IOException;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
|
||||||
public class H2FlowRepositoryTest extends AbstractJdbcFlowRepositoryTest {
|
public class H2FlowRepositoryTest extends AbstractJdbcFlowRepositoryTest {
|
||||||
|
|
||||||
@@ -25,7 +34,7 @@ public class H2FlowRepositoryTest extends AbstractJdbcFlowRepositoryTest {
|
|||||||
@Test
|
@Test
|
||||||
@Override
|
@Override
|
||||||
public void findSourceCode() {
|
public void findSourceCode() {
|
||||||
List<SearchResult<Flow>> search = flowRepository.findSourceCode(Pageable.from(1, 10, Sort.UNSORTED), "io.kestra.plugin.core.condition.MultipleCondition", null, null);
|
List<SearchResult<Flow>> search = flowRepository.findSourceCode(Pageable.from(1, 10, Sort.UNSORTED), "io.kestra.plugin.core.condition.MultipleCondition", MAIN_TENANT, null);
|
||||||
|
|
||||||
// FIXME since the big task renaming, H2 return 6 instead of 2
|
// FIXME since the big task renaming, H2 return 6 instead of 2
|
||||||
// as no core change this is a test artefact, or a latent bug in H2.
|
// as no core change this is a test artefact, or a latent bug in H2.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user