summaryrefslogtreecommitdiffstats
path: root/apex/tests
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2018-02-16 14:16:59 -0500
committerTim Rozet <trozet@redhat.com>2018-02-16 14:22:46 -0500
commit0e2c8a5a3dc5919df7d906be951331372775eeff (patch)
treeb137935b91975d336e2d5fdabb7c2c973a6d4417 /apex/tests
parentd75cbb74191e32e3ff996604e30a2954d889687b (diff)
Fixes ensuring VBMCs are actually running
We currently start VBMCs using CLI due to issues with the VBMC python lib. However when we start them, there is no check to make sure they are actually changed to 'running' status. This patch adds logic to check (up to 5 times) to ensure each VBMC is running or raises an error. Note this is for virtual deployments only. JIRA: APEX-527 Change-Id: Iab7ee3b76292d6fc547f18c83f23c04205e9bb2e Signed-off-by: Tim Rozet <trozet@redhat.com>
Diffstat (limited to 'apex/tests')
-rw-r--r--apex/tests/test_apex_virtual_utils.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/apex/tests/test_apex_virtual_utils.py b/apex/tests/test_apex_virtual_utils.py
index 643069f3..a9eb78dd 100644
--- a/apex/tests/test_apex_virtual_utils.py
+++ b/apex/tests/test_apex_virtual_utils.py
@@ -12,6 +12,7 @@ import unittest
from mock import patch
+from apex.virtual.exceptions import ApexVirtualException
from apex.virtual.utils import DEFAULT_VIRT_IP
from apex.virtual.utils import get_virt_ip
from apex.virtual.utils import generate_inventory
@@ -66,13 +67,30 @@ class TestVirtualUtils(unittest.TestCase):
assert_is_instance(generate_inventory('target_file', ha_enabled=True),
dict)
+ @patch('apex.virtual.utils.get_virt_ip')
+ @patch('apex.virtual.utils.subprocess.check_output')
@patch('apex.virtual.utils.iptc')
@patch('apex.virtual.utils.subprocess.check_call')
@patch('apex.virtual.utils.vbmc_lib')
- def test_host_setup(self, mock_vbmc_lib, mock_subprocess, mock_iptc):
+ def test_host_setup(self, mock_vbmc_lib, mock_subprocess, mock_iptc,
+ mock_check_output, mock_get_virt_ip):
+ mock_get_virt_ip.return_value = '192.168.122.1'
+ mock_check_output.return_value = b'blah |dummy \nstatus | running'
host_setup({'test': 2468})
mock_subprocess.assert_called_with(['vbmc', 'start', 'test'])
+ @patch('apex.virtual.utils.get_virt_ip')
+ @patch('apex.virtual.utils.subprocess.check_output')
+ @patch('apex.virtual.utils.iptc')
+ @patch('apex.virtual.utils.subprocess.check_call')
+ @patch('apex.virtual.utils.vbmc_lib')
+ def test_host_setup_vbmc_fails(self, mock_vbmc_lib, mock_subprocess,
+ mock_iptc, mock_check_output,
+ mock_get_virt_ip):
+ mock_get_virt_ip.return_value = '192.168.122.1'
+ mock_check_output.return_value = b'blah |dummy \nstatus | stopped'
+ assert_raises(ApexVirtualException, host_setup, {'test': 2468})
+
@patch('apex.virtual.utils.iptc')
@patch('apex.virtual.utils.subprocess.check_call')
@patch('apex.virtual.utils.vbmc_lib')