Skip to content
Merged
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
56 changes: 52 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ jobs:
run: |
case ${{ matrix.os }} in
centos7)
yum -y update && yum -y install gcc gcc-c++ libstdc++-static
sed -i 's|http://vault.centos.org/centos/$releasever/|https://vault.centos.org/7.9.2009/|g' /etc/yum.repos.d/CentOS-Base.repo
yum --disablerepo='*' --enablerepo=base,updates,extras -y install gcc gcc-c++ libstdc++-static
pushd examples
mkdir build
cmake \
Expand All @@ -156,14 +157,27 @@ jobs:
popd
;;
*)
export LD_LIBRARY_PATH=/usr/local/nebula/lib64:/usr/local/nebula/lib:$LD_LIBRARY_PATH
example_env=(env)
example_link_flags=()
case ${{ matrix.compiler }} in
clang-*)
asan_dir=$("$TOOLSET_CLANG_DIR/bin/clang++" -print-resource-dir)/lib/linux
asan_runtime="$asan_dir/libclang_rt.asan-$(uname -m).so"
test -f "$asan_runtime"
export LD_LIBRARY_PATH="$asan_dir:$LD_LIBRARY_PATH"
example_link_flags=("-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-rpath-link,$asan_dir")
example_env+=("LD_PRELOAD=$asan_runtime" "ASAN_OPTIONS=fast_unwind_on_malloc=1")
;;
esac
pushd examples
mkdir build
cmake -B build
cmake "${example_link_flags[@]}" -B build
cmake --build build/ -j $(nproc)
rm /usr/lib/x86_64-linux-gnu/libstdc++.so.6
ln -s /opt/vesoft/toolset/clang/10.0.0/lib64/libstdc++.so /usr/lib/x86_64-linux-gnu/libstdc++.so.6
LD_LIBRARY_PATH=/usr/local/nebula/lib64:/usr/local/nebula/lib:$LD_LIBRARY_PATH ./build/session_example graphd:9669
LD_LIBRARY_PATH=/usr/local/nebula/lib64:/usr/local/nebula/lib:$LD_LIBRARY_PATH ./build/session_pool_example graphd:9669
"${example_env[@]}" ./build/session_example graphd:9669
"${example_env[@]}" ./build/session_pool_example graphd:9669
popd
;;
esac
Expand Down Expand Up @@ -202,6 +216,23 @@ jobs:
options: --mount type=tmpfs,destination=/tmp/ccache/nebula-graph,tmpfs-size=1073741824 --cap-add=SYS_PTRACE
steps:
- uses: actions/checkout@v4
- name: Generate SSL test certificates
run: |
printf 'vesoft' > certs/test.ca.password
openssl genrsa -aes256 -passout file:certs/test.ca.password -out certs/test.ca.key 2048
openssl req -x509 -new -sha256 -days 3650 \
-key certs/test.ca.key -passin file:certs/test.ca.password \
-subj '/CN=Nebula Test CA' -out certs/test.ca.pem
openssl genrsa -out certs/test.derive.key 2048
openssl req -new -key certs/test.derive.key \
-subj '/CN=Nebula Test Server' -out certs/test.derive.csr
openssl x509 -req -sha256 -days 3650 -in certs/test.derive.csr \
-CA certs/test.ca.pem -CAkey certs/test.ca.key \
-passin file:certs/test.ca.password -CAcreateserial \
-out certs/test.derive.crt
openssl req -x509 -newkey rsa:2048 -nodes -sha256 -days 3650 \
-keyout certs/test.2.key -subj '/CN=Nebula Untrusted Test CA' \
-out certs/test.2.crt
- name: CMake
run: |
case ${{ matrix.compiler }} in
Expand Down Expand Up @@ -324,6 +355,23 @@ jobs:
options: --mount type=tmpfs,destination=/tmp/ccache/nebula-graph,tmpfs-size=1073741824 --cap-add=SYS_PTRACE
steps:
- uses: actions/checkout@v4
- name: Generate SSL test certificates
run: |
printf 'vesoft' > certs/test.ca.password
openssl genrsa -aes256 -passout file:certs/test.ca.password -out certs/test.ca.key 2048
openssl req -x509 -new -sha256 -days 3650 \
-key certs/test.ca.key -passin file:certs/test.ca.password \
-subj '/CN=Nebula Test CA' -out certs/test.ca.pem
openssl genrsa -out certs/test.derive.key 2048
openssl req -new -key certs/test.derive.key \
-subj '/CN=Nebula Test Server' -out certs/test.derive.csr
openssl x509 -req -sha256 -days 3650 -in certs/test.derive.csr \
-CA certs/test.ca.pem -CAkey certs/test.ca.key \
-passin file:certs/test.ca.password -CAcreateserial \
-out certs/test.derive.crt
openssl req -x509 -newkey rsa:2048 -nodes -sha256 -days 3650 \
-keyout certs/test.2.key -subj '/CN=Nebula Untrusted Test CA' \
-out certs/test.2.crt
- name: CMake
run: |
case ${{ matrix.compiler }} in
Expand Down
10 changes: 5 additions & 5 deletions cmake/nebula/GeneralCompilerConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-Wno-self-move)
add_compile_options(-Wno-format-pedantic)
add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)
set(libatomic_link_flags "-Wl,-Bstatic -latomic -Wl,-Bdynamic")
set(CMAKE_REQUIRED_FLAGS "${libatomic_link_flags}")
check_cxx_compiler_flag("${libatomic_link_flags}" has_static_libatomic)
if(NOT has_static_libatomic)
set(libatomic_link_flags "-latomic")
# The toolchain's static libatomic may contain non-PIC code.
find_library(NEBULA_LIBATOMIC_LIBRARY NAMES libatomic.so.1)
Comment thread
xiajingchun marked this conversation as resolved.
Resolved
if(NOT NEBULA_LIBATOMIC_LIBRARY)
message(FATAL_ERROR "Clang requires shared libatomic (libatomic.so.1)")
endif()
set(libatomic_link_flags "${NEBULA_LIBATOMIC_LIBRARY}")
endif()
4 changes: 4 additions & 0 deletions cmake/nebula/SanitizerConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ if(ENABLE_ASAN)
add_compile_options(-g)
add_compile_options(-fno-omit-frame-pointer)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address -shared-libasan")
Comment thread
xiajingchun marked this conversation as resolved.
Resolved
endif()
endif()

