Beispiel #1
0
    def test_build_image(self, mock_client):
        queue = mock.Mock()
        push_queue = mock.Mock()
        worker = build.WorkerThread(queue,
                                    push_queue,
                                    self.conf)
        worker.builder(self.image)

        mock_client().build.assert_called_once_with(
            path=self.image['path'], tag=self.image['fullname'],
            nocache=False, rm=True, pull=True, forcerm=True,
            buildargs=None)
Beispiel #2
0
    def test_build_arg_from_env(self, mock_client):
        build_args = {
            'http_proxy': 'http://FROM_ENV:8080',
        }
        worker = build.WorkerThread(mock.Mock(),
                                    mock.Mock(),
                                    self.conf)
        worker.builder(self.image)

        mock_client().build.assert_called_once_with(
            path=self.image['path'], tag=self.image['fullname'],
            nocache=False, rm=True, pull=True, forcerm=True,
            buildargs=build_args)
Beispiel #3
0
    def test_build_arg_precedence(self, mock_client):
        build_args = {
            'http_proxy': 'http://localhost:8080',
        }
        self.conf.set_override('build_args', build_args)
        worker = build.WorkerThread(mock.Mock(),
                                    mock.Mock(),
                                    self.conf)
        worker.builder(self.image)

        mock_client().build.assert_called_once_with(
            path=self.image['path'], tag=self.image['fullname'],
            nocache=False, rm=True, pull=True, forcerm=True,
            buildargs=build_args)
Beispiel #4
0
    def test_build_image_with_build_arg(self, mock_client):
        build_args = {
            'HTTP_PROXY': 'http://localhost:8080',
            'NO_PROXY': '127.0.0.1'
        }
        self.conf.set_override('build_args', build_args)
        worker = build.WorkerThread(mock.Mock(), mock.Mock(), self.conf)
        worker.builder(FAKE_IMAGE)

        mock_client().build.assert_called_once_with(path=FAKE_IMAGE['path'],
                                                    tag=FAKE_IMAGE['fullname'],
                                                    nocache=False,
                                                    rm=True,
                                                    pull=True,
                                                    forcerm=True,
                                                    buildargs=build_args)
Beispiel #5
0
    def test_requests_get_timeout(self, mock_get, mock_client):
        worker = build.WorkerThread(mock.Mock(),
                                    mock.Mock(),
                                    self.conf)
        self.image['source'] = {
            'source': 'http://fake/source',
            'type': 'url',
            'name': 'fake-image-base'
        }
        mock_get.side_effect = requests.exceptions.Timeout
        get_result = worker.process_source(self.image,
                                           self.image['source'])

        self.assertIsNone(get_result)
        self.assertEqual(self.image['status'], 'error')
        self.assertEqual(self.image['logs'], str())
        mock_get.assert_called_once_with(self.image['source']['source'],
                                         timeout=120)