def setUp(self): try: self.image = Image(ImageRevSpec.parse("lopter/sandbox-base:latest")) self.result_revspec = ImageRevSpec.parse(self.random_image_name()) self.container = self.image.instantiate(commit_as=self.result_revspec) except UnkownImageError as ex: return self.skipTest(str(ex))
def setUp(self): try: self.image = Image( ImageRevSpec.parse("lopter/sandbox-base:latest")) self.result_revspec = ImageRevSpec.parse(self.random_image_name()) self.container = self.image.instantiate( commit_as=self.result_revspec) except UnkownImageError as ex: return self.skipTest(str(ex))
def test_docker_revspecs(self): for revspec, expected in self.docker_revspec.iteritems(): if expected is None: with self.assertRaises(ValueError): ImageRevSpec.parse_from_docker(revspec) else: result = ImageRevSpec.parse_from_docker(revspec) self.assertEqual(result.username, expected.username) self.assertEqual(result.repository, expected.repository) self.assertEqual(result.revision, expected.revision) self.assertEqual(result.tag, expected.tag)
def test_human_revspecs(self): for revspec, expected in self.human_revspecs.iteritems(): if expected is None: with self.assertRaises(ValueError): ImageRevSpec.parse(revspec) else: result = ImageRevSpec.parse(revspec) # We don't want to test ImageRevSpec.__eq__ here: self.assertEqual(result.username, expected.username) self.assertEqual(result.repository, expected.repository) self.assertEqual(result.revision, expected.revision) self.assertEqual(result.tag, expected.tag)
def test_python_application_build(self): application = Application(os.path.join(self.path, "simple_python_app"), {}) images = application.build( base_image=Image(ImageRevSpec.parse("lopter/sandbox-base:latest"))) self.assertIsInstance(images, dict) result = images.get("www") self.assertIsNotNone(result)
def test_simple_application_build(self): application = Application(os.path.join(self.path, "simple_gunicorn_gevent_app"), {}) images = application.build(base_image=Image(ImageRevSpec.parse("lopter/sandbox-base:latest"))) self.assertIsInstance(images, dict) result = images.get("api") self.assertIsNotNone(result) container = result.instantiate(commit_as=ImageRevSpec.parse( ContainerTestCase.random_image_name() )) with _destroy_result(container): with container.run(["ls", "/home/dotcloud/current"]): pass self.assertIn("dotcloud.yml", container.logs) container = result.instantiate(commit_as=ImageRevSpec.parse( ContainerTestCase.random_image_name() )) with _destroy_result(container): with container.run(["stat", "-c", "%u", "/home/dotcloud/code"]): pass self.assertIn("1000", container.logs)
def test_custom_application_build(self): application = Application(os.path.join(self.path, "custom_app"), {}) images = application.build( base_image=Image(ImageRevSpec.parse("lopter/sandbox-base:latest"))) self.assertIsInstance(images, dict) result = images.get("db") self.assertIsNotNone(result) container = result.instantiate(commit_as=ImageRevSpec.parse( ContainerTestCase.random_image_name())) with _destroy_result(container): with container.run(["ls", "/tmp/code/"]): pass self.assertIn("dotcloud.yml", container.logs) self.assertIn("buildscript-stamp", container.logs) container = result.instantiate(commit_as=ImageRevSpec.parse( ContainerTestCase.random_image_name())) with _destroy_result(container): with container.run(["ls", "-R", "/usr/bin"]): pass self.assertIn("cmake", container.logs)
def test_simple_application_build(self): application = Application( os.path.join(self.path, "simple_gunicorn_gevent_app"), {}) images = application.build( base_image=Image(ImageRevSpec.parse("lopter/sandbox-base:latest"))) self.assertIsInstance(images, dict) result = images.get("api") self.assertIsNotNone(result) container = result.instantiate(commit_as=ImageRevSpec.parse( ContainerTestCase.random_image_name())) with _destroy_result(container): with container.run(["ls", "/home/dotcloud/current"]): pass self.assertIn("dotcloud.yml", container.logs) container = result.instantiate(commit_as=ImageRevSpec.parse( ContainerTestCase.random_image_name())) with _destroy_result(container): with container.run(["stat", "-c", "%u", "/home/dotcloud/code"]): pass self.assertIn("1000", container.logs)
def test_custom_application_build(self): application = Application(os.path.join(self.path, "custom_app"), {}) images = application.build(base_image=Image(ImageRevSpec.parse("lopter/sandbox-base:latest"))) self.assertIsInstance(images, dict) result = images.get("db") self.assertIsNotNone(result) container = result.instantiate(commit_as=ImageRevSpec.parse( ContainerTestCase.random_image_name() )) with _destroy_result(container): with container.run(["ls", "/tmp/code/"]): pass self.assertIn("dotcloud.yml", container.logs) self.assertIn("buildscript-stamp", container.logs) container = result.instantiate(commit_as=ImageRevSpec.parse( ContainerTestCase.random_image_name() )) with _destroy_result(container): with container.run(["ls", "-R", "/usr/bin"]): pass self.assertIn("cmake", container.logs)
def test_python_application_build(self): application = Application(os.path.join(self.path, "simple_python_app"), {}) images = application.build(base_image=Image(ImageRevSpec.parse("lopter/sandbox-base:latest"))) self.assertIsInstance(images, dict) result = images.get("www") self.assertIsNotNone(result)
def test_broken_application_build(self): application = Application(os.path.join(self.path, "broken_build"), {}) images = application.build(base_image=Image(ImageRevSpec.parse("lopter/sandbox-base:latest"))) self.assertEqual(images, None)
def test_mysql_application_build(self): application = Application(os.path.join(self.path, "mysql_app"), {}) images = application.build(base_image=Image(ImageRevSpec.parse("lopter/sandbox-base:latest"))) self.assertIsInstance(images, dict) self.assertEqual(len(images), 0)
def test_broken_application_build(self): application = Application(os.path.join(self.path, "broken_build"), {}) images = application.build( base_image=Image(ImageRevSpec.parse("lopter/sandbox-base:latest"))) self.assertEqual(images, None)
def test_mysql_application_build(self): application = Application(os.path.join(self.path, "mysql_app"), {}) images = application.build( base_image=Image(ImageRevSpec.parse("lopter/sandbox-base:latest"))) self.assertIsInstance(images, dict) self.assertEqual(len(images), 0)