Repository: ambari Updated Branches: refs/heads/branch-2.5 e4f66cd95 -> 0d1f4a653
AMBARI-18657 - Slider always creates storm slider conf directory Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0d1f4a65 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0d1f4a65 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0d1f4a65 Branch: refs/heads/branch-2.5 Commit: 0d1f4a653911a4864116994025efccf270a2ee2e Parents: e4f66cd Author: Tim Thorpe <[email protected]> Authored: Mon Oct 24 04:49:16 2016 -0700 Committer: Tim Thorpe <[email protected]> Committed: Mon Oct 24 04:49:16 2016 -0700 ---------------------------------------------------------------------- .../SLIDER/0.60.0.2.2/package/scripts/slider.py | 17 ++++--- .../stacks/2.2/SLIDER/test_slider_client.py | 51 ++++++++++++++++++++ 2 files changed, 61 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0d1f4a65/ambari-server/src/main/resources/common-services/SLIDER/0.60.0.2.2/package/scripts/slider.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/SLIDER/0.60.0.2.2/package/scripts/slider.py b/ambari-server/src/main/resources/common-services/SLIDER/0.60.0.2.2/package/scripts/slider.py index 8d80700..1f0bf99 100644 --- a/ambari-server/src/main/resources/common-services/SLIDER/0.60.0.2.2/package/scripts/slider.py +++ b/ambari-server/src/main/resources/common-services/SLIDER/0.60.0.2.2/package/scripts/slider.py @@ -65,14 +65,17 @@ def slider(): content=InlineTemplate(params.slider_env_sh_template) ) - Directory(params.storm_slider_conf_dir, - create_parents = True - ) + # check to see if the current/storm_slider_client symlink is broken if it is then the storm slider client is not installed + storm_slider_client_dir = os.path.join(params.storm_slider_conf_dir, "..") + if (os.path.exists(storm_slider_client_dir) or not os.path.islink(storm_slider_client_dir)): + Directory(params.storm_slider_conf_dir, + create_parents = True + ) - File(format("{storm_slider_conf_dir}/storm-slider-env.sh"), - mode=0755, - content=Template('storm-slider-env.sh.j2') - ) + File(format("{storm_slider_conf_dir}/storm-slider-env.sh"), + mode=0755, + content=Template('storm-slider-env.sh.j2') + ) if (params.log4j_props != None): File(format("{params.slider_conf_dir}/log4j.properties"), http://git-wip-us.apache.org/repos/asf/ambari/blob/0d1f4a65/ambari-server/src/test/python/stacks/2.2/SLIDER/test_slider_client.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.2/SLIDER/test_slider_client.py b/ambari-server/src/test/python/stacks/2.2/SLIDER/test_slider_client.py index 85fc86b..638f92e 100644 --- a/ambari-server/src/test/python/stacks/2.2/SLIDER/test_slider_client.py +++ b/ambari-server/src/test/python/stacks/2.2/SLIDER/test_slider_client.py @@ -18,6 +18,8 @@ See the License for the specific language governing permissions and limitations under the License. ''' import json +import os +from mock.mock import MagicMock, patch from stacks.utils.RMFTestCase import * @@ -75,6 +77,55 @@ class TestSliderClient(RMFTestCase): self.assertNoMoreResources() + @patch.object(os.path, "islink") + def test_configure_brokenlink(self, islink_mock): + self.maxDiff = None + self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/slider_client.py", + classname="SliderClient", + command="configure", + config_file="default.json", + stack_version = self.STACK_VERSION, + target = RMFTestCase.TARGET_COMMON_SERVICES + ) + + def islink_mock_call(path): + if path == "/usr/hdp/current/storm-slider-client": + return True + + return False + + islink_mock.side_effect = islink_mock_call + + self.assertResourceCalled('Directory', + '/usr/hdp/current/slider-client/conf', + create_parents = True + ) + + self.assertResourceCalled('XmlConfig', + 'slider-client.xml', + conf_dir='/usr/hdp/current/slider-client/conf', + configurations=self.getConfig()['configurations']['slider-client'], + mode=0644 + ) + + self.assertResourceCalled('File', '/usr/hdp/current/slider-client/conf/slider-env.sh', + content = InlineTemplate(self.getConfig()['configurations']['slider-env']['content']), + mode = 0755, + ) + + self.assertResourceCalled('File', + '/usr/hdp/current/slider-client/conf/log4j.properties', + mode=0644, + content='log4jproperties\nline2' + ) + self.assertResourceCalled('File', '/usr/hdp/current/slider-client/lib/slider.tar.gz', + owner = 'hdfs', + group = 'hadoop', + ) + + self.assertNoMoreResources() + + def test_svc_check_secured(self): self.maxDiff = None self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/service_check.py",
