示例#1
0
 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))
示例#2
0
 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))
示例#3
0
 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)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
 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)
示例#8
0
 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)
示例#9
0
 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)
示例#10
0
 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)
示例#11
0
 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)
示例#12
0
 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)
示例#13
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)
示例#14
0
 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)
示例#15
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)
示例#16
0
 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)