Exemple #1
0
def ceph_client(request):
    class CephClient(object):
        def __init__(self, mon_host, username, key, pool_name):
            self.mon_host = mon_host
            self.username = username
            self.key = key
            self.pool_name = pool_name

    pool_name = 'data'
    result = ceph_server.up('onedata/ceph', [(pool_name, '8')], 'storage', '1')

    [container] = result['docker_ids']
    username = result['username']
    key = str(result['key'])
    mon_host = docker.inspect(container)['NetworkSettings']['IPAddress']. \
        encode('ascii')

    def fin():
        docker.exec_(container, ['btrfs', 'subvolume', 'delete',
                                 '/var/lib/ceph/osd/ceph-0/current'])
        docker.exec_(container, ['btrfs', 'subvolume', 'delete',
                                 '/var/lib/ceph/osd/ceph-0/snap_1'])
        docker.remove([container], force=True, volumes=True)

    request.addfinalizer(fin)

    return CephClient(mon_host, username, key, pool_name)
 def test_rest_example(self):
     [container] = self.result['docker_ids']
     appmock_ip = docker.inspect(container)['NetworkSettings']['IPAddress'].encode(
         'ascii')
     # Run the tested code
     some_rest_using_function(appmock_ip)
     # Now, we can verify if expected requests were made by the tested code
     expected_history = [
         (8080, '/test1/[:binding]'),
         (8080, '/test1/[:binding]'),
         (8080, '/test2'),
         (8080, '/test2'),
         (8080, '/test2'),
         (9090, '/test_with_state'),
         (9090, '/test_with_state'),
         (9090, '/test_with_state'),
         (9090, '/test_with_state'),
         (9090, '/test_with_state'),
         (443, '/[:binding/[...]]')
     ]
     assert appmock_client.verify_rest_history(appmock_ip, expected_history)
     # Get number of requests on certain endpoint and check if it matches the expected value.
     assert 5 == appmock_client.rest_endpoint_request_count(appmock_ip, 9090, '/test_with_state')
     # Reset counters
     appmock_client.reset_rest_history(appmock_ip)
     assert appmock_client.verify_rest_history(appmock_ip, [])
     assert 0 == appmock_client.rest_endpoint_request_count(appmock_ip, 9090, '/test_with_state')
     # And check again if they work
     some_rest_using_function(appmock_ip)
     assert appmock_client.verify_rest_history(appmock_ip, expected_history)
     assert 5 == appmock_client.rest_endpoint_request_count(appmock_ip, 9090, '/test_with_state')
Exemple #3
0
def ceph_client(request):
    class CephClient(object):
        def __init__(self, mon_host, username, key, pool_name):
            self.mon_host = mon_host
            self.username = username
            self.key = key
            self.pool_name = pool_name

    pool_name = 'data'
    result = ceph_server.up('onedata/ceph', [(pool_name, '8')], 'storage', '1')

    [container] = result['docker_ids']
    username = result['username']
    key = str(result['key'])
    mon_host = docker.inspect(container)['NetworkSettings']['IPAddress']. \
        encode('ascii')

    def fin():
        docker.exec_(container, [
            'btrfs', 'subvolume', 'delete', '/var/lib/ceph/osd/ceph-0/current'
        ])
        docker.exec_(container, [
            'btrfs', 'subvolume', 'delete', '/var/lib/ceph/osd/ceph-0/snap_1'
        ])
        docker.remove([container], force=True, volumes=True)

    request.addfinalizer(fin)

    return CephClient(mon_host, username, key, pool_name)
Exemple #4
0
def client_ids(environment):
    ids = {}
    for client in environment['client_nodes']:
        client = str(client)
        client_name = client.split(".")[0]
        ids[client_name] = docker.inspect(client)['Id']
    return ids
 def test_tcp_example(self):
     [container] = self.result['docker_ids']
     appmock_ip = docker.inspect(container)['NetworkSettings']['IPAddress'].encode(
         'ascii')
     # Send some requests, check counters, order appmock to send something to the client and receive it
     send_some_and_receive(appmock_ip)
     # Send multiple messages to itself and verify if they were received
     make_appmock_send_to_itself(appmock_ip)
     # Check waiting for messages
     wait_until_appmock_receives(appmock_ip)
     # Check counter endpoint
     use_counter_endpoint(appmock_ip)
Exemple #6
0
def _appmock_client(request):
    test_dir = os.path.dirname(os.path.realpath(request.module.__file__))

    result = appmock.up(image='onedata/builder', bindir=appmock_dir,
                        dns_server='none', uid=common.generate_uid(),
                        config_path=os.path.join(test_dir, 'env.json'))

    [container] = result['docker_ids']
    appmock_ip = docker.inspect(container)['NetworkSettings']['IPAddress']. \
        encode('ascii')

    def fin():
        docker.remove([container], force=True, volumes=True)

    request.addfinalizer(fin)
    return AppmockClient(appmock_ip)
Exemple #7
0
def _appmock_client(request):
    test_dir = os.path.dirname(os.path.realpath(request.module.__file__))

    result = appmock.up(image='onedata/builder',
                        bindir=appmock_dir,
                        dns_server='none',
                        uid=common.generate_uid(),
                        config_path=os.path.join(test_dir, 'env.json'))

    [container] = result['docker_ids']
    appmock_ip = docker.inspect(container)['NetworkSettings']['IPAddress']. \
        encode('ascii')

    def fin():
        docker.remove([container], force=True, volumes=True)

    request.addfinalizer(fin)
    return AppmockClient(appmock_ip)
Exemple #8
0
def docker_ip(container):
    return docker.inspect(container)['NetworkSettings']['IPAddress']
Exemple #9
0
    action='store',
    default=common.generate_uid(),
    help='uid that will be concatenated to docker name',
    dest='uid')

parser.add_argument(
    '--root-servers',
    action='store',
    default=[],
    help='list of root servers for non-authoritative domain delegation, in format domain1/ip,domain2/ip...',
    dest='root_servers')

parser.add_argument(
    '-r', '--restart',
    action='store',
    default='none',
    help='use this flag with a docker name, then a dns server with this name will be restarted (uid arg will be ignored)',
    dest='restart')

args = parser.parse_args()
if args.restart is not 'none':
    try:
        docker.inspect(args.restart)
    except:
        sys.exit(1)

if args.root_servers:
    args.root_servers = args.root_servers.split(',')
output = dns.up(args.uid, args.root_servers, args.restart)
print(json.dumps(output))
Exemple #10
0
def docker_ip(container):
    return docker.inspect(container)['NetworkSettings']['IPAddress']
Exemple #11
0
                    dest='uid')

parser.add_argument(
    '--root-servers',
    action='store',
    default=[],
    help=
    'list of root servers for non-authoritative domain delegation, in format domain1/ip,domain2/ip...',
    dest='root_servers')

parser.add_argument(
    '-r',
    '--restart',
    action='store',
    default='none',
    help=
    'use this flag with a docker name, then a dns server with this name will be restarted (uid arg will be ignored)',
    dest='restart')

args = parser.parse_args()
if args.restart is not 'none':
    try:
        docker.inspect(args.restart)
    except:
        sys.exit(1)

if args.root_servers:
    args.root_servers = args.root_servers.split(',')
output = dns.up(args.uid, args.root_servers, [], args.restart)
print(json.dumps(output))