aboutsummaryrefslogtreecommitdiffstats
path: root/functest_kubernetes/test_k8stest.py
diff options
context:
space:
mode:
authorKonrad Djimeli <konraddjimeli@gmail.com>2018-04-26 08:40:17 +0100
committerKonrad Djimeli <konraddjimeli@gmail.com>2018-04-26 09:23:45 +0100
commit9f8e105025763e75273f430448518fea77a49d34 (patch)
treec0cfaaa2f5609a7394cd19faa08ac463441f2848 /functest_kubernetes/test_k8stest.py
parentf351c301be1396e5dd578209c606a111afbc8758 (diff)
Update logging to log Errors, when they occur
Enable logging of errors which can occur due to incorrect configfile, wrong KUBE_MASTER_URL or KUBE_MASTER_IP etc. Change-Id: I352ed0ab0376e9392d205decdc569bac6304ba27 Signed-off-by: Konrad Djimeli <konraddjimeli@gmail.com>
Diffstat (limited to 'functest_kubernetes/test_k8stest.py')
-rw-r--r--functest_kubernetes/test_k8stest.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/functest_kubernetes/test_k8stest.py b/functest_kubernetes/test_k8stest.py
index 05f40e12..9db14d5a 100644
--- a/functest_kubernetes/test_k8stest.py
+++ b/functest_kubernetes/test_k8stest.py
@@ -67,6 +67,20 @@ class K8sTests(unittest.TestCase):
self.k8stesting.run_kubetest()
@mock.patch('functest_kubernetes.k8stest.os.path.isfile')
+ def test_error_logging(self, mock_isfile):
+ # pylint: disable=unused-argument
+ with mock.patch('functest_kubernetes.k8stest.'
+ 'subprocess.Popen') as mock_popen, \
+ mock.patch.object(self.k8stesting,
+ '_K8sTesting__logger') as mock_logger:
+ mock_stdout = mock.Mock()
+ attrs = {'stdout.read.return_value': 'Error loading client'}
+ mock_stdout.configure_mock(**attrs)
+ mock_popen.return_value = mock_stdout
+ self.k8stesting.run_kubetest()
+ mock_logger.error.assert_called_with("Error loading client")
+
+ @mock.patch('functest_kubernetes.k8stest.os.path.isfile')
@mock.patch('functest_kubernetes.k8stest.subprocess.Popen')
def test_run(self, mock_open, mock_isfile):
self.assertEquals(self.k8stesting.run(),