def test__run_command_success(self):
        checker = pip_checker._OneshotPipCheck(['python3', '-m', 'pip'],
                                               packages=['six'])
        container = checker._build_container(MockDockerClient())

        returncode, output = checker._run_command(container,
                                                  ["echo", "testing"],
                                                  stdout=True,
                                                  stderr=True,
                                                  raise_on_failure=False)

        self.assertEqual(output, 'testing\n')
    def test__run_command_timeout(self):
        checker = pip_checker._OneshotPipCheck(['python3', '-m', 'pip'],
                                               packages=['six'])

        TIME_OUT = 0.1
        patch_timeout = mock.patch('pip_checker.TIME_OUT', TIME_OUT)

        with patch_timeout, self.assertRaises(pip_checker.PipCheckerError):
            container = checker._build_container(MockDockerClient())
            checker._run_command(container, ["sleep", "1"],
                                 stdout=True,
                                 stderr=True,
                                 raise_on_failure=False)
Пример #3
0
    def test__run_command_success(self):
        checker = pip_checker._OneshotPipCheck(['python3', '-m', 'pip'],
                                               packages=['six'],
                                               stats=self._stats)
        container = checker._run_container(MockDockerClient())

        returncode, output = checker._run_command(container,
                                                  ["echo", "testing"],
                                                  stdout=True,
                                                  stderr=True,
                                                  raise_on_failure=False)

        self.assertEqual(output, 'testing\n')

        docker_view_name = views.DOCKER_ERROR_VIEW.name
        docker_view_data = self._stats.view_manager.get_view(docker_view_name)
        self.assertEqual(docker_view_data._tag_value_aggregation_data_map, {})
Пример #4
0
    def test__run_command_timeout(self):
        checker = pip_checker._OneshotPipCheck(['python3', '-m', 'pip'],
                                               packages=['six'],
                                               stats=self._stats)

        TIME_OUT = 0.1
        patch_timeout = mock.patch('pip_checker.TIME_OUT', TIME_OUT)

        with patch_timeout, self.assertRaisesRegex(pip_checker.PipCheckerError,
                                                   'killed by signal 9'):
            container = checker._run_container(MockDockerClient())
            checker._run_command(container, ["sleep", "1"],
                                 stdout=True,
                                 stderr=True,
                                 raise_on_failure=False)

        docker_view_name = views.DOCKER_ERROR_VIEW.name
        docker_view_data = self._stats.view_manager.get_view(docker_view_name)
        docker_data_map = docker_view_data._tag_value_aggregation_data_map
        self.assertEqual(len(docker_data_map), 1)