Skip to content

Commit

Permalink
update integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: cosmicBboy <[email protected]>
  • Loading branch information
cosmicBboy committed Apr 7, 2021
1 parent dbc242e commit e5e317c
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions tests/flytekit/integration/control_plane/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from flytekit.models import literals

PROJECT = "flytesnacks"
VERSION = os.getpid()


@pytest.fixture(scope="session")
Expand All @@ -18,7 +19,7 @@ def flyte_workflows_source_dir():
@pytest.fixture(scope="session")
def flyte_workflows_register(docker_compose):
docker_compose.execute(
f"exec -w /flyteorg/src -e SANDBOX=1 -e PROJECT={PROJECT} -e VERSION=v{os.getpid()} "
f"exec -w /flyteorg/src -e SANDBOX=1 -e PROJECT={PROJECT} -e VERSION=v{VERSION} "
"backend make -C workflows register"
)

Expand All @@ -29,29 +30,29 @@ def test_client(flyteclient):


def test_launch_workflow(flyteclient, flyte_workflows_register):
execution = launch_plan.FlyteLaunchPlan.fetch(
PROJECT, "development", "workflows.basic.basic_workflow.my_wf", f"v{os.getpid()}"
).launch_with_literals(
PROJECT,
"development",
literals.LiteralMap(
{
"a": literals.Literal(literals.Scalar(literals.Primitive(integer=10))),
"b": literals.Literal(literals.Scalar(literals.Primitive(string_value="foobar"))),
}
),
)

for _ in range(20):
if not execution.is_complete:
time.sleep(0.5)
execution.sync()
if execution.node_executions is not None and len(execution.node_executions) > 1:
execution.node_executions["n0"]
# TODO: monitor and inspect node executions
continue
else:
break

assert execution.outputs.literals["o0"].scalar.primitive.integer == 12
assert execution.outputs.literals["o1"].scalar.primitive.string_value == "foobarworld"
for workflow, data in [
("workflows.basic.hello_world.my_wf", literals.LiteralMap({})),
]:
lp = launch_plan.FlyteLaunchPlan.fetch(PROJECT, "development", workflow, f"v{VERSION}")
execution = lp.launch_with_literals(PROJECT, "development", data)
execution.wait_for_completion()
print(execution.id)


def test_launch_workflow_with_args(flyteclient, flyte_workflows_register):
for workflow, data in [
(
"workflows.basic.basic_workflow.my_wf",
literals.LiteralMap(
{
"a": literals.Literal(literals.Scalar(literals.Primitive(integer=10))),
"b": literals.Literal(literals.Scalar(literals.Primitive(string_value="foobar"))),
}
),
)
]:
lp = launch_plan.FlyteLaunchPlan.fetch(PROJECT, "development", workflow, f"v{VERSION}")
execution = lp.launch_with_literals(PROJECT, "development", data)
execution.wait_for_completion()
assert execution.outputs.literals["o0"].scalar.primitive.integer == 12
assert execution.outputs.literals["o1"].scalar.primitive.string_value == "foobarworld"

0 comments on commit e5e317c

Please sign in to comment.