Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions itests/itest_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from functools import wraps
import os
import signal
import sys
import threading
import time

import requests
Expand All @@ -13,6 +11,7 @@
class TimeoutError(Exception):
pass


def timeout(seconds=10, error_message=os.strerror(errno.ETIME)):
def decorator(func):
def _handle_timeout(signum, frame):
Expand All @@ -39,7 +38,8 @@ def wait_for_marathon():
while True:
print 'Connecting to marathon on %s' % marathon_service
try:
response = requests.get('http://%s/ping' % marathon_service, timeout=2)
response = requests.get(
'http://%s/ping' % marathon_service, timeout=2)
except (
requests.exceptions.ConnectionError,
requests.exceptions.Timeout,
Expand Down
26 changes: 17 additions & 9 deletions itests/steps/marathon_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ def get_marathon_info(context):

@when(u'we create a trivial new app')
def create_trivial_new_app(context):
context.client.create_app('test-trivial-app', marathon.MarathonApp(cmd='sleep 3600', mem=16, cpus=1, instances=5))
context.client.create_app('test-trivial-app', marathon.MarathonApp(
cmd='sleep 3600', mem=16, cpus=1, instances=5))


@then(u'we should be able to kill the tasks')
def kill_a_task(context):
time.sleep(5)
app = context.client.get_app('test-trivial-app')
tasks = app.tasks
context.client.kill_task(app_id='test-trivial-app', task_id=tasks[0].id, scale=True)
context.client.kill_task(
app_id='test-trivial-app', task_id=tasks[0].id, scale=True)


@when(u'we create a complex new app')
Expand All @@ -42,14 +44,18 @@ def create_complex_new_app_with_unicode(context):
'container': {
'type': 'DOCKER',
'docker': {
'portMappings': [{'protocol': 'tcp', 'containerPort': 8888, 'hostPort': 0}],
'portMappings':
[{'protocol': 'tcp',
'containerPort': 8888,
'hostPort': 0}],
'image': u'localhost/fake_docker_url',
'network': 'BRIDGE',
'parameters': [
{'key': 'add-host', 'value': 'google-public-dns-a.google.com:8.8.8.8'},
],
'parameters': [{'key': 'add-host', 'value': 'google-public-dns-a.google.com:8.8.8.8'}],
},
'volumes': [{'hostPath': u'/etc/stuff', 'containerPath': u'/etc/stuff', 'mode': 'RO'}],
'volumes':
[{'hostPath': u'/etc/stuff',
'containerPath': u'/etc/stuff',
'mode': 'RO'}],
},
'instances': 1,
'mem': 30,
Expand All @@ -72,7 +78,8 @@ def create_complex_new_app_with_unicode(context):
},
],
}
context.client.create_app('test-complex-app', marathon.MarathonApp(**app_config))
context.client.create_app(
'test-complex-app', marathon.MarathonApp(**app_config))


@then(u'we should see the {which} app running via the marathon api')
Expand All @@ -92,7 +99,8 @@ def wait_deployment_finish(context, which):

@then(u'we should be able to kill the #{to_kill} tasks of the {which} app')
def kill_tasks(context, to_kill, which):
app_tasks = context.client.get_app('test-%s-app' % which, embed_tasks=True).tasks
app_tasks = context.client.get_app(
'test-%s-app' % which, embed_tasks=True).tasks

index_to_kill = eval("[" + to_kill + "]")
task_to_kill = [app_tasks[index].id for index in index_to_kill]
Expand Down
Loading