From 4ca71667972b56438cd38633998878babc58807a Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Wed, 18 Nov 2015 10:59:04 -0500 Subject: atomic-openshift-installer: HA for quick installer This adds the ability to quickly set up a multi-master environment. --- utils/test/cli_installer_tests.py | 1 + 1 file changed, 1 insertion(+) (limited to 'utils/test/cli_installer_tests.py') diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py index 40a2f844d..61bc77445 100644 --- a/utils/test/cli_installer_tests.py +++ b/utils/test/cli_installer_tests.py @@ -613,6 +613,7 @@ class AttendedCliTests(OOCliFixture): result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input) + print result self.assert_result(result, 0) self._verify_load_facts(load_facts_mock) -- cgit v1.2.3 From 42fd40f644c6a0b36577d96409b95c0895a5b282 Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Fri, 20 Nov 2015 10:09:24 -0500 Subject: Add interactive test --- utils/test/cli_installer_tests.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'utils/test/cli_installer_tests.py') diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py index 61bc77445..b5ef87cce 100644 --- a/utils/test/cli_installer_tests.py +++ b/utils/test/cli_installer_tests.py @@ -668,6 +668,33 @@ class AttendedCliTests(OOCliFixture): exp_hosts_to_run_on_len=2, force=False) + #interactive multimaster + @patch('ooinstall.openshift_ansible.run_main_playbook') + @patch('ooinstall.openshift_ansible.load_system_facts') + def test_quick_ha(self, load_facts_mock, run_playbook_mock): + load_facts_mock.return_value = (MOCK_FACTS, 0) + run_playbook_mock.return_value = 0 + + cli_input = self._build_input(hosts=[ + ('10.0.0.1', True), + ('10.0.0.2', True), + ('10.0.0.3', False), + ('10.0.0.4', True)], + ssh_user='root', + variant_num=1, + confirm_facts='y') + 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, 3, 3) + + written_config = self._read_yaml(self.config_file) + self._verify_config_hosts(written_config, 3) + + return # TODO: test with config file, attended add node # TODO: test with config file, attended new node already in config file # TODO: test with config file, attended new node already in config file, plus manually added nodes -- cgit v1.2.3 From 20f9d2c0d0387ffda27213b8f05f0e884fdd16ac Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Fri, 20 Nov 2015 15:13:51 -0500 Subject: cli_installer_tests: Add test for unattended quick HA --- utils/test/cli_installer_tests.py | 101 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) (limited to 'utils/test/cli_installer_tests.py') diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py index b5ef87cce..87aafe782 100644 --- a/utils/test/cli_installer_tests.py +++ b/utils/test/cli_installer_tests.py @@ -41,6 +41,41 @@ MOCK_FACTS = { }, } +MOCK_FACTS_QUICKHA = { + '10.0.0.1': { + 'common': { + 'ip': '10.0.0.1', + 'public_ip': '10.0.0.1', + 'hostname': 'master-private.example.com', + 'public_hostname': 'master.example.com' + } + }, + '10.0.0.2': { + 'common': { + 'ip': '10.0.0.2', + 'public_ip': '10.0.0.2', + 'hostname': 'node1-private.example.com', + 'public_hostname': 'node1.example.com' + } + }, + '10.0.0.3': { + 'common': { + 'ip': '10.0.0.3', + 'public_ip': '10.0.0.3', + 'hostname': 'node2-private.example.com', + 'public_hostname': 'node2.example.com' + } + }, + '10.0.0.4': { + 'common': { + 'ip': '10.0.0.4', + 'public_ip': '10.0.0.4', + 'hostname': 'proxy-private.example.com', + 'public_hostname': 'proxy.example.com' + } + }, +} + # Substitute in a product name before use: SAMPLE_CONFIG = """ variant: %s @@ -91,6 +126,38 @@ hosts: node: true """ +QUICKHA_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.3 + ip: 10.0.0.3 + hostname: node2-private.example.com + public_ip: 24.222.0.3 + public_hostname: node2.example.com + node: true + - connect_to: 10.0.0.4 + ip: 10.0.0.4 + hostname: proxy-private.example.com + public_ip: 24.222.0.4 + public_hostname: proxy.example.com + ha_proxy: true +""" + class OOCliFixture(OOInstallFixture): def setUp(self): @@ -504,6 +571,40 @@ class UnattendedCliTests(OOCliFixture): assert result.exit_code == 1 assert result.output == "You must specify either and 'ip' or 'hostname' to connect to.\n" + #unattended with two masters, one node, and haproxy + @patch('ooinstall.openshift_ansible.run_main_playbook') + @patch('ooinstall.openshift_ansible.load_system_facts') + def test_quick_ha_full_run(self, load_facts_mock, run_playbook_mock): + load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0) + run_playbook_mock.return_value = 0 + + config_file = self.write_config(os.path.join(self.work_dir, + 'ooinstall.conf'), QUICKHA_CONFIG % 'openshift-enterprise') + + self.cli_args.extend(["-c", config_file, "install"]) + result = self.runner.invoke(cli.cli, self.cli_args) + self.assert_result(result, 0) + + load_facts_args = load_facts_mock.call_args[0] + self.assertEquals(os.path.join(self.work_dir, ".ansible/hosts"), + load_facts_args[0]) + self.assertEquals(os.path.join(self.work_dir, + "playbooks/byo/openshift_facts.yml"), load_facts_args[1]) + env_vars = load_facts_args[2] + self.assertEquals(os.path.join(self.work_dir, + '.ansible/callback_facts.yaml'), + env_vars['OO_INSTALL_CALLBACK_FACTS_YAML']) + self.assertEqual('/tmp/ansible.log', env_vars['ANSIBLE_LOG_PATH']) + # If user running test has rpm installed, this might be set to default: + self.assertTrue('ANSIBLE_CONFIG' not in env_vars or + env_vars['ANSIBLE_CONFIG'] == cli.DEFAULT_ANSIBLE_CONFIG) + + # 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(4, len(hosts)) + self.assertEquals(4, len(hosts_to_run_on)) + class AttendedCliTests(OOCliFixture): def setUp(self): -- cgit v1.2.3 From 27a8228a81c81b2f7db003eedb3b9eaf03a849b4 Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Fri, 20 Nov 2015 15:34:35 -0500 Subject: atomic-openshift-installer: Reverse version and host collection Reverse the order we ask two questions: What variant the user wants to install and which hosts to install on. This lets us avoid asking for multiple masters for 3.0 installs. --- utils/test/cli_installer_tests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'utils/test/cli_installer_tests.py') diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py index 87aafe782..9cb44404c 100644 --- a/utils/test/cli_installer_tests.py +++ b/utils/test/cli_installer_tests.py @@ -628,6 +628,9 @@ class AttendedCliTests(OOCliFixture): if ssh_user: inputs.append(ssh_user) + if variant_num: + inputs.append(str(variant_num)) # Choose variant + version + if hosts: i = 0 for (host, is_master) in hosts: @@ -640,9 +643,6 @@ class AttendedCliTests(OOCliFixture): inputs.append('n') # Done adding hosts i += 1 - if variant_num: - inputs.append(str(variant_num)) # Choose variant + version - # TODO: support option 2, fresh install if add_nodes: inputs.append('1') # Add more nodes -- cgit v1.2.3 From 0b191360ec7d934b582d0c59cd8e377df92438dd Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Fri, 20 Nov 2015 15:58:05 -0500 Subject: atomic-openshift-installer: Rename ha_proxy Rename ha_proxy variables and methods to 'master_lb' to better future-proof things. --- utils/test/cli_installer_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/test/cli_installer_tests.py') diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py index 9cb44404c..ad00af76f 100644 --- a/utils/test/cli_installer_tests.py +++ b/utils/test/cli_installer_tests.py @@ -155,7 +155,7 @@ hosts: hostname: proxy-private.example.com public_ip: 24.222.0.4 public_hostname: proxy.example.com - ha_proxy: true + master_lb: true """ class OOCliFixture(OOInstallFixture): -- cgit v1.2.3