summaryrefslogtreecommitdiffstats
path: root/utils/test
diff options
context:
space:
mode:
Diffstat (limited to 'utils/test')
-rw-r--r--utils/test/cli_installer_tests.py511
-rw-r--r--utils/test/fixture.py80
-rw-r--r--utils/test/oo_config_tests.py224
3 files changed, 421 insertions, 394 deletions
diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py
index 66ed66660..6d9d443ff 100644
--- a/utils/test/cli_installer_tests.py
+++ b/utils/test/cli_installer_tests.py
@@ -76,6 +76,14 @@ MOCK_FACTS_QUICKHA = {
'common': {
'ip': '10.0.0.4',
'public_ip': '10.0.0.4',
+ 'hostname': 'node3-private.example.com',
+ 'public_hostname': 'node3.example.com'
+ }
+ },
+ '10.0.0.5': {
+ 'common': {
+ 'ip': '10.0.0.5',
+ 'public_ip': '10.0.0.5',
'hostname': 'proxy-private.example.com',
'public_hostname': 'proxy.example.com'
}
@@ -93,222 +101,286 @@ MOCK_FACTS_QUICKHA = {
# Missing connect_to on some hosts:
BAD_CONFIG = """
variant: %s
-ansible_ssh_user: root
-hosts:
- - connect_to: 10.0.0.1
- ip: 10.0.0.1
- hostname: master-private.example.com
- public_ip: 24.222.0.1
- public_hostname: master.example.com
- master: true
- node: true
- - ip: 10.0.0.2
- hostname: node1-private.example.com
- public_ip: 24.222.0.2
- public_hostname: node1.example.com
- node: true
- - connect_to: 10.0.0.3
- ip: 10.0.0.3
- hostname: node2-private.example.com
- public_ip: 24.222.0.3
- public_hostname: node2.example.com
- node: true
+version: v2
+deployment:
+ ansible_ssh_user: root
+ hosts:
+ - connect_to: 10.0.0.1
+ ip: 10.0.0.1
+ hostname: master-private.example.com
+ public_ip: 24.222.0.1
+ public_hostname: master.example.com
+ roles:
+ - master
+ - node
+ - ip: 10.0.0.2
+ hostname: node1-private.example.com
+ public_ip: 24.222.0.2
+ public_hostname: node1.example.com
+ roles:
+ - node
+ - connect_to: 10.0.0.3
+ ip: 10.0.0.3
+ hostname: node2-private.example.com
+ public_ip: 24.222.0.3
+ public_hostname: node2.example.com
+ roles:
+ - node
+ roles:
+ master:
+ node:
"""
QUICKHA_CONFIG = """
variant: %s
-ansible_ssh_user: root
-master_routingconfig_subdomain: example.com
-hosts:
- - connect_to: 10.0.0.1
- ip: 10.0.0.1
- hostname: master-private.example.com
- public_ip: 24.222.0.1
- public_hostname: master.example.com
- master: true
- node: true
- - connect_to: 10.0.0.2
- ip: 10.0.0.2
- hostname: node1-private.example.com
- public_ip: 24.222.0.2
- public_hostname: node1.example.com
- master: true
- node: true
- - connect_to: 10.0.0.3
- ip: 10.0.0.3
- hostname: node2-private.example.com
- public_ip: 24.222.0.3
- public_hostname: node2.example.com
- node: true
- master: true
- - connect_to: 10.0.0.4
- ip: 10.0.0.4
- hostname: node3-private.example.com
- public_ip: 24.222.0.4
- public_hostname: node3.example.com
- node: true
- - connect_to: 10.0.0.5
- ip: 10.0.0.5
- hostname: proxy-private.example.com
- public_ip: 24.222.0.5
- public_hostname: proxy.example.com
- master_lb: true
- - connect_to: 10.1.0.1
- ip: 10.1.0.1
- hostname: storage-private.example.com
- public_ip: 24.222.0.6
- public_hostname: storage.example.com
- storage: true
+version: v2
+deployment:
+ ansible_ssh_user: root
+ hosts:
+ - connect_to: 10.0.0.1
+ ip: 10.0.0.1
+ hostname: master-private.example.com
+ public_ip: 24.222.0.1
+ public_hostname: master.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.2
+ ip: 10.0.0.2
+ hostname: node1-private.example.com
+ public_ip: 24.222.0.2
+ public_hostname: node1.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.3
+ ip: 10.0.0.3
+ hostname: node2-private.example.com
+ public_ip: 24.222.0.3
+ public_hostname: node2.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.4
+ ip: 10.0.0.4
+ hostname: node3-private.example.com
+ public_ip: 24.222.0.4
+ public_hostname: node3.example.com
+ roles:
+ - node
+ - connect_to: 10.0.0.5
+ ip: 10.0.0.5
+ hostname: proxy-private.example.com
+ public_ip: 24.222.0.5
+ public_hostname: proxy.example.com
+ roles:
+ - master_lb
+ - connect_to: 10.1.0.1
+ ip: 10.1.0.1
+ hostname: storage-private.example.com
+ public_ip: 24.222.0.6
+ public_hostname: storage.example.com
+ roles:
+ - storage
+ roles:
+ master:
+ master_lb:
+ node:
+ storage:
"""
QUICKHA_2_MASTER_CONFIG = """
variant: %s
-ansible_ssh_user: root
-hosts:
- - connect_to: 10.0.0.1
- ip: 10.0.0.1
- hostname: master-private.example.com
- public_ip: 24.222.0.1
- public_hostname: master.example.com
- master: true
- node: true
- - connect_to: 10.0.0.2
- ip: 10.0.0.2
- hostname: node1-private.example.com
- public_ip: 24.222.0.2
- public_hostname: node1.example.com
- master: true
- node: true
- - connect_to: 10.0.0.4
- ip: 10.0.0.4
- hostname: node3-private.example.com
- public_ip: 24.222.0.4
- public_hostname: node3.example.com
- node: true
- - connect_to: 10.0.0.5
- ip: 10.0.0.5
- hostname: proxy-private.example.com
- public_ip: 24.222.0.5
- public_hostname: proxy.example.com
- master_lb: true
- - connect_to: 10.1.0.1
- ip: 10.1.0.1
- hostname: storage-private.example.com
- public_ip: 24.222.0.6
- public_hostname: storage.example.com
- storage: true
+version: v2
+deployment:
+ ansible_ssh_user: root
+ hosts:
+ - connect_to: 10.0.0.1
+ ip: 10.0.0.1
+ hostname: master-private.example.com
+ public_ip: 24.222.0.1
+ public_hostname: master.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.2
+ ip: 10.0.0.2
+ hostname: node1-private.example.com
+ public_ip: 24.222.0.2
+ public_hostname: node1.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.4
+ ip: 10.0.0.4
+ hostname: node3-private.example.com
+ public_ip: 24.222.0.4
+ public_hostname: node3.example.com
+ roles:
+ - node
+ - connect_to: 10.0.0.5
+ ip: 10.0.0.5
+ hostname: proxy-private.example.com
+ public_ip: 24.222.0.5
+ public_hostname: proxy.example.com
+ roles:
+ - master_lb
+ - connect_to: 10.1.0.1
+ ip: 10.1.0.1
+ hostname: storage-private.example.com
+ public_ip: 24.222.0.6
+ public_hostname: storage.example.com
+ roles:
+ - storage
+ roles:
+ master:
+ master_lb:
+ node:
+ storage:
"""
QUICKHA_CONFIG_REUSED_LB = """
variant: %s
-ansible_ssh_user: root
-hosts:
- - connect_to: 10.0.0.1
- ip: 10.0.0.1
- hostname: master-private.example.com
- public_ip: 24.222.0.1
- public_hostname: master.example.com
- master: true
- node: true
- - connect_to: 10.0.0.2
- ip: 10.0.0.2
- hostname: node1-private.example.com
- public_ip: 24.222.0.2
- public_hostname: node1.example.com
- master: true
- node: true
- master_lb: true
- - connect_to: 10.0.0.3
- ip: 10.0.0.3
- hostname: node2-private.example.com
- public_ip: 24.222.0.3
- public_hostname: node2.example.com
- node: true
- master: true
- - connect_to: 10.1.0.1
- ip: 10.1.0.1
- hostname: storage-private.example.com
- public_ip: 24.222.0.6
- public_hostname: storage.example.com
- storage: true
+version: v2
+deployment:
+ ansible_ssh_user: root
+ hosts:
+ - connect_to: 10.0.0.1
+ ip: 10.0.0.1
+ hostname: master-private.example.com
+ public_ip: 24.222.0.1
+ public_hostname: master.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.2
+ ip: 10.0.0.2
+ hostname: node1-private.example.com
+ public_ip: 24.222.0.2
+ public_hostname: node1.example.com
+ roles:
+ - master
+ - node
+ - master_lb
+ - connect_to: 10.0.0.3
+ ip: 10.0.0.3
+ hostname: node2-private.example.com
+ public_ip: 24.222.0.3
+ public_hostname: node2.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.1.0.1
+ ip: 10.1.0.1
+ hostname: storage-private.example.com
+ public_ip: 24.222.0.6
+ public_hostname: storage.example.com
+ roles:
+ - storage
+ roles:
+ master:
+ node:
+ storage:
"""
QUICKHA_CONFIG_NO_LB = """
variant: %s
-ansible_ssh_user: root
-hosts:
- - connect_to: 10.0.0.1
- ip: 10.0.0.1
- hostname: master-private.example.com
- public_ip: 24.222.0.1
- public_hostname: master.example.com
- master: true
- node: true
- - connect_to: 10.0.0.2
- ip: 10.0.0.2
- hostname: node1-private.example.com
- public_ip: 24.222.0.2
- public_hostname: node1.example.com
- master: true
- node: true
- - connect_to: 10.0.0.3
- ip: 10.0.0.3
- hostname: node2-private.example.com
- public_ip: 24.222.0.3
- public_hostname: node2.example.com
- node: true
- master: true
- - connect_to: 10.1.0.1
- ip: 10.1.0.1
- hostname: storage-private.example.com
- public_ip: 24.222.0.6
- public_hostname: storage.example.com
- storage: true
+version: v2
+deployment:
+ ansible_ssh_user: root
+ hosts:
+ - connect_to: 10.0.0.1
+ ip: 10.0.0.1
+ hostname: master-private.example.com
+ public_ip: 24.222.0.1
+ public_hostname: master.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.2
+ ip: 10.0.0.2
+ hostname: node1-private.example.com
+ public_ip: 24.222.0.2
+ public_hostname: node1.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.3
+ ip: 10.0.0.3
+ hostname: node2-private.example.com
+ public_ip: 24.222.0.3
+ public_hostname: node2.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.1.0.1
+ ip: 10.1.0.1
+ hostname: storage-private.example.com
+ public_ip: 24.222.0.6
+ public_hostname: storage.example.com
+ roles:
+ - storage
+ roles:
+ master:
+ node:
+ storage:
"""
QUICKHA_CONFIG_PRECONFIGURED_LB = """
variant: %s
-ansible_ssh_user: root
-master_routingconfig_subdomain: example.com
-hosts:
- - connect_to: 10.0.0.1
- ip: 10.0.0.1
- hostname: master-private.example.com
- public_ip: 24.222.0.1
- public_hostname: master.example.com
- master: true
- node: true
- - connect_to: 10.0.0.2
- ip: 10.0.0.2
- hostname: node1-private.example.com
- public_ip: 24.222.0.2
- public_hostname: node1.example.com
- master: true
- node: true
- - connect_to: 10.0.0.3
- ip: 10.0.0.3
- hostname: node2-private.example.com
- public_ip: 24.222.0.3
- public_hostname: node2.example.com
- node: true
- master: true
- - connect_to: 10.0.0.4
- ip: 10.0.0.4
- hostname: node3-private.example.com
- public_ip: 24.222.0.4
- public_hostname: node3.example.com
- node: true
- - connect_to: proxy-private.example.com
- hostname: proxy-private.example.com
- public_hostname: proxy.example.com
- master_lb: true
- preconfigured: true
- - connect_to: 10.1.0.1
- ip: 10.1.0.1
- hostname: storage-private.example.com
- public_ip: 24.222.0.6
- public_hostname: storage.example.com
- storage: true
+version: v2
+deployment:
+ ansible_ssh_user: root
+ hosts:
+ - connect_to: 10.0.0.1
+ ip: 10.0.0.1
+ hostname: master-private.example.com
+ public_ip: 24.222.0.1
+ public_hostname: master.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.2
+ ip: 10.0.0.2
+ hostname: node1-private.example.com
+ public_ip: 24.222.0.2
+ public_hostname: node1.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.3
+ ip: 10.0.0.3
+ hostname: node2-private.example.com
+ public_ip: 24.222.0.3
+ public_hostname: node2.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.4
+ ip: 10.0.0.4
+ hostname: node3-private.example.com
+ public_ip: 24.222.0.4
+ public_hostname: node3.example.com
+ roles:
+ - node
+ - connect_to: proxy-private.example.com
+ hostname: proxy-private.example.com
+ public_hostname: proxy.example.com
+ preconfigured: true
+ roles:
+ - master_lb
+ - connect_to: 10.1.0.1
+ ip: 10.1.0.1
+ hostname: storage-private.example.com
+ public_ip: 24.222.0.6
+ public_hostname: storage.example.com
+ roles:
+ - storage
+ roles:
+ master:
+ master_lb:
+ node:
+ storage:
"""
class UnattendedCliTests(OOCliFixture):
@@ -439,10 +511,7 @@ class UnattendedCliTests(OOCliFixture):
@patch('ooinstall.openshift_ansible.run_main_playbook')
@patch('ooinstall.openshift_ansible.load_system_facts')
def test_inventory_write(self, load_facts_mock, run_playbook_mock):
-
- # Add an ssh user so we can verify it makes it to the inventory file:
- merged_config = "%s\n%s" % (SAMPLE_CONFIG % 'openshift-enterprise',
- "ansible_ssh_user: bob")
+ merged_config = SAMPLE_CONFIG % 'openshift-enterprise'
load_facts_mock.return_value = (MOCK_FACTS, 0)
run_playbook_mock.return_value = 0
@@ -456,7 +525,7 @@ class UnattendedCliTests(OOCliFixture):
# Check the inventory file looks as we would expect:
inventory = ConfigParser.ConfigParser(allow_no_value=True)
inventory.read(os.path.join(self.work_dir, 'hosts'))
- self.assertEquals('bob',
+ self.assertEquals('root',
inventory.get('OSEv3:vars', 'ansible_ssh_user'))
self.assertEquals('openshift-enterprise',
inventory.get('OSEv3:vars', 'deployment_type'))
@@ -494,7 +563,7 @@ class UnattendedCliTests(OOCliFixture):
self.assertEquals('openshift-enterprise', written_config['variant'])
# We didn't specify a version so the latest should have been assumed,
# and written to disk:
- self.assertEquals('3.2', written_config['variant_version'])
+ self.assertEquals('3.3', written_config['variant_version'])
# Make sure the correct value was passed to ansible:
inventory = ConfigParser.ConfigParser(allow_no_value=True)
@@ -510,7 +579,7 @@ class UnattendedCliTests(OOCliFixture):
run_playbook_mock.return_value = 0
config = SAMPLE_CONFIG % 'openshift-enterprise'
- config = '%s\n%s' % (config, 'variant_version: 3.0')
+ config = '%s\n%s' % (config, 'variant_version: 3.3')
config_file = self.write_config(os.path.join(self.work_dir,
'ooinstall.conf'), config)
@@ -523,11 +592,11 @@ class UnattendedCliTests(OOCliFixture):
self.assertEquals('openshift-enterprise', written_config['variant'])
# Make sure our older version was preserved:
# and written to disk:
- self.assertEquals('3.0', written_config['variant_version'])
+ self.assertEquals('3.3', written_config['variant_version'])
inventory = ConfigParser.ConfigParser(allow_no_value=True)
inventory.read(os.path.join(self.work_dir, 'hosts'))
- self.assertEquals('enterprise',
+ self.assertEquals('openshift-enterprise',
inventory.get('OSEv3:vars', 'deployment_type'))
@patch('ooinstall.openshift_ansible.run_ansible')
@@ -659,7 +728,7 @@ class UnattendedCliTests(OOCliFixture):
# This is an invalid config:
self.assert_result(result, 1)
- self.assertTrue("A minimum of 3 Masters are required" in result.output)
+ self.assertTrue("A minimum of 3 masters are required" in result.output)
#unattended with three masters, one node, but no load balancer specified:
@patch('ooinstall.openshift_ansible.run_main_playbook')
@@ -752,9 +821,9 @@ class AttendedCliTests(OOCliFixture):
self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
'openshift_schedulable=False')
self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.2',
- 'openshift_schedulable')
+ 'openshift_schedulable=True')
self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.3',
- 'openshift_schedulable')
+ 'openshift_schedulable=True')
# interactive with config file and some installed some uninstalled hosts
@patch('ooinstall.openshift_ansible.run_main_playbook')
@@ -876,7 +945,7 @@ class AttendedCliTests(OOCliFixture):
self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.3',
'openshift_schedulable=False')
self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.4',
- 'openshift_schedulable')
+ 'openshift_schedulable=True')
self.assertTrue(inventory.has_section('etcd'))
self.assertEquals(3, len(inventory.items('etcd')))
@@ -1005,26 +1074,6 @@ class AttendedCliTests(OOCliFixture):
self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
'openshift_schedulable=True')
- #interactive 3.0 install confirm no HA hints
- @patch('ooinstall.openshift_ansible.run_main_playbook')
- @patch('ooinstall.openshift_ansible.load_system_facts')
- def test_ha_hint(self, load_facts_mock, run_playbook_mock):
- load_facts_mock.return_value = (MOCK_FACTS, 0)
- run_playbook_mock.return_value = 0
-
- cli_input = build_input(hosts=[
- ('10.0.0.1', True, False)],
- ssh_user='root',
- variant_num=3,
- confirm_facts='y',
- storage='10.1.0.1',)
- self.cli_args.append("install")
- result = self.runner.invoke(cli.cli, self.cli_args,
- input=cli_input)
- self.assert_result(result, 0)
- print result.output
- self.assertTrue("NOTE: Add a total of 3 or more Masters to perform an HA installation."
- not in result.output)
@patch('ooinstall.openshift_ansible.run_main_playbook')
@patch('ooinstall.openshift_ansible.load_system_facts')
@@ -1059,9 +1108,9 @@ class AttendedCliTests(OOCliFixture):
self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',
'openshift_schedulable=False')
self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.2',
- 'openshift_schedulable')
+ 'openshift_schedulable=True')
self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.3',
- 'openshift_schedulable')
+ 'openshift_schedulable=True')
# TODO: test with config file, attended add node
diff --git a/utils/test/fixture.py b/utils/test/fixture.py
index e01eaebaf..a883e5c56 100644
--- a/utils/test/fixture.py
+++ b/utils/test/fixture.py
@@ -10,28 +10,37 @@ from click.testing import CliRunner
# Substitute in a product name before use:
SAMPLE_CONFIG = """
variant: %s
-ansible_ssh_user: root
+variant_version: 3.3
master_routingconfig_subdomain: example.com
-hosts:
- - connect_to: 10.0.0.1
- ip: 10.0.0.1
- hostname: master-private.example.com
- public_ip: 24.222.0.1
- public_hostname: master.example.com
- master: true
- node: true
- - connect_to: 10.0.0.2
- ip: 10.0.0.2
- hostname: node1-private.example.com
- public_ip: 24.222.0.2
- public_hostname: node1.example.com
- node: true
- - connect_to: 10.0.0.3
- ip: 10.0.0.3
- hostname: node2-private.example.com
- public_ip: 24.222.0.3
- public_hostname: node2.example.com
- node: true
+version: v2
+deployment:
+ ansible_ssh_user: root
+ hosts:
+ - connect_to: 10.0.0.1
+ ip: 10.0.0.1
+ hostname: master-private.example.com
+ public_ip: 24.222.0.1
+ public_hostname: master.example.com
+ roles:
+ - master
+ - node
+ - connect_to: 10.0.0.2
+ ip: 10.0.0.2
+ hostname: node1-private.example.com
+ public_ip: 24.222.0.2
+ public_hostname: node1.example.com
+ roles:
+ - node
+ - connect_to: 10.0.0.3
+ ip: 10.0.0.3
+ hostname: node2-private.example.com
+ public_ip: 24.222.0.3
+ public_hostname: node2.example.com
+ roles:
+ - node
+ roles:
+ master:
+ node:
"""
def read_yaml(config_file_path):
@@ -87,12 +96,13 @@ class OOCliFixture(OOInstallFixture):
self.assertEquals(exp_hosts_to_run_on_len, len(hosts_to_run_on))
def _verify_config_hosts(self, written_config, host_count):
- self.assertEquals(host_count, len(written_config['hosts']))
- for host in written_config['hosts']:
+ self.assertEquals(host_count, len(written_config['deployment']['hosts']))
+ for host in written_config['deployment']['hosts']:
self.assertTrue('hostname' in host)
self.assertTrue('public_hostname' in host)
if 'preconfigured' not in host:
- self.assertTrue('node' in host or 'storage' in host)
+ if 'roles' in host:
+ self.assertTrue('node' in host['roles'] or 'storage' in host['roles'])
self.assertTrue('ip' in host)
self.assertTrue('public_ip' in host)
@@ -128,15 +138,19 @@ class OOCliFixture(OOInstallFixture):
written_config = read_yaml(config_file)
self._verify_config_hosts(written_config, exp_hosts_len)
- self.assert_result(result, 0)
- self._verify_load_facts(load_facts_mock)
- self._verify_run_playbook(run_playbook_mock, exp_hosts_len, exp_hosts_to_run_on_len)
-
- # Make sure we ran on the expected masters and nodes:
- hosts = run_playbook_mock.call_args[0][1]
- hosts_to_run_on = run_playbook_mock.call_args[0][2]
- self.assertEquals(exp_hosts_len, len(hosts))
- self.assertEquals(exp_hosts_to_run_on_len, len(hosts_to_run_on))
+ if "Uninstalled" in result.output:
+ # verify we exited on seeing uninstalled hosts
+ self.assertEqual(result.exit_code, 1)
+ else:
+ self.assert_result(result, 0)
+ self._verify_load_facts(load_facts_mock)
+ self._verify_run_playbook(run_playbook_mock, exp_hosts_len, exp_hosts_to_run_on_len)
+
+ # Make sure we ran on the expected masters and nodes:
+ hosts = run_playbook_mock.call_args[0][1]
+ hosts_to_run_on = run_playbook_mock.call_args[0][2]
+ self.assertEquals(exp_hosts_len, len(hosts))
+ self.assertEquals(exp_hosts_to_run_on_len, len(hosts_to_run_on))
#pylint: disable=too-many-arguments,too-many-branches,too-many-statements
diff --git a/utils/test/oo_config_tests.py b/utils/test/oo_config_tests.py
index 9f5f8e244..b5068cc14 100644
--- a/utils/test/oo_config_tests.py
+++ b/utils/test/oo_config_tests.py
@@ -12,89 +12,96 @@ from ooinstall.oo_config import OOConfig, Host, OOConfigInvalidHostError
SAMPLE_CONFIG = """
variant: openshift-enterprise
-ansible_ssh_user: root
-hosts:
- - connect_to: master-private.example.com
- ip: 10.0.0.1
- hostname: master-private.example.com
- public_ip: 24.222.0.1
- public_hostname: master.example.com
- master: true
- node: true
- - connect_to: node1-private.example.com
- ip: 10.0.0.2
- hostname: node1-private.example.com
- public_ip: 24.222.0.2
- public_hostname: node1.example.com
- node: true
- - connect_to: node2-private.example.com
- ip: 10.0.0.3
- hostname: node2-private.example.com
- public_ip: 24.222.0.3
- public_hostname: node2.example.com
- node: true
-"""
-
-# Used to test automatic upgrading of config:
-LEGACY_CONFIG = """
-Description: This is the configuration file for the OpenShift Ansible-Based Installer.
-Name: OpenShift Ansible-Based Installer Configuration
-Subscription: {type: none}
-Vendor: OpenShift Community
-Version: 0.0.1
-ansible_config: /tmp/notreal/ansible.cfg
-ansible_inventory_directory: /tmp/notreal/.config/openshift/.ansible
-ansible_log_path: /tmp/ansible.log
-ansible_plugins_directory: /tmp/notreal/.python-eggs/ooinstall-3.0.0-py2.7.egg-tmp/ooinstall/ansible_plugins
-masters: [10.0.0.1]
-nodes: [10.0.0.2, 10.0.0.3]
-validated_facts:
- 10.0.0.1: {hostname: master-private.example.com, ip: 10.0.0.1, public_hostname: master.example.com, public_ip: 24.222.0.1}
- 10.0.0.2: {hostname: node1-private.example.com, ip: 10.0.0.2, public_hostname: node1.example.com, public_ip: 24.222.0.2}
- 10.0.0.3: {hostname: node2-private.example.com, ip: 10.0.0.3, public_hostname: node2.example.com, public_ip: 24.222.0.3}
+variant_version: 3.3
+version: v2
+deployment:
+ ansible_ssh_user: root
+ hosts:
+ - connect_to: master-private.example.com
+ ip: 10.0.0.1
+ hostname: master-private.example.com
+ public_ip: 24.222.0.1
+ public_hostname: master.example.com
+ roles:
+ - master
+ - node
+ - connect_to: node1-private.example.com
+ ip: 10.0.0.2
+ hostname: node1-private.example.com
+ public_ip: 24.222.0.2
+ public_hostname: node1.example.com
+ roles:
+ - node
+ - connect_to: node2-private.example.com
+ ip: 10.0.0.3
+ hostname: node2-private.example.com
+ public_ip: 24.222.0.3
+ public_hostname: node2.example.com
+ roles:
+ - node
+ roles:
+ master:
+ node:
"""
CONFIG_INCOMPLETE_FACTS = """
-hosts:
- - connect_to: 10.0.0.1
- ip: 10.0.0.1
- hostname: master-private.example.com
- public_ip: 24.222.0.1
- public_hostname: master.example.com
- master: true
- - connect_to: 10.0.0.2
- ip: 10.0.0.2
- hostname: 24.222.0.2
- public_ip: 24.222.0.2
- node: true
- - connect_to: 10.0.0.3
- ip: 10.0.0.3
- node: true
+version: v2
+deployment:
+ ansible_ssh_user: root
+ hosts:
+ - connect_to: 10.0.0.1
+ ip: 10.0.0.1
+ hostname: master-private.example.com
+ public_ip: 24.222.0.1
+ public_hostname: master.example.com
+ roles:
+ - master
+ - connect_to: 10.0.0.2
+ ip: 10.0.0.2
+ hostname: 24.222.0.2
+ public_ip: 24.222.0.2
+ roles:
+ - node
+ - connect_to: 10.0.0.3
+ ip: 10.0.0.3
+ roles:
+ - node
+ roles:
+ master:
+ node:
"""
CONFIG_BAD = """
variant: openshift-enterprise
-ansible_ssh_user: root
-hosts:
- - connect_to: master-private.example.com
- ip: 10.0.0.1
- hostname: master-private.example.com
- public_ip: 24.222.0.1
- public_hostname: master.example.com
- master: true
- node: true
- - ip: 10.0.0.2
- hostname: node1-private.example.com
- public_ip: 24.222.0.2
- public_hostname: node1.example.com
- node: true
- - connect_to: node2-private.example.com
- ip: 10.0.0.3
- hostname: node2-private.example.com
- public_ip: 24.222.0.3
- public_hostname: node2.example.com
- node: true
+version: v2
+deployment:
+ ansible_ssh_user: root
+ hosts:
+ - connect_to: master-private.example.com
+ ip: 10.0.0.1
+ hostname: master-private.example.com
+ public_ip: 24.222.0.1
+ public_hostname: master.example.com
+ roles:
+ - master
+ - node
+ - ip: 10.0.0.2
+ hostname: node1-private.example.com
+ public_ip: 24.222.0.2
+ public_hostname: node1.example.com
+ roles:
+ - node
+ - connect_to: node2-private.example.com
+ ip: 10.0.0.3
+ hostname: node2-private.example.com
+ public_ip: 24.222.0.3
+ public_hostname: node2.example.com
+ roles:
+ - node
+ roles:
+ master:
+ node:
"""
class OOInstallFixture(unittest.TestCase):
@@ -123,47 +130,6 @@ class OOInstallFixture(unittest.TestCase):
return path
-class LegacyOOConfigTests(OOInstallFixture):
-
- def setUp(self):
- OOInstallFixture.setUp(self)
- self.cfg_path = self.write_config(os.path.join(self.work_dir,
- 'ooinstall.conf'), LEGACY_CONFIG)
- self.cfg = OOConfig(self.cfg_path)
-
- def test_load_config_memory(self):
- self.assertEquals('openshift-enterprise', self.cfg.settings['variant'])
- self.assertEquals('3.0', self.cfg.settings['variant_version'])
- self.assertEquals('v1', self.cfg.settings['version'])
-
- self.assertEquals(3, len(self.cfg.hosts))
- h1 = self.cfg.get_host('10.0.0.1')
- self.assertEquals('10.0.0.1', h1.ip)
- self.assertEquals('24.222.0.1', h1.public_ip)
- self.assertEquals('master-private.example.com', h1.hostname)
- self.assertEquals('master.example.com', h1.public_hostname)
-
- h2 = self.cfg.get_host('10.0.0.2')
- self.assertEquals('10.0.0.2', h2.ip)
- self.assertEquals('24.222.0.2', h2.public_ip)
- self.assertEquals('node1-private.example.com', h2.hostname)
- self.assertEquals('node1.example.com', h2.public_hostname)
-
- h3 = self.cfg.get_host('10.0.0.3')
- self.assertEquals('10.0.0.3', h3.ip)
- self.assertEquals('24.222.0.3', h3.public_ip)
- self.assertEquals('node2-private.example.com', h3.hostname)
- self.assertEquals('node2.example.com', h3.public_hostname)
-
- self.assertFalse('masters' in self.cfg.settings)
- self.assertFalse('nodes' in self.cfg.settings)
- self.assertFalse('Description' in self.cfg.settings)
- self.assertFalse('Name' in self.cfg.settings)
- self.assertFalse('Subscription' in self.cfg.settings)
- self.assertFalse('Vendor' in self.cfg.settings)
- self.assertFalse('Version' in self.cfg.settings)
- self.assertFalse('validates_facts' in self.cfg.settings)
-
class OOConfigTests(OOInstallFixture):
@@ -173,16 +139,16 @@ class OOConfigTests(OOInstallFixture):
'ooinstall.conf'), SAMPLE_CONFIG)
ooconfig = OOConfig(cfg_path)
- self.assertEquals(3, len(ooconfig.hosts))
- self.assertEquals("master-private.example.com", ooconfig.hosts[0].connect_to)
- self.assertEquals("10.0.0.1", ooconfig.hosts[0].ip)
- self.assertEquals("master-private.example.com", ooconfig.hosts[0].hostname)
+ self.assertEquals(3, len(ooconfig.deployment.hosts))
+ self.assertEquals("master-private.example.com", ooconfig.deployment.hosts[0].connect_to)
+ self.assertEquals("10.0.0.1", ooconfig.deployment.hosts[0].ip)
+ self.assertEquals("master-private.example.com", ooconfig.deployment.hosts[0].hostname)
self.assertEquals(["10.0.0.1", "10.0.0.2", "10.0.0.3"],
- [host['ip'] for host in ooconfig.settings['hosts']])
+ [host.ip for host in ooconfig.deployment.hosts])
self.assertEquals('openshift-enterprise', ooconfig.settings['variant'])
- self.assertEquals('v1', ooconfig.settings['version'])
+ self.assertEquals('v2', ooconfig.settings['version'])
def test_load_bad_config(self):
@@ -222,16 +188,18 @@ class OOConfigTests(OOInstallFixture):
written_config = yaml.safe_load(f.read())
f.close()
- self.assertEquals(3, len(written_config['hosts']))
- for h in written_config['hosts']:
+
+
+ self.assertEquals(3, len(written_config['deployment']['hosts']))
+ for h in written_config['deployment']['hosts']:
self.assertTrue('ip' in h)
self.assertTrue('public_ip' in h)
self.assertTrue('hostname' in h)
self.assertTrue('public_hostname' in h)
- self.assertTrue('ansible_ssh_user' in written_config)
+ self.assertTrue('ansible_ssh_user' in written_config['deployment'])
self.assertTrue('variant' in written_config)
- self.assertEquals('v1', written_config['version'])
+ self.assertEquals('v2', written_config['version'])
# Some advanced settings should not get written out if they
# were not specified by the user:
@@ -256,7 +224,3 @@ class HostTests(OOInstallFixture):
'public_hostname': 'a.example.com',
}
self.assertRaises(OOConfigInvalidHostError, Host, **yaml_props)
-
-
-
-