aboutsummaryrefslogtreecommitdiff
path: root/kolla/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-01-26 11:50:04 +0000
committerGerrit Code Review <review@openstack.org>2016-01-26 11:50:04 +0000
commit87355c231a3bdf17fc1e9b1412f44f85dd549632 (patch)
tree2ed410076b9a182fa0f92dedea080ba99be46791 /kolla/tests
parent75343870e395e257c8d8267ccd9c74e70c7fceb5 (diff)
parentb82111d589cf3f82cbe115d002b29eee959a428f (diff)
downloadkolla-87355c231a3bdf17fc1e9b1412f44f85dd549632.tar.gz
kolla-87355c231a3bdf17fc1e9b1412f44f85dd549632.zip
Merge "Pick up proxy buildargs from environment"
Diffstat (limited to 'kolla/tests')
-rw-r--r--kolla/tests/test_build.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/kolla/tests/test_build.py b/kolla/tests/test_build.py
index afc2e7546..d1ace9ec8 100644
--- a/kolla/tests/test_build.py
+++ b/kolla/tests/test_build.py
@@ -12,6 +12,7 @@
import fixtures
import mock
+import os
from kolla.cmd import build
from kolla.tests import base
@@ -34,6 +35,7 @@ class WorkerThreadTest(base.TestCase):
# NOTE(jeffrey4l): use a real, temporary dir
FAKE_IMAGE['path'] = self.useFixture(fixtures.TempDir()).path
+ @mock.patch.dict(os.environ, clear=True)
@mock.patch('docker.Client')
def test_build_image(self, mock_client):
queue = mock.Mock()
@@ -48,6 +50,7 @@ class WorkerThreadTest(base.TestCase):
nocache=False, rm=True, pull=True, forcerm=True,
buildargs=None)
+ @mock.patch.dict(os.environ, clear=True)
@mock.patch('docker.Client')
def test_build_image_with_build_arg(self, mock_client):
build_args = {
@@ -64,3 +67,38 @@ class WorkerThreadTest(base.TestCase):
path=FAKE_IMAGE['path'], tag=FAKE_IMAGE['fullname'],
nocache=False, rm=True, pull=True, forcerm=True,
buildargs=build_args)
+
+ @mock.patch.dict(os.environ, {'http_proxy': 'http://FROM_ENV:8080'},
+ clear=True)
+ @mock.patch('docker.Client')
+ 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(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)
+
+ @mock.patch.dict(os.environ, {'http_proxy': 'http://FROM_ENV:8080'},
+ clear=True)
+ @mock.patch('docker.Client')
+ 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(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)