ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject ambari git commit: AMBARI-14347. Stop-and-Start Upgrade: Fix unit tests that were ignored/missing on agent (dlysnichenko)
Date Sat, 12 Dec 2015 08:42:31 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 5295cc252 -> 46047accd


AMBARI-14347. Stop-and-Start Upgrade: Fix unit tests that were ignored/missing on agent (dlysnichenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/46047acc
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/46047acc
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/46047acc

Branch: refs/heads/trunk
Commit: 46047accd48088c4d4955a63df88a3bf9ca1952d
Parents: 5295cc2
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Sat Dec 12 10:41:48 2015 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Sat Dec 12 10:41:48 2015 +0200

----------------------------------------------------------------------
 .../python/ambari_agent/TestCertGeneration.py   |   2 -
 .../TestCustomServiceOrchestrator.py            |   1 -
 .../src/test/python/ambari_agent/TestMain.py    |   1 -
 .../test/python/ambari_agent/TestMetricAlert.py |   1 -
 .../python/ambari_agent/TestRecoveryManager.py  |   2 -
 .../python/ambari_agent/TestRegistration.py     |   1 -
 .../test/python/ambari_agent/TestScriptAlert.py |   1 -
 .../resource_management/TestDatanodeHelper.py   |   1 -
 .../STORM/0.9.1.2.1/package/scripts/storm.py    |  10 +-
 .../custom_actions/scripts/ru_set_all.py        |  11 +-
 .../src/test/python/TestAmbariServer.py         |  13 +--
 ambari-server/src/test/python/TestSetupAgent.py |   5 -
 .../python/custom_actions/TestRemoveBits.py     | 117 +++++++++++++++++++
 .../python/custom_actions/test_ru_set_all.py    |  76 ++++++++++++
 .../stacks/2.1/FALCON/test_falcon_server.py     |  23 +++-
 .../stacks/2.1/STORM/test_storm_nimbus.py       |  47 ++++++++
 .../stacks/2.1/STORM/test_storm_nimbus_prod.py  |   2 +
 .../2.1/STORM/test_storm_supervisor_prod.py     |   2 +
 18 files changed, 278 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-agent/src/test/python/ambari_agent/TestCertGeneration.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestCertGeneration.py b/ambari-agent/src/test/python/ambari_agent/TestCertGeneration.py
index 30bf2df..beafbf0 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestCertGeneration.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestCertGeneration.py
@@ -33,10 +33,8 @@ class TestCertGeneration(TestCase):
   def setUp(self):
     self.tmpdir = tempfile.mkdtemp()
     config = AmbariConfig.AmbariConfig()
-    #config.add_section('server')
     config.set('server', 'hostname', 'example.com')
     config.set('server', 'url_port', '777')
-    #config.add_section('security')
     config.set('security', 'keysdir', self.tmpdir)
     config.set('security', 'server_crt', 'ca.crt')
     server_hostname = config.get('server', 'hostname')

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
index a4025eb..5fc1fc8 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestCustomServiceOrchestrator.py
@@ -396,7 +396,6 @@ class TestCustomServiceOrchestrator(TestCase):
     FileCache_mock.return_value = None
     FileCache_mock.cache_dir = MagicMock()
     resolve_hook_script_path_mock.return_value = None
-#     shell.kill_process_with_children = MagicMock()
     dummy_controller = MagicMock()
     cfg = AmbariConfig()
     cfg.set('agent', 'tolerate_download_failures', 'true')

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-agent/src/test/python/ambari_agent/TestMain.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestMain.py b/ambari-agent/src/test/python/ambari_agent/TestMain.py
index d044027..cffe6c0 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestMain.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestMain.py
@@ -333,7 +333,6 @@ class TestMain(unittest.TestCase):
     self.assertTrue(setup_logging_mock.called)
     if OSCheck.get_os_family() != OSConst.WINSRV_FAMILY:
       self.assertTrue(stop_mock.called)
-    #self.assertTrue(resolve_ambari_config_mock.called)
     self.assertTrue(perform_prestart_checks_mock.called)
     if OSCheck.get_os_family() != OSConst.WINSRV_FAMILY:
       self.assertTrue(daemonize_mock.called)

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-agent/src/test/python/ambari_agent/TestMetricAlert.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestMetricAlert.py b/ambari-agent/src/test/python/ambari_agent/TestMetricAlert.py
index 30ba438..23e9f13 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestMetricAlert.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestMetricAlert.py
@@ -191,7 +191,6 @@ class TestMetricAlert(TestCase):
     def collector_side_effect(clus, data):
       self.assertEquals(data['name'], alert_meta['name'])
       self.assertEquals(data['label'], alert_meta['label'])
-      #self.assertEquals(data['text'], expected_text)
       self.assertEquals(data['service'], alert_meta['serviceName'])
       self.assertEquals(data['component'], alert_meta['componentName'])
       self.assertEquals(data['uuid'], alert_meta['uuid'])

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-agent/src/test/python/ambari_agent/TestRecoveryManager.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestRecoveryManager.py b/ambari-agent/src/test/python/ambari_agent/TestRecoveryManager.py
index a2b4968..0321a20 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestRecoveryManager.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestRecoveryManager.py
@@ -657,8 +657,6 @@ class _TestRecoveryManager(TestCase):
     rm = RecoveryManager(tempfile.mktemp(), True)
     rm.update_config(5, 60, 5, 16, True, False, "", "")
 
-    # rm.actions = {}
-
     time_mock.return_value = 0
     self.assertFalse(rm.is_action_info_stale("COMPONENT_NAME"))
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
index bac4945..0a70df2 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
@@ -51,7 +51,6 @@ class TestRegistration(TestCase):
     register = Register(config)
     reference_version = '2.1.0'
     data = register.build(reference_version, 1)
-    #print ("Register: " + pprint.pformat(data))
     self.assertEquals(len(data['hardwareProfile']) > 0, True, "hardwareProfile should
contain content")
     self.assertEquals(data['hostname'] != "", True, "hostname should not be empty")
     self.assertEquals(data['publicHostname'] != "", True, "publicHostname should not be empty")

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-agent/src/test/python/ambari_agent/TestScriptAlert.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestScriptAlert.py b/ambari-agent/src/test/python/ambari_agent/TestScriptAlert.py
index 7201a10..46c7651 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestScriptAlert.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestScriptAlert.py
@@ -49,7 +49,6 @@ class TestScriptAlert(TestCase):
     def collector_side_effect(clus, data):
       self.assertEquals(data['name'], alert_meta['name'])
       self.assertEquals(data['label'], alert_meta['label'])
-      #self.assertEquals(data['text'], expected_text)
       self.assertEquals(data['service'], alert_meta['serviceName'])
       self.assertEquals(data['component'], alert_meta['componentName'])
       self.assertEquals(data['uuid'], alert_meta['uuid'])

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-agent/src/test/python/resource_management/TestDatanodeHelper.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/resource_management/TestDatanodeHelper.py b/ambari-agent/src/test/python/resource_management/TestDatanodeHelper.py
index 2d9996c..4a1a1ba 100644
--- a/ambari-agent/src/test/python/resource_management/TestDatanodeHelper.py
+++ b/ambari-agent/src/test/python/resource_management/TestDatanodeHelper.py
@@ -115,7 +115,6 @@ class TestDatanodeHelper(TestCase):
     error_logs = []
     for (name, args, kwargs) in log_error.mock_calls:
       error_logs.append(args[0])    # this is a one-tuple
-      #print args[0]
     error_msg = "".join(error_logs)
 
     self.assertEquals(1, log_error.call_count)

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py
b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py
index 7000861..0fddcd2 100644
--- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py
+++ b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py
@@ -87,6 +87,11 @@ def storm(name=None):
        group=params.user_group
   )
 
+  File(format("{conf_dir}/storm-env.sh"),
+       owner=params.storm_user,
+       content=InlineTemplate(params.storm_env_sh_template)
+  )
+
   if params.has_metric_collector:
     File(format("{conf_dir}/storm-metrics2.properties"),
         owner=params.storm_user,
@@ -105,11 +110,6 @@ def storm(name=None):
             only_if=format("ls {metric_collector_sink_jar}")
     )
 
-  File(format("{conf_dir}/storm-env.sh"),
-    owner=params.storm_user,
-    content=InlineTemplate(params.storm_env_sh_template)
-  )
-  
   if params.storm_logs_supported:
     Directory(params.log4j_dir,
               owner=params.storm_user,

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py b/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
index 3414c22..885d650 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
@@ -154,13 +154,12 @@ def link_config(old_conf, link_conf):
   :old_conf: the old config directory, ie /etc/[component]/conf
   :link_conf: the new target for the config directory, ie /usr/hdp/current/[component-dir]/conf
   """
-  # if the link exists but is wrong, then change it
-  if os.path.islink(old_conf) and os.path.realpath(old_conf) != link_conf:
-    Link(old_conf, to = link_conf)
-    return
-
   if os.path.islink(old_conf):
-    Logger.debug("Skipping {0}; it is already a link".format(old_conf))
+    # if the link exists but is wrong, then change it
+    if os.path.realpath(old_conf) != link_conf:
+      Link(old_conf, to = link_conf)
+    else:
+      Logger.debug("Skipping {0}; it is already a link".format(old_conf))
     return
 
   if not os.path.exists(old_conf):

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index 16b46b1..fde647a 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -3705,7 +3705,6 @@ class TestAmbariServer(TestCase):
 
     # test not run setup if ambari-server setup executed with jdbc properties
     args = reset_mocks()
-    # is_server_runing_mock.return_value = (False, 1)
     args.jdbc_driver= "path/to/driver"
     args.jdbc_db = "test_db_name"
 
@@ -3771,7 +3770,6 @@ class TestAmbariServer(TestCase):
     run_os_command_mock.return_value = 3,"",""
     extract_views_mock.return_value = 0
     read_ambari_user_mock.return_value = "ambari"
-    #read_password_mock.return_value = "bigdata2"
     get_ambari_properties_mock.return_value = properties
     store_password_file_mock.return_value = "encrypted_bigdata2"
     ensure_jdbc_driver_installed_mock.return_value = True
@@ -3977,7 +3975,6 @@ class TestAmbariServer(TestCase):
     args = reset_mocks()
     args.dbms = "postgres"
 
-    #get_remote_script_line_mock.return_value = None
     try:
       #remote db case
       reset(args)
@@ -4123,12 +4120,10 @@ class TestAmbariServer(TestCase):
   @patch.object(PGConfig, "_setup_db")
   @patch("ambari_server.dbConfiguration_linux.print_info_msg")
   @patch("ambari_server.dbConfiguration_linux.run_os_command")
-  #@patch("ambari_server.serverSetup.parse_properties_file")
   @patch("ambari_server.serverSetup.is_root")
-  #@patch("ambari_server.serverSetup.check_database_name_property")
   @patch("ambari_server.serverSetup.is_server_runing")
-  def test_silent_reset(self, is_server_runing_mock, #check_database_name_property_mock,
-                        is_root_mock, #parse_properties_file_mock,
+  def test_silent_reset(self, is_server_runing_mock,
+                        is_root_mock,
                         run_os_command_mock, print_info_msg_mock,
                         setup_db_mock):
     is_root_mock.return_value = True
@@ -4357,7 +4352,6 @@ class TestAmbariServer(TestCase):
     except FatalException as e:
       # Expected
       self.assertTrue('Unable to start Ambari Server as user' in e.reason)
-      #self.assertFalse(parse_properties_file_mock.called)
 
     # If not active instance, exception should be thrown
     args = reset_mocks()
@@ -7076,7 +7070,6 @@ class TestAmbariServer(TestCase):
       else:
         return True
 
-    #get_YN_input_method.side_effect = yn_input_side_effect()
     get_YN_input_method.side_effect = [True, ]
 
     def valid_input_side_effect(*args, **kwargs):
@@ -7666,7 +7659,6 @@ class TestAmbariServer(TestCase):
     propertyMap = {"1": "1", "2": "2"}
     properties = MagicMock()
     f = MagicMock(name="file")
-    # f.__enter__.return_value = f #mimic file behavior
     search_file_mock.return_value = conf_file
     open_mock.return_value = f
 
@@ -7859,7 +7851,6 @@ class TestAmbariServer(TestCase):
     check_ambari_user_mock.return_value = (0, False, 'user', None)
     check_jdbc_drivers_mock.return_value = 0
     check_postgre_up_mock.return_value = "running", 0, "", ""
-    #is_local_database_mock.return_value = True
     configure_postgres_mock.return_value = 0, "", ""
     download_jdk_mock.return_value = 0
     configure_os_settings_mock.return_value = 0

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-server/src/test/python/TestSetupAgent.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestSetupAgent.py b/ambari-server/src/test/python/TestSetupAgent.py
index 5f66e2a..a366ddb 100644
--- a/ambari-server/src/test/python/TestSetupAgent.py
+++ b/ambari-server/src/test/python/TestSetupAgent.py
@@ -26,11 +26,6 @@ from only_for_platform import get_platform, not_for_platform, only_for_platform,
 from mock.mock import MagicMock, patch, ANY, Mock
 
 with patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value)):
-#  from ambari_agent import NetUtil, security
-
-#  if get_platform() != PLATFORM_WINDOWS:
-#    from ambari_commons.shell import shellRunnerLinux
-
   setup_agent = __import__('setupAgent')
 
 class TestSetupAgent(TestCase):

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-server/src/test/python/custom_actions/TestRemoveBits.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/TestRemoveBits.py b/ambari-server/src/test/python/custom_actions/TestRemoveBits.py
new file mode 100644
index 0000000..6537152
--- /dev/null
+++ b/ambari-server/src/test/python/custom_actions/TestRemoveBits.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+import json
+import os
+import subprocess
+import select
+import install_packages
+
+from mock.mock import patch
+from mock.mock import MagicMock
+from stacks.utils.RMFTestCase import *
+from mock.mock import patch, MagicMock
+from resource_management.core.base import Resource
+from resource_management.core.exceptions import Fail
+
+from only_for_platform import get_platform, not_for_platform, only_for_platform, os_distro_value,
PLATFORM_WINDOWS
+
+class TestRemoveBits(RMFTestCase):
+
+  def test_remove_hdp_21(self):
+    self.executeScript("scripts/remove_bits.py",
+                       classname="RemoveBits",
+                       command="remove_hdp_21",
+                       config_file="install_packages_config.json",
+                       target=RMFTestCase.TARGET_CUSTOM_ACTIONS,
+                       os_type=('Redhat', '6.4', 'Final'),
+                       )
+    self.assertResourceCalled('Package', 'phoenix',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hbase',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'flume',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'storm',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'tezfalcon',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'sqoop',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'pig',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'oozie-client',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'oozie',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'webhcat-tar-pig',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'webhcat-tar-hive',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hcatalog',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hive-webhcat',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hive-jdbc',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hive-hcatalog',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hive',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hadoop-mapreduce',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hadoop-client',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hadoop-yarn',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hadoop-libhdfs',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hadoop-hdfs',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hadoop-lzo',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'hadoop',
+                              action = ['remove'],
+                              )
+    self.assertResourceCalled('Package', 'zookeeper',
+                              action = ['remove'],
+                              )
+    self.assertNoMoreResources()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-server/src/test/python/custom_actions/test_ru_set_all.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/test_ru_set_all.py b/ambari-server/src/test/python/custom_actions/test_ru_set_all.py
index 162a2fd..2c39614 100644
--- a/ambari-server/src/test/python/custom_actions/test_ru_set_all.py
+++ b/ambari-server/src/test/python/custom_actions/test_ru_set_all.py
@@ -36,6 +36,7 @@ from ambari_agent.AmbariConfig import AmbariConfig
 from ambari_agent.FileCache import FileCache
 from ambari_commons.os_check import OSCheck
 from resource_management.core import shell
+from resource_management.core.environment import Environment
 import pprint
 
 
@@ -62,6 +63,8 @@ class TestRUSetAll(RMFTestCase):
     # method needs to be patched first.
     from ru_set_all import UpgradeSetAll
     global UpgradeSetAll
+    from ru_set_all import link_config
+    global link_config
 
   def tearDown(self):
     Logger.logger = None
@@ -278,3 +281,76 @@ class TestRUSetAll(RMFTestCase):
                      "'/fake/config')]]")
 
 
+  @patch("os.path.exists")
+  @patch("os.path.islink")
+  @patch("os.path.isdir")
+  @patch("os.path.isfile")
+  @patch("os.path.realpath")
+  @patch("shutil.rmtree")
+  def test_link_config(self, shutil_rmtree_mock, os_path_realpath_mock, os_path_isfile_mock,
+                       os_path_isdir_mock, os_path_islink_mock,
+                       os_path_exists_mock):
+    # Test normal flow
+    os_path_islink_mock.return_value = False
+    os_path_realpath_mock.return_value = "/some/another/path"
+    os_path_exists_mock.side_effect = [True, False]
+    old_config = "/old/config"
+    link_conf = "/link/config"
+
+    with Environment(test_mode=True) as RMFTestCase.env:
+      link_config(old_config, link_conf)
+      self.assertTrue(shutil_rmtree_mock.called)
+      self.assertEquals(shutil_rmtree_mock.call_args_list[0][0][0], old_config)
+      self.assertResourceCalled('Execute', ('cp', '-R', '-p', '/old/config', '/old/conf.backup'),
+                                logoutput = True,
+                                sudo = True,
+                                )
+      self.assertResourceCalled('Link', '/old/config',
+                                to = '/link/config',
+                                )
+      self.assertNoMoreResources()
+
+    # Test case when link exists but is wrong
+    shutil_rmtree_mock.reset_mock()
+    os_path_islink_mock.return_value = True
+    with Environment(test_mode=True) as RMFTestCase.env:
+      link_config(old_config, link_conf)
+      self.assertFalse(shutil_rmtree_mock.called)
+      self.assertResourceCalled('Link', '/old/config',
+                                to = '/link/config',
+                                )
+      self.assertNoMoreResources()
+
+    # Test case when link exists and is correct
+    shutil_rmtree_mock.reset_mock()
+    os_path_islink_mock.return_value = True
+    os_path_realpath_mock.return_value = link_conf
+
+    with Environment(test_mode=True) as RMFTestCase.env:
+      link_config(old_config, link_conf)
+      self.assertFalse(shutil_rmtree_mock.called)
+      self.assertNoMoreResources()
+
+    # Test case when old link does not exist at all
+    shutil_rmtree_mock.reset_mock()
+    os_path_islink_mock.return_value = False
+    os_path_exists_mock.side_effect = [False]
+
+    with Environment(test_mode=True) as RMFTestCase.env:
+      link_config(old_config, link_conf)
+      self.assertFalse(shutil_rmtree_mock.called)
+      self.assertNoMoreResources()
+
+    # Test case when backup directory already exists
+    shutil_rmtree_mock.reset_mock()
+    os_path_islink_mock.return_value = False
+    os_path_exists_mock.side_effect = [True, True]
+
+    with Environment(test_mode=True) as RMFTestCase.env:
+      link_config(old_config, link_conf)
+      self.assertTrue(shutil_rmtree_mock.called)
+      self.assertEquals(shutil_rmtree_mock.call_args_list[0][0][0], old_config)
+      self.assertResourceCalled('Link', '/old/config',
+                                to = '/link/config',
+                                )
+      self.assertNoMoreResources()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py b/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py
index b011f93..efdb9fe 100644
--- a/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py
+++ b/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py
@@ -513,7 +513,28 @@ class TestFalconServer(RMFTestCase):
                        target = RMFTestCase.TARGET_COMMON_SERVICES)
     self.assertResourceCalled('Execute',
                               ('ambari-python-wrap', '/usr/bin/hdp-select', 'set', 'falcon-server',
version), sudo=True,)
-    self.printResources()
+    self.assertResourceCalled('Execute', ('tar',
+                                          '-xvf',
+                                          '/tmp/falcon-upgrade-backup/falcon-conf-backup.tar',
+                                          '-C',
+                                          '/usr/hdp/current/falcon-server/conf/'),
+                              tries = 3,
+                              sudo = True,
+                              try_sleep = 1,
+                              )
+    self.assertResourceCalled('Execute', ('tar',
+                                          '-xvf',
+                                          '/tmp/falcon-upgrade-backup/falcon-local-backup.tar',
+                                          '-C',
+                                          u'/hadoop/falcon/'),
+                              tries = 3,
+                              sudo = True,
+                              try_sleep = 1,
+                              )
+    self.assertResourceCalled('Directory', '/tmp/falcon-upgrade-backup',
+                              action = ['delete'],
+                              )
+    self.assertNoMoreResources()
 
   @patch('os.path.isfile', new=MagicMock(return_value=True))
   @patch.object(tarfile, 'open')

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py
index 18e25c0..a59cc1f 100644
--- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py
+++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py
@@ -64,6 +64,51 @@ class TestStormNimbus(TestStormBase):
     )
     self.assertNoMoreResources()
 
+  def test_start_with_metrics_collector(self):
+    config_file = self.get_src_folder() + "/test/python/stacks/2.1/configs/default.json"
+    with open(config_file, "r") as f:
+      json_content = json.load(f)
+    json_content["clusterHostInfo"]["metrics_collector_hosts"] = ["host1", "host2"]
+
+    self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nimbus.py",
+                       classname = "Nimbus",
+                       command = "start",
+                       config_dict = json_content,
+                       hdp_stack_version = self.STACK_VERSION,
+                       target = RMFTestCase.TARGET_COMMON_SERVICES
+                       )
+    self.assert_configure_default()
+
+    self.assertResourceCalled('File', '/etc/storm/conf/storm-metrics2.properties',
+                              content = Template('storm-metrics2.properties.j2'),
+                              owner = 'storm',
+                              group = 'hadoop',
+                              )
+    self.assertResourceCalled('Link', '/usr/lib/storm/lib//ambari-metrics-storm-sink.jar',
+                              action = ['delete'],
+                              )
+    self.assertResourceCalled('Link', '/usr/lib/storm/lib/ambari-metrics-storm-sink.jar',
+                              action = ['delete'],
+                              )
+    self.assertResourceCalled('Execute', 'ambari-sudo.sh ln -s /usr/lib/storm/lib/ambari-metrics-storm-sink*.jar
/usr/lib/storm/lib//ambari-metrics-storm-sink.jar',
+                              not_if = 'ls /usr/lib/storm/lib//ambari-metrics-storm-sink.jar',
+                              only_if = 'ls /usr/lib/storm/lib/ambari-metrics-storm-sink*.jar',
+                              )
+    self.assertResourceCalled('Execute', 'source /etc/storm/conf/storm-env.sh ; export PATH=$JAVA_HOME/bin:$PATH
; storm nimbus > /var/log/storm/nimbus.out 2>&1',
+                              wait_for_finish = False,
+                              path = ['/usr/bin'],
+                              user = 'storm',
+                              not_if = "ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/nimbus.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/nimbus.pid`
>/dev/null 2>&1'",
+                              )
+    self.assertResourceCalled('Execute', "/usr/jdk64/jdk1.7.0_45/bin/jps -l  | grep storm.daemon.nimbus$
&& /usr/jdk64/jdk1.7.0_45/bin/jps -l  | grep storm.daemon.nimbus$ | awk {'print $1'}
> /var/run/storm/nimbus.pid",
+                              logoutput = True,
+                              path = ['/usr/bin'],
+                              tries = 6,
+                              user = 'storm',
+                              try_sleep = 10,
+                              )
+    self.assertNoMoreResources()
+
   @patch("os.path.exists")
   def test_stop_default(self, path_exists_mock):
     # Bool for the pid file
@@ -186,6 +231,7 @@ class TestStormNimbus(TestStormBase):
     self.assertEquals(
       ('ambari-python-wrap', '/usr/bin/conf-select', 'create-conf-dir', '--package', 'storm',
'--stack-version', '2.3.0.0-1234', '--conf-version', '0'),
        mocks_dict['call'].call_args_list[0][0][0])
+    self.assertNoMoreResources()
     
   @patch("resource_management.libraries.functions.security_commons.build_expectations")
   @patch("resource_management.libraries.functions.security_commons.get_params_from_filesystem")
@@ -288,3 +334,4 @@ class TestStormNimbus(TestStormBase):
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
     put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"})
+    self.assertNoMoreResources()

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus_prod.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus_prod.py b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus_prod.py
index 74877af..6ed2612 100644
--- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus_prod.py
+++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus_prod.py
@@ -122,6 +122,7 @@ class TestStormNimbus(TestStormBase):
 
     self.assertResourceCalled("Execute", ('ambari-python-wrap', '/usr/bin/hdp-select', 'set',
'storm-client', '2.2.1.0-2067'), sudo=True)
     self.assertResourceCalled("Execute", ('ambari-python-wrap', '/usr/bin/hdp-select', 'set',
'storm-nimbus', '2.2.1.0-2067'), sudo=True)
+    self.assertNoMoreResources()
 
   def test_pre_upgrade_restart_23(self):
     config_file = self.get_src_folder()+"/test/python/stacks/2.1/configs/default.json"
@@ -151,3 +152,4 @@ class TestStormNimbus(TestStormBase):
     self.assertEquals(
       ('ambari-python-wrap', '/usr/bin/conf-select', 'create-conf-dir', '--package', 'storm',
'--stack-version', '2.3.0.0-1234', '--conf-version', '0'),
        mocks_dict['call'].call_args_list[0][0][0])
+    self.assertNoMoreResources()

http://git-wip-us.apache.org/repos/asf/ambari/blob/46047acc/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor_prod.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor_prod.py
b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor_prod.py
index 8017ec2..df77506 100644
--- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor_prod.py
+++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor_prod.py
@@ -172,6 +172,7 @@ class TestStormSupervisor(TestStormBase):
 
     self.assertResourceCalled("Execute", ('ambari-python-wrap', '/usr/bin/hdp-select', 'set',
'storm-client', '2.2.1.0-2067'), sudo=True)
     self.assertResourceCalled("Execute", ('ambari-python-wrap', '/usr/bin/hdp-select', 'set',
'storm-supervisor', '2.2.1.0-2067'), sudo=True)
+    self.assertNoMoreResources()
 
   def test_pre_upgrade_restart_23(self):
     config_file = self.get_src_folder()+"/test/python/stacks/2.1/configs/default.json"
@@ -201,3 +202,4 @@ class TestStormSupervisor(TestStormBase):
     self.assertEquals(
       ('ambari-python-wrap', '/usr/bin/conf-select', 'create-conf-dir', '--package', 'storm',
'--stack-version', '2.3.0.0-1234', '--conf-version', '0'),
        mocks_dict['call'].call_args_list[0][0][0])
+    self.assertNoMoreResources()


Mime
View raw message