def test_external_volume(): volume_name = "marathon-si-test-vol-{}".format(uuid.uuid4().hex) app_def = common.external_volume_mesos_app(volume_name) app_id = app_def['id'] # Tested with root marathon since MoM doesn't have # --enable_features external_volumes option activated. # First deployment should create the volume since it has a unique name try: client = marathon.create_client() client.add_app(app_def) shakedown.deployment_wait() # Create the app: the volume should be successfully created common.assert_app_tasks_running(client, app_def) common.assert_app_tasks_healthy(client, app_def) # Scale down to 0 client.stop_app(app_id) shakedown.deployment_wait() # Scale up again: the volume should be successfully reused client.scale_app(app_id, 1) shakedown.deployment_wait() common.assert_app_tasks_running(client, app_def) common.assert_app_tasks_healthy(client, app_def) # Remove the app to be able to remove the volume client.remove_app(app_id) shakedown.deployment_wait() except Exception as e: print('Fail to test external volumes: {}'.format(e)) raise e finally: # Clean up after the test: external volumes are not destroyed by marathon or dcos # and have to be cleaned manually. agent = shakedown.get_private_agents()[0] result, output = shakedown.run_command_on_agent( agent, 'sudo /opt/mesosphere/bin/dvdcli remove --volumedriver=rexray --volumename={}' .format(volume_name)) # NOQA # Note: Removing the volume might fail sometimes because EC2 takes some time (~10min) to recognize that # the volume is not in use anymore hence preventing it's removal. This is a known pitfall: we log the error # and the volume should be cleaned up manually later. if not result: print('WARNING: Failed to remove external volume with name={}: {}'. format(volume_name, output))
def test_external_volume(): volume_name = "marathon-si-test-vol-{}".format(uuid.uuid4().hex) app_def = common.external_volume_mesos_app(volume_name) app_id = app_def['id'] # Tested with root marathon since MoM doesn't have # --enable_features external_volumes option activated. # First deployment should create the volume since it has a unique name try: client = marathon.create_client() client.add_app(app_def) shakedown.deployment_wait() # Create the app: the volume should be successfully created common.assert_app_tasks_running(client, app_def) common.assert_app_tasks_healthy(client, app_def) # Scale down to 0 client.stop_app(app_id) shakedown.deployment_wait() # Scale up again: the volume should be successfully reused client.scale_app(app_id, 1) shakedown.deployment_wait() common.assert_app_tasks_running(client, app_def) common.assert_app_tasks_healthy(client, app_def) # Remove the app to be able to remove the volume client.remove_app(app_id) shakedown.deployment_wait() except Exception as e: print('Fail to test external volumes: {}'.format(e)) raise e finally: # Clean up after the test: external volumes are not destroyed by marathon or dcos # and have to be cleaned manually. agent = shakedown.get_private_agents()[0] result, output = shakedown.run_command_on_agent(agent, 'sudo /opt/mesosphere/bin/dvdcli remove --volumedriver=rexray --volumename={}'.format(volume_name)) # NOQA # Note: Removing the volume might fail sometimes because EC2 takes some time (~10min) to recognize that # the volume is not in use anymore hence preventing it's removal. This is a known pitfall: we log the error # and the volume should be cleaned up manually later. if not result: print('WARNING: Failed to remove external volume with name={}: {}'.format(volume_name, output))
def test_external_volume(): volume_name = "marathon-si-test-vol-{}".format(uuid.uuid4().hex) app_def = common.external_volume_mesos_app(volume_name) app_id = app_def['id'] # Tested with root marathon since MoM doesn't have # --enable_features external_volumes option activated. # First deployment should create the volume since it has a unique name try: client = marathon.create_client() client.add_app(app_def) shakedown.deployment_wait() # Create the app: the volume should be successfully created common.assert_app_tasks_running(client, app_def) common.assert_app_tasks_healthy(client, app_def) # Scale down to 0 client.stop_app(app_id) shakedown.deployment_wait() # Scale up again: the volume should be successfully reused client.scale_app(app_id, 1) shakedown.deployment_wait() common.assert_app_tasks_running(client, app_def) common.assert_app_tasks_healthy(client, app_def) # Remove the app to be able to remove the volume client.remove_app(app_id) shakedown.deployment_wait() except Exception as e: print('Fail to test external volumes: {}'.format(e)) raise e finally: # Clean up after the test: external volumes are not destroyed by marathon or dcos # and have to be cleaned manually. agent = shakedown.get_private_agents()[0] result, output = shakedown.run_command_on_agent( agent, 'sudo /opt/mesosphere/bin/dvdcli remove --volumedriver=rexray --volumename={}' .format(volume_name)) assert result, 'Failed to remove external volume with name={}: {}'.format( volume_name, output)