def testBuild(self): # Test correct build config = self._loadFixture("valid_base.yml") # This will create a template named test.service.template_test:0.1 t = template.Template('template_test', config, 'test.service', '0.1') self.assertTrue(t.build()) # Verify the image really exists with docker. self.assertIsNotNone(utils.findImage(t.full_name(), t.version)) t.destroy() # Test correct build with a tag config = self._loadFixture("valid_base_tag.yml") t = template.Template('template_test', config, 'test.service', '0.1') self.assertTrue(t.build()) self.assertIsNotNone(utils.findImage(t.full_name(), t.version)) t.destroy() # Test invalid base image config = self._loadFixture("invalid_base.yml") t = template.Template('template_test', config, 'test.service', '0.1') with self.assertRaises(exceptions.TemplateError) as e: t.build() t.destroy() # Test no base image specified config = self._loadFixture("no_base.yml") t = template.Template('template_test', config, 'test.service', '0.1') with self.assertRaises(exceptions.TemplateError) as e: t.build() t.destroy()
def testGetIpAddress(self): # TODO: image_id will change c = container.Container('test_container', { 'image_id': utils.findImage('ubuntu') }, {'command': 'ps aux'}) c.run() self.assertIsNotNone(c.state['container_id']) self.assertIsNotNone(c.get_ip_address())
def testGetIpAddress(self): # TODO: image_id will change p = py_backend.PyBackend() c = p.run_container(utils.findImage('ubuntu'), {'command': 'ps aux'}) self.assertIsNotNone(c) self.assertIsNotNone(p.get_ip_address(c))
def testGetIpAddress(self): # TODO: image_id will change c = container.Container('test_container', {'image_id': utils.findImage('ubuntu')}, {'command': 'ps aux'}) c.run() self.assertIsNotNone(c.state['container_id']) self.assertIsNotNone(c.get_ip_address())
def testDestroy(self): c = container.Container('test_container', { 'image_id': utils.findImage('ubuntu') }, {'command': 'ps aux'}) c.run() self.assertIsNotNone(c.state['container_id']) c.destroy() with self.assertRaises(HTTPError) as e: c.backend.inspect_container(c.state['container_id']) self.assertEqual(str(e.exception), '404 Client Error: Not Found')
def testDestroy(self): c = container.Container('test_container', {'image_id': utils.findImage('ubuntu')}, {'command': 'ps aux'}) c.run() self.assertIsNotNone(c.state['container_id']) c.destroy() with self.assertRaises(HTTPError) as e: c.backend.inspect_container(c.state['container_id']) self.assertEqual(str(e.exception), '404 Client Error: Not Found')
def testStartStopRm(self): p = py_backend.PyBackend() c = p.create_container(utils.findImage('ubuntu'), {'command': '/bin/bash -c "while true; do echo hello world; sleep 60; done;"'}) state = p.docker_client.inspect_container(c) self.assertFalse(state['State']['Running']) p.start_container(c) state = p.docker_client.inspect_container(c) self.assertTrue(state['State']['Running']) p.stop_container(c, 1) state = p.docker_client.inspect_container(c) self.assertFalse(state['State']['Running']) p.remove_container(c, 1) with self.assertRaises(HTTPError) as e: p.docker_client.inspect_container(c) self.assertEqual(str(e.exception), '404 Client Error: Not Found')