def test_unhealthy_app_can_be_rolled_back(): """Verifies that an updated app gets rolled back due to being unhealthy.""" app_def = apps.readiness_and_health_app() app_id = app_def["id"] @retrying.retry( wait_fixed=1000, stop_max_attempt_number=30, retry_on_exception=common.ignore_provided_exception(DCOSException) ) def wait_for_deployment(): deployment_wait(service_id=app_id) client = marathon.create_client() client.add_app(app_def) wait_for_deployment() tasks = client.get_tasks(app_id) assert len(tasks) == 1, "The number of tasks is {} after deployment, but 1 was expected".format(len(tasks)) app_def['healthChecks'][0]['path'] = '/non-existent' app_def['instances'] = 2 deployment_id = client.update_app(app_id, app_def) try: wait_for_deployment() except Exception: client.rollback_deployment(deployment_id) wait_for_deployment() tasks = client.get_tasks(app_id) assert len(tasks) == 1, "The number of tasks is {} after rollback, but 1 was expected".format(len(tasks))
def test_unhealthy_app_can_be_rolled_back(): """Verifies that an updated app gets rolled back due to being unhealthy.""" app_def = apps.readiness_and_health_app() app_id = app_def["id"] client = marathon.create_client() client.add_app(app_def) shakedown.deployment_wait() tasks = client.get_tasks(app_id) assert len( tasks ) == 1, "The number of tasks is {} after deployment, but 1 was expected".format( len(tasks)) app_def['healthChecks'][0]['path'] = '/non-existent' app_def['instances'] = 2 deployment_id = client.update_app(app_id, app_def) try: shakedown.deployment_wait() except Exception: client.rollback_deployment(deployment_id) shakedown.deployment_wait() tasks = client.get_tasks(app_id) assert len( tasks ) == 1, "The number of tasks is {} after rollback, but 1 was expected".format( len(tasks))
def test_app_update_rollback(): """Tests that an updated app can be rolled back to its initial version.""" app_def = apps.readiness_and_health_app("app-update-rollback") app_id = app_def["id"] # First deployment client = marathon.create_client() client.add_app(app_def) deployment_wait(service_id=app_id) tasks = client.get_tasks(app_id) assert_that(tasks, has_len(equal_to(1))) # Second deployment app_def['instances'] = 2 client.update_app(app_id, app_def) deployment_wait(service_id=app_id) tasks = client.get_tasks(app_id) assert_that(tasks, has_len(equal_to(2))) # Third deployment with rollback # provides a testing delay to rollback in the meantime app_def['readinessChecks'][0]['intervalSeconds'] = 30 app_def['instances'] = 1 deployment_id = client.update_app(app_id, app_def) client.rollback_deployment(deployment_id) deployment_wait(service_id=app_id) # update to 1 instance is rollback to 2 tasks = client.get_tasks(app_id) assert_that(tasks, has_len(equal_to(2)))
def test_unhealthy_app_can_be_rolled_back(): """Verifies that an updated app gets rolled back due to being unhealthy.""" app_def = apps.readiness_and_health_app() app_id = app_def["id"] @retrying.retry( wait_fixed=1000, stop_max_attempt_number=30, retry_on_exception=common.ignore_provided_exception(DCOSException) ) def wait_for_deployment(): shakedown.deployment_wait() client = marathon.create_client() client.add_app(app_def) wait_for_deployment() tasks = client.get_tasks(app_id) assert len(tasks) == 1, "The number of tasks is {} after deployment, but 1 was expected".format(len(tasks)) app_def['healthChecks'][0]['path'] = '/non-existent' app_def['instances'] = 2 deployment_id = client.update_app(app_id, app_def) try: wait_for_deployment() except Exception: client.rollback_deployment(deployment_id) wait_for_deployment() tasks = client.get_tasks(app_id) assert len(tasks) == 1, "The number of tasks is {} after rollback, but 1 was expected".format(len(tasks))
def test_app_update_rollback(): """Tests that an updated app can be rolled back to its initial version.""" app_def = apps.readiness_and_health_app() app_id = app_def["id"] client = marathon.create_client() client.add_app(app_def) shakedown.deployment_wait(app_id=app_id) tasks = client.get_tasks(app_id) assert len(tasks) == 1, "The number of tasks is {} after deployment, but 1 was expected".format(len(tasks)) app_def['instances'] = 2 client.update_app(app_id, app_def) shakedown.deployment_wait(app_id=app_id) tasks = client.get_tasks(app_id) assert len(tasks) == 2, "The number of tasks is {} after update, but 2 was expected".format(len(tasks)) # provides a testing delay to rollback in the meantime app_def['readinessChecks'][0]['intervalSeconds'] = 30 app_def['instances'] = 1 deployment_id = client.update_app(app_id, app_def) client.rollback_deployment(deployment_id) shakedown.deployment_wait(app_id=app_id) # update to 1 instance is rollback to 2 tasks = client.get_tasks(app_id) assert len(tasks) == 2, "The number of tasks is {} after rollback, but 2 was expected".format(len(tasks))
def test_unhealthy_app_can_be_rolled_back(): """Verifies that an updated app gets rolled back due to being unhealthy.""" app_def = apps.readiness_and_health_app() app_id = app_def["id"] client = marathon.create_client() client.add_app(app_def) shakedown.deployment_wait() tasks = client.get_tasks(app_id) assert len(tasks) == 1, "The number of tasks is {} after deployment, but 1 was expected".format(len(tasks)) app_def['healthChecks'][0]['path'] = '/non-existent' app_def['instances'] = 2 deployment_id = client.update_app(app_id, app_def) try: shakedown.deployment_wait() except Exception: client.rollback_deployment(deployment_id) shakedown.deployment_wait() tasks = client.get_tasks(app_id) assert len(tasks) == 1, "The number of tasks is {} after rollback, but 1 was expected".format(len(tasks))
def test_app_update_rollback(): """Tests that an updated app can be rolled back to its initial version.""" app_def = apps.readiness_and_health_app() app_id = app_def["id"] client = marathon.create_client() client.add_app(app_def) shakedown.deployment_wait() tasks = client.get_tasks(app_id) assert len(tasks) == 1, "The number of tasks is {} after deployment, but 1 was expected".format(len(tasks)) app_def['instances'] = 2 client.update_app(app_id, app_def) shakedown.deployment_wait() tasks = client.get_tasks(app_id) assert len(tasks) == 2, "The number of tasks is {} after update, but 2 was expected".format(len(tasks)) # provides a testing delay to rollback in the meantime app_def['readinessChecks'][0]['intervalSeconds'] = 30 app_def['instances'] = 1 deployment_id = client.update_app(app_id, app_def) client.rollback_deployment(deployment_id) shakedown.deployment_wait() # update to 1 instance is rollback to 2 tasks = client.get_tasks(app_id) assert len(tasks) == 2, "The number of tasks is {} after rollback, but 2 was expected".format(len(tasks))