예제 #1
0
def test_start_volumes_from():

    with injector({'dns-server': 'local.dns', 'dns-search-suffix': 'local'}):
        s = Service()
        s.name = 'my_service'
        s.volumes_from = ['foo', 'bar']

        flexmock(s)

        s.client = flexmock()

        s.client.should_receive('find_container_by_name').with_args(
            'my_service').once().and_return(defer.succeed('123abc'))
        s.client.should_receive('start_container').with_args(
            '123abc',
            ticket_id=123123,
            config={
                "VolumesFrom": ['foo', 'bar'],
                'DnsSearch': 'None.local',
                'Dns': ['local.dns']
            }).once().and_return(defer.succeed('boo'))
        s.should_receive('inspect').with_args().once().and_return(
            defer.succeed('baz'))

        r = yield s.start(ticket_id=123123)

        assert r == 'baz'
예제 #2
0
def test_start_ports():

    with injector({'dns-server': 'local.dns', 'dns-search-suffix': 'local'}):
        s = Service()
        s.name = 'my_service'
        s.ports = ['22/tcp']

        flexmock(s)

        s.client = flexmock()

        s.client.should_receive('find_container_by_name').with_args(
            'my_service').once().and_return(defer.succeed('123abc'))
        s.client.should_receive('start_container').with_args(
            '123abc',
            ticket_id=123123,
            config={
                "PortBindings": {
                    '22/tcp': [{}]
                },
                'DnsSearch': 'None.local',
                'Dns': ['local.dns']
            }).once().and_return(defer.succeed('boo'))
        s.should_receive('inspect').with_args().once().and_return(
            defer.succeed('baz'))

        r = yield s.start(ticket_id=123123)

        assert r == 'baz'
예제 #3
0
def test_start_volumes():

    with injector({'dns-server': 'local.dns', 'dns-search-suffix': 'local'}):
        s = Service()
        s.name = 'my_service'
        s.volumes = [
            {'local': '/base/path/foo1', 'remote': '/bar1'},
            {'local': '/base/path/foo2', 'remote': '/bar2'},
            {'local': '/base/path/foo3', 'remote': '/bar3'}
        ]
        flexmock(s)

        s.client = flexmock()

        s.client.should_receive('find_container_by_name').with_args('my_service').once().and_return(defer.succeed('123abc'))
        s.client.should_receive('start_container').with_args('123abc', ticket_id=123123, config={
            "Binds": ['/base/path/foo1:/bar1', '/base/path/foo2:/bar2', '/base/path/foo3:/bar3'],
            'DnsSearch': 'None.local',
            'Dns': ['local.dns']
        }).once().and_return(defer.succeed('boo'))
        s.should_receive('inspect').with_args().once().and_return(defer.succeed('baz'))

        r = yield s.start(ticket_id=123123)

        assert r == 'baz'
예제 #4
0
def test_tasks_are_registered():

    with injector({}):

        ts = TaskService()
        tasks = ts.collect_tasks()

        assert tasks['help'] == ts.task_help
예제 #5
0
def test_tasks_are_registered():

    with injector({}):

        ts = TaskService()
        tasks = ts.collect_tasks()

        assert tasks['help'] == ts.task_help
예제 #6
0
def test_start():

    with injector({'dns-server': 'local.dns', 'dns-search-suffix': 'local'}):

        s = Service()
        s.name = 'my_service'
        flexmock(s)

        s.client = flexmock()

        s.client.should_receive('find_container_by_name').with_args('my_service').once().and_return(defer.succeed('123abc'))
        s.client.should_receive('start_container').with_args('123abc', ticket_id=123123, config={'DnsSearch': 'None.local', 'Dns': ['local.dns']}).once().and_return(defer.succeed('boo'))
        s.should_receive('inspect').with_args().once().and_return(defer.succeed('baz'))

        r = yield s.start(ticket_id=123123)

        assert r == 'baz'
예제 #7
0
def test_start_volumes():

    with injector({'dns-server': 'local.dns', 'dns-search-suffix': 'local'}):
        s = Service()
        s.name = 'my_service'
        s.volumes = [{
            'local': '/base/path/foo1',
            'remote': '/bar1'
        }, {
            'local': '/base/path/foo2',
            'remote': '/bar2'
        }, {
            'local': '/base/path/foo3',
            'remote': '/bar3'
        }]
        flexmock(s)

        s.client = flexmock()

        s.client.should_receive('find_container_by_name').with_args(
            'my_service').once().and_return(defer.succeed('123abc'))
        s.client.should_receive('start_container').with_args(
            '123abc',
            ticket_id=123123,
            config={
                "Binds": [
                    '/base/path/foo1:/bar1', '/base/path/foo2:/bar2',
                    '/base/path/foo3:/bar3'
                ],
                'DnsSearch':
                'None.local',
                'Dns': ['local.dns']
            }).once().and_return(defer.succeed('boo'))
        s.should_receive('inspect').with_args().once().and_return(
            defer.succeed('baz'))

        r = yield s.start(ticket_id=123123)

        assert r == 'baz'