-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): State task isolation per namespace
close #544
- Loading branch information
1 parent
41a4fdf
commit dc40a61
Showing
5 changed files
with
112 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
core/src/test/java/io/kestra/core/tasks/states/StateNamespaceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package io.kestra.core.tasks.states; | ||
|
||
import io.kestra.core.models.tasks.Task; | ||
import io.kestra.core.runners.RunContext; | ||
import io.kestra.core.runners.RunContextFactory; | ||
import io.kestra.core.utils.IdUtils; | ||
import io.kestra.core.utils.TestsUtils; | ||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest; | ||
import jakarta.inject.Inject; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Map; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
@MicronautTest | ||
class StateNamespaceTest { | ||
@Inject | ||
RunContextFactory runContextFactory; | ||
|
||
private RunContext runContextFlow1(Task task) { | ||
return TestsUtils.mockRunContext(runContextFactory, task, Map.of()); | ||
} | ||
|
||
private RunContext runContextFlow2(Task task) { | ||
return TestsUtils.mockRunContext(runContextFactory, task, Map.of()); | ||
} | ||
|
||
@Test | ||
void run() throws Exception { | ||
Set set = Set.builder() | ||
.id(IdUtils.create()) | ||
.type(Set.class.toString()) | ||
.namespace(true) | ||
.data(Map.of( | ||
"john", "doe" | ||
)) | ||
.build(); | ||
Set.Output setOutput = set.run(runContextFlow1(set)); | ||
assertThat(setOutput.getCount(), is(1)); | ||
|
||
Get get = Get.builder() | ||
.id(IdUtils.create()) | ||
.type(Get.class.toString()) | ||
.namespace(true) | ||
.build(); | ||
Get.Output getOutput = get.run(runContextFlow2(get)); | ||
assertThat(getOutput.getCount(), is(1)); | ||
assertThat(getOutput.getData().get("john"), is("doe")); | ||
|
||
get = Get.builder() | ||
.id(IdUtils.create()) | ||
.type(Get.class.toString()) | ||
.build(); | ||
getOutput = get.run(runContextFlow2(get)); | ||
assertThat(getOutput.getCount(), is(0)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters