Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ut and it test script1 #1755

Merged
merged 5 commits into from
Apr 23, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions dev/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,35 @@ set -o pipefail

DEV_DIR=$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)

function exit_with_usage {
cat << EOF
usage: run-test
Execute byzer's unit and integration testing.
Inputs are specified with the following environment variables:

MLSQL_SPARK_VERSION - the spark version, 2.4/3.0 default 2.4
TEST_MODULES_FLAG all|it|ut - type of test, default it
matches - Specify a regular expression for testfile, default .*
EOF
exit 1
}

if [[ $@ == *"help"* ]]; then
exit_with_usage
fi

if [ -n "$1" ]; then
export MLSQL_SPARK_VERSION=${1}
else
export MLSQL_SPARK_VERSION=${MLSQL_SPARK_VERSION:-3.0}
fi

TEST_MODULES_FLAG=${2:-it}
MATCHES=${3:-.*}
echo "Current parameters: $*"

if [ "${MLSQL_SPARK_VERSION}" == "3.0" ]; then
SCALA_BINARY_VERSION=2.12
if [ ! -f "${DEV_DIR}"/ansj_seg-5.1.6.jar ]; then
wget --no-check-certificate --no-verbose "http://download.mlsql.tech/nlp/ansj_seg-5.1.6.jar" --directory-prefix "${DEV_DIR}/"
fi
Expand All @@ -40,19 +62,25 @@ if [ "${MLSQL_SPARK_VERSION}" == "3.0" ]; then
./dev/make-distribution.sh

elif [ "${MLSQL_SPARK_VERSION}" == "2.4" ]; then
SCALA_BINARY_VERSION=2.11
./dev/change-scala-version.sh 2.11
python ./dev/python/convert_pom.py 2.4
else
echo "Only accept 2.4|3.0"
exit -1
exit 1
fi

case "${TEST_MODULES_FLAG}" in
all) TEST_MODULES=-DargLine='"'-Dmatches=${MATCHES}'"';;
it) TEST_MODULES="-pl streamingpro-it -DargLine=-Dmatches=${MATCHES}";;
ut) args=(-Dtest.regex='"(streamingpro-it-'"${MLSQL_SPARK_VERSION}""_""${SCALA_BINARY_VERSION}"')"') && TEST_MODULES=${args[@]};;
*) echo "Only support all|it|ut" && exit 1
esac
echo test moules is :"${TEST_MODULES}"

if [ "${SKIP_INSTALL:-}" != "skipInstall" ]; then
mvn clean install -DskipTests
else
mvn clean
fi

MATCHES=${2:-.*}

mvn test -pl streamingpro-it "-DargLine=-Dmatches=${MATCHES}"
mvn test $TEST_MODULES
23 changes: 22 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<test.regex>none</test.regex>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
Expand Down Expand Up @@ -959,6 +959,27 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>regex-property</id>
<phase>test</phase>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>maven.test.skip</name>
<value>${project.artifactId}</value>
<regex>${test.regex}</regex>
<replacement>true</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
Expand Down