-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from alexhsamuel/fix/schedule-action-tests
Fix/schedule action tests
- Loading branch information
Showing
17 changed files
with
126 additions
and
23 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
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
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
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 |
---|---|---|
|
@@ -4,6 +4,6 @@ program: | |
action: | ||
type: apsis.actions.test.SleepThreadAction | ||
duration: 2 | ||
condition: | ||
if: | ||
states: success | ||
|
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 |
---|---|---|
|
@@ -4,6 +4,6 @@ program: | |
|
||
action: | ||
type: apsis.actions.test.LogAction | ||
condition: | ||
if: | ||
states: success | ||
|
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,5 @@ | ||
params: [label] | ||
|
||
program: | ||
type: no-op | ||
|
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,26 @@ | ||
params: [label] | ||
|
||
program: | ||
type: no-op | ||
duration: 0.5 | ||
|
||
action: | ||
- type: schedule | ||
if: | ||
states: success | ||
job_id: second | ||
args: | ||
label: on-success | ||
|
||
- type: schedule | ||
if: | ||
states: [failure, error] | ||
job_id: third | ||
args: | ||
label: on-failure | ||
|
||
- type: schedule | ||
if: | ||
states: [success, error] | ||
job_id: fifth | ||
|
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,3 @@ | ||
program: | ||
type: no-op | ||
|
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,11 @@ | ||
params: [label] | ||
|
||
program: | ||
type: no-op | ||
|
||
action: | ||
type: schedule | ||
if: | ||
states: [success, failure, error] | ||
job_id: fourth | ||
|
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,5 @@ | ||
params: [label] | ||
|
||
program: | ||
type: no-op | ||
|
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,47 @@ | ||
from contextlib import closing | ||
from pathlib import Path | ||
import pytest | ||
|
||
from instance import ApsisInstance | ||
|
||
#------------------------------------------------------------------------------- | ||
|
||
job_dir = Path(__file__).absolute().parent / "schedule-jobs" | ||
|
||
@pytest.fixture(scope="function") | ||
def inst(): | ||
with closing(ApsisInstance(job_dir=job_dir)) as inst: | ||
inst.create_db() | ||
inst.write_cfg() | ||
inst.start_serve() | ||
inst.wait_for_serve() | ||
yield inst | ||
|
||
|
||
def test_schedule_action(inst): | ||
client = inst.client | ||
|
||
r1 = client.schedule("first", {"label": "foo"})["run_id"] | ||
# There should be only one one right now. | ||
assert { r["run_id"] for r in client.get_runs().values() } == {r1} | ||
|
||
inst.wait_run(r1) | ||
|
||
# first(label=foo) should have scheduled second(label=on-success). | ||
run, = tuple(client.get_runs(job_id="second").values()) | ||
assert run["args"] == {"label": "on-success"} | ||
|
||
# first(label=foo) should not have scheduled third. | ||
runs = tuple(client.get_runs(job_id="third").values()) | ||
assert len(runs) == 0 | ||
|
||
# second(label=on-success) should have scheduled fourth(). | ||
runs = tuple(client.get_runs(job_id="fourth").values()) | ||
assert len(runs) == 1 | ||
|
||
# first(label=foo) should have scheduled fifth(label=foo) with automatic | ||
# label. | ||
run, = tuple(client.get_runs(job_id="fifth").values()) | ||
assert run["args"] == {"label": "foo"} | ||
|
||
|