summaryrefslogtreecommitdiffstats
path: root/apex/tests
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2018-08-08 17:43:55 -0400
committerTim Rozet <trozet@redhat.com>2018-08-10 20:40:16 -0400
commitc5959cc14b95e9d10b78ebf3c8e2525c672fc0c7 (patch)
tree1ab5b0be3e893ac3f77f951abe0c8d7bdf07e6d6 /apex/tests
parent7bbbc905908be356fd1cf2f869b43d7e4d87c12b (diff)
Allow all in one deployments
This patch adds the ability to deploy all in one single nodes (Control + Compute). To enable this functionality do the following for each deployment type: - Baremetal: do not tag any nodes as compute in the inventory file - Virtual: use argument '--virtual-computes 0' JIRA: APEX-548 Change-Id: I22525c9eb21d331129c819449316c26a6fcf522d Signed-off-by: Tim Rozet <trozet@redhat.com>
Diffstat (limited to 'apex/tests')
-rw-r--r--apex/tests/config/inventory-virt-1-compute-node.yaml14
-rw-r--r--apex/tests/test_apex_inventory.py7
-rw-r--r--apex/tests/test_apex_overcloud_deploy.py54
3 files changed, 49 insertions, 26 deletions
diff --git a/apex/tests/config/inventory-virt-1-compute-node.yaml b/apex/tests/config/inventory-virt-1-compute-node.yaml
new file mode 100644
index 0000000..4c2dc5d
--- /dev/null
+++ b/apex/tests/config/inventory-virt-1-compute-node.yaml
@@ -0,0 +1,14 @@
+---
+nodes:
+ node0:
+ arch: x86_64
+ capabilities: profile:compute
+ cpu: 4
+ disk: 41
+ ipmi_ip: 192.168.122.1
+ ipmi_pass: password
+ ipmi_user: admin
+ mac_address: 00:a8:58:29:f9:99
+ memory: 10240
+ pm_port: 6230
+ pm_type: pxe_ipmitool
diff --git a/apex/tests/test_apex_inventory.py b/apex/tests/test_apex_inventory.py
index 7197946..38a4271 100644
--- a/apex/tests/test_apex_inventory.py
+++ b/apex/tests/test_apex_inventory.py
@@ -56,10 +56,15 @@ class TestInventory:
os.path.join(TEST_DUMMY_CONFIG, 'inventory-virt.yaml'),
virtual=True, ha=True)
+ def test_inventory_valid_allinone_count(self):
+ i = Inventory(os.path.join(TEST_DUMMY_CONFIG,
+ 'inventory-virt-1-node.yaml'), ha=False)
+ assert_equal(list(i.get_node_counts()), [1, 0])
+
def test_inventory_invalid_noha_count(self):
assert_raises(ApexInventoryException, Inventory,
os.path.join(TEST_DUMMY_CONFIG,
- 'inventory-virt-1-node.yaml'),
+ 'inventory-virt-1-compute-node.yaml'),
virtual=True, ha=False)
def test_inventory_virtual(self):
diff --git a/apex/tests/test_apex_overcloud_deploy.py b/apex/tests/test_apex_overcloud_deploy.py
index 41f2e01..a9e4bda 100644
--- a/apex/tests/test_apex_overcloud_deploy.py
+++ b/apex/tests/test_apex_overcloud_deploy.py
@@ -7,6 +7,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import mock
import os
import sys
import unittest
@@ -193,23 +194,6 @@ class TestOvercloudDeploy(unittest.TestCase):
assert_not_in('enable_congress.yaml', result_cmd)
assert_not_in('enable_barometer.yaml', result_cmd)
- @patch('apex.overcloud.deploy.prep_sriov_env')
- @patch('apex.overcloud.deploy.prep_storage_env')
- @patch('apex.overcloud.deploy.build_sdn_env_list')
- def test_create_deploy_cmd_raises(self, mock_sdn_list, mock_prep_storage,
- mock_prep_sriov):
- mock_sdn_list.return_value = []
- ds = {'deploy_options': MagicMock(),
- 'global_params': MagicMock()}
- ds['deploy_options'].__getitem__.side_effect = \
- lambda i: 'master' if i == 'os_version' else MagicMock()
- ns = {}
- inv = MagicMock()
- inv.get_node_counts.return_value = (0, 0)
- virt = False
- assert_raises(ApexDeployException, create_deploy_cmd,
- ds, ns, inv, '/tmp', virt)
-
@patch('apex.builders.overcloud_builder.inject_opendaylight')
@patch('apex.overcloud.deploy.virt_utils')
@patch('apex.overcloud.deploy.shutil')
@@ -374,16 +358,24 @@ class TestOvercloudDeploy(unittest.TestCase):
assert_in('-----BEGIN PRIVATE KEY-----', priv)
assert_in('ssh-rsa', pub)
+ @patch('apex.overcloud.deploy.yaml')
@patch('apex.overcloud.deploy.fileinput')
@patch('apex.overcloud.deploy.shutil')
- def test_prep_env(self, mock_shutil, mock_fileinput):
+ @patch('builtins.open', mock_open())
+ def test_prep_env(self, mock_shutil, mock_fileinput, mock_yaml):
mock_fileinput.input.return_value = \
['CloudDomain', 'replace_private_key', 'replace_public_key',
'opendaylight::vpp_routing_node', 'ControllerExtraConfig',
'NovaComputeExtraConfig', 'ComputeKernelArgs', 'HostCpusList',
'ComputeExtraConfigPre', 'resource_registry',
'NovaSchedulerDefaultFilters']
- ds = {'deploy_options':
+ mock_yaml.safe_load.return_value = {
+ 'parameter_defaults': {
+ 'ControllerServices': [1, 2, 3],
+ 'ComputeServices': [3, 4, 5]
+ }}
+ ds = {'global_params': {'ha_enabled': False},
+ 'deploy_options':
{'sdn_controller': 'opendaylight',
'odl_vpp_routing_node': 'test',
'dataplane': 'ovs_dpdk',
@@ -405,7 +397,8 @@ class TestOvercloudDeploy(unittest.TestCase):
{'members': ['ext_nic']},
'compute':
{'members': ['ext_nic']}}}]}}
- inv = None
+ inv = MagicMock()
+ inv.get_node_counts.return_value = (1, 0)
try:
# Swap stdout
saved_stdout = sys.stdout
@@ -421,6 +414,12 @@ class TestOvercloudDeploy(unittest.TestCase):
assert_in('ssh-rsa', output)
assert_in('ComputeKernelArgs: \'test=test \'', output)
assert_in('fdio::vpp_cpu_main_core: \'test\'', output)
+ mock_yaml.safe_dump.assert_called_with(
+ {'parameter_defaults': {
+ 'ControllerServices': [1, 2, 3, 4, 5],
+ }},
+ mock.ANY, default_flow_style=False
+ )
finally:
# put stdout back
sys.stdout = saved_stdout
@@ -430,7 +429,8 @@ class TestOvercloudDeploy(unittest.TestCase):
def test_prep_env_round_two(self, mock_shutil, mock_fileinput):
mock_fileinput.input.return_value = \
['NeutronVPPAgentPhysnets']
- ds = {'deploy_options':
+ ds = {'global_params': {'ha_enabled': False},
+ 'deploy_options':
{'sdn_controller': False,
'dataplane': 'fdio',
'sriov': 'xxx',
@@ -448,7 +448,8 @@ class TestOvercloudDeploy(unittest.TestCase):
{'members': ['ext_nic']},
'compute':
{'members': ['ext_nic']}}}]}}
- inv = None
+ inv = MagicMock()
+ inv.get_node_counts.return_value = (3, 2)
try:
# Swap stdout
saved_stdout = sys.stdout
@@ -474,7 +475,8 @@ class TestOvercloudDeploy(unittest.TestCase):
mock_fileinput.input.return_value = \
['OS::TripleO::Services::NeutronDhcpAgent',
'NeutronDhcpAgentsPerNetwork', 'ComputeServices']
- ds = {'deploy_options':
+ ds = {'global_params': {'ha_enabled': False},
+ 'deploy_options':
{'sdn_controller': 'opendaylight',
'dataplane': 'fdio',
'sriov': 'xxx',
@@ -515,7 +517,8 @@ class TestOvercloudDeploy(unittest.TestCase):
mock_fileinput.input.return_value = \
['NeutronNetworkVLANRanges',
'NeutronNetworkType', 'NeutronBridgeMappings']
- ds = {'deploy_options':
+ ds = {'global_params': {'ha_enabled': False},
+ 'deploy_options':
{'sdn_controller': False,
'dataplane': 'ovs',
'sriov': 'xxx',
@@ -566,7 +569,8 @@ class TestOvercloudDeploy(unittest.TestCase):
'NeutronNetworkType',
'NeutronBridgeMappings',
'OpenDaylightProviderMappings']
- ds = {'deploy_options':
+ ds = {'global_params': {'ha_enabled': False},
+ 'deploy_options':
{'sdn_controller': 'opendaylight',
'dataplane': 'ovs',
'sriov': 'xxx',