From 436f9decda2ca0157dcc493c85ce58773cc6c6f0 Mon Sep 17 00:00:00 2001 From: vivostar Date: Sun, 24 Dec 2023 15:32:36 +0800 Subject: [PATCH] BIGTOP-4055. Add Spark History Server Smoke Test --- bigtop-deploy/puppet/manifests/cluster.pp | 1 + bigtop-tests/smoke-tests/spark/.gitignore | 1 + .../smoke-tests/spark/TestSpark.groovy | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 bigtop-tests/smoke-tests/spark/.gitignore diff --git a/bigtop-deploy/puppet/manifests/cluster.pp b/bigtop-deploy/puppet/manifests/cluster.pp index ec81ada94e..7509578c4d 100644 --- a/bigtop-deploy/puppet/manifests/cluster.pp +++ b/bigtop-deploy/puppet/manifests/cluster.pp @@ -66,6 +66,7 @@ worker => ["solr-server"], }, spark => { + master => ["spark-history-server"], worker => ["spark-on-yarn"], client => ["spark-client"], library => ["spark-yarn-slave"], diff --git a/bigtop-tests/smoke-tests/spark/.gitignore b/bigtop-tests/smoke-tests/spark/.gitignore new file mode 100644 index 0000000000..b7265688ad --- /dev/null +++ b/bigtop-tests/smoke-tests/spark/.gitignore @@ -0,0 +1 @@ +examples \ No newline at end of file diff --git a/bigtop-tests/smoke-tests/spark/TestSpark.groovy b/bigtop-tests/smoke-tests/spark/TestSpark.groovy index 82bfe0df58..d28ebd702e 100644 --- a/bigtop-tests/smoke-tests/spark/TestSpark.groovy +++ b/bigtop-tests/smoke-tests/spark/TestSpark.groovy @@ -112,4 +112,35 @@ class TestSpark { logError(sh) assertTrue("Failed to execute SparkR script", sh.getRet() == 0); } + + // parse spark-defaults.conf to properties object + def parseSparkDefaultsConf(String path) { + + def file = new File(path) + def props = new Properties() + props.load(file.newDataInputStream()) + return props + + } + + @Test + void testSparkHistoryServer() { + + String SPARK_CONF_DIR = SPARK_HOME + File.separator + "conf" + String SPARK_DEFAULTS_CONF = SPARK_CONF_DIR + File.separator + "spark-defaults.conf" + + def props = parseSparkDefaultsConf(SPARK_DEFAULTS_CONF) + String spark_history_server_port = props.getProperty("spark.history.ui.port") + + sh.exec("hostname -f") + logError(sh) + String spark_history_server_host = sh.getOut()[0] + + sh.exec("curl -s -o /dev/null -w'%{http_code}' --negotiate -u: -k http://" + spark_history_server_host + + ":" + spark_history_server_port + " | grep 200") + logError(sh) + assertTrue("Failed to check spark history server", sh.getOut()[0] == "200") + + } + }