def test_env_vars_persisted(self, get_conf_mock): get_conf_mock.return_value = {'username': '******', 'port': '1234', 'coordinator': 'hello', 'workers': ['a', 'b']} try: main.main(['topology', 'show']) except SystemExit as e: self.assertEqual(e.code, 0) self.assertEqual(['hello', 'a', 'b'], main.state.env.hosts)
def test_hosts_on_cli_overrides_topology(self, unused_mock_load): try: main.main(['--hosts', 'master,slave1', 'topology', 'show']) except SystemExit as e: self.assertEqual(e.code, 0) self.assertDefaultRoledefs() self.assertEqual(main.state.env.hosts, ['master', 'slave1']) self.assertEqual(main.api.env.hosts, ['master', 'slave1'])
def test_env_vars_persisted(self, get_conf_mock): get_conf_mock.return_value = { 'username': '******', 'port': '1234', 'coordinator': 'hello', 'workers': ['a', 'b'] } try: main.main(['topology', 'show']) except SystemExit as e: self.assertEqual(e.code, 0) self.assertEqual(['hello', 'a', 'b'], main.state.env.hosts)
def test_nodeps_check(self): env.nodeps = True try: main.main(['topology', 'show', '--nodeps']) except SystemExit as e: self.assertEqual(e.code, 2) self.assertTrue('Invalid argument --nodeps to task: topology.show\n' in self.test_stderr.getvalue()) self.assertTrue('Displaying detailed information for task ' '\'topology show\':\n\n Shows the current topology ' 'configuration for the cluster (including the\n ' 'coordinators, workers, SSH port, and SSH username)' '\n\n' in self.test_stdout.getvalue())
def test_topology_defaults_override_fabric_defaults(self, get_conf_mock): self.remove_runs_once_flag(main.topology.show) get_conf_mock.return_value = {} try: main.main(['topology', 'show']) except SystemExit as e: self.assertEqual(e.code, 0) self.assertEqual(['localhost'], main.state.env.hosts) self.assertEqual({'coordinator': ['localhost'], 'worker': ['localhost'], 'all': ['localhost']}, main.state.env.roledefs) self.assertEqual('22', main.state.env.port) self.assertEqual('root', main.state.env.user)
def test_topology_defaults_override_fabric_defaults( self, unused_mock_load): self.remove_runs_once_flag(topology.show) try: main.main(['topology', 'show']) except SystemExit as e: self.assertEqual(e.code, 0) self.assertEqual(['localhost'], main.state.env.hosts) self.assertEqual({'coordinator': ['localhost'], 'worker': ['localhost'], 'all': ['localhost']}, main.state.env.roledefs) self.assertEqual(22, main.state.env.port) self.assertEqual('root', main.state.env.user)
def test_hosts_on_cli_overrides_topology(self, get_conf_mock): get_conf_mock.return_value = {'username': '******', 'port': '22', 'coordinator': 'hello', 'workers': ['a', 'b']} try: main.main(['--hosts', 'hello,a', 'topology', 'show']) except SystemExit as e: self.assertEqual(e.code, 0) self.assertEqual(main.state.env.roledefs, {'coordinator': ['hello'], 'worker': ['a', 'b'], 'all': ['hello', 'a', 'b']}) self.assertEqual(main.state.env.hosts, ['hello', 'a']) self.assertEqual(main.api.env.hosts, ['hello', 'a'])
def test_topology_defaults_override_fabric_defaults(self, get_conf_mock): self.remove_runs_once_flag(main.topology.show) get_conf_mock.return_value = {} try: main.main(['topology', 'show']) except SystemExit as e: self.assertEqual(e.code, 0) self.assertEqual(['localhost'], main.state.env.hosts) self.assertEqual( { 'coordinator': ['localhost'], 'worker': ['localhost'], 'all': ['localhost'] }, main.state.env.roledefs) self.assertEqual('22', main.state.env.port) self.assertEqual('root', main.state.env.user)
def test_topology_defaults_override_fabric_defaults( self, unused_mock_load): self.remove_runs_once_flag(topology.show) try: main.main(['topology', 'show']) except SystemExit as e: self.assertEqual(e.code, 0) self.assertEqual(['localhost'], main.state.env.hosts) self.assertEqual( { 'coordinator': ['localhost'], 'worker': ['localhost'], 'all': ['localhost'] }, main.state.env.roledefs) self.assertEqual(22, main.state.env.port) self.assertEqual('root', main.state.env.user)
def test_hosts_on_cli_overrides_topology(self, get_conf_mock): get_conf_mock.return_value = { 'username': '******', 'port': '22', 'coordinator': 'hello', 'workers': ['a', 'b'] } try: main.main(['--hosts', 'hello,a', 'topology', 'show']) except SystemExit as e: self.assertEqual(e.code, 0) self.assertEqual( main.state.env.roledefs, { 'coordinator': ['hello'], 'worker': ['a', 'b'], 'all': ['hello', 'a', 'b'] }) self.assertEqual(main.state.env.hosts, ['hello', 'a']) self.assertEqual(main.api.env.hosts, ['hello', 'a'])
def test_env_vars_persisted(self, unused_mock_load): try: main.main(['topology', 'show']) except SystemExit as e: self.assertEqual(e.code, 0) self.assertDefaultHosts()