Merge "Add Solr service test in cdh plugin integration test"

This commit is contained in:
Jenkins 2015-03-04 02:58:50 +00:00 committed by Gerrit Code Review
commit f3ad82f2dc
3 changed files with 49 additions and 0 deletions

View File

@ -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()

View File

@ -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):

View File

@ -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