diff --git a/sahara/tests/integration/tests/check_services.py b/sahara/tests/integration/tests/check_services.py index db6e4616..332141a8 100644 --- a/sahara/tests/integration/tests/check_services.py +++ b/sahara/tests/integration/tests/check_services.py @@ -97,3 +97,27 @@ class CheckServicesTest(base.ITestCase): print(six.text_type(e)) finally: self.close_ssh_connection() + + def check_solr_availability(self, cluster_info): + self._check_service_availability(cluster_info, 'solr_service_test.sh') + + def _check_service_availability(self, cluster_info, helper_script, + script_parameters=[], conf_files=[]): + namenode_ip = cluster_info['node_info']['namenode_ip'] + self.open_ssh_connection(namenode_ip) + try: + self.transfer_helper_script_to_node(helper_script) + if conf_files: + for conf_file in conf_files: + self.transfer_helper_conf_file_to_node(conf_file) + if script_parameters: + parameters = ' '.join(script_parameters) + script_command = './script.sh %s' % parameters + self.execute_command(script_command) + else: + self.execute_command('./script.sh') + except Exception as e: + with excutils.save_and_reraise_exception(): + print(six.text_type(e)) + finally: + self.close_ssh_connection() diff --git a/sahara/tests/integration/tests/gating/test_cdh_gating.py b/sahara/tests/integration/tests/gating/test_cdh_gating.py index 66c11900..31b96664 100644 --- a/sahara/tests/integration/tests/gating/test_cdh_gating.py +++ b/sahara/tests/integration/tests/gating/test_cdh_gating.py @@ -312,6 +312,8 @@ class CDHGatingTest(check_services.CheckServicesTest, self.check_sqoop2_availability(self.cluster_info) # check key value store self.check_key_value_store_availability(self.cluster_info) + # check solr + self.check_solr_availability(self.cluster_info) @b.errormsg("Failure while cluster scaling: ") def _check_scaling(self): diff --git a/sahara/tests/integration/tests/resources/solr_service_test.sh b/sahara/tests/integration/tests/resources/solr_service_test.sh new file mode 100755 index 00000000..166d3b06 --- /dev/null +++ b/sahara/tests/integration/tests/resources/solr_service_test.sh @@ -0,0 +1,23 @@ +#!/bin/bash -x + +set -e + +check_solr_availability(){ + solrctl instancedir --generate $HOME/solr_configs + sleep 3 + solrctl instancedir --create collection2 $HOME/solr_configs + sleep 30 + solrctl collection --create collection2 -s 1 -c collection2 + sleep 3 + cd /usr/share/doc/solr-doc/example/exampledocs + /usr/lib/jvm/java-7-oracle-cloudera/bin/java -Durl=http://localhost:8983/solr/collection2/update -jar post.jar monitor.xml + if [ `curl "http://localhost:8983/solr/collection2_shard1_replica1/select?q=UltraSharp&wt=json&indent=true" | grep "Dell Widescreen UltraSharp 3007WFP" | wc -l` -ge 1 ]; then + echo "solr is available" + exit 0 + else + echo "solr is not available" + exit 1 + fi +} + +check_solr_availability