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

build: install openmldb with rpath #3373

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
46 changes: 38 additions & 8 deletions .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ env:
NPROC: 2 # default Parallel build number for GitHub's Linux runner
EXAMPLES_ENABLE: OFF # turn off hybridse's example code
HYBRIDSE_TESTING_ENABLE: OFF # turn off hybridse's test code
SPARK_HOME: /tmp/spark/

jobs:
java-sdk:
Expand All @@ -41,9 +42,8 @@ jobs:
image: ghcr.io/4paradigm/hybridsql:latest
env:
SQL_JAVASDK_ENABLE: ON
OPENMLDB_BUILD_TARGET: "cp_native_so openmldb"
OPENMLDB_BUILD_TARGET: "cp_native_so openmldb test_udf"
MAVEN_OPTS: -Duser.home=/github/home
SPARK_HOME: /tmp/spark/
steps:
- uses: actions/checkout@v2

Expand All @@ -59,7 +59,7 @@ jobs:
- name: Import GPG key
id: import_gpg
if: github.event_name == 'push'
uses: crazy-max/ghaction-import-gpg@v4
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}

Expand All @@ -82,6 +82,11 @@ jobs:
run: |
make build

- name: build taskmanager
working-directory: java
run: |
./mvnw package --batch-mode -DskipTests=true -Dscalatest.skip=true -Dwagon.skip=true -Dmaven.test.skip=true

- name: upload linux library
if: github.event_name == 'push'
uses: actions/upload-artifact@v2
Expand All @@ -95,7 +100,9 @@ jobs:
run: |
sh steps/ut_zookeeper.sh start
sh steps/download_openmldb_spark.sh $SPARK_HOME
cd onebox && sh start_onebox.sh && sh start_onebox.sh standalone && cd - || exit
./onebox/start_onebox.sh
./onebox/start_onebox.sh standalone
./onebox/start_onebox.sh taskmanager

- name: run java modules smoke test
working-directory: java
Expand Down Expand Up @@ -137,20 +144,18 @@ jobs:

- name: stop services
run: |
cd onebox && ./stop_all.sh && cd - || exit
./onebox/stop_all.sh
sh steps/ut_zookeeper.sh stop

java-sdk-mac:
# mac job for java sdk. steps are almost same with job 'java-sdk'
# except mvn deploy won't target all modules, just hybridse-native & openmldb-native
# the job only run on tag push or manual workflow dispatch due to no test runs
runs-on: macos-latest
needs:
- java-sdk
if: github.event_name == 'push'
env:
SQL_JAVASDK_ENABLE: ON
OPENMLDB_BUILD_TARGET: "cp_native_so openmldb"
OPENMLDB_BUILD_TARGET: "cp_native_so openmldb test_udf"
NPROC: 3
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -189,6 +194,7 @@ jobs:

- name: Import GPG key
id: import_gpg
if: github.event_name == 'push'
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
Expand All @@ -197,6 +203,30 @@ jobs:
run: |
make build

- name: build taskmanager
working-directory: java
run: |
./mvnw package --batch-mode -DskipTests=true -Dscalatest.skip=true -Dwagon.skip=true -Dmaven.test.skip=true

# ======================================== #
# MacOS Tests
# ======================================== #
- name: start services
run: |
sh steps/ut_zookeeper.sh start
sh steps/download_openmldb_spark.sh $SPARK_HOME
./onebox/start_onebox.sh
./onebox/start_onebox.sh standalone
./onebox/start_onebox.sh taskmanager

- name: run java modules smoke test
working-directory: java
run: |
./mvnw --batch-mode test

