コード例 #1
0
ファイル: conftest.py プロジェクト: marswon/eru-core
def test_db(request, app):
    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:@localhost:3306/erutest'
    db.create_all()

    def tear_down():
        db.session.remove()
        db.drop_all()

    request.addfinalizer(tear_down)
コード例 #2
0
def test_db(request, app):
    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:@localhost:3306/erutest'
    db.create_all()

    def tear_down():
        db.session.remove()
        db.drop_all()
        rds.flushall()

    request.addfinalizer(tear_down)
コード例 #3
0
ファイル: fillup.py プロジェクト: lcsandy/eru-core
def fillup_data():
    app, _ = create_app_with_celery()
    with app.app_context():
        db.drop_all()
        db.create_all()

        group = Group.create('test-group', 'test-group')
        pod = Pod.create('test-pod', 'test-pod')
        pod.assigned_to_group(group)

        r = requests.get('http://192.168.59.103:2375/info').json()
        host = Host.create(pod, '192.168.59.103:2375', r['Name'], r['ID'], r['NCPU'], r['MemTotal'])
        host.assigned_to_group(group)

        app = App.get_or_create('nbetest', 'http://git.hunantv.com/platform/nbetest.git', 'token')
        app.add_version('96cbf8c68ed214f105d9f79fa4f22f0e80e75cf3')
        app.assigned_to_group(group)
        version = app.get_version('96cbf8')

        host_cores = group.get_free_cores(pod, 2, 2)
        cores = []
        for (host, cn), coress in host_cores.iteritems():
            print host, cn, coress
            cores = coress
        print cores
        ports = host.get_free_ports(2)
        print ports
        props = {
            'entrypoint': 'web',
            'ncontainer': 2,
            'env': 'PROD',
            'cores': [c.id for c in cores],
            'ports': [p.id for p in ports],
        }
        task = Task.create(1, version, host, props)
        print task.props
        host.occupy_cores(cores)
        host.occupy_ports(ports)
        print group.get_free_cores(pod, 1, 1)
コード例 #4
0
#!/usr/bin/env python
# encoding: utf-8

from eru.app import create_app_with_celery
from eru.models import db, Group, Pod, Host, App
from tests.utils import random_ipv4, random_string, random_uuid, random_sha1

host_number = int(raw_input("how many hosts: "))

app, _ = create_app_with_celery
app.config['TESTING'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:@localhost:3306/erutest'

with app.app_context():
    db.create_all()
    
    a = App.get_or_create('app', 'http://git.hunantv.com/group/app.git', '')
    v = a.add_version(random_sha1())
    g = Group.create('group', 'group')
    p = Pod.create('pod', 'pod', 10, -1)
    p.assigned_to_group(g)
    hosts = [Host.create(p, random_ipv4(), random_string(), random_uuid(), 24, 4096) for i in range(host_number)]
    
    for host in hosts:
        host.assigned_to_group(g)
コード例 #5
0
ファイル: flushdb.py プロジェクト: timfeirg/eru-core
def flushdb(app):
    with app.app_context():
        db.drop_all()
        db.create_all()
コード例 #6
0
ファイル: flushdb.py プロジェクト: linzhonghong/eru-core
def flushdb(app):
    with app.app_context():
        db.drop_all()
        db.create_all()