diff options
| -rw-r--r-- | .flake8 | 2 | ||||
| -rw-r--r-- | utils/test/cli_installer_tests.py | 285 | ||||
| -rw-r--r-- | utils/test/fixture.py | 11 | ||||
| -rw-r--r-- | utils/test/oo_config_tests.py | 31 | ||||
| -rw-r--r-- | utils/test/test_utils.py | 1 | 
5 files changed, 174 insertions, 156 deletions
| @@ -1,5 +1,5 @@  [flake8]  # TODO: cleanup flake8 issues with utils/test/* -exclude=.tox,inventory,utils/test +exclude=.tox,inventory  max_line_length = 120  ignore = E501,T003 diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py index 673997c42..2259f3416 100644 --- a/utils/test/cli_installer_tests.py +++ b/utils/test/cli_installer_tests.py @@ -384,6 +384,7 @@ deployment:          storage:  """ +  class UnattendedCliTests(OOCliFixture):      def setUp(self): @@ -402,8 +403,9 @@ class UnattendedCliTests(OOCliFixture):          load_facts_mock.return_value = (mock_facts, 0)          run_playbook_mock.return_value = 0 -        config_file = self.write_config(os.path.join(self.work_dir, -            'ooinstall.conf'), SAMPLE_CONFIG % 'openshift-enterprise') +        config_file = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), +            SAMPLE_CONFIG % 'openshift-enterprise')          self.cli_args.extend(["-c", config_file, "install"])          result = self.runner.invoke(cli.cli, self.cli_args) @@ -481,8 +483,9 @@ class UnattendedCliTests(OOCliFixture):          load_facts_mock.return_value = (MOCK_FACTS, 0)          run_playbook_mock.return_value = 0 -        config_file = self.write_config(os.path.join(self.work_dir, -            'ooinstall.conf'), SAMPLE_CONFIG % 'openshift-enterprise') +        config_file = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), +            SAMPLE_CONFIG % 'openshift-enterprise')          self.cli_args.extend(["-c", config_file, "install"])          result = self.runner.invoke(cli.cli, self.cli_args) @@ -490,16 +493,18 @@ class UnattendedCliTests(OOCliFixture):          load_facts_args = load_facts_mock.call_args[0]          self.assertEquals(os.path.join(self.work_dir, "hosts"), -            load_facts_args[0]) -        self.assertEquals(os.path.join(self.work_dir, -            "playbooks/byo/openshift_facts.yml"), load_facts_args[1]) +                          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'), +        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 +        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: @@ -515,8 +520,9 @@ class UnattendedCliTests(OOCliFixture):          load_facts_mock.return_value = (MOCK_FACTS, 0)          run_playbook_mock.return_value = 0 -        config_file = self.write_config(os.path.join(self.work_dir, -            'ooinstall.conf'), merged_config) +        config_file = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), +            merged_config)          self.cli_args.extend(["-c", config_file, "install"])          result = self.runner.invoke(cli.cli, self.cli_args) @@ -526,9 +532,9 @@ class UnattendedCliTests(OOCliFixture):          inventory = configparser.ConfigParser(allow_no_value=True)          inventory.read(os.path.join(self.work_dir, 'hosts'))          self.assertEquals('root', -            inventory.get('OSEv3:vars', 'ansible_ssh_user')) +                          inventory.get('OSEv3:vars', 'ansible_ssh_user'))          self.assertEquals('openshift-enterprise', -            inventory.get('OSEv3:vars', 'deployment_type')) +                          inventory.get('OSEv3:vars', 'deployment_type'))          # Check the masters:          self.assertEquals(1, len(inventory.items('masters'))) @@ -546,13 +552,13 @@ class UnattendedCliTests(OOCliFixture):      @patch('ooinstall.openshift_ansible.run_main_playbook')      @patch('ooinstall.openshift_ansible.load_system_facts') -    def test_variant_version_latest_assumed(self, load_facts_mock, -        run_playbook_mock): +    def test_variant_version_latest_assumed(self, load_facts_mock, run_playbook_mock):          load_facts_mock.return_value = (MOCK_FACTS, 0)          run_playbook_mock.return_value = 0 -        config_file = self.write_config(os.path.join(self.work_dir, -            'ooinstall.conf'), SAMPLE_CONFIG % 'openshift-enterprise') +        config_file = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), +            SAMPLE_CONFIG % 'openshift-enterprise')          self.cli_args.extend(["-c", config_file, "install"])          result = self.runner.invoke(cli.cli, self.cli_args) @@ -569,19 +575,18 @@ class UnattendedCliTests(OOCliFixture):          inventory = configparser.ConfigParser(allow_no_value=True)          inventory.read(os.path.join(self.work_dir, 'hosts'))          self.assertEquals('openshift-enterprise', -            inventory.get('OSEv3:vars', 'deployment_type')) +                          inventory.get('OSEv3:vars', 'deployment_type'))      @patch('ooinstall.openshift_ansible.run_main_playbook')      @patch('ooinstall.openshift_ansible.load_system_facts') -    def test_variant_version_preserved(self, load_facts_mock, -        run_playbook_mock): +    def test_variant_version_preserved(self, load_facts_mock, run_playbook_mock):          load_facts_mock.return_value = (MOCK_FACTS, 0)          run_playbook_mock.return_value = 0          config = SAMPLE_CONFIG % 'openshift-enterprise'          config = '%s\n%s' % (config, 'variant_version: 3.3') -        config_file = self.write_config(os.path.join(self.work_dir, -            'ooinstall.conf'), config) +        config_file = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), config)          self.cli_args.extend(["-c", config_file, "install"])          result = self.runner.invoke(cli.cli, self.cli_args) @@ -597,7 +602,7 @@ class UnattendedCliTests(OOCliFixture):          inventory = configparser.ConfigParser(allow_no_value=True)          inventory.read(os.path.join(self.work_dir, 'hosts'))          self.assertEquals('openshift-enterprise', -            inventory.get('OSEv3:vars', 'deployment_type')) +                          inventory.get('OSEv3:vars', 'deployment_type'))      # unattended with bad config file and no installed hosts (without --force)      @patch('ooinstall.openshift_ansible.run_main_playbook') @@ -606,25 +611,28 @@ class UnattendedCliTests(OOCliFixture):          load_facts_mock.return_value = (MOCK_FACTS, 0)          run_playbook_mock.return_value = 0 -        config_file = self.write_config(os.path.join(self.work_dir, -            'ooinstall.conf'), BAD_CONFIG % 'openshift-enterprise') +        config_file = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), +            BAD_CONFIG % 'openshift-enterprise')          self.cli_args.extend(["-c", config_file, "install"])          result = self.runner.invoke(cli.cli, self.cli_args)          self.assertEquals(1, result.exit_code) -        self.assertTrue("You must specify either an ip or hostname" +        self.assertTrue( +            "You must specify either an ip or hostname"              in result.output) -    #unattended with three masters, one node, and haproxy +    # unattended with three 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') +        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) @@ -636,15 +644,16 @@ class UnattendedCliTests(OOCliFixture):          self.assertEquals(6, len(hosts))          self.assertEquals(6, len(hosts_to_run_on)) -    #unattended with two masters, one node, and haproxy +    # 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_only_2_masters(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_2_MASTER_CONFIG % 'openshift-enterprise') +        config_file = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), +            QUICKHA_2_MASTER_CONFIG % 'openshift-enterprise')          self.cli_args.extend(["-c", config_file, "install"])          result = self.runner.invoke(cli.cli, self.cli_args) @@ -653,15 +662,16 @@ class UnattendedCliTests(OOCliFixture):          self.assert_result(result, 1)          self.assertTrue("A minimum of 3 masters are required" in result.output) -    #unattended with three masters, one node, but no load balancer specified: +    # unattended with three 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') +        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) @@ -670,15 +680,16 @@ class UnattendedCliTests(OOCliFixture):          self.assert_result(result, 1)          self.assertTrue('No master load balancer specified in config' in result.output) -    #unattended with three masters, one node, and one of the masters reused as load balancer: +    # unattended with three 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') +        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) @@ -686,15 +697,16 @@ class UnattendedCliTests(OOCliFixture):          # This is not a valid configuration:          self.assert_result(result, 1) -    #unattended with preconfigured lb +    # unattended with preconfigured lb      @patch('ooinstall.openshift_ansible.run_main_playbook')      @patch('ooinstall.openshift_ansible.load_system_facts')      def test_quick_ha_preconfigured_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_PRECONFIGURED_LB % 'openshift-enterprise') +        config_file = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), +            QUICKHA_CONFIG_PRECONFIGURED_LB % 'openshift-enterprise')          self.cli_args.extend(["-c", config_file, "install"])          result = self.runner.invoke(cli.cli, self.cli_args) @@ -706,6 +718,7 @@ class UnattendedCliTests(OOCliFixture):          self.assertEquals(6, len(hosts))          self.assertEquals(6, len(hosts_to_run_on)) +  class AttendedCliTests(OOCliFixture):      def setUp(self): @@ -720,17 +733,18 @@ class AttendedCliTests(OOCliFixture):          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), -            ('10.0.0.2', False, False), -            ('10.0.0.3', False, False)], -                                      ssh_user='root', -                                      variant_num=1, -                                      confirm_facts='y', -                                      storage='10.1.0.1',) +        cli_input = build_input( +            hosts=[ +                ('10.0.0.1', True, False), +                ('10.0.0.2', False, False), +                ('10.0.0.3', False, False)], +            ssh_user='root', +            variant_num=1, +            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) +        result = self.runner.invoke( +            cli.cli, self.cli_args, input=cli_input)          self.assert_result(result, 0)          self._verify_load_facts(load_facts_mock) @@ -741,12 +755,12 @@ class AttendedCliTests(OOCliFixture):          inventory = configparser.ConfigParser(allow_no_value=True)          inventory.read(os.path.join(self.work_dir, 'hosts')) -        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=True') -        self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.3', -                                 'openshift_schedulable=True') +        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=True') +        self.assert_inventory_host_var_unset( +            inventory, 'nodes', '10.0.0.3', 'openshift_schedulable=True')      # interactive with config file and some installed some uninstalled hosts      @patch('ooinstall.openshift_ansible.run_main_playbook') @@ -762,15 +776,16 @@ class AttendedCliTests(OOCliFixture):          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), -            ('10.0.0.2', False, False), +        cli_input = build_input( +            hosts=[ +                ('10.0.0.1', True, False), +                ('10.0.0.2', False, False),              ], -                                      add_nodes=[('10.0.0.3', False, False)], -                                      ssh_user='root', -                                      variant_num=1, -                                      confirm_facts='y', -                                      storage='10.0.0.1',) +            add_nodes=[('10.0.0.3', False, False)], +            ssh_user='root', +            variant_num=1, +            confirm_facts='y', +            storage='10.0.0.1',)          self.cli_args.append("install")          result = self.runner.invoke(cli.cli,                                      self.cli_args, @@ -781,7 +796,6 @@ class AttendedCliTests(OOCliFixture):          self.assertTrue('scaleup' in result.output)          self.assert_result(result, 1) -      @patch('ooinstall.openshift_ansible.run_main_playbook')      @patch('ooinstall.openshift_ansible.load_system_facts')      def test_fresh_install_with_config(self, load_facts_mock, run_playbook_mock): @@ -830,26 +844,27 @@ class AttendedCliTests(OOCliFixture):  #                                         exp_hosts_to_run_on_len=2,  #                                         force=False) -    #interactive multimaster: one more node than master +    # interactive multimaster: one more node than master      @patch('ooinstall.openshift_ansible.run_main_playbook')      @patch('ooinstall.openshift_ansible.load_system_facts')      def test_ha_dedicated_node(self, load_facts_mock, run_playbook_mock):          load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)          run_playbook_mock.return_value = 0 -        cli_input = build_input(hosts=[ -            ('10.0.0.1', True, False), -            ('10.0.0.2', True, False), -            ('10.0.0.3', True, False), -            ('10.0.0.4', False, False)], -                                      ssh_user='root', -                                      variant_num=1, -                                      confirm_facts='y', -                                      master_lb=('10.0.0.5', False), -                                      storage='10.1.0.1',) +        cli_input = build_input( +            hosts=[ +                ('10.0.0.1', True, False), +                ('10.0.0.2', True, False), +                ('10.0.0.3', True, False), +                ('10.0.0.4', False, False)], +            ssh_user='root', +            variant_num=1, +            confirm_facts='y', +            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) +        result = self.runner.invoke( +            cli.cli, self.cli_args, input=cli_input)          self.assert_result(result, 0)          self._verify_load_facts(load_facts_mock) @@ -872,25 +887,26 @@ class AttendedCliTests(OOCliFixture):          self.assertTrue(inventory.has_section('etcd'))          self.assertEquals(3, len(inventory.items('etcd'))) -    #interactive multimaster: identical masters and nodes +    # interactive multimaster: identical masters and nodes      @patch('ooinstall.openshift_ansible.run_main_playbook')      @patch('ooinstall.openshift_ansible.load_system_facts')      def test_ha_no_dedicated_nodes(self, load_facts_mock, run_playbook_mock):          load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)          run_playbook_mock.return_value = 0 -        cli_input = build_input(hosts=[ -            ('10.0.0.1', True, False), -            ('10.0.0.2', True, False), -            ('10.0.0.3', True, False)], -                                      ssh_user='root', -                                      variant_num=1, -                                      confirm_facts='y', -                                      master_lb=('10.0.0.5', False), -                                      storage='10.1.0.1',) +        cli_input = build_input( +            hosts=[ +                ('10.0.0.1', True, False), +                ('10.0.0.2', True, False), +                ('10.0.0.3', True, False)], +            ssh_user='root', +            variant_num=1, +            confirm_facts='y', +            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) +        result = self.runner.invoke( +            cli.cli, self.cli_args, input=cli_input)          self.assert_result(result, 0)          self._verify_load_facts(load_facts_mock) @@ -919,7 +935,9 @@ class AttendedCliTests(OOCliFixture):              full_line = "%s=%s" % (a, b)              tokens = full_line.split()              if tokens[0] == host: -                self.assertTrue(variable in tokens[1:], "Unable to find %s in line: %s" % (variable, full_line)) +                self.assertTrue( +                    variable in tokens[1:], +                    "Unable to find %s in line: %s" % (variable, full_line))                  return          self.fail("unable to find host %s in inventory" % host) @@ -938,45 +956,46 @@ class AttendedCliTests(OOCliFixture):                  return          self.fail("unable to find host %s in inventory" % host) - -    #interactive multimaster: attempting to use a master as the load balancer should fail: +    # interactive multimaster: attempting to use a master as the load balancer should fail:      @patch('ooinstall.openshift_ansible.run_main_playbook')      @patch('ooinstall.openshift_ansible.load_system_facts')      def test_ha_reuse_master_as_lb(self, load_facts_mock, run_playbook_mock):          load_facts_mock.return_value = (MOCK_FACTS_QUICKHA, 0)          run_playbook_mock.return_value = 0 -        cli_input = build_input(hosts=[ -                                      ('10.0.0.1', True, False), -                                      ('10.0.0.2', True, False), -                                      ('10.0.0.3', False, False), -                                      ('10.0.0.4', True, False)], -                                      ssh_user='root', -                                      variant_num=1, -                                      confirm_facts='y', -                                      master_lb=(['10.0.0.2', '10.0.0.5'], False), -                                      storage='10.1.0.1') +        cli_input = build_input( +            hosts=[ +                ('10.0.0.1', True, False), +                ('10.0.0.2', True, False), +                ('10.0.0.3', False, False), +                ('10.0.0.4', True, False)], +            ssh_user='root', +            variant_num=1, +            confirm_facts='y', +            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) +        result = self.runner.invoke( +            cli.cli, self.cli_args, input=cli_input)          self.assert_result(result, 0) -    #interactive all-in-one +    # interactive all-in-one      @patch('ooinstall.openshift_ansible.run_main_playbook')      @patch('ooinstall.openshift_ansible.load_system_facts')      def test_all_in_one(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=1, -                                      confirm_facts='y', -                                      storage='10.0.0.1') +        cli_input = build_input( +            hosts=[ +                ('10.0.0.1', True, False)], +            ssh_user='root', +            variant_num=1, +            confirm_facts='y', +            storage='10.0.0.1')          self.cli_args.append("install") -        result = self.runner.invoke(cli.cli, self.cli_args, -            input=cli_input) +        result = self.runner.invoke( +            cli.cli, self.cli_args, input=cli_input)          self.assert_result(result, 0)          self._verify_load_facts(load_facts_mock) @@ -990,25 +1009,25 @@ class AttendedCliTests(OOCliFixture):          self.assert_inventory_host_var(inventory, 'nodes', '10.0.0.1',                                         'openshift_schedulable=True') -      @patch('ooinstall.openshift_ansible.run_main_playbook')      @patch('ooinstall.openshift_ansible.load_system_facts')      def test_gen_inventory(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), -            ('10.0.0.2', False, False), -            ('10.0.0.3', False, False)], -                                ssh_user='root', -                                variant_num=1, -                                confirm_facts='y', -                                storage='10.1.0.1',) +        cli_input = build_input( +            hosts=[ +                ('10.0.0.1', True, False), +                ('10.0.0.2', False, False), +                ('10.0.0.3', False, False)], +            ssh_user='root', +            variant_num=1, +            confirm_facts='y', +            storage='10.1.0.1',)          self.cli_args.append("install")          self.cli_args.append("--gen-inventory") -        result = self.runner.invoke(cli.cli, self.cli_args, -            input=cli_input) +        result = self.runner.invoke( +            cli.cli, self.cli_args, input=cli_input)          self.assert_result(result, 0)          self._verify_load_facts(load_facts_mock) @@ -1021,12 +1040,12 @@ class AttendedCliTests(OOCliFixture):          inventory = configparser.ConfigParser(allow_no_value=True)          inventory.read(os.path.join(self.work_dir, 'hosts')) -        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=True') -        self.assert_inventory_host_var_unset(inventory, 'nodes', '10.0.0.3', -                                 'openshift_schedulable=True') +        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=True') +        self.assert_inventory_host_var_unset( +            inventory, 'nodes', '10.0.0.3', 'openshift_schedulable=True')  # TODO: test with config file, attended add node diff --git a/utils/test/fixture.py b/utils/test/fixture.py index 873ac4a27..5c0d1d2c1 100644 --- a/utils/test/fixture.py +++ b/utils/test/fixture.py @@ -43,6 +43,7 @@ deployment:          node:  """ +  def read_yaml(config_file_path):      cfg_f = open(config_file_path, 'r')      config = yaml.safe_load(cfg_f.read()) @@ -105,7 +106,7 @@ class OOCliFixture(OOInstallFixture):                  self.assertTrue('ip' in host)                  self.assertTrue('public_ip' in host) -    #pylint: disable=too-many-arguments +    # pylint: disable=too-many-arguments      def _verify_get_hosts_to_run_on(self, mock_facts, load_facts_mock,                                      run_playbook_mock, cli_input,                                      exp_hosts_len=None, exp_hosts_to_run_on_len=None, @@ -152,7 +153,7 @@ class OOCliFixture(OOInstallFixture):              self.assertEquals(exp_hosts_to_run_on_len, len(hosts_to_run_on)) -#pylint: disable=too-many-arguments,too-many-branches,too-many-statements +# 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=('', False), storage=None): @@ -190,7 +191,7 @@ def build_input(ssh_user=None, hosts=None, variant_num=None,              else:                  inputs.append('rpm') -            #inputs.append('rpm') +            # inputs.append('rpm')              # We should not be prompted to add more hosts if we're currently at              # 2 masters, this is an invalid HA configuration, so this question              # will not be asked, and the user must enter the next host: @@ -224,13 +225,13 @@ def build_input(ssh_user=None, hosts=None, variant_num=None,              inputs.append('y')          inputs.append('1')  # Add more nodes          i = 0 -        for (host, is_master, is_containerized) in add_nodes: +        for (host, _, is_containerized) in add_nodes:              inputs.append(host)              if is_containerized:                  inputs.append('container')              else:                  inputs.append('rpm') -            #inputs.append('rpm') +            # inputs.append('rpm')              if i < len(add_nodes) - 1:                  inputs.append('y')  # Add more hosts              else: diff --git a/utils/test/oo_config_tests.py b/utils/test/oo_config_tests.py index 5651e6e7a..80cdbe618 100644 --- a/utils/test/oo_config_tests.py +++ b/utils/test/oo_config_tests.py @@ -107,6 +107,7 @@ deployment:          node:  """ +  class OOInstallFixture(unittest.TestCase):      def setUp(self): @@ -133,13 +134,12 @@ class OOInstallFixture(unittest.TestCase):          return path -  class OOConfigTests(OOInstallFixture):      def test_load_config(self): -        cfg_path = self.write_config(os.path.join(self.work_dir, -            'ooinstall.conf'), SAMPLE_CONFIG) +        cfg_path = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), SAMPLE_CONFIG)          ooconfig = OOConfig(cfg_path)          self.assertEquals(3, len(ooconfig.deployment.hosts)) @@ -155,26 +155,25 @@ class OOConfigTests(OOInstallFixture):      def test_load_bad_config(self): -        cfg_path = self.write_config(os.path.join(self.work_dir, -            'ooinstall.conf'), CONFIG_BAD) +        cfg_path = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), CONFIG_BAD)          try:              OOConfig(cfg_path)              assert False          except OOConfigInvalidHostError:              assert True -      def test_load_complete_facts(self): -        cfg_path = self.write_config(os.path.join(self.work_dir, -            'ooinstall.conf'), SAMPLE_CONFIG) +        cfg_path = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), SAMPLE_CONFIG)          ooconfig = OOConfig(cfg_path)          missing_host_facts = ooconfig.calc_missing_facts()          self.assertEquals(0, len(missing_host_facts))      # Test missing optional facts the user must confirm:      def test_load_host_incomplete_facts(self): -        cfg_path = self.write_config(os.path.join(self.work_dir, -            'ooinstall.conf'), CONFIG_INCOMPLETE_FACTS) +        cfg_path = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), CONFIG_INCOMPLETE_FACTS)          ooconfig = OOConfig(cfg_path)          missing_host_facts = ooconfig.calc_missing_facts()          self.assertEquals(2, len(missing_host_facts)) @@ -182,8 +181,8 @@ class OOConfigTests(OOInstallFixture):          self.assertEquals(3, len(missing_host_facts['10.0.0.3']))      def test_write_config(self): -        cfg_path = self.write_config(os.path.join(self.work_dir, -            'ooinstall.conf'), SAMPLE_CONFIG) +        cfg_path = self.write_config( +            os.path.join(self.work_dir, 'ooinstall.conf'), SAMPLE_CONFIG)          ooconfig = OOConfig(cfg_path)          ooconfig.save_to_disk() @@ -191,8 +190,6 @@ class OOConfigTests(OOInstallFixture):          written_config = yaml.safe_load(f.read())          f.close() - -          self.assertEquals(3, len(written_config['deployment']['hosts']))          for h in written_config['deployment']['hosts']:              self.assertTrue('ip' in h) @@ -259,8 +256,10 @@ class HostTests(OOInstallFixture):          # Given the `yaml_props` above we should see a line like this:          #     openshift_node_labels="{'region': 'infra'}" -        node_labels_expected = '''openshift_node_labels="{'region': 'infra'}"'''  # Quotes around the hash -        node_labels_bad = '''openshift_node_labels={'region': 'infra'}'''  # No quotes around the hash +        # Quotes around the hash +        node_labels_expected = '''openshift_node_labels="{'region': 'infra'}"''' +        # No quotes around the hash +        node_labels_bad = '''openshift_node_labels={'region': 'infra'}'''          # The good line is present in the written inventory line          self.assertIn(node_labels_expected, legacy_inventory_line) diff --git a/utils/test/test_utils.py b/utils/test/test_utils.py index cabeaee34..a72e429d1 100644 --- a/utils/test/test_utils.py +++ b/utils/test/test_utils.py @@ -29,7 +29,6 @@ class TestUtils(unittest.TestCase):              mock.call('OO_FOO: bar'),          ] -      ######################################################################      # Validate ooinstall.utils.debug_env functionality | 
