Merge pull request #4405 from sfc-gh-anoyes/anoyes/cluster-for-java-test
anoyes/cluster-for-java-test
This commit is contained in:
commit
061c733a9c
|
@ -307,7 +307,7 @@ if(NOT OPEN_FOR_IDE)
|
||||||
#
|
#
|
||||||
# Note: if you are running from ${BUILD_DIR}, additional tests of the native logic will be run. To avoid these, use
|
# Note: if you are running from ${BUILD_DIR}, additional tests of the native logic will be run. To avoid these, use
|
||||||
#
|
#
|
||||||
# ctest . -R junit
|
# ctest . -R java-unit
|
||||||
#
|
#
|
||||||
# ctest has lots of flexible command options, so be sure to refer to its documentation if you want to do something specific(documentation
|
# ctest has lots of flexible command options, so be sure to refer to its documentation if you want to do something specific(documentation
|
||||||
# can be found at https://cmake.org/cmake/help/v3.19/manual/ctest.1.html)
|
# can be found at https://cmake.org/cmake/help/v3.19/manual/ctest.1.html)
|
||||||
|
@ -350,6 +350,11 @@ if(NOT OPEN_FOR_IDE)
|
||||||
#
|
#
|
||||||
# To add an integration test, add the relative class file path to the JAVA_INTEGRATION_TESTS variable in `src/tests.cmake`
|
# To add an integration test, add the relative class file path to the JAVA_INTEGRATION_TESTS variable in `src/tests.cmake`
|
||||||
#
|
#
|
||||||
|
# All integration tests share the same fdb cluster, so you should design
|
||||||
|
# your test with that in mind (e.g. don't depend on the database being
|
||||||
|
# empty, consider generating a random prefix for the keys you write, use
|
||||||
|
# the directory layer with a unique path, etc.)
|
||||||
|
#
|
||||||
add_jar(fdb-integration SOURCES ${JAVA_INTEGRATION_TESTS} ${JAVA_INTEGRATION_RESOURCES} INCLUDE_JARS fdb-java
|
add_jar(fdb-integration SOURCES ${JAVA_INTEGRATION_TESTS} ${JAVA_INTEGRATION_RESOURCES} INCLUDE_JARS fdb-java
|
||||||
${CMAKE_BINARY_DIR}/packages/junit-jupiter-api-5.7.1.jar
|
${CMAKE_BINARY_DIR}/packages/junit-jupiter-api-5.7.1.jar
|
||||||
${CMAKE_BINARY_DIR}/packages/junit-jupiter-engine-5.7.1.jar
|
${CMAKE_BINARY_DIR}/packages/junit-jupiter-engine-5.7.1.jar
|
||||||
|
@ -359,10 +364,9 @@ if(NOT OPEN_FOR_IDE)
|
||||||
get_property(integration_jar_path TARGET fdb-integration PROPERTY JAR_FILE)
|
get_property(integration_jar_path TARGET fdb-integration PROPERTY JAR_FILE)
|
||||||
|
|
||||||
|
|
||||||
add_test(NAME java-integration
|
# add_fdbclient_test will set FDB_CLUSTER_FILE if it's not set already
|
||||||
COMMAND ${CMAKE_COMMAND}
|
add_fdbclient_test(NAME java-integration
|
||||||
-E env "FDB_CLUSTER_FILE=${PROJECT_BINARY_DIR}/fdb.cluster"
|
COMMAND ${Java_JAVA_EXECUTABLE}
|
||||||
${Java_JAVA_EXECUTABLE}
|
|
||||||
-classpath "${target_jar}:${integration_jar_path}:${JUNIT_CLASSPATH}"
|
-classpath "${target_jar}:${integration_jar_path}:${JUNIT_CLASSPATH}"
|
||||||
-Djava.library.path=${CMAKE_BINARY_DIR}/lib
|
-Djava.library.path=${CMAKE_BINARY_DIR}/lib
|
||||||
org.junit.platform.console.ConsoleLauncher "--details=summary" "--class-path=${integration_jar_path}" "--scan-classpath" "--disable-banner"
|
org.junit.platform.console.ConsoleLauncher "--details=summary" "--class-path=${integration_jar_path}" "--scan-classpath" "--disable-banner"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
@ -52,6 +53,8 @@ if __name__ == '__main__':
|
||||||
- All occurrences of @DATA_DIR@ will be replaced with the path to the data directory.
|
- All occurrences of @DATA_DIR@ will be replaced with the path to the data directory.
|
||||||
- All occurrences of @LOG_DIR@ will be replaced with the path to the log directory.
|
- All occurrences of @LOG_DIR@ will be replaced with the path to the log directory.
|
||||||
- All occurrences of @ETC_DIR@ will be replaced with the path to the configuration directory.
|
- All occurrences of @ETC_DIR@ will be replaced with the path to the configuration directory.
|
||||||
|
|
||||||
|
The environment variable FDB_CLUSTER_FILE is set to the generated cluster for the command if it is not set already.
|
||||||
""")
|
""")
|
||||||
parser.add_argument('--build-dir', '-b', metavar='BUILD_DIRECTORY', help='FDB build directory', required=True)
|
parser.add_argument('--build-dir', '-b', metavar='BUILD_DIRECTORY', help='FDB build directory', required=True)
|
||||||
parser.add_argument('cmd', metavar="COMMAND", nargs="+", help="The command to run")
|
parser.add_argument('cmd', metavar="COMMAND", nargs="+", help="The command to run")
|
||||||
|
@ -74,5 +77,7 @@ if __name__ == '__main__':
|
||||||
cmd_args.append(str(cluster.etc))
|
cmd_args.append(str(cluster.etc))
|
||||||
else:
|
else:
|
||||||
cmd_args.append(cmd)
|
cmd_args.append(cmd)
|
||||||
errcode = subprocess.run(cmd_args, stdout=sys.stdout, stderr=sys.stderr).returncode
|
env = dict(**os.environ)
|
||||||
|
env['FDB_CLUSTER_FILE'] = env.get('FDB_CLUSTER_FILE', cluster.etc.joinpath('fdb.cluster'))
|
||||||
|
errcode = subprocess.run(cmd_args, stdout=sys.stdout, stderr=sys.stderr, env=env).returncode
|
||||||
sys.exit(errcode)
|
sys.exit(errcode)
|
||||||
|
|
Loading…
Reference in New Issue