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:
Nicolas K.
2025-05-19 14:49:10 +02:00
committed by GitHub
parent 05e348370f
commit 11a7e68e93
152 changed files with 1427 additions and 1207 deletions

View File

@@ -1,5 +1,7 @@
package io.kestra.cli;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.http.HttpHeaders;
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 '/'");
}
return tenantId == null ? "/api/v1" + path : "/api/v1/" + tenantId + path;
return tenantId == null ? "/api/v1/" + MAIN_TENANT + path : "/api/v1/" + tenantId + path;
}
@Builder

View File

@@ -89,7 +89,7 @@ public class FlowTestCommand extends AbstractCommand {
try {
runner.run();
repositoryLoader.load(null, file.toFile());
repositoryLoader.load(file.toFile());
List<Flow> all = flowRepository.findAllForAllTenants();
if (all.size() != 1) {

View File

@@ -15,7 +15,7 @@ public class LocalFlowFileWatcher implements FlowFilesManager {
@Override
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))
.orElseGet(() -> flowRepository.create(flow));
}

View File

@@ -142,7 +142,7 @@ class FlowUpdatesCommandTest {
};
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");
}
}

View File

@@ -16,6 +16,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.util.Map;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
class KvUpdateCommandTest {
@@ -40,7 +41,7 @@ class KvUpdateCommandTest {
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
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(((InternalKVStore) kvStore).getRawValue("string").get()).isEqualTo("\"stringValue\"");
@@ -68,7 +69,7 @@ class KvUpdateCommandTest {
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
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(((InternalKVStore) kvStore).getRawValue("int").get()).isEqualTo("1");
@@ -98,7 +99,7 @@ class KvUpdateCommandTest {
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
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(((InternalKVStore) kvStore).getRawValue("intStr").get()).isEqualTo("\"1\"");
@@ -126,7 +127,7 @@ class KvUpdateCommandTest {
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
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(((InternalKVStore) kvStore).getRawValue("object").get()).isEqualTo("{some:\"json\"}");
@@ -156,7 +157,7 @@ class KvUpdateCommandTest {
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
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(((InternalKVStore) kvStore).getRawValue("objectStr").get()).isEqualTo("\"{\\\"some\\\":\\\"json\\\"}\"");
@@ -190,7 +191,7 @@ class KvUpdateCommandTest {
PicocliRunner.call(KvUpdateCommand.class, ctx, args);
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(((InternalKVStore) kvStore).getRawValue("objectFromFile").get()).isEqualTo("{some:\"json\",from:\"file\"}");

View File

@@ -18,6 +18,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeoutException;
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 org.assertj.core.api.Assertions.assertThat;
@@ -57,7 +58,7 @@ class FileChangedEventListenerTest {
@RetryingTest(5) // Flaky on CI but always pass locally
void test() throws IOException, TimeoutException {
// 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
String flow = """
@@ -71,11 +72,11 @@ class FileChangedEventListenerTest {
""";
Files.write(Path.of(FILE_WATCH + "/myflow.yaml"), flow.getBytes());
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.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().getFirst().getId()).isEqualTo("hello");
assertThat(myflow.getTasks().getFirst().getType()).isEqualTo("io.kestra.plugin.core.log.Log");
@@ -83,7 +84,7 @@ class FileChangedEventListenerTest {
// delete the flow
Files.delete(Path.of(FILE_WATCH + "/myflow.yaml"));
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.ofSeconds(10)
);
@@ -92,7 +93,7 @@ class FileChangedEventListenerTest {
@RetryingTest(5) // Flaky on CI but always pass locally
void testWithPluginDefault() throws IOException, TimeoutException {
// 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
String pluginDefault = """
@@ -110,11 +111,11 @@ class FileChangedEventListenerTest {
""";
Files.write(Path.of(FILE_WATCH + "/plugin-default.yaml"), pluginDefault.getBytes());
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.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().getFirst().getId()).isEqualTo("helloWithDefault");
assertThat(pluginDefaultFlow.getTasks().getFirst().getType()).isEqualTo("io.kestra.plugin.core.log.Log");
@@ -122,7 +123,7 @@ class FileChangedEventListenerTest {
// delete both files
Files.delete(Path.of(FILE_WATCH + "/plugin-default.yaml"));
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.ofSeconds(10)
);

View File

@@ -2,6 +2,7 @@ micronaut:
io:
watch:
enabled: true
tenantId: main
paths:
- build/file-watch

View File

@@ -27,6 +27,7 @@ public class FlowWithPath {
public static FlowWithPath of(FlowInterface flow, String path) {
return FlowWithPath.builder()
.tenantId(flow.getTenantId())
.id(flow.getId())
.namespace(flow.getNamespace())
.path(path)

View File

@@ -46,6 +46,7 @@ public class Template implements DeletedInterface, TenantInterface, HasUID {
})
.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
@Setter
@Hidden
@Pattern(regexp = "^[a-z0-9][a-z0-9_-]*")
private String tenantId;

View File

@@ -32,6 +32,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static io.kestra.core.utils.Rethrow.throwConsumer;
@Singleton
@@ -48,7 +49,7 @@ public class LocalFlowRepositoryLoader {
private PluginDefaultService pluginDefaultService;
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 {
@@ -78,7 +79,7 @@ public class LocalFlowRepositoryLoader {
}
public void load(File basePath) throws IOException {
load(null, basePath);
load(MAIN_TENANT, basePath);
}
public void load(String tenantId, File basePath) throws IOException {

View File

@@ -35,7 +35,6 @@ import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.GeneralSecurityException;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

View File

@@ -1,5 +1,7 @@
package io.kestra.core.runners;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import com.google.common.annotations.VisibleForTesting;
import io.kestra.core.metrics.MetricRegistry;
import io.kestra.core.models.executions.Execution;
@@ -180,7 +182,7 @@ public class RunContextFactory {
@Override
public String getTenantId() {
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")

View File

@@ -5,13 +5,15 @@ import jakarta.inject.Singleton;
@Singleton
public class TenantService {
public static final String MAIN_TENANT = "main";
/**
* 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
*/
public String resolveTenant() {
return null;
return MAIN_TENANT;
}
}

View File

@@ -2,6 +2,7 @@ package io.kestra.core.http.client;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.net.HttpHeaders;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
import io.kestra.core.http.HttpRequest;
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.QueueInterface;
import io.kestra.core.runners.RunContext;
import io.kestra.core.runners.RunContextFactory;
import io.kestra.core.serializers.JacksonMapper;
import io.kestra.core.utils.IdUtils;
import io.kestra.core.utils.TestsUtils;
@@ -71,7 +71,7 @@ class HttpClientTest {
private ApplicationContext applicationContext;
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
private URI embeddedServerUri;

View File

@@ -1,5 +1,6 @@
package io.kestra.core.models.flows.sla.types;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.exceptions.InternalException;
import io.kestra.core.junit.annotations.KestraTest;
import io.kestra.core.models.flows.sla.Violation;
@@ -18,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@KestraTest
class ExecutionAssertionSLATest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Test
void shouldEvaluateToAViolation() throws InternalException {

View File

@@ -32,6 +32,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest(startRunner = true)
@@ -300,7 +301,7 @@ class FlowGraphTest {
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.");
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(),
"flowId", "switch"
));
@@ -377,7 +378,10 @@ class FlowGraphTest {
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) {

View File

@@ -1,5 +1,6 @@
package io.kestra.core.models.property;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
import io.kestra.core.junit.annotations.KestraTest;
import io.kestra.core.runners.RunContextFactory;
@@ -20,6 +21,7 @@ import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static java.util.Map.entry;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -28,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
class PropertyTest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Inject
private StorageInterface storage;
@@ -155,7 +157,7 @@ class PropertyTest {
FileSerde.writeAll(Files.newBufferedWriter(messages), Flux.fromIterable(inputValues)).block();
URI uri;
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()

View File

@@ -1,5 +1,6 @@
package io.kestra.core.models.tasks.runners;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.executions.TaskRun;
@@ -28,7 +29,7 @@ import static org.hamcrest.Matchers.*;
@KestraTest
class ScriptServiceTest {
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
void replaceInternalStorage() throws IOException {
@@ -39,7 +40,7 @@ class ScriptServiceTest {
command = ScriptService.replaceInternalStorage(runContext, "my command", false);
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()) {
Files.createFile(path);
}
@@ -71,7 +72,7 @@ class ScriptServiceTest {
void uploadInputFiles() throws IOException {
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()) {
Files.createFile(path);
}
@@ -118,12 +119,12 @@ class ScriptServiceTest {
@Test
void uploadOutputFiles() throws IOException {
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()) {
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.get("file.txt")).isEqualTo(URI.create("kestra:///file.txt"));

View File

@@ -36,6 +36,7 @@ import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
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.groups.Tuple.tuple;
import static org.hamcrest.Matchers.*;
@@ -60,6 +61,7 @@ public abstract class AbstractExecutionRepositoryTest {
Execution.ExecutionBuilder execution = Execution.builder()
.id(FriendlyId.createFriendlyId())
.namespace(namespace)
.tenantId(MAIN_TENANT)
.flowId(flowId == null ? FLOW : flowId)
.flowRevision(1)
.state(finalState);
@@ -155,7 +157,7 @@ public abstract class AbstractExecutionRepositoryTest {
protected void find() {
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.size()).isEqualTo(10);
@@ -164,7 +166,7 @@ public abstract class AbstractExecutionRepositoryTest {
.operation(QueryFilter.Op.EQUALS)
.value( List.of(State.Type.RUNNING, State.Type.FAILED))
.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);
filters = List.of(QueryFilter.builder()
@@ -172,7 +174,7 @@ public abstract class AbstractExecutionRepositoryTest {
.operation(QueryFilter.Op.EQUALS)
.value(Map.of("key", "value"))
.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);
filters = List.of(QueryFilter.builder()
@@ -180,7 +182,7 @@ public abstract class AbstractExecutionRepositoryTest {
.operation(QueryFilter.Op.EQUALS)
.value(Map.of("key", "value2"))
.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);
filters = List.of(QueryFilter.builder()
@@ -189,7 +191,7 @@ public abstract class AbstractExecutionRepositoryTest {
.value(Map.of("key", "value", "keyTest", "valueTest"))
.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);
filters = List.of(QueryFilter.builder()
@@ -197,7 +199,7 @@ public abstract class AbstractExecutionRepositoryTest {
.operation(QueryFilter.Op.EQUALS)
.value("second")
.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);
filters = List.of(QueryFilter.builder()
@@ -211,7 +213,7 @@ public abstract class AbstractExecutionRepositoryTest {
.value(NAMESPACE)
.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);
filters = List.of(QueryFilter.builder()
@@ -219,7 +221,7 @@ public abstract class AbstractExecutionRepositoryTest {
.operation(QueryFilter.Op.STARTS_WITH)
.value("io.kestra")
.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);
}
@@ -235,7 +237,7 @@ public abstract class AbstractExecutionRepositoryTest {
.operation(QueryFilter.Op.EQUALS)
.value(executionTriggerId)
.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.size()).isEqualTo(10);
assertThat(executions.getFirst().getTrigger().getVariables().get("executionId")).isEqualTo(executionTriggerId);
@@ -245,7 +247,7 @@ public abstract class AbstractExecutionRepositoryTest {
.value(ExecutionRepositoryInterface.ChildFilter.CHILD)
.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.size()).isEqualTo(10);
assertThat(executions.getFirst().getTrigger().getVariables().get("executionId")).isEqualTo(executionTriggerId);
@@ -256,12 +258,12 @@ public abstract class AbstractExecutionRepositoryTest {
.value(ExecutionRepositoryInterface.ChildFilter.MAIN)
.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.size()).isEqualTo(10);
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);
}
@@ -269,7 +271,7 @@ public abstract class AbstractExecutionRepositoryTest {
protected void findWithSort() {
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.size()).isEqualTo(10);
@@ -278,7 +280,7 @@ public abstract class AbstractExecutionRepositoryTest {
.operation(QueryFilter.Op.EQUALS)
.value(List.of(State.Type.RUNNING, State.Type.FAILED))
.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);
}
@@ -286,7 +288,7 @@ public abstract class AbstractExecutionRepositoryTest {
protected void findTaskRun() {
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.size()).isEqualTo(10);
@@ -296,7 +298,7 @@ public abstract class AbstractExecutionRepositoryTest {
.value(Map.of("key", "value"))
.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.size()).isEqualTo(1);
}
@@ -306,7 +308,7 @@ public abstract class AbstractExecutionRepositoryTest {
protected void findById() {
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();
full.ifPresent(current -> {
@@ -330,7 +332,7 @@ public abstract class AbstractExecutionRepositoryTest {
protected void purge() {
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();
executionRepository.purge(ExecutionFixture.EXECUTION_1);
@@ -343,12 +345,12 @@ public abstract class AbstractExecutionRepositoryTest {
protected void delete() {
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();
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();
}
@@ -357,7 +359,7 @@ public abstract class AbstractExecutionRepositoryTest {
executionRepository.save(ExecutionFixture.EXECUTION_2);
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);
}
@@ -376,7 +378,7 @@ public abstract class AbstractExecutionRepositoryTest {
Map<String, Map<String, List<DailyExecutionStatistics>>> result = executionRepository.dailyGroupByFlowStatistics(
null,
null,
MAIN_TENANT,
null,
null,
null,
@@ -405,7 +407,7 @@ public abstract class AbstractExecutionRepositoryTest {
result = executionRepository.dailyGroupByFlowStatistics(
null,
null,
MAIN_TENANT,
null,
null,
null,
@@ -426,7 +428,7 @@ public abstract class AbstractExecutionRepositoryTest {
result = executionRepository.dailyGroupByFlowStatistics(
null,
null,
MAIN_TENANT,
null,
null,
List.of(ExecutionRepositoryInterface.FlowFilter.builder().namespace("io.kestra.unittest").id(FLOW).build()),
@@ -489,7 +491,7 @@ public abstract class AbstractExecutionRepositoryTest {
Thread.sleep(500);
List<Execution> result = executionRepository.lastExecutions(
null,
MAIN_TENANT,
List.of(
ExecutionRepositoryInterface.FlowFilter.builder()
.id(FLOW)
@@ -531,7 +533,7 @@ public abstract class AbstractExecutionRepositoryTest {
List<DailyExecutionStatistics> result = executionRepository.dailyStatistics(
null,
null,
MAIN_TENANT,
null,
null,
null,
@@ -551,7 +553,7 @@ public abstract class AbstractExecutionRepositoryTest {
result = executionRepository.dailyStatistics(
null,
null,
MAIN_TENANT,
List.of(FlowScope.USER, FlowScope.SYSTEM),
null,
null,
@@ -566,7 +568,7 @@ public abstract class AbstractExecutionRepositoryTest {
result = executionRepository.dailyStatistics(
null,
null,
MAIN_TENANT,
List.of(FlowScope.USER),
null,
null,
@@ -580,7 +582,7 @@ public abstract class AbstractExecutionRepositoryTest {
result = executionRepository.dailyStatistics(
null,
null,
MAIN_TENANT,
List.of(FlowScope.SYSTEM),
null,
null,
@@ -609,7 +611,7 @@ public abstract class AbstractExecutionRepositoryTest {
List<DailyExecutionStatistics> result = executionRepository.dailyStatistics(
null,
null,
MAIN_TENANT,
null,
null,
null,
@@ -629,7 +631,7 @@ public abstract class AbstractExecutionRepositoryTest {
result = executionRepository.dailyStatistics(
null,
null,
MAIN_TENANT,
List.of(FlowScope.USER, FlowScope.SYSTEM),
null,
null,
@@ -644,7 +646,7 @@ public abstract class AbstractExecutionRepositoryTest {
result = executionRepository.dailyStatistics(
null,
null,
MAIN_TENANT,
List.of(FlowScope.USER),
null,
null,
@@ -658,7 +660,7 @@ public abstract class AbstractExecutionRepositoryTest {
result = executionRepository.dailyStatistics(
null,
null,
MAIN_TENANT,
List.of(FlowScope.SYSTEM),
null,
null,
@@ -685,7 +687,7 @@ public abstract class AbstractExecutionRepositoryTest {
Thread.sleep(500);
List<ExecutionCount> result = executionRepository.executionCounts(
null,
MAIN_TENANT,
List.of(
new Flow(NAMESPACE, "first"),
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);
result = executionRepository.executionCounts(
null,
MAIN_TENANT,
List.of(
new Flow(NAMESPACE, "first"),
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);
result = executionRepository.executionCounts(
null,
MAIN_TENANT,
null,
null,
null,
@@ -741,7 +743,7 @@ public abstract class AbstractExecutionRepositoryTest {
Execution updated = execution.toBuilder().labels(List.of(label)).build();
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.get().getLabels().size()).isEqualTo(1);
assertThat(validation.get().getLabels().getFirst()).isEqualTo(label);
@@ -755,7 +757,7 @@ public abstract class AbstractExecutionRepositoryTest {
executionRepository.save(earliest);
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.get().getId()).isEqualTo(latest.getId());
}
@@ -799,6 +801,7 @@ public abstract class AbstractExecutionRepositoryTest {
return Execution.builder()
.id(IdUtils.create())
.namespace("io.kestra.unittest")
.tenantId(MAIN_TENANT)
.flowId("full")
.flowRevision(1)
.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() {
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
}
}

View File

@@ -36,6 +36,7 @@ import java.util.*;
import java.util.concurrent.TimeoutException;
import jakarta.validation.ConstraintViolationException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.doReturn;
@@ -59,7 +60,7 @@ public abstract class AbstractFlowRepositoryTest {
@BeforeEach
protected void init() throws IOException, URISyntaxException {
TestsUtils.loads(null, repositoryLoader);
TestsUtils.loads(MAIN_TENANT, repositoryLoader);
FlowListener.reset();
}
@@ -77,15 +78,16 @@ public abstract class AbstractFlowRepositoryTest {
@Test
void findById() {
FlowWithSource flow = builder()
.tenantId(MAIN_TENANT)
.revision(3)
.build();
flow = flowRepository.create(GenericFlow.of(flow));
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.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();
} finally {
deleteFlow(flow);
@@ -95,15 +97,16 @@ public abstract class AbstractFlowRepositoryTest {
@Test
void findByIdWithoutAcl() {
FlowWithSource flow = builder()
.tenantId(MAIN_TENANT)
.revision(3)
.build();
flow = flowRepository.create(GenericFlow.of(flow));
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.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();
} finally {
deleteFlow(flow);
@@ -113,13 +116,14 @@ public abstract class AbstractFlowRepositoryTest {
@Test
void findByIdWithSource() {
FlowWithSource flow = builder()
.tenantId(MAIN_TENANT)
.revision(3)
.build();
String source = "# comment\n" + flow.sourceOrGenerateIfNull();
flow = flowRepository.create(GenericFlow.fromYaml(null, source));
flow = flowRepository.create(GenericFlow.fromYaml(MAIN_TENANT, source));
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();
full.ifPresent(current -> {
@@ -159,14 +163,14 @@ public abstract class AbstractFlowRepositoryTest {
@Test
void findAll() {
List<Flow> save = flowRepository.findAll(null);
List<Flow> save = flowRepository.findAll(MAIN_TENANT);
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT);
}
@Test
void findAllWithSource() {
List<FlowWithSource> save = flowRepository.findAllWithSource(null);
List<FlowWithSource> save = flowRepository.findAllWithSource(MAIN_TENANT);
assertThat((long) save.size()).isEqualTo(Helpers.FLOWS_COUNT);
}
@@ -187,25 +191,25 @@ public abstract class AbstractFlowRepositoryTest {
@Test
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);
save = flowRepository.findByNamespace(null, "io.kestra.tests2");
save = flowRepository.findByNamespace(MAIN_TENANT, "io.kestra.tests2");
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);
}
@Test
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);
save = flowRepository.findByNamespace(null, "io.kestra.tests2");
save = flowRepository.findByNamespace(MAIN_TENANT, "io.kestra.tests2");
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);
}
@@ -215,10 +219,10 @@ public abstract class AbstractFlowRepositoryTest {
.revision(3)
.build();
String flowSource = "# comment\n" + flow.sourceOrGenerateIfNull();
flow = flowRepository.create(GenericFlow.fromYaml(null, flowSource));
flow = flowRepository.create(GenericFlow.fromYaml(MAIN_TENANT, flowSource));
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(save.getFirst().getSource()).isEqualTo(FlowService.cleanupSource(flowSource));
@@ -229,51 +233,51 @@ public abstract class AbstractFlowRepositoryTest {
@Test
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);
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);
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);
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);
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);
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);
}
@Test
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);
}
@Test
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);
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);
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);
}
@Test
void delete() {
Flow flow = builder().build();
Flow flow = builder().tenantId(MAIN_TENANT).build();
FlowWithSource save = flowRepository.create(GenericFlow.of(flow));
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) {
deleteFlow(save);
throw e;
@@ -281,10 +285,10 @@ public abstract class AbstractFlowRepositoryTest {
Flow delete = flowRepository.delete(save);
assertThat(flowRepository.findById(null, 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()).isPresent()).isFalse();
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());
}
@@ -295,6 +299,7 @@ public abstract class AbstractFlowRepositoryTest {
Flow flow = Flow.builder()
.id(flowId)
.namespace(TEST_NAMESPACE)
.tenantId(MAIN_TENANT)
.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()))
.build();
@@ -302,11 +307,12 @@ public abstract class AbstractFlowRepositoryTest {
Flow save = flowRepository.create(GenericFlow.of(flow));
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()
.id(IdUtils.create())
.namespace("io.kestra.unittest2")
.tenantId(MAIN_TENANT)
.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()))
.build();
@@ -330,6 +336,7 @@ public abstract class AbstractFlowRepositoryTest {
Flow flow = Flow.builder()
.id(flowId)
.namespace(TEST_NAMESPACE)
.tenantId(MAIN_TENANT)
.triggers(Collections.singletonList(AbstractSchedulerTest.UnitTest.builder()
.id("sleep")
.type(AbstractSchedulerTest.UnitTest.class.getName())
@@ -339,11 +346,12 @@ public abstract class AbstractFlowRepositoryTest {
flow = flowRepository.create(GenericFlow.of(flow));
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()
.id(flowId)
.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()))
.build();
;
@@ -362,12 +370,13 @@ public abstract class AbstractFlowRepositoryTest {
@Test
void removeTriggerDelete() throws TimeoutException, QueueException {
void removeTriggerDelete() throws TimeoutException {
String flowId = IdUtils.create();
Flow flow = Flow.builder()
.id(flowId)
.namespace(TEST_NAMESPACE)
.tenantId(MAIN_TENANT)
.triggers(Collections.singletonList(AbstractSchedulerTest.UnitTest.builder()
.id("sleep")
.type(AbstractSchedulerTest.UnitTest.class.getName())
@@ -377,7 +386,7 @@ public abstract class AbstractFlowRepositoryTest {
Flow save = flowRepository.create(GenericFlow.of(flow));
try {
assertThat(flowRepository.findById(null, flow.getNamespace(), flow.getId()).isPresent()).isTrue();
assertThat(flowRepository.findById(MAIN_TENANT, flow.getNamespace(), flow.getId()).isPresent()).isTrue();
} finally {
deleteFlow(save);
}
@@ -389,45 +398,10 @@ public abstract class AbstractFlowRepositoryTest {
@Test
void findDistinctNamespace() {
List<String> distinctNamespace = flowRepository.findDistinctNamespace(null);
List<String> distinctNamespace = flowRepository.findDistinctNamespace(MAIN_TENANT);
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
protected void shouldReturnNullRevisionForNonExistingFlow() {
assertThat(flowRepository.lastRevision(TEST_TENANT_ID, TEST_NAMESPACE, IdUtils.create())).isNull();
@@ -583,7 +557,7 @@ public abstract class AbstractFlowRepositoryTest {
@Test
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.getTotal()).isEqualTo(Helpers.FLOWS_COUNT);
}
@@ -593,7 +567,7 @@ public abstract class AbstractFlowRepositoryTest {
List<QueryFilter> filters = List.of(
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.getTotal()).isEqualTo(Helpers.FLOWS_COUNT);
}
@@ -601,12 +575,14 @@ public abstract class AbstractFlowRepositoryTest {
@Test
void findByExecution() {
Flow flow = builder()
.tenantId(MAIN_TENANT)
.revision(1)
.build();
flowRepository.create(GenericFlow.of(flow));
Execution execution = Execution.builder()
.id(IdUtils.create())
.namespace(flow.getNamespace())
.tenantId(MAIN_TENANT)
.flowId(flow.getId())
.flowRevision(flow.getRevision())
.state(new State())
@@ -667,7 +643,7 @@ public abstract class AbstractFlowRepositoryTest {
Flow flow = createTestFlowForNamespace(TEST_NAMESPACE);
toDelete = flowRepository.create(GenericFlow.of(flow));
// When
int count = flowRepository.count(null);
int count = flowRepository.count(MAIN_TENANT);
// Then
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("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);
count = flowRepository.countForNamespace(null, TEST_NAMESPACE);
count = flowRepository.countForNamespace(MAIN_TENANT, TEST_NAMESPACE);
assertThat(count).isEqualTo(2);
} finally {
for (FlowWithSource flow : toDelete) {
@@ -702,6 +678,7 @@ public abstract class AbstractFlowRepositoryTest {
return Flow.builder()
.id(IdUtils.create())
.namespace(namespace)
.tenantId(MAIN_TENANT)
.tasks(List.of(Return.builder()
.id(IdUtils.create())
.type(Return.class.getName())
@@ -710,7 +687,7 @@ public abstract class AbstractFlowRepositoryTest {
.build();
}
private void deleteFlow(Flow flow) {
protected void deleteFlow(Flow flow) {
if (flow == null) {
return;
}

View File

@@ -1,5 +1,7 @@
package io.kestra.core.repositories;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import com.google.common.collect.ImmutableMap;
import io.kestra.core.models.executions.*;
import io.kestra.core.models.flows.State;
@@ -12,6 +14,7 @@ class ExecutionFixture {
public static final Execution EXECUTION_1 = Execution.builder()
.id(IdUtils.create())
.namespace("io.kestra.unittest")
.tenantId(MAIN_TENANT)
.flowId("full")
.flowRevision(1)
.state(new State())
@@ -36,6 +39,7 @@ class ExecutionFixture {
public static final Execution EXECUTION_2 = Execution.builder()
.id(IdUtils.create())
.namespace("io.kestra.unittest")
.tenantId(MAIN_TENANT)
.flowId("full")
.flowRevision(1)
.state(new State())

View File

@@ -1,5 +1,6 @@
package io.kestra.core.runners;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import io.kestra.core.junit.annotations.ExecuteFlow;
@@ -42,7 +43,7 @@ public abstract class AbstractRunnerTest {
private RestartCaseTest restartCaseTest;
@Inject
private FlowTriggerCaseTest flowTriggerCaseTest;
protected FlowTriggerCaseTest flowTriggerCaseTest;
@Inject
protected MultipleConditionTriggerCaseTest multipleConditionTriggerCaseTest;
@@ -494,7 +495,7 @@ public abstract class AbstractRunnerTest {
@Test
@LoadFlows({"flows/valids/if.yaml"})
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));
assertThat(execution.getTaskRunList()).hasSize(12);

View File

@@ -17,6 +17,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@Singleton
@@ -74,7 +75,7 @@ public class ChangeStateTestCase {
});
// 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.getTaskRunList()).hasSize(1);
assertThat(execution.getTaskRunList().getFirst().getState().getCurrent()).isEqualTo(State.Type.FAILED);

View File

@@ -1,5 +1,6 @@
package io.kestra.core.runners;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.encryption.EncryptionService;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
import io.kestra.core.models.tasks.common.EncryptedString;
@@ -25,7 +26,7 @@ class DefaultRunContextTest {
private String secretKey;
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Test
void shouldGetKestraVersion() {

View File

@@ -11,6 +11,7 @@ import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest(startRunner = true)
@@ -25,7 +26,7 @@ public class EmptyVariablesTest {
@LoadFlows({"flows/valids/empty-variables.yml"})
void emptyVariables() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"empty-variables",
null,

View File

@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Optional;
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.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.not;
@@ -56,7 +57,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/restart_last_failed.yaml"})
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.getState().getCurrent()).isEqualTo(State.Type.FAILED);
@@ -75,11 +76,11 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/restart_last_failed.yaml"})
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.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(
GenericFlow.of(flow),
flow.updateTask(
@@ -108,7 +109,7 @@ class ExecutionServiceTest {
@RetryingTest(5)
@LoadFlows({"flows/valids/restart-each.yaml"})
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);
Execution restart = executionService.restart(execution, null);
@@ -124,7 +125,7 @@ class ExecutionServiceTest {
@RetryingTest(5)
@LoadFlows({"flows/valids/restart-each.yaml"})
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);
Execution restart = executionService.restart(execution, null);
@@ -140,7 +141,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/working-directory.yaml"})
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.getState().getCurrent()).isEqualTo(State.Type.FAILED);
@@ -156,7 +157,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/logs.yaml"})
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -177,7 +178,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/logs.yaml"})
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -196,7 +197,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/restart-each.yaml"})
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -214,7 +215,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/parallel-nested.yaml"})
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -272,7 +273,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/dynamic-task.yaml"})
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -292,7 +293,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/each-parallel-nested.yaml"})
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -312,7 +313,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/each-parallel-nested.yaml"})
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);
assertThat(execution.getTaskRunList()).hasSize(11);
@@ -344,7 +345,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/pause.yaml"})
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);
assertThat(execution.getTaskRunList()).hasSize(1);
@@ -364,7 +365,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/pause.yaml"})
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);
assertThat(execution.getTaskRunList()).hasSize(1);
@@ -403,7 +404,7 @@ class ExecutionServiceTest {
@Test
@LoadFlows({"flows/valids/pause_no_tasks.yaml"})
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);
assertThat(execution.getTaskRunList()).hasSize(1);

View File

@@ -1,5 +1,6 @@
package io.kestra.core.runners;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.junit.annotations.KestraTest;
import jakarta.inject.Inject;
import org.apache.commons.io.FileUtils;
@@ -14,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
class FilesServiceTest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Test
void overrideExistingInputFile() throws Exception {

View File

@@ -21,6 +21,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
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.junit.jupiter.api.Assertions.assertTrue;
@@ -37,8 +38,8 @@ public class FlowConcurrencyCaseTest {
protected QueueInterface<Execution> executionQueue;
public void flowConcurrencyCancel() throws TimeoutException, QueueException, InterruptedException {
Execution execution1 = runnerUtils.runOneUntilRunning(null, "io.kestra.tests", "flow-concurrency-cancel", null, null, Duration.ofSeconds(30));
Execution execution2 = runnerUtils.runOne(null, "io.kestra.tests", "flow-concurrency-cancel");
Execution execution1 = runnerUtils.runOneUntilRunning(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-cancel", null, null, Duration.ofSeconds(30));
Execution execution2 = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-cancel");
assertThat(execution1.getState().isRunning()).isTrue();
assertThat(execution2.getState().getCurrent()).isEqualTo(State.Type.CANCELLED);
@@ -60,8 +61,8 @@ public class FlowConcurrencyCaseTest {
}
public void flowConcurrencyFail() throws TimeoutException, QueueException, InterruptedException {
Execution execution1 = runnerUtils.runOneUntilRunning(null, "io.kestra.tests", "flow-concurrency-fail", null, null, Duration.ofSeconds(30));
Execution execution2 = runnerUtils.runOne(null, "io.kestra.tests", "flow-concurrency-fail");
Execution execution1 = runnerUtils.runOneUntilRunning(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-fail", null, null, Duration.ofSeconds(30));
Execution execution2 = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-fail");
assertThat(execution1.getState().isRunning()).isTrue();
assertThat(execution2.getState().getCurrent()).isEqualTo(State.Type.FAILED);
@@ -83,9 +84,9 @@ public class FlowConcurrencyCaseTest {
}
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
.findById(null, "io.kestra.tests", "flow-concurrency-queue", Optional.empty())
.findById(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-queue", Optional.empty())
.orElseThrow();
Execution execution2 = Execution.newExecution(flow, null, null, Optional.empty());
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
.findById(null, "io.kestra.tests", "flow-concurrency-queue-pause", Optional.empty())
.findById(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-queue-pause", Optional.empty())
.orElseThrow();
Execution execution2 = Execution.newExecution(flow, null, null, Optional.empty());
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
.findById(null, "io.kestra.tests", "flow-concurrency-cancel-pause", Optional.empty())
.findById(MAIN_TENANT, "io.kestra.tests", "flow-concurrency-cancel-pause", Optional.empty())
.orElseThrow();
Execution execution2 = Execution.newExecution(flow, null, null, Optional.empty());
executionQueue.emit(execution2);

View File

@@ -1,6 +1,5 @@
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.GenericFlow;
import io.kestra.core.models.property.Property;
@@ -17,6 +16,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import jakarta.inject.Inject;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
@@ -28,6 +28,7 @@ abstract public class FlowListenersTest {
FlowWithSource flow = FlowWithSource.builder()
.id(flowId)
.namespace("io.kestra.unittest")
.tenantId(MAIN_TENANT)
.revision(1)
.tasks(Collections.singletonList(Return.builder()
.id(taskId)

View File

@@ -1,7 +1,6 @@
package io.kestra.core.runners;
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.queues.QueueException;
import io.kestra.core.queues.QueueFactoryInterface;
@@ -19,6 +18,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
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.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.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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);

View File

@@ -34,6 +34,7 @@ import java.time.LocalTime;
import java.util.*;
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.junit.jupiter.api.Assertions.assertThrows;
@@ -91,7 +92,7 @@ public class InputsTest {
private FlowInputOutput flowInputOutput;
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) {
@@ -100,6 +101,7 @@ public class InputsTest {
Execution.builder()
.id("test")
.namespace(flow.getNamespace())
.tenantId(MAIN_TENANT)
.flowRevision(1)
.flowId(flow.getId())
.build(),
@@ -142,7 +144,7 @@ public class InputsTest {
assertThat(typeds.get("time")).isEqualTo(LocalTime.parse("18:27:49"));
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(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("uri")).isEqualTo("https://www.google.com");
assertThat(((Map<String, Object>) typeds.get("nested")).get("string")).isEqualTo("a string");
@@ -183,7 +185,7 @@ public class InputsTest {
@LoadFlows({"flows/valids/inputs.yaml"})
void inputFlow() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"inputs",
null,
@@ -358,7 +360,7 @@ public class InputsTest {
map.put("json", "{}");
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"inputs",
null,
@@ -379,7 +381,7 @@ public class InputsTest {
Flux<LogEntry> receive = TestsUtils.receive(logQueue, l -> {});
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"input-log-secret",
null,

View File

@@ -15,6 +15,7 @@ import java.net.URISyntaxException;
import java.util.Objects;
import java.util.concurrent.TimeoutException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest(startRunner = true)
@@ -28,17 +29,17 @@ class ListenersTest {
@BeforeEach
void initListeners() throws IOException, URISyntaxException {
repositoryLoader.load(null, 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(null, 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(null, Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-failed.yaml")));
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners.yaml")));
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-flowable.yaml")));
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-multiple.yaml")));
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-multiple-failed.yaml")));
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/listeners-failed.yaml")));
}
@Test
void success() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"listeners",
null,
@@ -53,7 +54,7 @@ class ListenersTest {
@Test
void failed() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"listeners",
null,
@@ -68,7 +69,7 @@ class ListenersTest {
@Test
void flowableExecution() throws TimeoutException, QueueException{
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"listeners-flowable",
null,
@@ -84,7 +85,7 @@ class ListenersTest {
@Test
void multipleListeners() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"listeners-multiple"
);
@@ -97,7 +98,7 @@ class ListenersTest {
@Test
void failedListeners() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"listeners-failed"
);
@@ -111,7 +112,7 @@ class ListenersTest {
@Test
void failedMultipleListeners() throws TimeoutException, QueueException{
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"listeners-multiple-failed"
);

View File

@@ -1,5 +1,7 @@
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.repositories.ExecutionRepositoryInterface;
import io.kestra.core.utils.RetryUtils;
@@ -37,7 +39,7 @@ public class ListenersTestTask extends Task implements RunnableTask<ListenersTes
Execution execution = retryInstance.run(
NoSuchElementException.class,
() -> executionRepository.findById(null, executionRendererId)
() -> executionRepository.findById(MAIN_TENANT, executionRendererId)
.filter(e -> e.getState().getCurrent().isTerminated())
.orElseThrow(() -> new NoSuchElementException("Unable to find execution '" + executionRendererId + "'"))
);

View File

@@ -15,6 +15,7 @@ import java.nio.charset.StandardCharsets;
import java.util.List;
import org.junit.jupiter.api.Test;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest(startRunner = true)
@@ -32,7 +33,7 @@ public class LogToFileTest {
TaskRunAttempt attempt = taskRun.getAttempts().getFirst();
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);
assertThat(strings).isNotNull();
assertThat(strings.size()).isEqualTo(1);

View File

@@ -24,6 +24,7 @@ import jakarta.inject.Named;
import jakarta.inject.Singleton;
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.junit.jupiter.api.Assertions.assertTrue;
@@ -60,7 +61,7 @@ public class MultipleConditionTriggerCaseTest {
});
// 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));
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -70,7 +71,7 @@ public class MultipleConditionTriggerCaseTest {
assertThat(ended.size()).isEqualTo(1);
// 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));
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -80,7 +81,7 @@ public class MultipleConditionTriggerCaseTest {
receive.blockLast();
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();
Execution triggerExecution = ended.entrySet()
.stream()
@@ -110,7 +111,7 @@ public class MultipleConditionTriggerCaseTest {
});
// 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));
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.FAILED);
@@ -120,7 +121,7 @@ public class MultipleConditionTriggerCaseTest {
assertThat(listener.get()).isNull();
// 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));
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -147,17 +148,17 @@ public class MultipleConditionTriggerCaseTest {
});
// 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));
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
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
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));
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
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));
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -189,13 +190,13 @@ public class MultipleConditionTriggerCaseTest {
});
// 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));
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
// 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));
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
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));
assertThat(execution.getTaskRunList().size()).isEqualTo(2);
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);

View File

@@ -19,6 +19,7 @@ import org.junit.jupiter.api.TestInstance;
import java.util.HashMap;
import java.util.Map;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -59,12 +60,13 @@ public class NoEncryptionConfiguredTest implements TestPropertyProvider {
@Test
@LoadFlows({"flows/valids/inputs.yaml"})
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()
.id("test")
.namespace(flow.getNamespace())
.tenantId(MAIN_TENANT)
.flowRevision(1)
.flowId(flow.getId())
.build();

View File

@@ -1,17 +1,15 @@
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.LoadFlows;
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.flows.State;
import io.kestra.core.queues.QueueException;
import jakarta.inject.Inject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.concurrent.TimeoutException;
import static org.assertj.core.api.Assertions.assertThat;
@@ -20,9 +18,6 @@ public class NullOutputTest {
@Inject
protected StandAloneRunner runner;
@Inject
protected RunnerUtils runnerUtils;
@BeforeEach
protected void init() throws IOException, URISyntaxException {
if (!runner.isRunning()) {
@@ -31,10 +26,8 @@ public class NullOutputTest {
}
@Test
@LoadFlows("flows/valids/null-output.yaml")
void shouldIncludeNullOutput() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "null-output");
@ExecuteFlow("flows/valids/null-output.yaml")
void shouldIncludeNullOutput(Execution execution){
assertThat(execution).isNotNull();
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
assertThat(execution.getTaskRunList()).hasSize(1);

View File

@@ -24,6 +24,7 @@ import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.stream.Stream;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@Singleton
@@ -32,7 +33,7 @@ public class PluginDefaultsCaseTest {
private RunnerUtils runnerUtils;
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);

View File

@@ -23,6 +23,8 @@ import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.inject.Singleton;
import reactor.core.publisher.Flux;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import static io.kestra.core.utils.Rethrow.throwRunnable;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -43,9 +45,9 @@ public class RestartCaseTest {
private QueueInterface<Execution> executionQueue;
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.getTaskRunList()).hasSize(3);
@@ -82,9 +84,9 @@ public class RestartCaseTest {
}
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.getTaskRunList()).hasSize(2);
@@ -117,9 +119,9 @@ public class RestartCaseTest {
}
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.getTaskRunList()).hasSize(5);
@@ -154,9 +156,9 @@ public class RestartCaseTest {
}
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);
@@ -186,7 +188,7 @@ public class RestartCaseTest {
}
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.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.getState().getCurrent()).isEqualTo(State.Type.FAILED);

View File

@@ -1,5 +1,6 @@
package io.kestra.core.runners;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
import io.kestra.core.junit.annotations.KestraTest;
import io.kestra.core.models.property.Property;
@@ -15,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
class RunContextPropertyTest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Test
void asShouldReturnEmptyForNullProperty() throws IllegalVariableEvaluationException {

View File

@@ -60,6 +60,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
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.within;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -110,7 +111,7 @@ class RunContextTest {
LogEntry matchingLog;
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);
@@ -147,7 +148,7 @@ class RunContextTest {
inputs.put("string", new String(chars));
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"inputs-large",
null,
@@ -179,7 +180,7 @@ class RunContextTest {
@Test
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();
}
@@ -195,7 +196,7 @@ class RunContextTest {
p.destroy();
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

View File

@@ -10,6 +10,7 @@ import jakarta.inject.Singleton;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@Singleton
@@ -18,31 +19,31 @@ public class SLATestCase {
private RunnerUtils runnerUtils;
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);
}
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);
}
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);
}
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);
}
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.getLabels()).contains(new Label("sla", "violated"));

View File

@@ -18,6 +18,7 @@ import java.util.Optional;
import java.util.concurrent.CountDownLatch;
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.junit.jupiter.api.Assertions.assertTrue;
@@ -32,7 +33,7 @@ public class ScheduleDateCaseTest {
public void shouldScheduleOnDate() throws QueueException, InterruptedException {
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));
this.executionQueue.emit(execution);

View File

@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeoutException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@Singleton
@@ -46,17 +47,18 @@ public class SkipExecutionCaseTest {
skipExecutionService.setSkipExecutions(List.of(execution1Id));
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
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);
}
private Flow createFlow() {
return Flow.builder()
.id(IdUtils.create())
.tenantId(MAIN_TENANT)
.namespace("io.kestra.unittest")
.revision(1)
.tasks(Collections.singletonList(Return.builder()

View File

@@ -1,5 +1,6 @@
package io.kestra.core.runners;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import io.kestra.core.junit.annotations.ExecuteFlow;
@@ -46,7 +47,7 @@ public class TaskWithAllowFailureTest {
@LoadFlows({"flows/valids/task-allow-failure-executable-flow.yml",
"flows/valids/for-each-item-subflow-failed.yaml"})
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.getTaskRunList()).hasSize(2);
}
@@ -57,7 +58,7 @@ public class TaskWithAllowFailureTest {
void executableTask_ForEachItem() throws TimeoutException, QueueException, URISyntaxException, IOException {
URI file = storageUpload();
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.getTaskRunList()).hasSize(4);
@@ -76,7 +77,7 @@ public class TaskWithAllowFailureTest {
Files.write(tempFile.toPath(), content());
return storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/file/storage/file.txt"),
new FileInputStream(tempFile)

View File

@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.concurrent.TimeoutException;
import java.util.stream.IntStream;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest(startRunner = true)
@@ -47,7 +48,7 @@ public class TaskWithAllowWarningTest {
@LoadFlows({"flows/valids/task-allow-warning-executable-flow.yml",
"flows/valids/for-each-item-subflow-failed.yaml"})
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.getTaskRunList()).hasSize(2);
}
@@ -57,7 +58,7 @@ public class TaskWithAllowWarningTest {
void executableTask_ForEachItem() throws TimeoutException, QueueException, URISyntaxException, IOException {
URI file = storageUpload();
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.getTaskRunList()).hasSize(4);
@@ -76,7 +77,7 @@ public class TaskWithAllowWarningTest {
Files.write(tempFile.toPath(), content());
return storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/file/storage/file.txt"),
new FileInputStream(tempFile)

View File

@@ -25,6 +25,7 @@ import java.util.Map;
import java.util.Optional;
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.within;
@@ -133,7 +134,7 @@ class TestSuiteTest {
}
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()
.id(IdUtils.create())

View File

@@ -14,6 +14,7 @@ import java.io.IOException;
import java.net.URI;
import java.util.Map;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.junit.jupiter.api.Assertions.*;
@KestraTest
@@ -33,7 +34,7 @@ class FileExistsFunctionTest {
}
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
@@ -46,7 +47,8 @@ class FileExistsFunctionTest {
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", FLOW,
"namespace", NAMESPACE),
"namespace", NAMESPACE,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", executionId)
);
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ fileExists('" + internalStorageFile + "') }}", variables));
@@ -57,12 +59,12 @@ class FileExistsFunctionTest {
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
String namespace = "io.kestra.tests";
String filePath = "file.txt";
storageInterface.createDirectory(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
storageInterface.put(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("NOT AN EMPTY FILE".getBytes()));
storageInterface.createDirectory(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
storageInterface.put(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("NOT AN EMPTY FILE".getBytes()));
boolean render = Boolean.parseBoolean(
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);
}
@@ -76,7 +78,8 @@ class FileExistsFunctionTest {
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", FLOW,
"namespace", NAMESPACE),
"namespace", NAMESPACE,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", executionId)
);
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ fileExists('" + internalStorageFile + "') }}", variables));

View File

@@ -14,6 +14,7 @@ import java.io.IOException;
import java.net.URI;
import java.util.Map;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.validator.internal.util.Contracts.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -42,7 +43,8 @@ public class FileSizeFunctionTest {
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", FLOW,
"namespace", NAMESPACE),
"namespace", NAMESPACE,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", executionId)
);
@@ -54,10 +56,10 @@ public class FileSizeFunctionTest {
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
String namespace = "io.kestra.tests";
String filePath = "file.txt";
storageInterface.createDirectory(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
storageInterface.put(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream(FILE_TEXT.getBytes()));
storageInterface.createDirectory(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
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);
}
@@ -70,12 +72,14 @@ public class FileSizeFunctionTest {
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", "subflow",
"namespace", NAMESPACE),
"namespace", NAMESPACE,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", IdUtils.create()),
"trigger", Map.of(
"flowId", FLOW,
"namespace", NAMESPACE,
"executionId", executionId
"executionId", executionId,
"tenantId", MAIN_TENANT
)
);
@@ -92,7 +96,8 @@ public class FileSizeFunctionTest {
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", "subflow",
"namespace", NAMESPACE),
"namespace", NAMESPACE,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", IdUtils.create())
);
@@ -109,11 +114,13 @@ public class FileSizeFunctionTest {
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", "subflow",
"namespace", NAMESPACE),
"namespace", NAMESPACE,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", IdUtils.create()),
"trigger", Map.of(
"flowId", FLOW,
"executionId", executionId
"executionId", executionId,
"tenantId", MAIN_TENANT
)
);
@@ -135,7 +142,8 @@ public class FileSizeFunctionTest {
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", FLOW,
"namespace", NAMESPACE),
"namespace", NAMESPACE,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", executionId),
"file", internalStorageFile
);
@@ -153,12 +161,14 @@ public class FileSizeFunctionTest {
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", "subflow",
"namespace", NAMESPACE),
"namespace", NAMESPACE,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", IdUtils.create()),
"trigger", Map.of(
"flowId", FLOW,
"namespace", NAMESPACE,
"executionId", executionId
"executionId", executionId,
"tenantId", MAIN_TENANT
),
"file", internalStorageFile
);
@@ -172,6 +182,6 @@ public class FileSizeFunctionTest {
}
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()));
}
}

View File

@@ -14,6 +14,7 @@ import java.io.*;
import java.net.URI;
import java.util.Map;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.not;
@@ -49,12 +50,12 @@ class FromIonFunctionTest {
}
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")
);
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);
assertThat(render).contains("\"id\":0");

View File

@@ -14,6 +14,7 @@ import java.io.IOException;
import java.net.URI;
import java.util.Map;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.junit.jupiter.api.Assertions.*;
@KestraTest
@@ -33,7 +34,7 @@ class IsFileEmptyFunctionTest {
}
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
@@ -46,7 +47,8 @@ class IsFileEmptyFunctionTest {
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", FLOW,
"namespace", NAMESPACE),
"namespace", NAMESPACE,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", executionId)
);
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ isFileEmpty('" + internalStorageFile + "') }}", variables));
@@ -57,12 +59,12 @@ class IsFileEmptyFunctionTest {
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
String namespace = "io.kestra.tests";
String filePath = "file.txt";
storageInterface.createDirectory(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
storageInterface.put(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("NOT AN EMPTY FILE".getBytes()));
storageInterface.createDirectory(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
storageInterface.put(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("NOT AN EMPTY FILE".getBytes()));
boolean render = Boolean.parseBoolean(
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);
}
@@ -76,7 +78,8 @@ class IsFileEmptyFunctionTest {
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", FLOW,
"namespace", NAMESPACE),
"namespace", NAMESPACE,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", executionId)
);
boolean render = Boolean.parseBoolean(variableRenderer.render("{{ isFileEmpty('" + internalStorageFile + "') }}", variables));

View File

@@ -18,6 +18,7 @@ import java.io.IOException;
import java.net.URI;
import java.util.Map;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -34,10 +35,10 @@ class ReadFileFunctionTest {
void readNamespaceFile() throws IllegalVariableEvaluationException, IOException {
String namespace = "io.kestra.tests";
String filePath = "file.txt";
storageInterface.createDirectory(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
storageInterface.put(null, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace) + "/" + filePath), new ByteArrayInputStream("Hello from {{ flow.namespace }}".getBytes()));
storageInterface.createDirectory(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
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);
}
@@ -45,10 +46,10 @@ class ReadFileFunctionTest {
void readNamespaceFileWithNamespace() throws IllegalVariableEvaluationException, IOException {
String namespace = "io.kestra.tests";
String filePath = "file.txt";
storageInterface.createDirectory(null, 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.createDirectory(MAIN_TENANT, namespace, URI.create(StorageContext.namespaceFilePrefix(namespace)));
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");
}
@@ -65,13 +66,14 @@ class ReadFileFunctionTest {
String flowId = "flow";
String executionId = IdUtils.create();
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
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", flowId,
"namespace", namespace),
"namespace", namespace,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", executionId)
);
@@ -82,12 +84,14 @@ class ReadFileFunctionTest {
variables = Map.of(
"flow", Map.of(
"id", "subflow",
"namespace", namespace),
"namespace", namespace,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", IdUtils.create()),
"trigger", Map.of(
"flowId", flowId,
"namespace", namespace,
"executionId", executionId
"executionId", executionId,
"tenantId", MAIN_TENANT
)
);
@@ -102,13 +106,14 @@ class ReadFileFunctionTest {
String flowId = "flow";
String executionId = IdUtils.create();
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
Map<String, Object> variables = Map.of(
"flow", Map.of(
"id", flowId,
"namespace", namespace),
"namespace", namespace,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", executionId),
"file", internalStorageFile
);
@@ -120,12 +125,14 @@ class ReadFileFunctionTest {
variables = Map.of(
"flow", Map.of(
"id", "subflow",
"namespace", namespace),
"namespace", namespace,
"tenantId", MAIN_TENANT),
"execution", Map.of("id", IdUtils.create()),
"trigger", Map.of(
"flowId", flowId,
"namespace", namespace,
"executionId", executionId
"executionId", executionId,
"tenantId", MAIN_TENANT
)
);
@@ -139,12 +146,13 @@ class ReadFileFunctionTest {
String flowId = "flow";
String executionId = IdUtils.create();
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(
"flow", Map.of(
"id", "notme",
"namespace", "notme"),
"namespace", "notme",
"tenantId", MAIN_TENANT),
"execution", Map.of("id", "notme")
);

View File

@@ -1,5 +1,6 @@
package io.kestra.core.secret;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
@@ -56,7 +57,7 @@ public class SecretFunctionTest {
List<LogEntry> logs = new CopyOnWriteArrayList<>();
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().get(2).getOutputs().get("value")).isEqualTo("passwordveryveryveyrlongpasswordveryveryveyrlongpasswordveryveryveyrlongpasswordveryveryveyrlongpasswordveryveryveyrlong");
assertThat(execution.getTaskRunList().get(3).getOutputs().get("value")).isEqualTo("secretValue");
@@ -122,7 +123,7 @@ public class SecretFunctionTest {
public static class TestSecretService extends SecretService {
private static final Map<String, String> SECRETS = Map.of(
"io.kestra.unittest.json-secret", """
"io.kestra.unittest.json-secret", """
{
"string": "value",
"number": 42,

View File

@@ -1,5 +1,6 @@
package io.kestra.core.services;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.junit.annotations.KestraTest;
import io.kestra.core.models.Label;
import io.kestra.core.models.flows.Flow;
@@ -22,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
class LabelServiceTest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Test
void shouldFilterSystemLabels() {

View File

@@ -43,6 +43,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
@@ -70,7 +71,7 @@ class PluginDefaultServiceTest {
@Test
void shouldInjectGivenFlowWithNullSource() throws FlowProcessingException {
// Given
FlowInterface flow = GenericFlow.fromYaml(null, TEST_LOG_FLOW_SOURCE);
FlowInterface flow = GenericFlow.fromYaml(MAIN_TENANT, TEST_LOG_FLOW_SOURCE);
// When
FlowWithSource result = pluginDefaultService.injectAllDefaults(flow, true);
@@ -193,7 +194,7 @@ class PluginDefaultServiceTest {
- id: test
type: io.kestra.core.services.PluginDefaultServiceTest$DefaultTester
set: 666
pluginDefaults:
- type: "%s"
forced: false
@@ -236,12 +237,12 @@ class PluginDefaultServiceTest {
String source = """
id: default-test
namespace: io.kestra.tests
tasks:
- id: test
type: io.kestra.core.services.PluginDefaultServiceTest$DefaultTester
set: 1
pluginDefaults:
- type: io.kestra.core.services.PluginDefaultServiceTest$DefaultTester
forced: true
@@ -283,7 +284,7 @@ class PluginDefaultServiceTest {
- id: test
type: io.kestra.core.services.PluginDefaultServiceTest$DefaultTester
set: 666
pluginDefaults:
- type: io.kestra.core.services.PluginDefaultServiceTest$DefaultTester
values:
@@ -308,7 +309,7 @@ class PluginDefaultServiceTest {
@Test
void shouldInjectFlowDefaultsGivenAlias() throws FlowProcessingException {
// Given
GenericFlow flow = GenericFlow.fromYaml(null, """
GenericFlow flow = GenericFlow.fromYaml(MAIN_TENANT, """
id: default-test
namespace: io.kestra.tests
@@ -316,7 +317,7 @@ class PluginDefaultServiceTest {
- id: test
type: io.kestra.core.services.PluginDefaultServiceTest$DefaultTester
set: 666
pluginDefaults:
- type: io.kestra.core.services.DefaultTesterAlias
values:
@@ -332,7 +333,7 @@ class PluginDefaultServiceTest {
@Test
void shouldInjectFlowDefaultsGivenType() throws FlowProcessingException {
GenericFlow flow = GenericFlow.fromYaml(null, """
GenericFlow flow = GenericFlow.fromYaml(MAIN_TENANT, """
id: default-test
namespace: io.kestra.tests
@@ -340,7 +341,7 @@ class PluginDefaultServiceTest {
- id: test
type: io.kestra.core.services.PluginDefaultServiceTest$DefaultTester
set: 666
pluginDefaults:
- type: io.kestra.core.services.PluginDefaultServiceTest$DefaultTester
values:
@@ -355,7 +356,7 @@ class PluginDefaultServiceTest {
@Test
public void shouldNotInjectDefaultsGivenExistingTaskValue() throws FlowProcessingException {
// Given
GenericFlow flow = GenericFlow.fromYaml(null, """
GenericFlow flow = GenericFlow.fromYaml(MAIN_TENANT, """
id: default-test
namespace: io.kestra.tests
@@ -364,7 +365,7 @@ class PluginDefaultServiceTest {
type: io.kestra.plugin.core.log.Log
message: testing
level: INFO
pluginDefaults:
- type: io.kestra.core.services.PluginDefaultServiceTest$DefaultTester
values:

View File

@@ -28,6 +28,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.within;
class InternalKVStoreTest {
private static final Instant date = Instant.now().truncatedTo(ChronoUnit.MILLIS);
@@ -46,7 +47,7 @@ class InternalKVStoreTest {
@Test
void list() throws IOException {
Instant before = Instant.now().minusMillis(100);
Instant now = Instant.now();
InternalKVStore kv = kv();
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("my-second-key", new KVValueAndMetadata(new KVMetadata(Duration.ofMinutes(10)), complexValue));
kv.put("expired-key", new KVValueAndMetadata(new KVMetadata(Duration.ofMillis(1)), complexValue));
Instant after = Instant.now().plusMillis(100);
List<KVEntry> list = kv.list();
assertThat(list.size()).isEqualTo(2);
list.forEach(kvEntry -> {
assertThat(kvEntry.creationDate().isAfter(before) && kvEntry.creationDate().isBefore(after)).isTrue();
assertThat(kvEntry.updateDate().isAfter(before) && kvEntry.updateDate().isBefore(after)).isTrue();
assertThat(kvEntry.creationDate()).isCloseTo(now, within(1, ChronoUnit. SECONDS));
assertThat(kvEntry.updateDate()).isCloseTo(now, within(1, ChronoUnit. SECONDS));
});
Map<String, KVEntry> map = list.stream().collect(Collectors.toMap(KVEntry::key, Function.identity()));

View File

@@ -1,5 +1,6 @@
package io.kestra.core.storages;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.exceptions.MigrationRequiredException;
import io.kestra.core.exceptions.ResourceExpiredException;
import io.kestra.core.runners.RunContext;
@@ -23,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@MicronautTest
public class StateStoreTest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Test
void all() throws IOException, ResourceExpiredException {

View File

@@ -1,5 +1,6 @@
package io.kestra.core.tasks;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
import io.kestra.core.models.tasks.runners.PluginUtilsService;
import io.kestra.core.runners.RunContextFactory;
@@ -20,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
@KestraTest
public class PluginUtilsServiceTest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Test
void outputFiles() throws IOException {

View File

@@ -14,7 +14,7 @@ class TenantServiceTest {
@Test
void test() {
var tenant = tenantService.resolveTenant();
assertThat(tenant).isNull();
assertThat(tenant).isEqualTo("main");
}
}

View File

@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
@@ -54,7 +55,7 @@ class NamespaceFilesUtilsTest {
ByteArrayInputStream data = new ByteArrayInputStream("a".repeat(1024).getBytes(StandardCharsets.UTF_8));
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());
@@ -78,7 +79,7 @@ class NamespaceFilesUtilsTest {
ByteArrayInputStream data = new ByteArrayInputStream("a".repeat(1024).getBytes(StandardCharsets.UTF_8));
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());
@@ -101,9 +102,9 @@ class NamespaceFilesUtilsTest {
String namespace = IdUtils.create();
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(null, 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("/folder1/test.txt")), data);
storageInterface.put(MAIN_TENANT, namespace, toNamespacedStorageUri(namespace, URI.create("/folder2/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());

View File

@@ -21,6 +21,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
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.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
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());
executionQueue.emit(execution);

View File

@@ -1,5 +1,6 @@
package io.kestra.plugin.core.execution;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import io.kestra.core.junit.annotations.KestraTest;
@@ -23,8 +24,8 @@ public class FailTest {
@Test
@LoadFlows({"flows/valids/fail-on-switch.yaml"})
void failOnSwitch() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "fail-on-switch", null,
(f, e) -> Map.of("param", "fail") , Duration.ofSeconds(120));
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "fail-on-switch", null,
(f, e) -> Map.of("param", "fail") , Duration.ofSeconds(20));
assertThat(execution.getTaskRunList()).hasSize(1);
assertThat(execution.findTaskRunsByTaskId("switch").getFirst().getState().getCurrent()).isEqualTo(State.Type.FAILED);
@@ -34,8 +35,8 @@ public class FailTest {
@Test
@LoadFlows({"flows/valids/fail-on-condition.yaml"})
void failOnCondition() throws TimeoutException, QueueException{
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "fail-on-condition", null,
(f, e) -> Map.of("param", "fail") , Duration.ofSeconds(120));
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "fail-on-condition", null,
(f, e) -> Map.of("param", "fail") , Duration.ofSeconds(20));
assertThat(execution.getTaskRunList()).hasSize(2);
assertThat(execution.findTaskRunsByTaskId("fail").getFirst().getState().getCurrent()).isEqualTo(State.Type.FAILED);
@@ -45,8 +46,8 @@ public class FailTest {
@Test
@LoadFlows({"flows/valids/fail-on-condition.yaml"})
void dontFailOnCondition() throws TimeoutException, QueueException{
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "fail-on-condition", null,
(f, e) -> Map.of("param", "success") , Duration.ofSeconds(120));
Execution execution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "fail-on-condition", null,
(f, e) -> Map.of("param", "success") , Duration.ofSeconds(20));
assertThat(execution.getTaskRunList()).hasSize(3);
assertThat(execution.findTaskRunsByTaskId("fail").getFirst().getState().getCurrent()).isEqualTo(State.Type.SUCCESS);

View File

@@ -1,5 +1,6 @@
package io.kestra.plugin.core.execution;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.junit.annotations.KestraTest;
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.flows.State;
@@ -20,7 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
class PurgeExecutionsTest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Inject
private ExecutionRepositoryInterface executionRepository;

View File

@@ -13,6 +13,7 @@ import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.util.Map;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest(startRunner = true)
@@ -28,14 +29,14 @@ class ResumeTest {
@LoadFlows({"flows/valids/pause.yaml",
"flows/valids/resume-execution.yaml"})
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();
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);
Await.until(
() -> executionRepository.findById(null, pauseId).orElseThrow().getState().getCurrent().isTerminated(),
() -> executionRepository.findById(MAIN_TENANT, pauseId).orElseThrow().getState().getCurrent().isTerminated(),
Duration.ofMillis(100),
Duration.ofSeconds(5)
);

View File

@@ -14,6 +14,7 @@ import io.kestra.core.models.flows.State;
import java.util.concurrent.TimeoutException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest(startRunner = true)
@@ -37,7 +38,7 @@ class AllowFailureTest {
@LoadFlows({"flows/valids/allow-failure.yaml"})
void failed() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"allow-failure",
null,

View File

@@ -21,6 +21,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
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.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);
assertTrue(countDownLatch.await(1, TimeUnit.MINUTES));

View File

@@ -1,5 +1,6 @@
package io.kestra.plugin.core.flow;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import io.kestra.core.junit.annotations.ExecuteFlow;
@@ -70,7 +71,7 @@ public class DagTest {
@LoadFlows({"flows/valids/finally-dag.yaml"})
void errors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests", "finally-dag", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
Duration.ofSeconds(60)

View File

@@ -24,6 +24,7 @@ import jakarta.inject.Inject;
import jakarta.inject.Named;
import reactor.core.publisher.Flux;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest(startRunner = true)
@@ -95,7 +96,7 @@ public class EachSequentialTest {
List<LogEntry> logs = new CopyOnWriteArrayList<>();
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.getState().getCurrent()).isEqualTo(State.Type.FAILED);

View File

@@ -15,10 +15,13 @@ import java.time.Duration;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest(startRunner = true)
class FinallyTest {
public static final String NAMESPACE = "io.kestra.tests";
@Inject
protected RunnerUtils runnerUtils;
@@ -29,8 +32,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-sequential.yaml"})
void sequentialWithoutErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-sequential", null,
MAIN_TENANT,
NAMESPACE, "finally-sequential", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
Duration.ofSeconds(60)
);
@@ -46,8 +49,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-sequential.yaml"})
void sequentialWithErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-sequential", null,
MAIN_TENANT,
NAMESPACE, "finally-sequential", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
Duration.ofSeconds(60)
);
@@ -63,8 +66,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-sequential-error.yaml"})
void sequentialErrorBlockWithoutErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-sequential-error", null,
MAIN_TENANT,
NAMESPACE, "finally-sequential-error", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
Duration.ofSeconds(60)
);
@@ -79,7 +82,7 @@ class FinallyTest {
@Test
@LoadFlows({"flows/valids/finally-sequential-error-first.yaml"})
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.getState().getCurrent()).isEqualTo(State.Type.FAILED);
@@ -92,8 +95,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-sequential-error.yaml"})
void sequentialErrorBlockWithErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-sequential-error", null,
MAIN_TENANT,
NAMESPACE, "finally-sequential-error", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
Duration.ofSeconds(60)
);
@@ -111,8 +114,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-allowfailure.yaml"})
void allowFailureWithoutErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-allowfailure", null,
MAIN_TENANT,
NAMESPACE, "finally-allowfailure", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
Duration.ofSeconds(60)
);
@@ -128,8 +131,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-allowfailure.yaml"})
void allowFailureWithErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-allowfailure", null,
MAIN_TENANT,
NAMESPACE, "finally-allowfailure", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
Duration.ofSeconds(60)
);
@@ -147,8 +150,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-parallel.yaml"})
void parallelWithoutErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-parallel", null,
MAIN_TENANT,
NAMESPACE, "finally-parallel", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
Duration.ofSeconds(60)
);
@@ -164,8 +167,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-parallel.yaml"})
void parallelWithErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-parallel", null,
MAIN_TENANT,
NAMESPACE, "finally-parallel", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
Duration.ofSeconds(60)
);
@@ -183,8 +186,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-foreach.yaml"})
void forEachWithoutErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-foreach", null,
MAIN_TENANT,
NAMESPACE, "finally-foreach", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
Duration.ofSeconds(60)
);
@@ -200,8 +203,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-foreach.yaml"})
void forEachWithErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-foreach", null,
MAIN_TENANT,
NAMESPACE, "finally-foreach", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
Duration.ofSeconds(60)
);
@@ -219,8 +222,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-eachparallel.yaml"})
void eachParallelWithoutErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-eachparallel", null,
MAIN_TENANT,
NAMESPACE, "finally-eachparallel", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
Duration.ofSeconds(60)
);
@@ -236,8 +239,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-eachparallel.yaml"})
void eachParallelWithErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-eachparallel", null,
MAIN_TENANT,
NAMESPACE, "finally-eachparallel", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
Duration.ofSeconds(60)
);
@@ -255,8 +258,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-dag.yaml"})
void dagWithoutErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-dag", null,
MAIN_TENANT,
NAMESPACE, "finally-dag", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
Duration.ofSeconds(60)
);
@@ -272,8 +275,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-dag.yaml"})
void dagWithErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-dag", null,
MAIN_TENANT,
NAMESPACE, "finally-dag", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
Duration.ofSeconds(60)
);
@@ -291,8 +294,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-flow.yaml"})
void flowWithoutErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-flow", null,
MAIN_TENANT,
NAMESPACE, "finally-flow", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
Duration.ofSeconds(60)
);
@@ -308,8 +311,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-flow.yaml"})
void flowWithErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-flow", null,
MAIN_TENANT,
NAMESPACE, "finally-flow", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
Duration.ofSeconds(60)
);
@@ -325,8 +328,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-flow-error.yaml"})
void flowErrorBlockWithoutErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-flow-error", null,
MAIN_TENANT,
NAMESPACE, "finally-flow-error", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", false)),
Duration.ofSeconds(60)
);
@@ -342,8 +345,8 @@ class FinallyTest {
@LoadFlows({"flows/valids/finally-flow-error.yaml"})
void flowErrorBlockWithErrors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
"io.kestra.tests", "finally-flow-error", null,
MAIN_TENANT,
NAMESPACE, "finally-flow-error", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
Duration.ofSeconds(60)
);
@@ -360,7 +363,7 @@ class FinallyTest {
@Test
@LoadFlows({"flows/valids/finally-flow-error-first.yaml"})
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.getState().getCurrent()).isEqualTo(State.Type.FAILED);

View File

@@ -21,6 +21,7 @@ import jakarta.inject.Named;
import jakarta.inject.Singleton;
import reactor.core.publisher.Flux;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@Singleton
@@ -61,7 +62,7 @@ public class FlowCaseTest {
});
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"subflow-old-task-name"
);
@@ -92,7 +93,7 @@ public class FlowCaseTest {
});
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
testInherited ? "task-flow" : "task-flow-inherited-labels",
null,

View File

@@ -38,6 +38,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.IntStream;
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 org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -78,7 +79,7 @@ public class ForEachItemCaseTest {
URI file = storageUpload();
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),
Duration.ofSeconds(30));
@@ -112,7 +113,7 @@ public class ForEachItemCaseTest {
public void forEachItemEmptyItems() throws TimeoutException, URISyntaxException, IOException, QueueException {
URI file = emptyItems();
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),
Duration.ofSeconds(30));
@@ -140,7 +141,7 @@ public class ForEachItemCaseTest {
URI file = storageUpload();
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),
Duration.ofSeconds(30));
@@ -187,7 +188,7 @@ public class ForEachItemCaseTest {
URI file = storageUpload();
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),
Duration.ofSeconds(60));
@@ -230,7 +231,7 @@ public class ForEachItemCaseTest {
URI file = storageUpload();
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),
Duration.ofSeconds(30));
@@ -261,7 +262,7 @@ public class ForEachItemCaseTest {
// asserts for subflow merged outputs
Map<String, Object> mergeTaskOutputs = execution.getTaskRunList().get(3).getOutputs();
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))) {
// one line per sub-flows
@@ -280,7 +281,7 @@ public class ForEachItemCaseTest {
URI file = storageUpload();
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),
Duration.ofSeconds(30));
assertThat(execution.getTaskRunList()).hasSize(3);
@@ -326,7 +327,7 @@ public class ForEachItemCaseTest {
URI file = storageUpload();
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),
Duration.ofSeconds(30));
@@ -361,7 +362,7 @@ public class ForEachItemCaseTest {
Files.write(tempFile.toPath(), content());
return storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/file/storage/file.txt"),
new FileInputStream(tempFile)
@@ -372,7 +373,7 @@ public class ForEachItemCaseTest {
File tempFile = File.createTempFile("file", ".txt");
return storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/file/storage/file.txt"),
new FileInputStream(tempFile)

View File

@@ -14,6 +14,7 @@ import java.time.Duration;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest(startRunner = true)
@@ -25,21 +26,21 @@ class IfTest {
@Test
@LoadFlows({"flows/valids/if-condition.yaml"})
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));
assertThat(execution.getTaskRunList()).hasSize(2);
assertThat(execution.findTaskRunsByTaskId("when-true").getFirst().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));
assertThat(execution.getTaskRunList()).hasSize(2);
assertThat(execution.findTaskRunsByTaskId("when-true").getFirst().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));
assertThat(execution.getTaskRunList()).hasSize(2);
@@ -50,28 +51,28 @@ class IfTest {
@Test
@LoadFlows({"flows/valids/if-condition.yaml"})
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));
assertThat(execution.getTaskRunList()).hasSize(2);
assertThat(execution.findTaskRunsByTaskId("when-false").getFirst().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));
assertThat(execution.getTaskRunList()).hasSize(2);
assertThat(execution.findTaskRunsByTaskId("when-false").getFirst().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));
assertThat(execution.getTaskRunList()).hasSize(2);
assertThat(execution.findTaskRunsByTaskId("when-false").getFirst().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));
assertThat(execution.getTaskRunList()).hasSize(2);
@@ -84,14 +85,14 @@ class IfTest {
@Test
@LoadFlows({"flows/valids/if-without-else.yaml"})
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));
assertThat(execution.getTaskRunList()).hasSize(2);
assertThat(execution.findTaskRunsByTaskId("when-true").getFirst().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));
assertThat(execution.getTaskRunList()).hasSize(1);
assertThat(execution.findTaskRunsByTaskId("when-true").isEmpty()).isTrue();
@@ -101,7 +102,7 @@ class IfTest {
@Test
@LoadFlows({"flows/valids/if-in-flowable.yaml"})
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));
assertThat(execution.getTaskRunList()).hasSize(8);

View File

@@ -1,5 +1,6 @@
package io.kestra.plugin.core.flow;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import io.kestra.core.junit.annotations.ExecuteFlow;
@@ -41,7 +42,7 @@ class ParallelTest {
@LoadFlows({"flows/valids/finally-parallel.yaml"})
void errors() throws QueueException, TimeoutException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests", "finally-parallel", null,
(flow, execution1) -> flowIO.readExecutionInputs(flow, execution1, Map.of("failed", true)),
Duration.ofSeconds(60)

View File

@@ -39,6 +39,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static io.kestra.core.utils.Rethrow.throwRunnable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -148,7 +149,7 @@ public class PauseTest {
protected QueueInterface<Execution> executionQueue;
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();
Flow flow = flowRepository.findByExecution(execution);
@@ -173,7 +174,7 @@ public class PauseTest {
}
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();
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
@@ -191,7 +192,7 @@ public class PauseTest {
}
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();
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
@@ -209,14 +210,14 @@ public class PauseTest {
}
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.getTaskRunList()).hasSize(7);
}
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();
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
@@ -235,7 +236,7 @@ public class PauseTest {
}
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();
Flow flow = flowRepository.findByExecution(execution);
@@ -261,7 +262,7 @@ public class PauseTest {
@SuppressWarnings("unchecked")
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();
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");
assertThat(outputs.get("asked")).isEqualTo("restarted");
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 {
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);
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);
@@ -312,7 +313,7 @@ public class PauseTest {
@SuppressWarnings("unchecked")
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();
Flow flow = flowRepository.findByExecution(execution);
@@ -333,7 +334,7 @@ public class PauseTest {
}
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();
assertThat(execution.getState().getCurrent()).isEqualTo(State.Type.PAUSED);

View File

@@ -21,6 +21,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@Slf4j
@@ -86,7 +87,7 @@ public class RetryCaseTest {
});
runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"retry-new-execution-task-duration",
null,
@@ -113,7 +114,7 @@ public class RetryCaseTest {
});
runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"retry-new-execution-task-attempts",
null,
@@ -140,7 +141,7 @@ public class RetryCaseTest {
});
runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"retry-new-execution-flow-duration",
null,
@@ -167,7 +168,7 @@ public class RetryCaseTest {
});
runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"retry-new-execution-flow-attempts",
null,

View File

@@ -1,5 +1,6 @@
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.hamcrest.Matchers.is;
@@ -27,7 +28,7 @@ class RuntimeLabelsTest {
@LoadFlows({"flows/valids/labels-update-task.yml"})
void update() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"labels-update-task",
null,
@@ -75,7 +76,7 @@ class RuntimeLabelsTest {
@LoadFlows({"flows/valids/primitive-labels-flow.yml"})
void primitiveTypeLabels() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"primitive-labels-flow",
null,

View File

@@ -1,5 +1,6 @@
package io.kestra.plugin.core.flow;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import com.google.common.collect.ImmutableMap;
@@ -29,17 +30,17 @@ class StateTest {
void set() throws TimeoutException, QueueException {
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
assertThat((Integer) execution.findTaskRunsByTaskId("deleteGet").getFirst().getOutputs().get("count")).isZero();
@@ -50,7 +51,7 @@ class StateTest {
@LoadFlows({"flows/valids/state.yaml"})
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
assertThat(((Map<String, String>) execution.findTaskRunByTaskIdAndValue("regetEach1", List.of("b")).getOutputs().get("data")).get("value")).isEqualTo("null-b");

View File

@@ -1,5 +1,6 @@
package io.kestra.plugin.core.flow;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import com.google.common.collect.ImmutableMap;
@@ -23,7 +24,7 @@ class SwitchTest {
@LoadFlows({"flows/valids/switch.yaml"})
void switchFirst() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"switch",
null,
@@ -39,7 +40,7 @@ class SwitchTest {
@LoadFlows({"flows/valids/switch.yaml"})
void switchSecond() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"switch",
null,
@@ -56,7 +57,7 @@ class SwitchTest {
@LoadFlows({"flows/valids/switch.yaml"})
void switchThird() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"switch",
null,
@@ -74,7 +75,7 @@ class SwitchTest {
@LoadFlows({"flows/valids/switch.yaml"})
void switchDefault() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"switch",
null,
@@ -90,7 +91,7 @@ class SwitchTest {
@LoadFlows({"flows/valids/switch-impossible.yaml"})
void switchImpossible() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"switch-impossible",
null,

View File

@@ -28,6 +28,7 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeoutException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@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()
.id("template")
.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();
public static void withTemplate(
@@ -62,7 +64,7 @@ public class TemplateTest {
Flux<LogEntry> receive = TestsUtils.receive(logQueue, either -> logs.add(either.getLeft()));
Execution execution = runnerUtils.runOne(
null,
MAIN_TENANT,
"io.kestra.tests",
"with-template",
null,
@@ -92,7 +94,7 @@ public class TemplateTest {
List<LogEntry> logs = new CopyOnWriteArrayList<>();
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.getState().getCurrent()).isEqualTo(State.Type.FAILED);

View File

@@ -1,5 +1,6 @@
package io.kestra.plugin.core.flow;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import io.kestra.core.junit.annotations.ExecuteFlow;
@@ -49,7 +50,7 @@ class VariablesTest {
List<LogEntry> logs = new CopyOnWriteArrayList<>();
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);

View File

@@ -3,24 +3,22 @@ package io.kestra.plugin.core.flow;
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.flows.State;
import io.kestra.core.queues.QueueException;
import io.kestra.core.repositories.FlowRepositoryInterface;
import io.kestra.core.runners.RunnerUtils;
import jakarta.inject.Inject;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
public class WaitForCaseTest {
@Inject
FlowRepositoryInterface flowRepository;
@Inject
protected RunnerUtils runnerUtils;
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.getTaskRunList().getFirst().getOutputs()).isNotNull();
@@ -28,7 +26,7 @@ public class WaitForCaseTest {
}
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.getTaskRunList().getFirst().getOutputs()).isNotNull();
@@ -36,13 +34,13 @@ public class WaitForCaseTest {
}
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);
}
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.getTaskRunList().getFirst().getOutputs()).isNotNull();
@@ -51,7 +49,7 @@ public class WaitForCaseTest {
@SuppressWarnings("unchecked")
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);
@@ -62,14 +60,14 @@ public class WaitForCaseTest {
}
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.getTaskRunList().getLast().attemptNumber()).isEqualTo(1);
}
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((Integer) execution.getTaskRunList().getFirst().getOutputs().get("iterationCount")).isGreaterThan(1);

View File

@@ -1,5 +1,6 @@
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.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -116,7 +117,7 @@ public class WorkingDirectoryTest {
StorageInterface storageInterface;
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)
);
@@ -126,7 +127,7 @@ public class WorkingDirectoryTest {
}
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)
);
@@ -136,7 +137,7 @@ public class WorkingDirectoryTest {
}
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -146,7 +147,7 @@ public class WorkingDirectoryTest {
@SuppressWarnings("unchecked")
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -173,7 +174,7 @@ public class WorkingDirectoryTest {
@SuppressWarnings("unchecked")
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -203,6 +204,7 @@ public class WorkingDirectoryTest {
.builder()
.namespace("io.kestra.tests")
.id("working-directory-cache")
.tenantId(MAIN_TENANT)
.build()
);
InternalStorage storage = new InternalStorage(
@@ -214,9 +216,9 @@ public class WorkingDirectoryTest {
storage.deleteCacheFile("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().stream()
@@ -224,10 +226,10 @@ public class WorkingDirectoryTest {
.findFirst().get()
.getOutputs()).containsAllEntriesOf(Map.of("uris", Collections.emptyMap()));
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
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(((Map<String, String>) execution.getTaskRunList().stream()
@@ -240,7 +242,7 @@ public class WorkingDirectoryTest {
}
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -248,7 +250,7 @@ public class WorkingDirectoryTest {
}
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.getState().getCurrent()).isEqualTo(State.Type.SUCCESS);
@@ -261,7 +263,7 @@ public class WorkingDirectoryTest {
put("/a/b/3.txt", "third");
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.getState().getCurrent()).isEqualTo(State.Type.WARNING);
@@ -285,7 +287,7 @@ public class WorkingDirectoryTest {
//third namespace
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.getState().getCurrent()).isEqualTo(State.Type.WARNING);
@@ -297,7 +299,7 @@ public class WorkingDirectoryTest {
@SuppressWarnings("unchecked")
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);
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 {
storageInterface.put(
null,
MAIN_TENANT,
null,
URI.create(StorageContext.namespaceFilePrefix(namespace) + path),
new ByteArrayInputStream(content.getBytes())

View File

@@ -1,6 +1,7 @@
package io.kestra.plugin.core.http;
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.configurations.HttpConfiguration;
import io.kestra.core.junit.annotations.KestraTest;
@@ -26,6 +27,7 @@ import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.List;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -34,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
class DownloadTest {
public static final String FILE = "https://sampletestfile.com/wp-content/uploads/2023/07/500KB-CSV.csv";
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Inject
private StorageInterface storageInterface;
@@ -54,7 +56,7 @@ class DownloadTest {
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");
}
@@ -95,7 +97,7 @@ class DownloadTest {
Download.Output output = assertDoesNotThrow(() -> task.run(runContext));
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
@@ -134,7 +136,7 @@ class DownloadTest {
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

View File

@@ -2,6 +2,7 @@ package io.kestra.plugin.core.http;
import com.devskiller.friendly_id.FriendlyId;
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.HttpClientResponseException;
import io.kestra.core.http.client.configurations.*;
@@ -36,6 +37,7 @@ import java.util.Base64;
import java.util.Map;
import java.util.Objects;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static io.kestra.core.utils.Rethrow.throwFunction;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -43,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
@KestraTest
class RequestTest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Inject
private StorageInterface storageInterface;
@@ -356,7 +358,7 @@ class RequestTest {
File file = new File(Objects.requireNonNull(RequestTest.class.getClassLoader().getResource("application-test.yml")).toURI());
URI fileStorage = storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/" + FriendlyId.createFriendlyId()),
new FileInputStream(file)
@@ -390,7 +392,7 @@ class RequestTest {
File file = new File(Objects.requireNonNull(RequestTest.class.getClassLoader().getResource("application-test.yml")).toURI());
URI fileStorage = storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/" + FriendlyId.createFriendlyId()),
new FileInputStream(file)

View File

@@ -60,7 +60,7 @@ class TriggerTest {
worker.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));
receive.blockLast();
@@ -89,7 +89,7 @@ class TriggerTest {
worker.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));
worker.shutdown();

View File

@@ -5,7 +5,6 @@ import io.kestra.core.junit.annotations.LoadFlows;
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.executions.LogEntry;
import io.kestra.core.repositories.LogRepositoryInterface;
import io.kestra.core.runners.RunContextFactory;
import io.kestra.core.runners.RunnerUtils;
import jakarta.inject.Inject;
import java.time.temporal.ChronoUnit;
@@ -18,13 +17,12 @@ import org.slf4j.event.Level;
import java.time.Instant;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
@KestraTest(startRunner = true)
class PurgeLogsTest {
@Inject
private RunContextFactory runContextFactory;
@Inject
private LogRepositoryInterface logRepository;
@@ -39,13 +37,14 @@ class PurgeLogsTest {
var logEntry = LogEntry.builder()
.namespace("namespace")
.flowId("flowId")
.tenantId(MAIN_TENANT)
.timestamp(Instant.now())
.level(Level.INFO)
.message("Hello World")
.build();
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());
assertThat(execution.getTaskRunList()).hasSize(1);
@@ -59,7 +58,7 @@ class PurgeLogsTest {
void run_with_full_arguments(LogEntry logEntry, int resultCount, String failingReason) throws Exception {
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());
assertThat(execution.getTaskRunList().size()).isEqualTo(1);
@@ -71,6 +70,7 @@ class PurgeLogsTest {
Arguments.of(LogEntry.builder()
.namespace("purge.namespace")
.flowId("purgeFlowId")
.tenantId(MAIN_TENANT)
.timestamp(Instant.now().plus(5, ChronoUnit.HOURS))
.level(Level.INFO)
.message("Hello World")
@@ -78,6 +78,7 @@ class PurgeLogsTest {
Arguments.of(LogEntry.builder()
.namespace("purge.namespace")
.flowId("purgeFlowId")
.tenantId(MAIN_TENANT)
.timestamp(Instant.now().minus(5, ChronoUnit.HOURS))
.level(Level.INFO)
.message("Hello World")
@@ -85,6 +86,7 @@ class PurgeLogsTest {
Arguments.of(LogEntry.builder()
.namespace("uncorrect.namespace")
.flowId("purgeFlowId")
.tenantId(MAIN_TENANT)
.timestamp(Instant.now().minusSeconds(10))
.level(Level.INFO)
.message("Hello World")
@@ -92,6 +94,7 @@ class PurgeLogsTest {
Arguments.of(LogEntry.builder()
.namespace("purge.namespace")
.flowId("wrongFlowId")
.tenantId(MAIN_TENANT)
.timestamp(Instant.now().minusSeconds(10))
.level(Level.INFO)
.message("Hello World")
@@ -99,6 +102,7 @@ class PurgeLogsTest {
Arguments.of(LogEntry.builder()
.namespace("purge.namespace")
.flowId("purgeFlowId")
.tenantId(MAIN_TENANT)
.timestamp(Instant.now().minusSeconds(10))
.level(Level.WARN)
.message("Hello World")
@@ -106,6 +110,7 @@ class PurgeLogsTest {
Arguments.of(LogEntry.builder()
.namespace("purge.namespace")
.flowId("purgeFlowId")
.tenantId(MAIN_TENANT)
.timestamp(Instant.now().minusSeconds(10))
.level(Level.INFO)
.message("Hello World")

View File

@@ -1,5 +1,6 @@
package io.kestra.plugin.core.metric;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.junit.annotations.KestraTest;
import io.kestra.core.models.property.Property;
import io.kestra.core.models.tasks.metrics.CounterMetric;
@@ -19,7 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
public class PublishTest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Test
void run() throws Exception {

View File

@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
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());
URI fileStorage = storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/" + FriendlyId.createFriendlyId()),
new FileInputStream(file)
@@ -169,7 +170,7 @@ public class UploadFilesTest {
File file = new File(Objects.requireNonNull(UploadFilesTest.class.getClassLoader().getResource(fileToLoad)).toURI());
return storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/" + FriendlyId.createFriendlyId()),
new FileInputStream(file)

View File

@@ -19,6 +19,7 @@ import java.util.List;
import java.util.Objects;
import jakarta.inject.Inject;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
@@ -38,7 +39,7 @@ class ConcatTest {
.toURI());
URI put = storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/file/storage/get.yml"),
new FileInputStream(Objects.requireNonNull(resource).getFile())
@@ -56,7 +57,7 @@ class ConcatTest {
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");
}

View File

@@ -1,10 +1,10 @@
package io.kestra.plugin.core.storage;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.junit.annotations.KestraTest;
import io.kestra.core.models.property.Property;
import org.junit.jupiter.api.Test;
import io.kestra.core.runners.RunContext;
import io.kestra.core.runners.RunContextFactory;
import io.kestra.core.storages.StorageInterface;
import java.io.FileInputStream;
@@ -14,13 +14,14 @@ import java.util.NoSuchElementException;
import java.util.Objects;
import jakarta.inject.Inject;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
@KestraTest
class DeleteTest {
@Inject
RunContextFactory runContextFactory;
TestRunContextFactory runContextFactory;
@Inject
StorageInterface storageInterface;
@@ -31,7 +32,7 @@ class DeleteTest {
URL resource = DeleteTest.class.getClassLoader().getResource("application-test.yml");
URI put = storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/file/storage/get.yml"),
new FileInputStream(Objects.requireNonNull(resource).getFile())

View File

@@ -19,6 +19,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -35,7 +36,7 @@ class LocalFilesTest {
var resource = ConcatTest.class.getClassLoader().getResource("application-test.yml");
return storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/file/storage/get.yml"),
new FileInputStream(Objects.requireNonNull(resource).getFile())
@@ -63,10 +64,10 @@ class LocalFilesTest {
assertThat(outputs).isNotNull();
assertThat(outputs.getUris()).isNotNull();
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(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();
}
@@ -91,11 +92,11 @@ class LocalFilesTest {
assertThat(outputs).isNotNull();
assertThat(outputs.getUris()).isNotNull();
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(null, null, outputs.getUris().get("test/sub/dir/2/execution.txt"))
assertThat(new String(storageInterface.get(MAIN_TENANT, null, outputs.getUris().get("test/hello-input.txt")).readAllBytes())).isEqualTo("Hello Input");
assertThat(new String(storageInterface.get(MAIN_TENANT, null, outputs.getUris().get("test/sub/dir/2/execution.txt"))
.readAllBytes())).isEqualTo("tata");
assertThat(new String(storageInterface.get(null, null, outputs.getUris().get("test/sub/dir/3/application-test.yml"))
.readAllBytes())).isEqualTo(new String(storageInterface.get(null, null, storageFile).readAllBytes()));
assertThat(new String(storageInterface.get(MAIN_TENANT, null, outputs.getUris().get("test/sub/dir/3/application-test.yml"))
.readAllBytes())).isEqualTo(new String(storageInterface.get(MAIN_TENANT, null, storageFile).readAllBytes()));
runContext.cleanup();
}

View File

@@ -1,5 +1,6 @@
package io.kestra.plugin.core.storage;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.junit.annotations.KestraTest;
import io.kestra.core.models.flows.Flow;
import io.kestra.core.runners.RunContextFactory;
@@ -13,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
class PurgeCurrentExecutionFilesTest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Test
void run() throws Exception {

View File

@@ -13,6 +13,7 @@ import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;
import java.net.URI;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
@@ -28,7 +29,7 @@ class ReverseTest {
RunContext runContext = runContextFactory.of();
URI put = storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/file/storage/get.yml"),
new ByteArrayInputStream("1\n2\n3\n".getBytes())
@@ -42,6 +43,6 @@ class ReverseTest {
Reverse.Output run = result.run(runContext);
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");
}
}

View File

@@ -1,8 +1,8 @@
package io.kestra.plugin.core.storage;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.models.property.Property;
import io.kestra.core.runners.RunContext;
import io.kestra.core.runners.RunContextFactory;
import io.kestra.core.storages.StorageInterface;
import io.kestra.core.junit.annotations.KestraTest;
import org.junit.jupiter.api.Test;
@@ -13,12 +13,13 @@ import java.util.Random;
import jakarta.inject.Inject;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
class SizeTest {
@Inject
RunContextFactory runContextFactory;
TestRunContextFactory runContextFactory;
@Inject
StorageInterface storageInterface;
@@ -32,7 +33,7 @@ class SizeTest {
new Random().nextBytes(randomBytes);
URI put = storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/file/storage/get.yml"),
new ByteArrayInputStream(randomBytes)

View File

@@ -22,6 +22,7 @@ import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
@@ -91,7 +92,7 @@ class SplitTest {
private String readAll(List<URI> uris) throws IOException {
return uris
.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());
}
@@ -102,7 +103,7 @@ class SplitTest {
Files.write(tempFile.toPath(), content(count));
return storageInterface.put(
null,
MAIN_TENANT,
null,
new URI("/file/storage/get.yml"),
new FileInputStream(tempFile)

View File

@@ -10,6 +10,7 @@ import org.junit.jupiter.api.Test;
import java.io.InputStream;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
@KestraTest
@@ -33,7 +34,7 @@ class WriteTest {
assertThat(output).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();
inputStream.close();
}

View File

@@ -1,5 +1,6 @@
package io.kestra.plugin.core.templating;
import io.kestra.core.context.TestRunContextFactory;
import io.kestra.core.models.property.Property;
import io.kestra.core.models.tasks.Output;
import io.kestra.core.runners.RunContext;
@@ -18,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
class TemplatedTaskTest {
@Inject
private RunContextFactory runContextFactory;
private TestRunContextFactory runContextFactory;
@Test
void templatedType() throws Exception {

View File

@@ -1,5 +1,6 @@
package io.kestra.plugin.core.trigger;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import static org.assertj.core.api.Assertions.assertThat;
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.getTaskRunList()).hasSize(1);

View File

@@ -4,4 +4,4 @@ namespace: io.kestra.tests
tasks:
- id: sleep-short
type: io.kestra.plugin.core.flow.Sleep
duration: PT10S
duration: PT3S

View File

@@ -2,9 +2,15 @@ package io.kestra.repository.h2;
import io.kestra.core.models.SearchResult;
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.plugin.core.flow.Template;
import io.micronaut.data.model.Pageable;
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.Test;
@@ -12,7 +18,10 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
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 {
@@ -25,7 +34,7 @@ public class H2FlowRepositoryTest extends AbstractJdbcFlowRepositoryTest {
@Test
@Override
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
// 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