def test_rr_by_hostname(): sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) options = _escape_placement_for_1_9({ "service": { "yaml": "marathon_constraint" }, "hello": { "count": config.get_num_private_agents() * 2, "placement": "[[\"hostname\", \"GROUP_BY\", \"{}\"]]".format( config.get_num_private_agents()) }, "world": { "count": config.get_num_private_agents() * 2, "placement": "[[\"hostname\", \"GROUP_BY\", \"{}\"]]".format( config.get_num_private_agents()) } }) sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents() * 4, additional_options=options) ensure_max_count_per_agent(hello_count=2, world_count=2)
def test_rr_by_hostname(): sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) options = { "service": { "spec_file": "examples/marathon_constraint.yml" }, "hello": { "count": config.get_num_private_agents() * 2, "placement": "hostname:GROUP_BY:{}".format(config.get_num_private_agents()) }, "world": { "count": config.get_num_private_agents() * 2, "placement": "hostname:GROUP_BY:{}".format(config.get_num_private_agents()) } } sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents() * 4, additional_options=options) ensure_max_count_per_agent(hello_count=2, world_count=2)
def test_hostname_unique(): options = { "service": { "spec_file": "examples/marathon_constraint.yml" }, "hello": { "count": config.get_num_private_agents(), "placement": "hostname:UNIQUE" }, "world": { "count": config.get_num_private_agents(), "placement": "hostname:UNIQUE" } } sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents() * 2, additional_options=options) # hello deploys first. One "world" task should end up placed with each "hello" task. # ensure "hello" task can still be placed with "world" task sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME, 'pod replace hello-0') sdk_tasks.check_running(config.SERVICE_NAME, config.get_num_private_agents() * 2 - 1, timeout_seconds=10) sdk_tasks.check_running(config.SERVICE_NAME, config.get_num_private_agents() * 2) ensure_count_per_agent(hello_count=1, world_count=1)
def test_hostname_unique(): sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) options = _escape_placement_for_1_9({ "service": { "yaml": "marathon_constraint" }, "hello": { "count": config.get_num_private_agents(), "placement": "[[\"hostname\", \"UNIQUE\"]]" }, "world": { "count": config.get_num_private_agents(), "placement": "[[\"hostname\", \"UNIQUE\"]]" } }) sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents() * 2, additional_options=options) # hello deploys first. One "world" task should end up placed with each "hello" task. # ensure "hello" task can still be placed with "world" task sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME, 'pod replace hello-0') sdk_plan.wait_for_kicked_off_recovery(config.SERVICE_NAME) sdk_plan.wait_for_completed_recovery(config.SERVICE_NAME) sdk_tasks.check_running(config.SERVICE_NAME, config.get_num_private_agents() * 2 - 1, timeout_seconds=10) sdk_tasks.check_running(config.SERVICE_NAME, config.get_num_private_agents() * 2) ensure_count_per_agent(hello_count=1, world_count=1)
def test_hostname_unique(): sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) options = _escape_placement_for_1_9({ "service": { "yaml": "marathon_constraint" }, "hello": { "count": config.get_num_private_agents(), "placement": "[[\"hostname\", \"UNIQUE\"]]" }, "world": { "count": config.get_num_private_agents(), "placement": "[[\"hostname\", \"UNIQUE\"]]" } }) sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents() * 2, additional_options=options) # hello deploys first. One "world" task should end up placed with each "hello" task. # ensure "hello" task can still be placed with "world" task sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME, 'pod replace hello-0') sdk_plan.wait_for_kicked_off_recovery(config.SERVICE_NAME) sdk_plan.wait_for_completed_recovery(config.SERVICE_NAME) sdk_tasks.check_running(config.SERVICE_NAME, config.get_num_private_agents() * 2 - 1, timeout_seconds=10) sdk_tasks.check_running(config.SERVICE_NAME, config.get_num_private_agents() * 2) ensure_count_per_agent(hello_count=1, world_count=1)
def test_cluster(): sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) some_agent = shakedown.get_private_agents().pop() options = _escape_placement_for_1_9({ "service": { "yaml": "marathon_constraint" }, "hello": { "count": config.get_num_private_agents(), "placement": "[[\"hostname\", \"CLUSTER\", \"{}\"]]".format(some_agent) }, "world": { "count": 0 } }) sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents(), additional_options=options) ensure_count_per_agent(hello_count=config.get_num_private_agents(), world_count=0)
def test_max_per_hostname(): sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) options = _escape_placement_for_1_9({ "service": { "yaml": "marathon_constraint" }, "hello": { "count": config.get_num_private_agents() * 2, "placement": "[[\"hostname\", \"MAX_PER\", \"2\"]]" }, "world": { "count": config.get_num_private_agents() * 3, "placement": "[[\"hostname\", \"MAX_PER\", \"3\"]]" } }) sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents() * 5, additional_options=options) ensure_max_count_per_agent(hello_count=2, world_count=3)
def test_cluster(): sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) some_agent = shakedown.get_private_agents().pop() options = _escape_placement_for_1_9({ "service": { "yaml": "marathon_constraint" }, "hello": { "count": config.get_num_private_agents(), "placement": "[[\"hostname\", \"CLUSTER\", \"{}\"]]".format(some_agent) }, "world": { "count": 0 } }) sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents(), additional_options=options) ensure_count_per_agent(hello_count=config.get_num_private_agents(), world_count=0)
def test_rr_by_hostname(): sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) options = _escape_placement_for_1_9({ "service": { "yaml": "marathon_constraint" }, "hello": { "count": config.get_num_private_agents() * 2, "placement": "[[\"hostname\", \"GROUP_BY\", \"{}\"]]".format(config.get_num_private_agents()) }, "world": { "count": config.get_num_private_agents() * 2, "placement": "[[\"hostname\", \"GROUP_BY\", \"{}\"]]".format(config.get_num_private_agents()) } }) sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents() * 4, additional_options=options) ensure_max_count_per_agent(hello_count=2, world_count=2)
def test_max_per_hostname(): sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) options = _escape_placement_for_1_9({ "service": { "yaml": "marathon_constraint" }, "hello": { "count": config.get_num_private_agents() * 2, "placement": "[[\"hostname\", \"MAX_PER\", \"2\"]]" }, "world": { "count": config.get_num_private_agents() * 3, "placement": "[[\"hostname\", \"MAX_PER\", \"3\"]]" } }) sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents() * 5, additional_options=options) ensure_max_count_per_agent(hello_count=2, world_count=3)
def test_max_per_hostname(): sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) options = { "service": { "spec_file": "examples/marathon_constraint.yml" }, "hello": { "count": config.get_num_private_agents() * 2, "placement": "hostname:MAX_PER:2" }, "world": { "count": config.get_num_private_agents() * 3, "placement": "hostname:MAX_PER:3" } } sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents() * 5, additional_options=options) ensure_max_count_per_agent(hello_count=2, world_count=3)
def test_cluster(): sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME) some_agent = shakedown.get_private_agents().pop() options = { "service": { "spec_file": "examples/marathon_constraint.yml" }, "hello": { "count": config.get_num_private_agents(), "placement": "hostname:CLUSTER:{}".format(some_agent) }, "world": { "count": 0 } } sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, config.get_num_private_agents(), additional_options=options) ensure_count_per_agent(hello_count=config.get_num_private_agents(), world_count=0)