This is an automated email from the ASF dual-hosted git repository. nizhikov pushed a commit to branch ignite-ducktape in repository https://gitbox.apache.org/repos/asf/ignite.git
commit 53755e9d3e004fa565fd75fb338bc03745e9d259 Author: Nikolay Izhikov <[email protected]> AuthorDate: Tue May 12 18:33:54 2020 +0300 ignite-ducktape: Spark integration test added. --- .gitignore | 1 + bin/include/build-classpath.sh | 27 ++-- modules/integration-tests/pom.xml | 141 +++++++++++++++++++++ .../ignite/internal/test/IgniteApplication.java | 12 +- .../ignite/internal/test/SparkApplication.java | 111 ++++++++++++++++ parent/pom.xml | 2 +- pom.xml | 1 + tests/docker/Dockerfile | 29 +++-- tests/docker/build/cluster.json | 51 +++++--- tests/docker/build/node_hosts | 12 +- tests/docker/run_tests.sh | 2 +- tests/ignitetest/ignite_utils/ignite_config.py | 7 +- tests/ignitetest/services/{ignite => }/ignite.py | 1 + tests/ignitetest/services/ignite/__init__.py | 14 -- tests/ignitetest/services/ignite_client_app.py | 76 +++++++---- tests/ignitetest/services/spark.py | 119 +++++++++++++++++ tests/ignitetest/suites/add_node_rebalance_test.py | 5 +- tests/ignitetest/suites/spark_integration_test.py | 36 ++++++ 18 files changed, 560 insertions(+), 87 deletions(-) diff --git a/.gitignore b/.gitignore index 18bcd81..b0cc5b7 100644 --- a/.gitignore +++ b/.gitignore @@ -111,3 +111,4 @@ packages /results .ducktape *.pyc +/tests/venv diff --git a/bin/include/build-classpath.sh b/bin/include/build-classpath.sh index edfb267..9a43683 100644 --- a/bin/include/build-classpath.sh +++ b/bin/include/build-classpath.sh @@ -47,20 +47,25 @@ includeToClassPath() { for file in $1/* do - if [ -d ${file} ] && [ -d "${file}/target" ]; then - if [ -d "${file}/target/classes" ]; then - IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/classes - fi + if [[ -z "${EXCLUDE_MODULES}" ]] || [[ ${EXCLUDE_MODULES} != *"`basename $file`"* ]]; then + echo "$file included" + if [ -d ${file} ] && [ -d "${file}/target" ]; then + if [ -d "${file}/target/classes" ]; then + IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/classes + fi - if [[ -z "${EXCLUDE_TEST_CLASSES}" ]]; then - if [ -d "${file}/target/test-classes" ]; then - IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/test-classes - fi - fi + if [[ -z "${EXCLUDE_TEST_CLASSES}" ]]; then + if [ -d "${file}/target/test-classes" ]; then + IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/test-classes + fi + fi - if [ -d "${file}/target/libs" ]; then - IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/libs/* + if [ -d "${file}/target/libs" ]; then + IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/target/libs/* + fi fi + else + echo "$file excluded by EXCLUDE_MODULES settings" fi done diff --git a/modules/integration-tests/pom.xml b/modules/integration-tests/pom.xml new file mode 100644 index 0000000..47fd080 --- /dev/null +++ b/modules/integration-tests/pom.xml @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- + POM file. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-parent</artifactId> + <version>1</version> + <relativePath>../../parent</relativePath> + </parent> + + <artifactId>ignite-integration-tests</artifactId> + <version>2.9.0-SNAPSHOT</version> + <url>http://ignite.apache.org</url> + + <dependencies> + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-core</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-indexing</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-spark</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.spark</groupId> + <artifactId>spark-core_2.11</artifactId> + <version>${spark.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.spark</groupId> + <artifactId>spark-sql_2.11</artifactId> + <version>${spark.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.spark</groupId> + <artifactId>spark-tags_2.11</artifactId> + <version>${spark.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.spark</groupId> + <artifactId>spark-catalyst_2.11</artifactId> + <version>${spark.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.spark</groupId> + <artifactId>spark-network-shuffle_2.11</artifactId> + <version>${spark.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.spark</groupId> + <artifactId>spark-network-common_2.11</artifactId> + <version>${spark.version}</version> + </dependency> + + <dependency> + <groupId>com.fasterxml.woodstox</groupId> + <artifactId>woodstox-core</artifactId> + <version>5.0.3</version> + </dependency> + + <dependency> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>stax2-api</artifactId> + <version>3.1.4</version> + </dependency> + + <dependency> + <groupId>org.apache.htrace</groupId> + <artifactId>htrace-core4</artifactId> + <version>4.1.0-incubating</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-libs</id> + <phase>test-compile</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <excludeGroupIds>org.apache.ignite</excludeGroupIds> + <outputDirectory>target/libs</outputDirectory> + <includeScope>compile</includeScope> + <excludeTransitive>false</excludeTransitive> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/test/IgniteApplication.java b/modules/integration-tests/src/main/java/org/apache/ignite/internal/test/IgniteApplication.java similarity index 76% rename from modules/benchmarks/src/main/java/org/apache/ignite/internal/test/IgniteApplication.java rename to modules/integration-tests/src/main/java/org/apache/ignite/internal/test/IgniteApplication.java index dffa891..1a480bb 100644 --- a/modules/benchmarks/src/main/java/org/apache/ignite/internal/test/IgniteApplication.java +++ b/modules/integration-tests/src/main/java/org/apache/ignite/internal/test/IgniteApplication.java @@ -21,13 +21,14 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.Ignition; +import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgnitionEx; import org.apache.ignite.internal.processors.resource.GridSpringResourceContext; import org.apache.ignite.lang.IgniteBiTuple; public class IgniteApplication { - public static final String CONFIG_PATH = "/mnt/client_app/ignite-config.xml"; + public static final String CONFIG_PATH = "/mnt/client_app/ignite-client-config.xml"; public static void main(String[] args) throws IgniteCheckedException { IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> cfgs = IgnitionEx.loadConfiguration(CONFIG_PATH); @@ -46,7 +47,16 @@ public class IgniteApplication { cache.put(i, i); } + executeSql(cache, "CREATE TABLE person(id INT, fio VARCHAR, PRIMARY KEY(id))"); + executeSql(cache, "INSERT INTO person(id, fio) VALUES(?, ?)", 1, "Ivanov Ivan"); + executeSql(cache, "INSERT INTO person(id, fio) VALUES(?, ?)", 2, "Petrov Petr"); + executeSql(cache, "INSERT INTO person(id, fio) VALUES(?, ?)", 3, "Sidorov Sidr"); + System.out.println("Ignite Client Finish."); } } + + private static void executeSql(IgniteCache<Integer, Integer> cache, String query, Object...args) { + cache.query(new SqlFieldsQuery(query).setArgs(args)).getAll(); + } } diff --git a/modules/integration-tests/src/main/java/org/apache/ignite/internal/test/SparkApplication.java b/modules/integration-tests/src/main/java/org/apache/ignite/internal/test/SparkApplication.java new file mode 100644 index 0000000..8a88079 --- /dev/null +++ b/modules/integration-tests/src/main/java/org/apache/ignite/internal/test/SparkApplication.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.test; + +import org.apache.ignite.spark.IgniteDataFrameSettings; +import org.apache.spark.sql.Dataset; +import org.apache.spark.sql.Row; +import org.apache.spark.sql.SparkSession; +import org.apache.spark.sql.ignite.IgniteSparkSession; + +import static org.apache.ignite.internal.test.IgniteApplication.CONFIG_PATH; + +public class SparkApplication { + public static final String HOME = "/opt/ignite-dev"; + + public static final String VER = "2.9.0-SNAPSHOT"; + + public static final String SPRING_VER = "4.3.26.RELEASE"; + + public static void main(String[] args) { + System.out.println("SparkApplication.main - args"); + for (String arg : args) + System.out.println("SparkApplication.main - " + arg); + + sparkSession(args[0]); + + igniteSession(args[0]); + + System.out.println("Ignite Client Finish."); + } + + private static void sparkSession(String masterUrl) { + //Creating spark session. + try (SparkSession spark = SparkSession.builder() + .appName("SparkApplication") + .master(masterUrl) + .getOrCreate()) { + spark.sparkContext().addJar(HOME + "/modules/core/target/ignite-core-" + VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spring/target/ignite-spring-" + VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/log4j/target/ignite-log4j-" + VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spark/target/ignite-spark-" + VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/indexing/target/ignite-indexing-" + VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spring/target/libs/spring-beans-" + SPRING_VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spring/target/libs/spring-core-" + SPRING_VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spring/target/libs/spring-context-" + SPRING_VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spring/target/libs/spring-expression-" + SPRING_VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/core/target/libs/cache-api-1.0.0.jar"); + spark.sparkContext().addJar(HOME + "/modules/indexing/target/libs/h2-1.4.197.jar"); + + sparkDSLExample(spark); + } + } + + private static void igniteSession(String masterUrl) { + //Creating spark session. + try (IgniteSparkSession spark = IgniteSparkSession.builder() + .appName("SparkApplication") + .igniteConfig(CONFIG_PATH) + .master(masterUrl) + .getOrCreate()) { + spark.sparkContext().addJar(HOME + "/modules/core/target/ignite-core-" + VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spring/target/ignite-spring-" + VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/log4j/target/ignite-log4j-" + VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spark/target/ignite-spark-" + VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/indexing/target/ignite-indexing-" + VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spring/target/libs/spring-beans-" + SPRING_VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spring/target/libs/spring-core-" + SPRING_VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spring/target/libs/spring-context-" + SPRING_VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/spring/target/libs/spring-expression-" + SPRING_VER + ".jar"); + spark.sparkContext().addJar(HOME + "/modules/core/target/libs/cache-api-1.0.0.jar"); + spark.sparkContext().addJar(HOME + "/modules/indexing/target/libs/h2-1.4.197.jar"); + + spark.catalog().listTables().show(); + + sparkDSLExample(spark); + } + } + + private static void sparkDSLExample(SparkSession spark) { + System.out.println("Querying using Spark DSL."); + + Dataset<Row> igniteDF = spark.read() + .format(IgniteDataFrameSettings.FORMAT_IGNITE()) //Data source type. + .option(IgniteDataFrameSettings.OPTION_TABLE(), "person") //Table to read. + .option(IgniteDataFrameSettings.OPTION_CONFIG_FILE(), CONFIG_PATH) //Ignite config. + .load(); + + System.out.println("Data frame schema:"); + + igniteDF.printSchema(); //Printing query schema to console. + + System.out.println("Data frame content:"); + + igniteDF.show(); //Printing query results to console. + } +} diff --git a/parent/pom.xml b/parent/pom.xml index 929e7f7..1fdccb4 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -123,7 +123,7 @@ <slf4j16.version>1.6.4</slf4j16.version> <snappy.version>1.1.7.2</snappy.version> <spark.hadoop.version>2.6.5</spark.hadoop.version> - <spark.version>2.3.0</spark.version> + <spark.version>2.3.4</spark.version> <spring.data.version>1.13.23.RELEASE</spring.data.version> <!-- don't forget to update spring version --> <spring.version>4.3.26.RELEASE</spring.version><!-- don't forget to update spring-data version --> <spring.data-2.0.version>2.0.13.RELEASE</spring.data-2.0.version> <!-- don't forget to update spring-5.0 version --> diff --git a/pom.xml b/pom.xml index 325f383..e56fd2f 100644 --- a/pom.xml +++ b/pom.xml @@ -617,6 +617,7 @@ <id>benchmarks</id> <modules> <module>modules/benchmarks</module> + <module>modules/integration-tests</module> </modules> </profile> diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index c94e9f3..593806b 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -42,17 +42,30 @@ COPY ./ssh-config /root/.ssh/config RUN ssh-keygen -m PEM -q -t rsa -N '' -f /root/.ssh/id_rsa && cp -f /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys RUN echo 'PermitUserEnvironment yes' >> /etc/ssh/sshd_config -# Install binary test dependencies. -# we use the same versions as in vagrant/base.sh -ARG IGNITE_MIRROR="https://apache-mirror.rbc.ru/pub/apache/" -ARG IGNITE_NAME="ignite-2.8.0" -ARG RELEASE_NAME="apache-ignite-2.8.0-bin" RUN chmod a+wr /opt -RUN curl -s "$IGNITE_MIRROR/ignite/2.8.0/$RELEASE_NAME.zip" > /opt/$RELEASE_NAME.zip -RUN cd /opt && unzip $RELEASE_NAME.zip && rm $RELEASE_NAME.zip -RUN mv /opt/$RELEASE_NAME /opt/$IGNITE_NAME + +ARG APACHE_MIRROR="https://apache-mirror.rbc.ru/pub/apache/" + +# Install binary test dependencies. +ARG IGNITE_VERSION="2.8.0" +ARG IGNITE_NAME="ignite-$IGNITE_VERSION" +ARG IGNITE_RELEASE_NAME="apache-ignite-$IGNITE_VERSION-bin" + +ADD $APACHE_MIRROR/ignite/$IGNITE_VERSION/$IGNITE_RELEASE_NAME.zip /opt/ +RUN cd /opt && unzip $IGNITE_RELEASE_NAME.zip && rm $IGNITE_RELEASE_NAME.zip +RUN mv /opt/$IGNITE_RELEASE_NAME /opt/$IGNITE_NAME RUN chmod a+wr /opt/$IGNITE_NAME -R +# Install spark +ARG SPARK_VERSION="2.3.4" +ARG SPARK_NAME="spark-$SPARK_VERSION" +ARG SPARK_RELEASE_NAME="spark-$SPARK_VERSION-bin-hadoop2.7" + +ADD $APACHE_MIRROR/spark/$SPARK_NAME/$SPARK_RELEASE_NAME.tgz /opt/ +RUN cd /opt && tar xvf $SPARK_RELEASE_NAME.tgz && rm $SPARK_RELEASE_NAME.tgz +RUN mv /opt/$SPARK_RELEASE_NAME /opt/$SPARK_NAME +RUN chmod a+wr /opt/$SPARK_NAME -R + # The version of Kibosh to use for testing. # If you update this, also update vagrant/base.sh ARG KIBOSH_VERSION="8841dd392e6fbf02986e2fb1f1ebf04df344b65a" diff --git a/tests/docker/build/cluster.json b/tests/docker/build/cluster.json index 4c15a52..4332532 100644 --- a/tests/docker/build/cluster.json +++ b/tests/docker/build/cluster.json @@ -17,47 +17,58 @@ ], "nodes": [ { - "externally_routable_ip": "130.193.62.38", + "externally_routable_ip": "ducker02", "ssh_config": { - "host": "130.193.62.38", - "hostname": "ignite-1", - "identityfile": "/home/ducker/.ssh/id_rsa_yandex", + "host": "ducker02", + "hostname": "ducker02", + "identityfile": "/home/ducker/.ssh/id_rsa", "password": "", "port": 22, - "user": "nizhikov" + "user": "ducker" } }, { - "externally_routable_ip": "84.201.189.216", + "externally_routable_ip": "ducker03", "ssh_config": { - "host": "84.201.189.216", - "hostname": "ignite-2", - "identityfile": "/home/ducker/.ssh/id_rsa_yandex", + "host": "ducker03", + "hostname": "ducker03", + "identityfile": "/home/ducker/.ssh/id_rsa", "password": "", "port": 22, - "user": "nizhikov" + "user": "ducker" } }, { - "externally_routable_ip": "130.193.62.6", + "externally_routable_ip": "ducker04", "ssh_config": { - "host": "130.193.62.6", - "hostname": "ignite-3", - "identityfile": "/home/ducker/.ssh/id_rsa_yandex", + "host": "ducker04", + "hostname": "ducker04", + "identityfile": "/home/ducker/.ssh/id_rsa", "password": "", "port": 22, - "user": "nizhikov" + "user": "ducker" } }, { - "externally_routable_ip": "130.193.62.60", + "externally_routable_ip": "ducker05", "ssh_config": { - "host": "130.193.62.60", - "hostname": "ignite-4", - "identityfile": "/home/ducker/.ssh/id_rsa_yandex", + "host": "ducker05", + "hostname": "ducker05", + "identityfile": "/home/ducker/.ssh/id_rsa", "password": "", "port": 22, - "user": "nizhikov" + "user": "ducker" + } + }, + { + "externally_routable_ip": "ducker06", + "ssh_config": { + "host": "ducker06", + "hostname": "ducker06", + "identityfile": "/home/ducker/.ssh/id_rsa", + "password": "", + "port": 22, + "user": "ducker" } } ] diff --git a/tests/docker/build/node_hosts b/tests/docker/build/node_hosts index 805226f..173c478 100644 --- a/tests/docker/build/node_hosts +++ b/tests/docker/build/node_hosts @@ -1,5 +1,7 @@ -130.193.62.16 ignite-coordinator -130.193.62.38 ignite-1 -84.201.189.216 ignite-2 -130.193.62.6 ignite-3 -130.193.62.60 ignite-4 \ No newline at end of file +172.18.0.2 ducker01 +172.18.0.3 ducker02 +172.18.0.4 ducker03 +172.18.0.5 ducker04 +172.18.0.6 ducker05 +172.18.0.7 ducker06 +.60 ignite-4 \ No newline at end of file diff --git a/tests/docker/run_tests.sh b/tests/docker/run_tests.sh index 9de2317..477ec82 100755 --- a/tests/docker/run_tests.sh +++ b/tests/docker/run_tests.sh @@ -16,7 +16,7 @@ # limitations under the License. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -IGNITE_NUM_CONTAINERS=${IGNITE_NUM_CONTAINERS:-5} +IGNITE_NUM_CONTAINERS=${IGNITE_NUM_CONTAINERS:-6} TC_PATHS=${TC_PATHS:-./ignitetest/} die() { diff --git a/tests/ignitetest/ignite_utils/ignite_config.py b/tests/ignitetest/ignite_utils/ignite_config.py index 534df42..f8bd92b 100644 --- a/tests/ignitetest/ignite_utils/ignite_config.py +++ b/tests/ignitetest/ignite_utils/ignite_config.py @@ -22,7 +22,7 @@ class IgniteConfig: def __init__(self, project="ignite"): self.project = project - def render(self, config_dir, work_dir): + def render(self, config_dir, work_dir, client_mode="false"): return """<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" @@ -36,9 +36,12 @@ class IgniteConfig: <constructor-arg type="java.lang.String" value="{config_dir}/ignite-log4j.xml"/> </bean> </property> + <property name="clientMode" value="{client_mode}" /> </bean> </beans> - """.format(config_dir=config_dir, work_dir=work_dir) + """.format(config_dir=config_dir, + work_dir=work_dir, + client_mode=client_mode) def render_log4j(self, work_dir): return """<?xml version="1.0" encoding="UTF-8"?> diff --git a/tests/ignitetest/services/ignite/ignite.py b/tests/ignitetest/services/ignite.py similarity index 98% rename from tests/ignitetest/services/ignite/ignite.py rename to tests/ignitetest/services/ignite.py index 1107ffe..f864f88 100644 --- a/tests/ignitetest/services/ignite/ignite.py +++ b/tests/ignitetest/services/ignite.py @@ -16,6 +16,7 @@ import os.path import signal +from ducktape.cluster.remoteaccount import RemoteCommandError from ducktape.services.service import Service from ducktape.utils.util import wait_until diff --git a/tests/ignitetest/services/ignite/__init__.py b/tests/ignitetest/services/ignite/__init__.py deleted file mode 100644 index ec20143..0000000 --- a/tests/ignitetest/services/ignite/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/tests/ignitetest/services/ignite_client_app.py b/tests/ignitetest/services/ignite_client_app.py index 82a661a..228e76b 100644 --- a/tests/ignitetest/services/ignite_client_app.py +++ b/tests/ignitetest/services/ignite_client_app.py @@ -32,7 +32,7 @@ class IgniteClientApp(BackgroundThreadService): PERSISTENT_ROOT = "/mnt/client_app" STDOUT_STDERR_CAPTURE = os.path.join(PERSISTENT_ROOT, "console.log") WORK_DIR = os.path.join(PERSISTENT_ROOT, "work") - CONFIG_FILE = os.path.join(PERSISTENT_ROOT, "ignite-config.xml") + CLIENT_CONFIG_FILE = os.path.join(PERSISTENT_ROOT, "ignite-client-config.xml") LOG4J_CONFIG_FILE = os.path.join(PERSISTENT_ROOT, "ignite-log4j.xml") logs = { @@ -41,17 +41,19 @@ class IgniteClientApp(BackgroundThreadService): "collect_default": True} } - def __init__(self, context, version=DEV_BRANCH, num_nodes=1): + def __init__(self, context, java_class_name, version=DEV_BRANCH, num_nodes=1): """ Args: num_nodes: number of nodes to use (this should be 1) """ BackgroundThreadService.__init__(self, context, num_nodes) - self.stop_timeout_sec = 10 self.log_level = "DEBUG" self.config = IgniteConfig() self.path = IgnitePath() + self.java_class_name = java_class_name + self.timeout_sec = 60 + self.stop_timeout_sec = 10 for node in self.nodes: node.version = version @@ -59,16 +61,11 @@ class IgniteClientApp(BackgroundThreadService): def start_cmd(self, node): """Return the start command appropriate for the given node.""" - jvm_opts = "-J-DIGNITE_SUCCESS_FILE=" + IgniteClientApp.PERSISTENT_ROOT + "/success_file " - jvm_opts += "-J-Dlog4j.configDebug=true" - - cmd = "export MAIN_CLASS={main_class}; ".format(main_class=self.java_class_name()) - cmd += "export EXCLUDE_TEST_CLASSES=true; " - cmd += "export IGNITE_LOG_DIR=" + IgniteClientApp.PERSISTENT_ROOT + "; " + cmd = self.env() cmd += "%s %s %s 1>> %s 2>> %s " % \ (self.path.script("ignite.sh", node), - jvm_opts, - IgniteClientApp.CONFIG_FILE, + self.jvm_opts(), + self.app_args(), IgniteClientApp.STDOUT_STDERR_CAPTURE, IgniteClientApp.STDOUT_STDERR_CAPTURE) return cmd @@ -78,7 +75,7 @@ class IgniteClientApp(BackgroundThreadService): def stop_node(self, node): self.logger.info("%s Stopping node %s" % (self.__class__.__name__, str(node.account))) - node.account.kill_java_processes(self.java_class_name(), + node.account.kill_java_processes(self.java_class_name, clean_shutdown=True, allow_fail=True) @@ -91,29 +88,64 @@ class IgniteClientApp(BackgroundThreadService): self.logger.warn("%s %s was still alive at cleanup time. Killing forcefully..." % (self.__class__.__name__, node.account)) - node.account.kill_java_processes(self.java_class_name(), + node.account.kill_java_processes(self.java_class_name, clean_shutdown=False, allow_fail=True) node.account.ssh("rm -rf %s" % IgniteClientApp.PERSISTENT_ROOT, allow_fail=False) def pids(self, node): - return node.account.java_pids(self.java_class_name()) + return node.account.java_pids(self.java_class_name) def alive(self, node): return len(self.pids(node)) > 0 def _worker(self, idx, node): - node.account.mkdirs(IgniteClientApp.PERSISTENT_ROOT) - node.account.create_file(IgniteClientApp.CONFIG_FILE, - self.config.render(IgniteClientApp.PERSISTENT_ROOT, IgniteClientApp.WORK_DIR)) - node.account.create_file(IgniteClientApp.LOG4J_CONFIG_FILE, - self.config.render_log4j(IgniteClientApp.WORK_DIR)) + create_client_configs(node, self.config) # Just run application. cmd = self.start_cmd(node) self.logger.info("Ignite client application command: %s", cmd) - node.account.ssh(cmd, allow_fail=False) - def java_class_name(self): - return "org.apache.ignite.internal.test.IgniteApplication" + with node.account.monitor_log(IgniteClientApp.STDOUT_STDERR_CAPTURE) as monitor: + node.account.ssh(cmd, allow_fail=False) + monitor.wait_until("Ignite Client Finish.", timeout_sec=self.timeout_sec, backoff_sec=5, + err_msg="Ignite client don't finish before timeout %s" % self.timeout_sec) + + def app_args(self): + return IgniteClientApp.CLIENT_CONFIG_FILE + + def jvm_opts(self): + return "-J-DIGNITE_SUCCESS_FILE=" + IgniteClientApp.PERSISTENT_ROOT + "/success_file " + \ + "-J-Dlog4j.configDebug=true " \ + "-J-Xmx1G" + + def env(self): + return "export MAIN_CLASS={main_class}; ".format(main_class=self.java_class_name) + \ + "export EXCLUDE_TEST_CLASSES=true; " + \ + "export IGNITE_LOG_DIR={log_dir}; ".format(log_dir=IgniteClientApp.PERSISTENT_ROOT) + + +class SparkIgniteClientApp(IgniteClientApp): + def __init__(self, context, master_node): + IgniteClientApp.__init__(self, context, java_class_name="org.apache.ignite.internal.test.SparkApplication") + self.master_node = master_node + self.timeout_sec = 120 + + def app_args(self): + return " spark://" + self.master_node.account.hostname + ":7077" + + def env(self): + return IgniteClientApp.env(self) + \ + "export EXCLUDE_MODULES=\"kubernetes,aws,gce,mesos,rest-http,web-agent,zookeeper,serializers,store," \ + "rocketmq\"; " + + +def create_client_configs(node, config): + node.account.mkdirs(IgniteClientApp.PERSISTENT_ROOT) + node.account.create_file(IgniteClientApp.CLIENT_CONFIG_FILE, + config.render(IgniteClientApp.PERSISTENT_ROOT, + IgniteClientApp.WORK_DIR, + "true")) + node.account.create_file(IgniteClientApp.LOG4J_CONFIG_FILE, + config.render_log4j(IgniteClientApp.WORK_DIR)) diff --git a/tests/ignitetest/services/spark.py b/tests/ignitetest/services/spark.py new file mode 100644 index 0000000..58f25a4 --- /dev/null +++ b/tests/ignitetest/services/spark.py @@ -0,0 +1,119 @@ +import os.path + +from ducktape.cluster.remoteaccount import RemoteCommandError +from ducktape.services.service import Service + +from ignitetest.ignite_utils.ignite_config import IgniteConfig +from ignitetest.services.ignite_client_app import IgniteClientApp, create_client_configs + + +class SparkService(Service): + INSTALL_DIR = "/opt/spark-{version}".format(version="2.3.4") + PERSISTENT_ROOT = "/mnt/spark" + + logs = {} + + def __init__(self, context, num_nodes=3): + """ + :param context: test context + :param num_nodes: number of Ignite nodes. + """ + Service.__init__(self, context, num_nodes) + + self.log_level = "DEBUG" + self.ignite_config = IgniteConfig() + + for node in self.nodes: + self.logs["master_logs" + node.account.hostname] = { + "path": self.master_log_path(node), + "collect_default": True + } + self.logs["worker_logs" + node.account.hostname] = { + "path": self.slave_log_path(node), + "collect_default": True + } + + def start(self): + Service.start(self) + + self.logger.info("Waiting for Spark to start...") + + def start_cmd(self, node): + if node == self.nodes[0]: + script = "start-master.sh" + else: + script = "start-slave.sh spark://{spark_master}:7077".format(spark_master=self.nodes[0].account.hostname) + + start_script = os.path.join(SparkService.INSTALL_DIR, "sbin", script) + + cmd = "export SPARK_LOG_DIR={spark_dir}; ".format(spark_dir=SparkService.PERSISTENT_ROOT) + cmd += "export SPARK_WORKER_DIR={spark_dir}; ".format(spark_dir=SparkService.PERSISTENT_ROOT) + cmd += "{start_script} &".format(start_script=start_script) + + return cmd + + def start_node(self, node, timeout_sec=30): + create_client_configs(node, self.ignite_config) + + cmd = self.start_cmd(node) + self.logger.debug("Attempting to start SparkService on %s with command: %s" % (str(node.account), cmd)) + + if node == self.nodes[0]: + log_file = self.master_log_path(node) + log_msg = "Started REST server for submitting applications" + else: + log_file = self.slave_log_path(node) + log_msg = "Successfully registered with master" + + self.logger.debug("Monitoring - %s" % log_file) + + with node.account.monitor_log(log_file) as monitor: + node.account.ssh(cmd) + monitor.wait_until(log_msg, timeout_sec=timeout_sec, backoff_sec=5, + err_msg="Spark doesn't start at %d seconds" % timeout_sec) + + if len(self.pids(node)) == 0: + raise Exception("No process ids recorded on node %s" % node.account.hostname) + + def stop_node(self, node, clean_shutdown=True, timeout_sec=60): + if node == self.nodes[0]: + node.account.ssh(os.path.join(SparkService.INSTALL_DIR, "sbin", "stop-master.sh")) + else: + node.account.ssh(os.path.join(SparkService.INSTALL_DIR, "sbin", "stop-slave.sh")) + + def clean_node(self, node): + node.account.kill_java_processes(self.java_class_name(node), + clean_shutdown=False, allow_fail=True) + node.account.ssh("sudo rm -rf -- %s" % SparkService.PERSISTENT_ROOT, allow_fail=False) + + def pids(self, node): + """Return process ids associated with running processes on the given node.""" + try: + cmd = "jcmd | grep -e %s | awk '{print $1}'" % self.java_class_name(node) + pid_arr = [pid for pid in node.account.ssh_capture(cmd, allow_fail=True, callback=int)] + return pid_arr + except (RemoteCommandError, ValueError) as e: + return [] + + def java_class_name(self, node): + if node == self.nodes[0]: + return "org.apache.spark.deploy.master.Master" + else: + return "org.apache.spark.deploy.worker.Worker" + + def alive(self, node): + return len(self.pids(node)) > 0 + + def master_log_path(self, node): + return "{SPARK_LOG_DIR}/spark-{userID}-org.apache.spark.deploy.master.Master-{instance}-{host}.out".format( + SPARK_LOG_DIR=SparkService.PERSISTENT_ROOT, + userID=node.account.user, + instance=1, + host=node.account.hostname) + + def slave_log_path(self, node): + return "{SPARK_LOG_DIR}/spark-{userID}-org.apache.spark.deploy.worker.Worker-{instance}-{host}.out".format( + SPARK_LOG_DIR=SparkService.PERSISTENT_ROOT, + userID=node.account.user, + instance=1, + host=node.account.hostname) diff --git a/tests/ignitetest/suites/add_node_rebalance_test.py b/tests/ignitetest/suites/add_node_rebalance_test.py index 569ed74..828ec5a 100644 --- a/tests/ignitetest/suites/add_node_rebalance_test.py +++ b/tests/ignitetest/suites/add_node_rebalance_test.py @@ -15,7 +15,7 @@ from ducktape.tests.test import Test -from ignitetest.services.ignite.ignite import IgniteService +from ignitetest.services.ignite import IgniteService from ignitetest.services.ignite_client_app import IgniteClientApp @@ -48,7 +48,8 @@ class AddNodeRebalanceTest(Test): self.logger.info("Start add node rebalance test.") # This client just put some data to the cache. - IgniteClientApp(self.test_context).run() + IgniteClientApp(self.test_context, + java_class_name="org.apache.ignite.internal.test.IgniteApplication").run() self.ignite.start_node(self.ignite.nodes[AddNodeRebalanceTest.NUM_NODES-1], timeout_sec=AddNodeRebalanceTest.REBALANCE_TIMEOUT, diff --git a/tests/ignitetest/suites/spark_integration_test.py b/tests/ignitetest/suites/spark_integration_test.py new file mode 100644 index 0000000..57c741c --- /dev/null +++ b/tests/ignitetest/suites/spark_integration_test.py @@ -0,0 +1,36 @@ +from ducktape.tests.test import Test + +from ignitetest.services.ignite import IgniteService +from ignitetest.services.ignite_client_app import IgniteClientApp, SparkIgniteClientApp +from ignitetest.services.spark import SparkService + + +class SparkIntegrationTest(Test): + """ + Test performs: + 1. Start of Spark cluster. + 2. Start of Spark client application. + 3. Checks results of client application. + """ + + def __init__(self, test_context): + super(SparkIntegrationTest, self).__init__(test_context=test_context) + self.spark = SparkService(test_context, num_nodes=2) + self.ignite = IgniteService(test_context, num_nodes=1) + + def setUp(self): + # starting all nodes except last. + self.spark.start() + self.ignite.start() + + def teardown(self): + self.spark.stop() + self.ignite.stop() + + def test_spark_client(self): + self.logger.info("Spark integration test.") + + IgniteClientApp(self.test_context, + java_class_name="org.apache.ignite.internal.test.IgniteApplication").run() + + SparkIgniteClientApp(self.test_context, self.spark.nodes[0]).run()
