Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Add custom plans with unique resource sets (#2978)
Browse files Browse the repository at this point in the history
  • Loading branch information
takirala authored Mar 13, 2019
1 parent 2c81500 commit 6f1ee9f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 20 deletions.
37 changes: 36 additions & 1 deletion frameworks/helloworld/src/main/dist/plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ pods:
delay: 0
timeout: 10
max-consecutive-failures: 3
custom-pod-A:
count: 1
tasks:
simple-task:
cpus: 0.1
memory: 32
goal: RUNNING
cmd: "echo custom-pod-A-simple-task && sleep 10000"
custom-pod-B:
count: 1
tasks:
simple-task:
cpus: 0.1
memory: 32
goal: RUNNING
cmd: "echo custom-pod-B-simple-task && sleep 10000"
custom-pod-C:
count: 1
tasks:
simple-task:
cpus: 0.1
memory: 32
goal: RUNNING
cmd: "echo custom-pod-C-simple-task && sleep 10000"
plans:
deploy:
strategy: serial
Expand All @@ -55,4 +79,15 @@ plans:
world-deploy:
strategy: parallel
pod: world

manual-plan-0:
phases:
manual-plan-0-phase:
pod: custom-pod-A
manual-plan-1:
phases:
manual-plan-1-phase:
pod: custom-pod-B
manual-plan-2:
phases:
manual-plan-2-phase:
pod: custom-pod-C
41 changes: 22 additions & 19 deletions frameworks/helloworld/tests/test_parallel_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def configure_package(configure_security):

@pytest.mark.sanity
def test_all_tasks_are_launched():
service_options = {"service": {"yaml": "sidecar"}, "hello": {"count": 1}}
service_options = {"service": {"yaml": "plan"}}
sdk_install.install(
config.PACKAGE_NAME,
foldered_name,
Expand All @@ -36,21 +36,24 @@ def test_all_tasks_are_launched():
wait_for_all_conditions=True
)
# after above method returns, start all plans right away.
sdk_plan.start_plan(foldered_name, "sidecar")
sdk_plan.start_plan(foldered_name, "sidecar-parameterized", {"PLAN_PARAMETER": "parameterized"})
sdk_plan.wait_for_completed_plan(foldered_name, "sidecar")
sdk_plan.wait_for_completed_plan(foldered_name, "sidecar-parameterized")
# /pod/<pod-id>/info fetches data from SDK's persistence layer
pod_hello_0_info = sdk_cmd.service_request(
"GET", foldered_name, "/v1/pod/hello-0/info"
).json()
for taskInfoAndStatus in pod_hello_0_info:
info = taskInfoAndStatus["info"]
status = taskInfoAndStatus["status"]
# While `info` object is always present, `status` may or may not be present based on whether the
# task was launched and we received an update from mesos (or not).
if status:
assert info["taskId"]["value"] == status["taskId"]["value"]
assert len(info["taskId"]["value"]) > 0
else:
assert len(info["taskId"]["value"]) == 0
plans = ["manual-plan-0", "manual-plan-1", "manual-plan-2"]
for plan in plans:
sdk_plan.start_plan(foldered_name, plan)
for plan in plans:
sdk_plan.wait_for_completed_plan(foldered_name, plan)
pods = ["custom-pod-A-0", "custom-pod-B-0", "custom-pod-C-0"]
for pod in pods:
# /pod/<pod-id>/info fetches data from SDK's persistence layer
pod_hello_0_info = sdk_cmd.service_request(
"GET", foldered_name, "/v1/pod/{}/info".format(pod)
).json()
for taskInfoAndStatus in pod_hello_0_info:
info = taskInfoAndStatus["info"]
status = taskInfoAndStatus["status"]
# While `info` object is always present, `status` may or may not be present based
# on whether the task was launched and we received an update from mesos (or not).
if status:
assert info["taskId"]["value"] == status["taskId"]["value"]
assert len(info["taskId"]["value"]) > 0
else:
assert len(info["taskId"]["value"]) == 0

0 comments on commit 6f1ee9f

Please sign in to comment.