From 81e3719bce31a74b027e5ba97b5b89d76e133e5e Mon Sep 17 00:00:00 2001 From: "jose.lausuch" Date: Wed, 31 May 2017 17:17:44 +0200 Subject: Remove call to fetch_os_creds.sh After [1], the openstack credentials are provided to Functest as a volume directly from CI. The same has to be done manually. Functest doesn't need the script fetch_os_creds.sh any longer. [1] https://gerrit.opnfv.org/gerrit/#/c/35199/ Change-Id: I0883ad7b248526cfe9df3fde984345bd41869e82 Signed-off-by: jose.lausuch --- functest/tests/unit/ci/test_prepare_env.py | 15 ++--- functest/tests/unit/cli/commands/test_cli_os.py | 74 ------------------------- functest/tests/unit/cli/test_cli_base.py | 7 --- 3 files changed, 5 insertions(+), 91 deletions(-) (limited to 'functest/tests') diff --git a/functest/tests/unit/ci/test_prepare_env.py b/functest/tests/unit/ci/test_prepare_env.py index 513e72308..d38fa976a 100644 --- a/functest/tests/unit/ci/test_prepare_env.py +++ b/functest/tests/unit/ci/test_prepare_env.py @@ -46,14 +46,9 @@ class PrepareEnvTesting(unittest.TestCase): prepare_env.check_env_variables() mock_logger_info.assert_any_call("Checking environment variables" "...") - mock_logger_warn.assert_any_call("The env variable 'INSTALLER_IP'" - " is not defined. It is needed to" - " fetch the OpenStack credentials." - " If the credentials are not" - " provided to the container as a" - " volume, please add this env" - " variable to the 'docker run'" - " command.") + mock_logger_warn.assert_any_call( + "The env variable 'INSTALLER_IP' is not defined. It is recommended" + " to extract some information from the deployment") @mock.patch('functest.ci.prepare_env.logger.info') @mock.patch('functest.ci.prepare_env.logger.warning') @@ -271,8 +266,8 @@ class PrepareEnvTesting(unittest.TestCase): mock.patch('functest.ci.prepare_env.subprocess.Popen') \ as mock_subproc_popen, \ self.assertRaises(Exception): - CONST.__setattr__('openstack_creds', 'test_creds') - CONST.__setattr__('INSTALLER_IP', None) + CONST.__setattr__('openstack_creds', None) + CONST.__setattr__('INSTALLER_IP', 'test_ip') CONST.__setattr__('INSTALLER_TYPE', 'test_type') opnfv_constants.INSTALLERS = ['test_type'] diff --git a/functest/tests/unit/cli/commands/test_cli_os.py b/functest/tests/unit/cli/commands/test_cli_os.py index b551ee4d2..c3285ecbe 100644 --- a/functest/tests/unit/cli/commands/test_cli_os.py +++ b/functest/tests/unit/cli/commands/test_cli_os.py @@ -61,80 +61,6 @@ class CliOpenStackTesting(unittest.TestCase): self.endpoint_ip) mock_exit.assert_called_once_with(0) - @mock.patch('functest.cli.commands.cli_os.ft_utils.execute_command') - @mock.patch('functest.cli.commands.cli_os.os.path.isfile', - return_value=False) - @mock.patch('functest.cli.commands.cli_os.click.echo') - def test_fetch_credentials_default(self, mock_click_echo, - mock_os_path, - mock_ftutils_execute): - CONST.__setattr__('INSTALLER_TYPE', self.installer_type) - CONST.__setattr__('INSTALLER_IP', self.installer_ip) - cmd = ("fetch_os_creds.sh -d %s -i %s -a %s" - % (self.openstack_creds, - self.installer_type, - self.installer_ip)) - self.cli_os.openstack_creds = self.openstack_creds - self.cli_os.fetch_credentials() - mock_click_echo.assert_called_once_with("Fetching credentials from " - "installer node '%s' with " - "IP=%s.." % - (self.installer_type, - self.installer_ip)) - mock_ftutils_execute.assert_called_once_with(cmd, verbose=False) - - @mock.patch('functest.cli.commands.cli_os.ft_utils.execute_command') - @mock.patch('functest.cli.commands.cli_os.os.path.isfile', - return_value=False) - @mock.patch('functest.cli.commands.cli_os.click.echo') - def test_fetch_credentials_missing_installer_type(self, mock_click_echo, - mock_os_path, - mock_ftutils_execute): - CONST.__setattr__('INSTALLER_TYPE', None) - CONST.__setattr__('INSTALLER_IP', self.installer_ip) - cmd = ("fetch_os_creds.sh -d %s -i %s -a %s" - % (self.openstack_creds, - None, - self.installer_ip)) - self.cli_os.openstack_creds = self.openstack_creds - self.cli_os.fetch_credentials() - mock_click_echo.assert_any_call("The environment variable " - "'INSTALLER_TYPE' is not" - "defined. Please export it") - mock_click_echo.assert_any_call("Fetching credentials from " - "installer node '%s' with " - "IP=%s.." % - (None, - self.installer_ip)) - mock_ftutils_execute.assert_called_once_with(cmd, verbose=False) - - @mock.patch('functest.cli.commands.cli_os.ft_utils.execute_command') - @mock.patch('functest.cli.commands.cli_os.os.path.isfile', - return_value=False) - @mock.patch('functest.cli.commands.cli_os.click.echo') - def test_fetch_credentials_missing_installer_ip(self, mock_click_echo, - mock_os_path, - mock_ftutils_execute): - installer_type = self.installer_type - installer_ip = None - CONST.__setattr__('INSTALLER_TYPE', installer_type) - CONST.__setattr__('INSTALLER_IP', installer_ip) - cmd = ("fetch_os_creds.sh -d %s -i %s -a %s" - % (self.openstack_creds, - installer_type, - installer_ip)) - self.cli_os.openstack_creds = self.openstack_creds - self.cli_os.fetch_credentials() - mock_click_echo.assert_any_call("The environment variable " - "'INSTALLER_IP' is not" - "defined. Please export it") - mock_click_echo.assert_any_call("Fetching credentials from " - "installer node '%s' with " - "IP=%s.." % - (installer_type, - installer_ip)) - mock_ftutils_execute.assert_called_once_with(cmd, verbose=False) - @mock.patch('functest.cli.commands.cli_os.ft_utils.execute_command') def test_check(self, mock_ftutils_execute): with mock.patch.object(self.cli_os, 'ping_endpoint'): diff --git a/functest/tests/unit/cli/test_cli_base.py b/functest/tests/unit/cli/test_cli_base.py index 896032795..61bd093e6 100644 --- a/functest/tests/unit/cli/test_cli_base.py +++ b/functest/tests/unit/cli/test_cli_base.py @@ -62,13 +62,6 @@ class CliBaseTesting(unittest.TestCase): self.assertEqual(result.exit_code, 0) self.assertTrue(mock_method.called) - def test_os_fetch_rc(self): - with mock.patch.object(self._openstack, 'fetch_credentials') \ - as mock_method: - result = self.runner.invoke(cli_base.os_fetch_rc) - self.assertEqual(result.exit_code, 0) - self.assertTrue(mock_method.called) - def test_env_prepare(self): with mock.patch.object(self._env, 'prepare') as mock_method: result = self.runner.invoke(cli_base.env_prepare) -- cgit 1.2.3-korg