示例#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'])
示例#2
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)
示例#3
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)
示例#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}})
示例#5
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)
示例#6
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)
示例#7
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))
示例#8
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)
示例#9
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
     })
示例#10
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
     })
示例#11
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])
示例#12
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)