def test_scale_app_in_group():
    """ Tests the scaling of an individual app in a group
    """
    with marathon_on_marathon():
        client = marathon.create_client()
        try:
            client.remove_group('/test-group', True)
            shakedown.deployment_wait()
        except Exception as e:
            pass

        client.create_group(group())
        shakedown.deployment_wait()

        group_apps = client.get_group('/test-group/sleep')
        apps = group_apps['apps']
        assert len(apps) == 2
        tasks1 = client.get_tasks('/test-group/sleep/goodnight')
        tasks2 = client.get_tasks('/test-group/sleep/goodnight2')
        assert len(tasks1) == 1
        assert len(tasks2) == 1

        # scaling just an app in the group
        client.scale_app('/test-group/sleep/goodnight', 2)
        shakedown.deployment_wait()
        tasks1 = client.get_tasks('/test-group/sleep/goodnight')
        tasks2 = client.get_tasks('/test-group/sleep/goodnight2')
        assert len(tasks1) == 2
        assert len(tasks2) == 1
def test_scale_app_in_group():
    """ Tests the scaling of an individual app in a group
    """
    client = marathon.create_client()
    try:
        client.remove_group('/test-group', True)
        shakedown.deployment_wait()
    except Exception as e:
        pass

    client.create_group(group())
    shakedown.deployment_wait()

    group_apps = client.get_group('/test-group/sleep')
    apps = group_apps['apps']
    assert len(apps) == 2
    tasks1 = client.get_tasks('/test-group/sleep/goodnight')
    tasks2 = client.get_tasks('/test-group/sleep/goodnight2')
    assert len(tasks1) == 1
    assert len(tasks2) == 1

    # scaling just an app in the group
    client.scale_app('/test-group/sleep/goodnight', 2)
    shakedown.deployment_wait()
    tasks1 = client.get_tasks('/test-group/sleep/goodnight')
    tasks2 = client.get_tasks('/test-group/sleep/goodnight2')
    assert len(tasks1) == 2
    assert len(tasks2) == 1
Esempio n. 3
0
def test_scale_group():
    """ Tests the scaling of a group
    """
    client = marathon.create_client()
    try:
        client.remove_group('/test-group', True)
        shakedown.deployment_wait()
    except Exception as e:
        pass

    client.create_group(group())
    shakedown.deployment_wait()

    group_apps = client.get_group('/test-group/sleep')
    apps = group_apps['apps']
    assert len(apps) == 2
    tasks1 = client.get_tasks('/test-group/sleep/goodnight')
    tasks2 = client.get_tasks('/test-group/sleep/goodnight2')
    assert len(tasks1) == 1
    assert len(tasks2) == 1

    # scale by 2 for the entire group
    client.scale_group('/test-group/sleep', 2)
    shakedown.deployment_wait()
    tasks1 = client.get_tasks('/test-group/sleep/goodnight')
    tasks2 = client.get_tasks('/test-group/sleep/goodnight2')
    assert len(tasks1) == 2
    assert len(tasks2) == 2
Esempio n. 4
0
def test_scale_app_in_group():
    """ Tests the scaling of an individual app in a group
    """
    client = marathon.create_client()
    try:
        client.remove_group('/test-group', True)
        shakedown.deployment_wait()
    except Exception as e:
        pass

    client.create_group(group())
    shakedown.deployment_wait()

    group_apps = client.get_group('/test-group/sleep')
    apps = group_apps['apps']
    assert len(apps) == 2, "Num of Apps: {} is not 2".format(len(apps))
    tasks1 = client.get_tasks('/test-group/sleep/goodnight')
    tasks2 = client.get_tasks('/test-group/sleep/goodnight2')
    assert len(tasks1) == 1, "Num of tasks 1: {} is not 1 after deployment".format(len(tasks1))
    assert len(tasks2) == 1, "Num of tasks 2: {} is not 1 after deployment".format(len(tasks2))

    # scaling just an app in the group
    client.scale_app('/test-group/sleep/goodnight', 2)
    shakedown.deployment_wait()
    tasks1 = client.get_tasks('/test-group/sleep/goodnight')
    tasks2 = client.get_tasks('/test-group/sleep/goodnight2')
    assert len(tasks1) == 2, "Num of tasks 1: {} is not 2 after scale".format(len(tasks1))
    assert len(tasks2) == 1, "Num of tasks 2: {} is not 1 after scale".format(len(tasks2))
Esempio n. 5
0
def test_launch_group():
    """ Tests the lauching a group of apps at the same time (by request, it is 2 deep)
    """
    client = marathon.create_client()
    try:
        client.remove_group('/')
        shakedown.deployment_wait()
    except Exception as e:
        pass

    client.create_group(group())
    shakedown.deployment_wait()

    group_apps = client.get_group('/test-group/sleep')
    apps = group_apps['apps']
    assert len(apps) == 2
Esempio n. 6
0
def test_scale_app_in_group_then_group():
    """ Tests the scaling of an app in the group, then the group
    """
    client = marathon.create_client()
    try:
        client.remove_group('/test-group', True)
        shakedown.deployment_wait()
    except Exception as e:
        pass

    client.create_group(group())
    shakedown.deployment_wait()

    group_apps = client.get_group('/test-group/sleep')
    apps = group_apps['apps']
    assert len(apps) == 2
    tasks1 = client.get_tasks('/test-group/sleep/goodnight')
    tasks2 = client.get_tasks('/test-group/sleep/goodnight2')
    assert len(tasks1) == 1
    assert len(tasks2) == 1

    # scaling just an app
    client.scale_app('/test-group/sleep/goodnight', 2)
    shakedown.deployment_wait()
    tasks1 = client.get_tasks('/test-group/sleep/goodnight')
    tasks2 = client.get_tasks('/test-group/sleep/goodnight2')
    assert len(tasks1) == 2
    assert len(tasks2) == 1

    # scaling the group after 1 app in the group was scaled.
    client.scale_group('/test-group/sleep', 2)
    shakedown.deployment_wait()
    time.sleep(1)
    tasks1 = client.get_tasks('/test-group/sleep/goodnight')
    tasks2 = client.get_tasks('/test-group/sleep/goodnight2')
    assert len(tasks1) == 4
    assert len(tasks2) == 2
Esempio n. 7
0
import common as c

html = BeautifulSoup( urllib2.urlopen( URL ) )
table = html.table

header = table.tr.find_all('th')
header = map( lambda x : x.string.strip() if x.string else '', header )

data = {}

for s in table.find_all('tr', 'student'):
	cols = s.find_all('td')
	## first td is user name
	d = {};

	username = cols[0].string.strip()
	color = c.group( username )
	tasks = map( lambda x : x.string != None, cols[1:] )

	if color not in data:
		data[color] = []


	d['color'] = color
	d['tasks'] = tasks

	data[color].append( tasks )
	data['_' + username] = d

json.dump( data , open( FILE, 'w' ) )
Esempio n. 8
0
FILE = '../data/points-all.json'
URL = 'http://tmc.mooc.fi/mooc/courses/15/points.csv'

import json
import csv
import urllib2

import common as c

## load previous data if needed
try:
	data = json.load( open( FILE, 'r') )
except IOError:
	data = {}

web = csv.DictReader( urllib2.urlopen( URL ) )

for line in web:
	username = line['Username'];
	if username not in data:
		data[ username ] = { 'data' : [] }
	data[username]['group'] = c.group( line['Username'] )
	d = { 'time' : c.now(), 'points' : int( line['Total'] ) }
	data[username]['data'].append( d )

json.dump( data, open( FILE, 'w') )