コード例 #1
0
 def test_start_container(self):
     docker.create_container(self._container)
     self.assertIsNotNone(docker.inspect_container(self._container))
     docker.start_container(self._container)
     stat = docker.inspect_container(self._container)
     self.assertIsNotNone(stat)
     self.assertTrue(stat['State']['Running'])
コード例 #2
0
 def test_create_container(self):
     docker.create_container(self._container, force=False)
     self.assertIsNotNone(docker.inspect_container(self._container))
     self.assertRaises(
         Exception,
         lambda: docker.create_container(self._container, force=False))
     self.assertIsNotNone(docker.inspect_container(self._container))
コード例 #3
0
 def test_container_exec_error(self):
     docker.create_container(self._container)
     self.assertIsNotNone(docker.inspect_container(self._container))
     self.assertRaises(
         Exception, lambda: docker.exec_cmd(self._container, 'echo hello!'))
     docker.delete_container(self._container)
     self.assertIsNone(docker.inspect_container(self._container))
     self.assertRaises(
         Exception, lambda: docker.exec_cmd(self._container, 'echo hello!'))
コード例 #4
0
    def test_image(self):
        file = 'data/examples/nc-server/nc-image.yaml'
        up_plan = self.o.read_plan_file(
            'data/examples/nc-server/nc-image.up.plan')
        down_plan = self.o.read_plan_file(
            'data/examples/nc-server/nc-image.down.plan')
        tpl = self.get_tpl(file)

        temp_stdout = StringIO()
        with self.redirect_stdout(temp_stdout):
            self.assertTrue(self.o.orchestrate(file, up_plan))
        self.assert_create(tpl)
        self.assert_start(tpl)

        con_id = docker.inspect_container('tosker_nc-image.server')['Id']
        output = temp_stdout.getvalue().strip()
        self.assertIn('- container_id: {}'.format(con_id), output)
        self.assertIn('- env_variable: hello_world', output)

        with self.redirect_stdout(StringIO()):
            self.assertTrue(self.o.orchestrate(file, down_plan))
        self.assert_delete(tpl)
コード例 #5
0
    def assert_delete(self, tpl):
        for c in tpl.containers:
            self.assertIsNone(docker.inspect_container(c))

        for c in tpl.volumes:
            self.assertIsNone(docker.inspect_volume(c))
コード例 #6
0
 def _assert_start(self, tpl, check):
     for c in tpl.containers:
         stat = docker.inspect_container(c)
         self.assertIsNotNone(stat)
         self.assertTrue(check(stat))
コード例 #7
0
 def test_container_exec(self):
     docker.create_container(self._container)
     self.assertIsNotNone(docker.inspect_container(self._container))
     docker.start_container(self._container)
     docker.exec_cmd(self._container, 'echo hello!')
コード例 #8
0
 def test_container_delete_error(self):
     self.assertRaises(Exception,
                       lambda: docker.delete_container(self._container))
     self.assertIsNone(docker.inspect_container(self._container))
コード例 #9
0
    def test_container_delete(self):
        docker.create_container(self._container)
        self.assertIsNotNone(docker.inspect_container(self._container))

        docker.delete_container(self._container)
        self.assertIsNone(docker.inspect_container(self._container))