|
@@ -512,3 +512,43 @@ class TestHookAfterInstall(RMFTestCase):
|
|
|
to = '/usr/hdp/current/hive-client/conf')
|
|
|
|
|
|
self.assertNoMoreResources()
|
|
|
+
|
|
|
+
|
|
|
+ @patch("shared_initialization.load_version", new = MagicMock(return_value="2.3.0.0-1243"))
|
|
|
+ @patch("resource_management.libraries.functions.conf_select.create")
|
|
|
+ @patch("resource_management.libraries.functions.conf_select.select")
|
|
|
+ @patch("os.symlink")
|
|
|
+ @patch("shutil.rmtree")
|
|
|
+ def test_hook_default_hdp_select_specific_version(self, rmtree_mock, symlink_mock, conf_select_select_mock, conf_select_create_mock):
|
|
|
+ """
|
|
|
+ Tests that hdp-select set all on a specific version, not a 2.3* wildcard is used when
|
|
|
+ installing a component when the cluster version is already set.
|
|
|
+
|
|
|
+ :param rmtree_mock:
|
|
|
+ :param symlink_mock:
|
|
|
+ :param conf_select_select_mock:
|
|
|
+ :param conf_select_create_mock:
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+
|
|
|
+ def mocked_conf_select(arg1, arg2, arg3, dry_run = False):
|
|
|
+ return "/etc/{0}/{1}/0".format(arg2, arg3)
|
|
|
+
|
|
|
+ conf_select_create_mock.side_effect = mocked_conf_select
|
|
|
+
|
|
|
+ config_file = self.get_src_folder() + "/test/python/stacks/2.0.6/configs/default.json"
|
|
|
+ with open(config_file, "r") as f:
|
|
|
+ json_content = json.load(f)
|
|
|
+
|
|
|
+ version = '2.3.0.0-1234'
|
|
|
+ json_content['commandParams']['version'] = version
|
|
|
+ json_content['hostLevelParams']['stack_version'] = "2.3"
|
|
|
+ json_content['hostLevelParams']['current_version'] = "2.3.0.0-1234"
|
|
|
+
|
|
|
+ self.executeScript("2.0.6/hooks/after-INSTALL/scripts/hook.py",
|
|
|
+ classname="AfterInstallHook",
|
|
|
+ command="hook",
|
|
|
+ config_dict = json_content)
|
|
|
+
|
|
|
+ self.assertResourceCalled('Execute', 'ambari-sudo.sh /usr/bin/hdp-select set all `ambari-python-wrap /usr/bin/hdp-select versions | grep ^2.3.0.0-1234 | tail -1`',
|
|
|
+ only_if = 'ls -d /usr/hdp/2.3.0.0-1234*')
|