if(ENABLE_TSAN)
Expand Down
13 changes: 13 additions & 0 deletions examples/SessionPoolExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ int main(int argc, char* argv[]) {
auto resp = session.execute(
"CREATE SPACE IF NOT EXISTS session_pool_test(vid_type = FIXED_STRING(16));");
assert(resp.errorCode == nebula::ErrorCode::SUCCEEDED);

// Wait for the new space to reach graphd before initializing the session pool.
for (int attempt = 0; attempt < 60; ++attempt) {
resp = session.execute("USE session_pool_test");
if (resp.errorCode == nebula::ErrorCode::SUCCEEDED) {
break;
}
std::this_thread::sleep_for(std::chrono::seconds(1));
}
if (resp.errorCode != nebula::ErrorCode::SUCCEEDED) {
std::cerr << "Space session_pool_test is not ready: " << *resp.errorMsg << std::endl;
return 1;
}
}

nebula::SessionPoolConfig config;
Expand Down
2 changes: 1 addition & 1 deletion include/nebula/client/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Session {
void release();

bool valid() const {
return sessionId_ > 0;
return sessionId_ != -1;
}

const std::string &timeZoneName() const {
Expand Down
3 changes: 2 additions & 1 deletion src/client/tests/ConnectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ TEST_F(ConnectionTest, Timeout) {
c.execute(*authResp.sessionId,
"SHOW QUERIES "
"| YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur "
"WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS 'GO' "
"WHERE $-.DurationInUSec > 1000000 "
"AND $-.`Query` STARTS WITH 'use conn_test;GO 100000 STEPS' "
"| ORDER BY $-.dur "
"| KILL QUERY(session=$-.sid, plan=$-.eid)");
ASSERT_EQ(resp.errorCode, nebula::ErrorCode::SUCCEEDED);
Expand Down
3 changes: 2 additions & 1 deletion src/client/tests/SessionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ TEST_F(SessionTest, Timeout) {
resp = session.execute(
"SHOW QUERIES "
"| YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur "
"WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS 'GO' "
"WHERE $-.DurationInUSec > 1000000 "
"AND $-.`Query` STARTS WITH 'use session_test;GO 100000 STEPS' "
"| ORDER BY $-.dur "
"| KILL QUERY(session=$-.sid, plan=$-.eid)");
ASSERT_EQ(resp.errorCode, nebula::ErrorCode::SUCCEEDED);
Expand Down
Loading