Skip to content

Commit

Permalink
Regist storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shylock-Hg committed Dec 29, 2021
1 parent 9c5cf59 commit c0531e3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ jobs:
ASAN_OPTIONS: fast_unwind_on_malloc=1
run: |
pushd build
# register storage to meta
./bin/regist_host --host=127.0.0.1:9779
ctest -j $(nproc) -E '\w*_ssl_test' --timeout 10000 --output-on-failure
make install
popd
Expand Down
13 changes: 13 additions & 0 deletions src/client/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ nebula_add_test(
${NEBULA_THIRD_PARTY_LIBRARIES}
)

nebula_add_test(
NAME
regist_host
SOURCES
RegistHost.cpp
OBJECTS
${NEBULA_CLIENT_OBJS}
$<TARGET_OBJECTS:nebula_common_obj>
$<TARGET_OBJECTS:nebula_graph_client_obj>
LIBRARIES
${NEBULA_THIRD_PARTY_LIBRARIES}
)

nebula_add_test(
NAME
session_ssl_test
Expand Down
36 changes: 36 additions & 0 deletions src/client/tests/RegistHost.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#include <common/Init.h>
#include <folly/Format.h>
#include <glog/logging.h>
#include <nebula/client/Config.h>
#include <nebula/client/ConnectionPool.h>
#include <nebula/client/Session.h>

#include <atomic>
#include <chrono>
#include <thread>

// Require a nebula server could access

DEFINE_string(host, "", "Register host address.");
DEFINE_string(server, "127.0.0.1:9669", "Nebula server address.");

int main(int argc, char** argv) {
nebula::init(&argc, &argv);
google::SetStderrLogging(google::INFO);

nebula::ConnectionPool pool;
nebula::Config c{10, 0, 300, 0, "", false};
pool.init({FLAGS_server}, c);
auto session = pool.getSession("root", "nebula");
CHECK(session.valid());

auto resp =
session.execute(folly::format("ADD HOSTS {} INTO NEW ZONE 'default_zone'", FLAGS_host).str());
CHECK_EQ(resp.errorCode, nebula::ErrorCode::SUCCEEDED) << *resp.errorMsg;
return 0;
}

0 comments on commit c0531e3

Please sign in to comment.