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_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)
class ContainerTestCase(unittest.TestCase): @staticmethod def random_image_name(): return "{0}:unittest".format("".join( random.choice(string.ascii_lowercase) for i in xrange(10))) 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 tearDown(self): if self.container.result: self.container.result.destroy()
class ContainerTestCase(unittest.TestCase): @staticmethod def random_image_name(): return "{0}:unittest".format("".join( random.choice(string.ascii_lowercase) for i in xrange(10) )) 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 tearDown(self): if self.container.result: self.container.result.destroy()
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_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)