From b81bd42a8e724938b05e43c171ea2696d02137b2 Mon Sep 17 00:00:00 2001 From: luhuichun Date: Sat, 14 Feb 2015 02:16:43 +0800 Subject: [PATCH] Add Solr service test in cdh plugin integration test Currently we have no services test in the integration test add solr service test in cdh plugin partially implements bp: add-service-test-in-integration Change-Id: I1a0a616d7510295f822145a4ffee8b63e4d429aa --- .../tests/integration/tests/check_services.py | 24 +++++++++++++++++++ .../tests/gating/test_cdh_gating.py | 2 ++ .../tests/resources/solr_service_test.sh | 23 ++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100755 sahara/tests/integration/tests/resources/solr_service_test.sh 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 cb7b16b6..4acf6021 100644 --- a/sahara/tests/integration/tests/gating/test_cdh_gating.py +++ b/sahara/tests/integration/tests/gating/test_cdh_gating.py @@ -315,6 +315,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