Ejemplo n.º 1
0
 def test_dns_as_list_option(self):
     service = entities.Service('foo', 'stackbrew/ubuntu', env={})
     container = entities.Container('foo1',
                                    entities.Ship('ship', 'shipip'),
                                    service,
                                    config={'dns': ['8.8.8.8', '8.8.4.4']})
     self.assertEqual(container.dns, ['8.8.8.8', '8.8.4.4'])
Ejemplo n.º 2
0
 def _cntr(service_name=SERVICE, service_env=None, image=IMAGE,
           ship_name=SHIP, ship_ip=SHIP_IP,
           container_name=CONTAINER, config=None, schema=SCHEMA):
     service = entities.Service(service_name, image, schema, service_env)
     return entities.Container(container_name,
                               entities.Ship(ship_name, ship_ip),
                               service, config=config, schema=schema)
Ejemplo n.º 3
0
 def test_no_dns_option(self):
     service = entities.Service('foo', 'stackbrew/ubuntu', env={})
     container = entities.Container('foo1',
                                    entities.Ship('ship', 'shipip'),
                                    service,
                                    config={})
     self.assertIsNone(container.dns)
Ejemplo n.º 4
0
 def _get_container(self):
     ship = entities.Ship('ship', 'ship.ip')
     service = entities.Service('foo', 'stackbrew/ubuntu')
     return entities.Container(
         'foo1', ship, service,
         config={'ports': {'server': '4242/tcp', 'data': '4243/udp'},
                 'env': {'foo': 'bar', 'wid': 42}})
Ejemplo n.º 5
0
 def test_swap_limit_number(self):
     config = {'limits': {'swap': 42}}
     service = entities.Service('foo', 'stackbrew/ubuntu', env={})
     container = entities.Container('foo1',
                                    entities.Ship('ship', 'shipip'),
                                    service,
                                    config=config)
     self.assertEqual(container.memswap_limit, 42)
Ejemplo n.º 6
0
 def test_swap_limit_string_with_suffix(self):
     config = {'limits': {'swap': '42k'}}
     service = entities.Service('foo', 'stackbrew/ubuntu', env={})
     container = entities.Container('foo1',
                                    entities.Ship('ship', 'shipip'),
                                    service,
                                    config=config)
     self.assertEqual(container.memswap_limit, 42 * 1024)
Ejemplo n.º 7
0
 def test_get_image_details_custom_port_notag_invalid(self):
     # If the registry as a non-standard port, the tag must be specified.
     # This test case validates that it is still parsed correctly, and
     # yielded the invalid result.
     service = entities.Service('foo', 'quay.io:8081/foo/bar')
     d = service.get_image_details()
     self.assertEqual(d['repository'], 'quay.io')
     self.assertEqual(d['tag'], '8081/foo/bar')
Ejemplo n.º 8
0
 def test_limits_option(self):
     service = entities.Service('foo',
                                'stackbrew/ubuntu:13.10',
                                limits={
                                    'cpu': 2,
                                    'memory': '10m'
                                })
     self.assertEqual(service.limits, {'cpu': 2, 'memory': '10m'})
Ejemplo n.º 9
0
 def test_restart_policy_wrong_name(self):
     config = {'restart': 'noclue'}
     service = entities.Service('foo', 'stackbrew/ubuntu', env={})
     self.assertRaises(
         exceptions.InvalidRestartPolicyConfigurationException,
         lambda: entities.Container('foo1',
                                    entities.Ship('ship', 'shipip'),
                                    service,
                                    config=config))
Ejemplo n.º 10
0
 def _cntr(service_name=SERVICE, service_env=None, image=IMAGE,
           ship_name=SHIP, ship_ip=SHIP_IP,
           container_name=CONTAINER, config=None, schema=SCHEMA,
           api_version=DOCKER_VERSION):
     service = entities.Service(service_name, image, schema=schema,
                                env=service_env)
     return entities.Container(container_name,
                               entities.Ship(ship_name, ship_ip,
                                             api_version=api_version),
                               service, config=config, schema=schema)
Ejemplo n.º 11
0
 def test_restart_policy_wrong_type(self):
     config = {'restart': []}
     service = entities.Service('foo', 'stackbrew/ubuntu', env={})
     container = entities.Container('foo1',
                                    entities.Ship('ship', 'shipip'),
                                    service,
                                    config=config)
     self.assertEqual(container.restart_policy, {
         'Name': 'no',
         'MaximumRetryCount': 0
     })
Ejemplo n.º 12
0
 def test_restart_policy_missing_retries(self):
     config = {'restart': {'name': 'on-failure'}}
     service = entities.Service('foo', 'stackbrew/ubuntu', env={})
     container = entities.Container('foo1',
                                    entities.Ship('ship', 'shipip'),
                                    service,
                                    config=config)
     self.assertEqual(container.restart_policy, {
         'Name': 'on-failure',
         'MaximumRetryCount': 0
     })
Ejemplo n.º 13
0
 def test_env_propagates_from_service(self):
     service_env = {'ENV_VAR': 'value'}
     container_env = {'OTHER_ENV_VAR': 'other-value'}
     service = entities.Service('foo', 'stackbrew/ubuntu', service_env)
     container = entities.Container('foo1', entities.Ship('ship', 'shipip'),
                                    service, config={'env': container_env})
     for k, v in service_env.items():
         self.assertIn(k, container.env)
         self.assertEqual(v, container.env[k])
     for k, v in container_env.items():
         self.assertIn(k, container.env)
         self.assertEqual(v, container.env[k])
Ejemplo n.º 14
0
 def _cntr(service_name=SERVICE, service_env=None, image=IMAGE,
           ship_name=SHIP, ship_ip=SHIP_IP,
           container_name=CONTAINER, config=None, schema=SCHEMA,
           api_version=DOCKER_VERSION, ports=PORTS):
     service = entities.Service(name=service_name, image=image,
                                maestro_schema=schema,
                                env=service_env, ports=ports)
     ship = entities.Ship(ship_name, ship_ip, api_version=api_version)
     cfg = {'ship': ship.name}
     if config:
         cfg.update(config)
     return entities.Container({ship_name: ship}, container_name,
                               service, config=cfg,
                               maestro_schema=schema)
Ejemplo n.º 15
0
 def test_get_image_details_custom_port(self):
     service = entities.Service('foo', 'quay.io:8081/foo/bar:13.10')
     d = service.get_image_details()
     self.assertEqual(d['repository'], 'quay.io:8081/foo/bar')
     self.assertEqual(d['tag'], '13.10')
Ejemplo n.º 16
0
 def test_get_image_details_notag(self):
     service = entities.Service('foo', 'stackbrew/ubuntu')
     d = service.get_image_details()
     self.assertEqual(d['repository'], 'stackbrew/ubuntu')
     self.assertEqual(d['tag'], 'latest')
Ejemplo n.º 17
0
 def test_get_image(self):
     service = entities.Service('foo', 'stackbrew/ubuntu:13.10')
     self.assertEqual(service.image, 'stackbrew/ubuntu:13.10')
Ejemplo n.º 18
0
 def test_no_ports_option(self):
     service = entities.Service('foo', 'stackbrew/ubuntu:13.10')
     self.assertEqual(service.ports, {})
Ejemplo n.º 19
0
 def test_ports_option(self):
     service = entities.Service('foo',
                                'stackbrew/ubuntu:13.10',
                                ports={'server: 4848'})
     self.assertEqual(service.ports, {'server: 4848'})