diff options
| author | Devan Goodwin <dgoodwin@redhat.com> | 2015-11-26 12:20:25 -0400 | 
|---|---|---|
| committer | Devan Goodwin <dgoodwin@redhat.com> | 2015-11-26 12:20:25 -0400 | 
| commit | 8a0153e992938a9b3441faca77305be1bb42f4d2 (patch) | |
| tree | 3e0585b29bd671814ce152b92da78dd224053f65 | |
| parent | e6054d0ef7d07f370496dac82975b17dc3dfce70 (diff) | |
| download | openshift-8a0153e992938a9b3441faca77305be1bb42f4d2.tar.gz openshift-8a0153e992938a9b3441faca77305be1bb42f4d2.tar.bz2 openshift-8a0153e992938a9b3441faca77305be1bb42f4d2.tar.xz openshift-8a0153e992938a9b3441faca77305be1bb42f4d2.zip  | |
Test unattended HA quick install.
Checking behavior when there is no LB specified, and when the user attempts
to re-use a master or node as their LB.
| -rw-r--r-- | utils/src/ooinstall/cli_installer.py | 23 | ||||
| -rw-r--r-- | utils/src/ooinstall/openshift_ansible.py | 2 | ||||
| -rw-r--r-- | utils/test/cli_installer_tests.py | 109 | 
3 files changed, 125 insertions, 9 deletions
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index acfb5065b..82f695fca 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -278,22 +278,28 @@ def check_hosts_config(oo_cfg, unattended):              # Check for another host with same connect_to?          else:              message = """ -No HAProxy given in config. Either specify one or provide a load balancing solution -of your choice to balance the master API (port 8443) on all master hosts. +WARNING: No master load balancer specified in config. If you proceed you will +need to provide a load balancing solution of your choice to balance the +API (port 8443) on all master hosts.  https://docs.openshift.org/latest/install_config/install/advanced_install.html#multiple-masters  """ -            if not unattended: +            if unattended: +                click.echo(message) +            else:                  confirm_continue(message)      nodes = [host for host in oo_cfg.hosts if host.node] +    # TODO: This looks a little unsafe, maybe look for dedicated nodes only:      if len(masters) == len(nodes):          message = """ -No dedicated Nodes specified. By default, colocated Masters have their Nodes -set to unscheduleable.  Continuing at this point will label all nodes as -scheduleable. +WARNING: No dedicated Nodes specified. By default, colocated Masters have +their Nodes set to unscheduleable.  If you proceed all nodes will be labelled +as schedulable.  """ -        if not unattended: +        if unattended: +            click.echo(message) +        else:              confirm_continue(message)      return @@ -318,7 +324,8 @@ def get_variant_and_version(multi_master=False):      return product, version  def confirm_continue(message): -    click.echo(message) +    if message: +        click.echo(message)      click.confirm("Are you ready to continue?", default=False, abort=True)      return diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 84e4db61d..866590c49 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -106,7 +106,7 @@ def write_inventory_vars(base_inventory, multiple_masters, proxy):      base_inventory.write('ansible_ssh_user={}\n'.format(CFG.settings['ansible_ssh_user']))      if CFG.settings['ansible_ssh_user'] != 'root':          base_inventory.write('ansible_become=true\n') -    if multiple_masters: +    if multiple_masters and proxy is not None:          base_inventory.write('openshift_master_cluster_method=native\n')          base_inventory.write("openshift_master_cluster_hostname={}\n".format(proxy.hostname))          base_inventory.write("openshift_master_cluster_public_hostname={}\n".format(proxy.public_hostname)) diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py index 2891cefcc..b1ab7b283 100644 --- a/utils/test/cli_installer_tests.py +++ b/utils/test/cli_installer_tests.py @@ -102,6 +102,7 @@ hosts:      node: true  """ +# Missing connect_to on some hosts:  BAD_CONFIG = """  variant: %s  ansible_ssh_user: root @@ -158,6 +159,59 @@ hosts:      master_lb: true  """ +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 +""" + +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 +""" +  class OOCliFixture(OOInstallFixture):      def setUp(self): @@ -606,6 +660,61 @@ class UnattendedCliTests(OOCliFixture):          self.assertEquals(4, len(hosts))          self.assertEquals(4, len(hosts_to_run_on)) +    #unattended with two masters, one node, but no load balancer specified: +    @patch('ooinstall.openshift_ansible.run_main_playbook') +    @patch('ooinstall.openshift_ansible.load_system_facts') +    def test_quick_ha_no_lb(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_NO_LB % 'openshift-enterprise') + +        self.cli_args.extend(["-c", config_file, "install"]) +        result = self.runner.invoke(cli.cli, self.cli_args) + +        # We consider this a valid outcome but lets make sure the warning +        # was displayed: +        self.assert_result(result, 0) +        self.assertTrue('No master load balancer specified in config' in result.output) + +        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(3, len(hosts)) +        self.assertEquals(3, len(hosts_to_run_on)) + +    #unattended with two masters, one node, and one of the masters reused as load balancer: +    @patch('ooinstall.openshift_ansible.run_main_playbook') +    @patch('ooinstall.openshift_ansible.load_system_facts') +    def test_quick_ha_reused_lb(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_REUSED_LB % 'openshift-enterprise') + +        self.cli_args.extend(["-c", config_file, "install"]) +        result = self.runner.invoke(cli.cli, self.cli_args) + +        # This is not a valid configuration: +        self.assert_result(result, 0) + +  class AttendedCliTests(OOCliFixture):      def setUp(self):  | 
