From bcbb870431bea53a9863802e15bbfad98931b04d Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Wed, 9 Mar 2016 08:45:09 -0500 Subject: a-o-i: Fix NFS storage tests Fix the nosetests after the rebase --- utils/src/ooinstall/cli_installer.py | 16 ++++++---- utils/src/ooinstall/oo_config.py | 3 +- utils/test/cli_installer_tests.py | 57 +++++++++++++++++++++++++++++------- utils/test/fixture.py | 9 ++++-- 4 files changed, 65 insertions(+), 20 deletions(-) diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 465b2e6d2..c53ca7b18 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -248,6 +248,8 @@ def print_host_summary(all_hosts, host): click.echo(" - Etcd Member") else: click.echo(" - Etcd (Embedded)") + if host.storage: + click.echo(" - Storage") def collect_master_lb(hosts): @@ -372,11 +374,15 @@ Notes: for h in hosts: if h.preconfigured == True: continue - default_facts[h.connect_to] = {} - h.ip = callback_facts[h.connect_to]["common"]["ip"] - h.public_ip = callback_facts[h.connect_to]["common"]["public_ip"] - h.hostname = callback_facts[h.connect_to]["common"]["hostname"] - h.public_hostname = callback_facts[h.connect_to]["common"]["public_hostname"] + try: + default_facts[h.connect_to] = {} + h.ip = callback_facts[h.connect_to]["common"]["ip"] + h.public_ip = callback_facts[h.connect_to]["common"]["public_ip"] + h.hostname = callback_facts[h.connect_to]["common"]["hostname"] + h.public_hostname = callback_facts[h.connect_to]["common"]["public_hostname"] + except KeyError: + click.echo("Problem fetching facts from {}".format(h.connect_to)) + continue default_facts_lines.append(",".join([h.connect_to, h.ip, diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py index 8e3a11240..c9498542f 100644 --- a/utils/src/ooinstall/oo_config.py +++ b/utils/src/ooinstall/oo_config.py @@ -59,7 +59,8 @@ class Host(object): raise OOConfigInvalidHostError("You must specify either an ip " \ "or hostname as 'connect_to'") - if self.master is False and self.node is False and self.master_lb is False: + if self.master is False and self.node is False and \ + self.master_lb is False and self.storage is False: raise OOConfigInvalidHostError( "You must specify each host as either a master or a node.") diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py index baab5d56f..6ba5ec1eb 100644 --- a/utils/test/cli_installer_tests.py +++ b/utils/test/cli_installer_tests.py @@ -72,6 +72,14 @@ MOCK_FACTS_QUICKHA = { 'public_hostname': 'proxy.example.com' } }, + '10.1.0.1': { + 'common': { + 'ip': '10.1.0.1', + 'public_ip': '10.1.0.1', + 'hostname': 'storage-private.example.com', + 'public_hostname': 'storage.example.com' + } + }, } # Missing connect_to on some hosts: @@ -137,6 +145,12 @@ hosts: 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 """ QUICKHA_2_MASTER_CONFIG = """ @@ -169,6 +183,12 @@ hosts: 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 """ QUICKHA_CONFIG_REUSED_LB = """ @@ -197,6 +217,12 @@ hosts: 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 """ QUICKHA_CONFIG_NO_LB = """ @@ -263,6 +289,12 @@ hosts: 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 """ class UnattendedCliTests(OOCliFixture): @@ -595,8 +627,8 @@ class UnattendedCliTests(OOCliFixture): # Make sure we ran on the expected masters and nodes: hosts = run_playbook_mock.call_args[0][0] hosts_to_run_on = run_playbook_mock.call_args[0][1] - self.assertEquals(5, len(hosts)) - self.assertEquals(5, len(hosts_to_run_on)) + self.assertEquals(6, len(hosts)) + self.assertEquals(6, len(hosts_to_run_on)) #unattended with two masters, one node, and haproxy @patch('ooinstall.openshift_ansible.run_main_playbook') @@ -665,8 +697,8 @@ class UnattendedCliTests(OOCliFixture): # Make sure we ran on the expected masters and nodes: hosts = run_playbook_mock.call_args[0][0] hosts_to_run_on = run_playbook_mock.call_args[0][1] - self.assertEquals(5, len(hosts)) - self.assertEquals(5, len(hosts_to_run_on)) + self.assertEquals(6, len(hosts)) + self.assertEquals(6, len(hosts_to_run_on)) class AttendedCliTests(OOCliFixture): @@ -805,17 +837,18 @@ class AttendedCliTests(OOCliFixture): ssh_user='root', variant_num=1, confirm_facts='y', - master_lb=('10.0.0.5', False)) + master_lb=('10.0.0.5', False), + 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) self._verify_load_facts(load_facts_mock) - self._verify_run_playbook(run_playbook_mock, 5, 5) + self._verify_run_playbook(run_playbook_mock, 6, 6) written_config = read_yaml(self.config_file) - self._verify_config_hosts(written_config, 5) + self._verify_config_hosts(written_config, 6) inventory = ConfigParser.ConfigParser(allow_no_value=True) inventory.read(os.path.join(self.work_dir, '.ansible/hosts')) @@ -845,17 +878,18 @@ class AttendedCliTests(OOCliFixture): ssh_user='root', variant_num=1, confirm_facts='y', - master_lb=('10.0.0.5', False)) + master_lb=('10.0.0.5', False), + 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) self._verify_load_facts(load_facts_mock) - self._verify_run_playbook(run_playbook_mock, 4, 4) + self._verify_run_playbook(run_playbook_mock, 5, 5) written_config = read_yaml(self.config_file) - self._verify_config_hosts(written_config, 4) + self._verify_config_hosts(written_config, 5) inventory = ConfigParser.ConfigParser(allow_no_value=True) inventory.read(os.path.join(self.work_dir, '.ansible/hosts')) @@ -881,7 +915,8 @@ class AttendedCliTests(OOCliFixture): ssh_user='root', variant_num=1, confirm_facts='y', - master_lb=(['10.0.0.2', '10.0.0.5'], False)) + master_lb=(['10.0.0.2', '10.0.0.5'], False), + storage='10.1.0.1') self.cli_args.append("install") result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input) diff --git a/utils/test/fixture.py b/utils/test/fixture.py index 1b1c2e5c2..d6222dfaa 100644 --- a/utils/test/fixture.py +++ b/utils/test/fixture.py @@ -92,7 +92,7 @@ class OOCliFixture(OOInstallFixture): self.assertTrue('hostname' in host) self.assertTrue('public_hostname' in host) if 'preconfigured' not in host: - self.assertTrue(host['node']) + self.assertTrue('node' in host or 'storage' in host) self.assertTrue('ip' in host) self.assertTrue('public_ip' in host) @@ -142,7 +142,7 @@ class OOCliFixture(OOInstallFixture): #pylint: disable=too-many-arguments,too-many-branches,too-many-statements def build_input(ssh_user=None, hosts=None, variant_num=None, add_nodes=None, confirm_facts=None, schedulable_masters_ok=None, - master_lb=None): + master_lb=None, storage=None): """ Build an input string simulating a user entering values in an interactive attended install. @@ -197,7 +197,10 @@ def build_input(ssh_user=None, hosts=None, variant_num=None, inputs.append(master_lb[0]) inputs.append('y' if master_lb[1] else 'n') - inputs.append('example.com') + if storage: + inputs.append(storage) + + inputs.append('subdomain.example.com') # TODO: support option 2, fresh install if add_nodes: -- cgit v1.2.3