|
@@ -130,6 +130,118 @@ class TestHiveServerInteractive(RMFTestCase):
|
|
|
)
|
|
|
self.assertNoMoreResources()
|
|
|
|
|
|
+ """
|
|
|
+ Tests HSI start with llap package creation output having single line.
|
|
|
+ Sample output : "Prepared llap-slider-05Apr2016/run.sh for running LLAP"
|
|
|
+ HSI HA is enabled and llap is stopped, so it will be restartd
|
|
|
+ """
|
|
|
+ #@patch("Script.get_tmp_dir()")
|
|
|
+ @patch("os.path.isfile")
|
|
|
+ @patch("resource_management.libraries.functions.copy_tarball.copy_to_hdfs")
|
|
|
+ @patch("socket.socket")
|
|
|
+ @patch("time.sleep")
|
|
|
+ def test_start_hsi_ha_with_llap_single_line_output(self, sleep_mock, socket_mock, copy_to_hfds_mock, is_file_mock): #, get_tmp_dir_mock):
|
|
|
+ self.maxDiff = None
|
|
|
+ copy_to_hfds_mock.return_value = False
|
|
|
+ s = socket_mock.return_value
|
|
|
+ is_file_mock.return_value = True
|
|
|
+ #get_tmp_dir_mock.return_value = "/var/lib/ambari-agent/tmp"
|
|
|
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_server_interactive.py",
|
|
|
+ classname="HiveServerInteractive",
|
|
|
+ command="start",
|
|
|
+ config_file=self.get_src_folder() + "/test/python/stacks/2.5/configs/hsi_ha.json",
|
|
|
+ stack_version=self.STACK_VERSION,
|
|
|
+ target=RMFTestCase.TARGET_COMMON_SERVICES,
|
|
|
+ checked_call_mocks=[(0, """{
|
|
|
+ \"state\" : \"COMPLETED\"
|
|
|
+ }""", ""),
|
|
|
+ (0, "Prepared llap-slider-05Apr2016/run.sh for running LLAP", ""),
|
|
|
+ (0, """{
|
|
|
+ \"state\" : \"RUNNING_ALL\"
|
|
|
+ }""", ""),
|
|
|
+ (0, """{
|
|
|
+ \"state\" : \"RUNNING_ALL\"
|
|
|
+ }""", ""),
|
|
|
+ (0, "OK.", "")],
|
|
|
+ )
|
|
|
+
|
|
|
+ self.assert_configure_default()
|
|
|
+
|
|
|
+ self.assertResourceCalled('Execute',
|
|
|
+ '/home/hive/llap-slider-05Apr2016/run.sh',
|
|
|
+ logoutput= True, user='hive'
|
|
|
+ )
|
|
|
+ self.assertResourceCalled('Execute',
|
|
|
+ 'hive --config /usr/hdp/current/hive-server2-hive2/conf/conf.server --service metatool -updateLocation hdfs://c6401.ambari.apache.org:8020 OK.',
|
|
|
+ environment={'PATH': '/usr/hdp/current/hadoop-client/bin'},
|
|
|
+ user='hive'
|
|
|
+ )
|
|
|
+ self.assertResourceCalled('Execute',
|
|
|
+ '/tmp/start_hiveserver2_interactive_script /var/run/hive/hive-server2-interactive.out /var/log/hive/hive-server2-interactive.err /var/run/hive/hive-interactive.pid /usr/hdp/current/hive-server2-hive2/conf/conf.server /var/log/hive',
|
|
|
+ environment={'HADOOP_HOME': '/usr/hdp/current/hadoop-client',
|
|
|
+ 'HIVE_BIN': 'hive2',
|
|
|
+ 'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
|
|
|
+ not_if="ls /var/run/hive/hive-interactive.pid >/dev/null 2>&1 && ps -p 123 >/dev/null 2>&1",
|
|
|
+ user='hive',
|
|
|
+ path=['/bin:/usr/hdp/current/hive-server2-hive2/bin:/usr/hdp/current/hadoop-client/bin'],
|
|
|
+ )
|
|
|
+ self.assertResourceCalled('Execute',
|
|
|
+ '/usr/jdk64/jdk1.7.0_45/bin/java -cp /usr/lib/ambari-agent/DBConnectionVerification.jar:/usr/hdp/current/hive-server2-hive2/lib/mysql-connector-java.jar org.apache.ambari.server.DBConnectionVerification \'jdbc:mysql://c6402.ambari.apache.org/hive?createDatabaseIfNotExist=true\' hive \'!`"\'"\'"\' 1\' com.mysql.jdbc.Driver',
|
|
|
+ path=['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
|
|
|
+ tries=5,
|
|
|
+ try_sleep=10
|
|
|
+ )
|
|
|
+ self.assertNoMoreResources()
|
|
|
+
|
|
|
+ """
|
|
|
+ Tests HSI start with llap running and HA deployment. As llap is running it will not be started."
|
|
|
+ """
|
|
|
+ #@patch("Script.get_tmp_dir()")
|
|
|
+ @patch("os.path.isfile")
|
|
|
+ @patch("resource_management.libraries.functions.copy_tarball.copy_to_hdfs")
|
|
|
+ @patch("socket.socket")
|
|
|
+ @patch("time.sleep")
|
|
|
+ def test_start_with_ha_and_llap_running(self, sleep_mock, socket_mock, copy_to_hfds_mock, is_file_mock): #, get_tmp_dir_mock):
|
|
|
+ self.maxDiff = None
|
|
|
+ copy_to_hfds_mock.return_value = False
|
|
|
+ s = socket_mock.return_value
|
|
|
+ is_file_mock.return_value = True
|
|
|
+ #get_tmp_dir_mock.return_value = "/var/lib/ambari-agent/tmp"
|
|
|
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_server_interactive.py",
|
|
|
+ classname="HiveServerInteractive",
|
|
|
+ command="start",
|
|
|
+ config_file=self.get_src_folder() + "/test/python/stacks/2.5/configs/hsi_ha.json",
|
|
|
+ stack_version=self.STACK_VERSION,
|
|
|
+ target=RMFTestCase.TARGET_COMMON_SERVICES,
|
|
|
+ checked_call_mocks=[(0, """{
|
|
|
+ \"state\" : \"RUNNING_ALL\"
|
|
|
+ }""", "")],
|
|
|
+ )
|
|
|
+
|
|
|
+ self.assert_configure_default()
|
|
|
+
|
|
|
+ self.assertResourceCalled('Execute',
|
|
|
+ 'hive --config /usr/hdp/current/hive-server2-hive2/conf/conf.server --service metatool -updateLocation hdfs://c6401.ambari.apache.org:8020 OK.',
|
|
|
+ environment={'PATH': '/usr/hdp/current/hadoop-client/bin'},
|
|
|
+ user='hive'
|
|
|
+ )
|
|
|
+ self.assertResourceCalled('Execute',
|
|
|
+ '/tmp/start_hiveserver2_interactive_script /var/run/hive/hive-server2-interactive.out /var/log/hive/hive-server2-interactive.err /var/run/hive/hive-interactive.pid /usr/hdp/current/hive-server2-hive2/conf/conf.server /var/log/hive',
|
|
|
+ environment={'HADOOP_HOME': '/usr/hdp/current/hadoop-client',
|
|
|
+ 'HIVE_BIN': 'hive2',
|
|
|
+ 'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
|
|
|
+ not_if="ls /var/run/hive/hive-interactive.pid >/dev/null 2>&1 && ps -p 123 >/dev/null 2>&1",
|
|
|
+ user='hive',
|
|
|
+ path=['/bin:/usr/hdp/current/hive-server2-hive2/bin:/usr/hdp/current/hadoop-client/bin'],
|
|
|
+ )
|
|
|
+ self.assertResourceCalled('Execute',
|
|
|
+ '/usr/jdk64/jdk1.7.0_45/bin/java -cp /usr/lib/ambari-agent/DBConnectionVerification.jar:/usr/hdp/current/hive-server2-hive2/lib/mysql-connector-java.jar org.apache.ambari.server.DBConnectionVerification \'jdbc:mysql://c6402.ambari.apache.org/hive?createDatabaseIfNotExist=true\' hive \'!`"\'"\'"\' 1\' com.mysql.jdbc.Driver',
|
|
|
+ path=['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
|
|
|
+ tries=5,
|
|
|
+ try_sleep=10
|
|
|
+ )
|
|
|
+ self.assertNoMoreResources()
|
|
|
+
|
|
|
"""
|
|
|
Tests HSI start with llap package creation output having multiple lines.
|
|
|
Sample output : "UNWANTED STRING \n Prepared llap-slider-05Apr2016/run.sh for running LLAP \n UNWANTED STRING \n"
|