# ======================================== #
# Deploy java modules
# ======================================== #
- name: mvn deploy
working-directory: java
run: |
Expand Down
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required (VERSION 3.13)
# RPATH "$ORIGIN" tokens are properly escaped if policy CMP0095 ON, which requires cmake >= 3.16
cmake_minimum_required (VERSION 3.16)
if (POLICY CMP0068)
cmake_policy(SET CMP0068 NEW)
endif ()
Expand Down Expand Up @@ -97,6 +98,8 @@ option(COVERAGE_NO_DEPS "Coverage without test deps, should ensure test built" O
option(SANITIZER_ENABLE "Enable AddressSanitizer in Debug mode" OFF)
# add_library can reply on this variable
# see https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html#variable:BUILD_SHARED_LIBS
# WARN: installed binaries like openmldb may not runnable since the INSTALL_RPATH is not updated accordingly
# Solution: 1. update INSTALL_RPATH for install target 2. install dependent shared libraries
option(BUILD_SHARED_LIBS "Enable build shared Libraries instead static" OFF)
option(TESTING_ENABLE_STRIP "Strip test binary that may help reduce storage space" OFF)

Expand Down Expand Up @@ -140,6 +143,11 @@ include(farmhash)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(OS_LIB ${CMAKE_THREAD_LIBS_INIT} rt)
set(BRPC_LIBS ${BRPC_LIBRARY} ${Protobuf_LIBRARIES} ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${UNWIND_LIBRARY} ${OPENSSL_LIBRARIES} ${LEVELDB_LIBRARY} ${Z_LIBRARY} ${SNAPPY_LIBRARY} dl pthread ${OS_LIB})
# OPENMLDB_RPATH
# custom RPATH tag for necessary install binaries (like bin/openmldb)
# relative to binary location so any install location works, binary is
# by convention installed to 'bin/' directory, search to '<binary_dir>/../$LIB' and '<binary_dir>/../udf'
set(OPENMLDB_RPATH "$ORIGIN/../$LIB" "$ORIGIN/../udf")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(OS_LIB
${CMAKE_THREAD_LIBS_INIT}
Expand All @@ -153,6 +161,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop")
set(BRPC_LIBS ${BRPC_LIBRARY} ${Protobuf_LIBRARIES} ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${OPENSSL_LIBRARIES} ${LEVELDB_LIBRARY} ${Z_LIBRARY} ${SNAPPY_LIBRARY} dl pthread ${OS_LIB})
set(OPENMLDB_RPATH "@loader_path/../lib" "@loader_path/../udf")
endif ()

if (SANITIZER_ENABLE)
Expand Down Expand Up @@ -309,9 +318,9 @@ install(
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
)
install(
FILES ${OPENMLDB_SBINS}
DESTINATION sbin
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
FILES ${OPENMLDB_SBINS}
DESTINATION sbin
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
)
install(FILES ${OPENMLDB_CONFS} DESTINATION conf)
install(
Expand Down
2 changes: 1 addition & 1 deletion hybridse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.16)

if (POLICY CMP0068)
cmake_policy(SET CMP0068 NEW)
Expand Down
4 changes: 2 additions & 2 deletions hybridse/src/udf/dynamic_lib_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ base::Status DynamicLibManager::ExtractFunction(const std::string& name, bool is
}
}
if (!so_handle) {
void* handle = dlopen(file.c_str(), RTLD_LAZY);
void* handle = dlopen(file.c_str(), RTLD_LAZY | RTLD_LOCAL);
if (handle == nullptr) {
std::string err_msg;
err_msg = "can not open the dynamic library: " + file + ", error: " + dlerror() + ", try to use abs path";
Expand All @@ -57,7 +57,7 @@ base::Status DynamicLibManager::ExtractFunction(const std::string& name, bool is
return {common::kExternalUDFError, err_msg};
}

handle = dlopen(abs_path_buff, RTLD_LAZY);
handle = dlopen(abs_path_buff, RTLD_LAZY | RTLD_LOCAL);
if (handle == nullptr) {
err_msg.append("dlopen abs path failed, error: ").append(dlerror());
return {common::kExternalUDFError, err_msg};
Expand Down
2 changes: 1 addition & 1 deletion java/hybridse-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion java/openmldb-batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions java/openmldb-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -59,4 +59,4 @@
</dependency>
</dependencies>

</project>
</project>
11 changes: 9 additions & 2 deletions java/openmldb-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,21 @@
<version>2.17.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<scope>test</scope>
</dependency>


</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public void connection() {
connection = DriverManager.getConnection(
String.format("jdbc:openmldb:///%s?zk=%s&zkPath=%s&zkLogLevel=0", dbName, zk, zkPath));
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
Assert.fail("jdbc connection failed");
Assert.fail("jdbc connection failed", e);
}
}

Expand Down Expand Up @@ -162,8 +161,7 @@ public void testForPulsarConnector() throws SQLException {
deleteStatement.setInt(1, 1);
deleteStatement.execute();
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
Assert.fail("catched exception", e);
}

// useless but won't fail
Expand Down Expand Up @@ -227,8 +225,7 @@ public void testForKafkaConnector() throws SQLException {
.prepareStatement("DELETE FROM " + tableName + " WHERE c1=?");
preparedStatement.setInt(1, 1);
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
Assert.fail("catched exception", e);
}

// sink, catalog and schema patterns are always be null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ public void testRequest() {
ok = executor.dropDB(dbname);
Assert.assertTrue(ok);
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
Assert.fail("catched exception", e);
} finally {
try {
if (resultSet != null) {
Expand Down
Loading