From 1e4850f62691ae5f8c71722f13ac5fe94f48b30b Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Mon, 23 May 2022 09:56:40 -0700 Subject: [PATCH] Java build: finish compiling before testing (etc) (#10034) Summary: Lack of ordering dependencies could lead to random build-linux-java failures with "Truncated class file" because tests started before compilation was finished. (Fix to java/Makefile) Also: * export SHA256_CMD to save copy-paste * Actually fail if Java sample build fails--which it was in CircleCI * Don't require Snappy for Java sample build (for more compatibility) * Remove check_all_python from jtest because it's running in `make check` builds in CircleCI Pull Request resolved: https://github.com/facebook/rocksdb/pull/10034 Test Plan: CI, some manual Reviewed By: jay-zhuang Differential Revision: D36596541 Pulled By: pdillinger fbshipit-source-id: 230d79db4b7ae93a366871ff09d0a88e8e1c8af3 --- Makefile | 10 +++++----- java/Makefile | 3 ++- java/samples/src/main/java/RocksDBSample.java | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 9cd3b70a3..8a4e3eb72 100644 --- a/Makefile +++ b/Makefile @@ -2064,6 +2064,7 @@ ifeq ($(PLATFORM), OS_OPENBSD) ROCKSDBJNILIB = librocksdbjni-openbsd$(ARCH).so ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-openbsd$(ARCH).jar endif +export SHA256_CMD zlib-$(ZLIB_VER).tar.gz: curl --fail --output zlib-$(ZLIB_VER).tar.gz --location ${ZLIB_DOWNLOAD_BASE}/zlib-$(ZLIB_VER).tar.gz @@ -2196,7 +2197,7 @@ JAR_CMD := jar endif endif rocksdbjavastatic_javalib: - cd java; SHA256_CMD='$(SHA256_CMD)' $(MAKE) javalib + cd java; $(MAKE) javalib rm -f java/target/$(ROCKSDBJNILIB) $(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC \ -o ./java/target/$(ROCKSDBJNILIB) $(ALL_JNI_NATIVE_SOURCES) \ @@ -2310,7 +2311,7 @@ rocksdbjava: $(LIB_OBJECTS) ifeq ($(JAVA_HOME),) $(error JAVA_HOME is not set) endif - $(AM_V_GEN)cd java; SHA256_CMD='$(SHA256_CMD)' $(MAKE) javalib; + $(AM_V_GEN)cd java; $(MAKE) javalib; $(AM_V_at)rm -f ./java/target/$(ROCKSDBJNILIB) $(AM_V_at)$(CXX) $(CXXFLAGS) -I./java/. -I./java/rocksjni $(JAVA_INCLUDE) $(ROCKSDB_PLUGIN_JNI_CXX_INCLUDEFLAGS) -shared -fPIC -o ./java/target/$(ROCKSDBJNILIB) $(ALL_JNI_NATIVE_SOURCES) $(LIB_OBJECTS) $(JAVA_LDFLAGS) $(COVERAGEFLAGS) $(AM_V_at)cd java; $(JAR_CMD) -cf target/$(ROCKSDB_JAR) HISTORY*.md @@ -2322,14 +2323,13 @@ jclean: cd java;$(MAKE) clean; jtest_compile: rocksdbjava - cd java; SHA256_CMD='$(SHA256_CMD)' $(MAKE) java_test + cd java;$(MAKE) java_test jtest_run: cd java;$(MAKE) run_test jtest: rocksdbjava - cd java;$(MAKE) sample; SHA256_CMD='$(SHA256_CMD)' $(MAKE) test; - $(PYTHON) tools/check_all_python.py # TODO peterd: find a better place for this check in CI targets + cd java;$(MAKE) sample test jdb_bench: cd java;$(MAKE) db_bench; diff --git a/java/Makefile b/java/Makefile index f580fda27..9a28abadf 100644 --- a/java/Makefile +++ b/java/Makefile @@ -437,7 +437,8 @@ java_test: java resolve_test_deps $(AM_V_at) $(JAVAC_CMD) $(JAVAC_ARGS) -cp $(MAIN_CLASSES):$(JAVA_TESTCLASSPATH) -h $(NATIVE_INCLUDE) -d $(TEST_CLASSES)\ $(TEST_SOURCES) -test: java java_test run_test +test: java java_test + $(MAKE) run_test run_test: $(JAVA_CMD) $(JAVA_ARGS) -Djava.library.path=target -cp "$(MAIN_CLASSES):$(TEST_CLASSES):$(JAVA_TESTCLASSPATH):target/*" org.rocksdb.test.RocksJunitRunner $(ALL_JAVA_TESTS) diff --git a/java/samples/src/main/java/RocksDBSample.java b/java/samples/src/main/java/RocksDBSample.java index 0637c1114..ea650b141 100644 --- a/java/samples/src/main/java/RocksDBSample.java +++ b/java/samples/src/main/java/RocksDBSample.java @@ -46,7 +46,7 @@ public class RocksDBSample { .setWriteBufferSize(8 * SizeUnit.KB) .setMaxWriteBufferNumber(3) .setMaxBackgroundJobs(10) - .setCompressionType(CompressionType.SNAPPY_COMPRESSION) + .setCompressionType(CompressionType.ZLIB_COMPRESSION) .setCompactionStyle(CompactionStyle.UNIVERSAL); } catch (final IllegalArgumentException e) { assert (false); @@ -56,7 +56,7 @@ public class RocksDBSample { assert (options.writeBufferSize() == 8 * SizeUnit.KB); assert (options.maxWriteBufferNumber() == 3); assert (options.maxBackgroundJobs() == 10); - assert (options.compressionType() == CompressionType.SNAPPY_COMPRESSION); + assert (options.compressionType() == CompressionType.ZLIB_COMPRESSION); assert (options.compactionStyle() == CompactionStyle.UNIVERSAL); assert (options.memTableFactoryName().equals("SkipListFactory"));