diff --git a/.github/workflows/import_braft.yml b/.github/workflows/import_braft.yml new file mode 100644 index 000000000..c0c01f3fe --- /dev/null +++ b/.github/workflows/import_braft.yml @@ -0,0 +1,58 @@ +name: Import BRaft Actions (Temporary) + +on: + push: + pull_request: + branches: [ "import-braft" ] + +jobs: + check_format: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: bash ci/build.sh + + - name: Check Format + working-directory: ${{ github.workspace }}/build + run: make check-format + + build_on_macos: + runs-on: macos-latest + needs: check_format + + steps: + - uses: actions/checkout@v4 + + - name: Build + env: + CPLUS_INCLUDE_PATH: /usr/local/opt/openssl/include + run: | + sh build.sh + + - name: Run Go E2E Tests + working-directory: ${{ github.workspace }}/build + run: | + cd ../tests + go mod tidy + go test ./pikiwidb_suite_test.go ./consistency_test.go -v + + build_on_ubuntu: + runs-on: ubuntu-latest + needs: check_format + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + bash build.sh + + - name: Run Go E2E Tests + working-directory: ${{ github.workspace }}/build + run: | + cd ../tests + go mod tidy + go test ./pikiwidb_suite_test.go ./consistency_test.go -v diff --git a/cmake/braft.cmake b/cmake/braft.cmake index 87aff68a1..43ea4a350 100644 --- a/cmake/braft.cmake +++ b/cmake/braft.cmake @@ -16,8 +16,8 @@ ExternalProject_Add( extern_braft ${EXTERNAL_PROJECT_LOG_ARGS} DEPENDS brpc - URL "https://github.com/baidu/braft/archive/v1.1.2.tar.gz" - URL_HASH SHA256=bb3705f61874f8488e616ae38464efdec1a20610ddd6cd82468adc814488f14e + URL "https://github.com/pikiwidb/braft/archive/refs/heads/stable.zip" + URL_HASH SHA256=e73831f9768ac57d07f01ed81a11c8368e259c25315a960c29a6422f31f42fd1 PREFIX ${BRAFT_SOURCES_DIR} UPDATE_COMMAND "" CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} diff --git a/src/client.h b/src/client.h index dc95d8c27..3cbc936a4 100644 --- a/src/client.h +++ b/src/client.h @@ -102,7 +102,6 @@ enum ClientFlag { kClientFlagMaster = (1 << 3), }; -class DB; struct PSlaveInfo; class PClient : public std::enable_shared_from_this, public CmdRes { @@ -250,4 +249,4 @@ class PClient : public std::enable_shared_from_this, public CmdRes { static thread_local PClient* s_current; }; -} // namespace pikiwidb \ No newline at end of file +} // namespace pikiwidb diff --git a/src/cmd_admin.cc b/src/cmd_admin.cc index 2ab195afc..d7aa678be 100644 --- a/src/cmd_admin.cc +++ b/src/cmd_admin.cc @@ -5,9 +5,10 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include "cmd_admin.h" #include "braft/raft.h" -#include "praft.h" + +#include "cmd_admin.h" +#include "praft/praft.h" #include "store.h" namespace pikiwidb { @@ -154,4 +155,4 @@ void InfoCmd::DoCmd(PClient* client) { } } -} // namespace pikiwidb \ No newline at end of file +} // namespace pikiwidb diff --git a/src/cmd_raft.cc b/src/cmd_raft.cc index 8b58e6684..64d3dd2cf 100644 --- a/src/cmd_raft.cc +++ b/src/cmd_raft.cc @@ -5,17 +5,19 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#include "cmd_raft.h" + #include #include #include +#include "net/event_loop.h" +#include "praft/praft.h" +#include "pstd/log.h" +#include "pstd/pstd_string.h" + #include "client.h" -#include "cmd_raft.h" -#include "event_loop.h" -#include "log.h" #include "pikiwidb.h" -#include "praft.h" -#include "pstd_string.h" namespace pikiwidb { @@ -36,10 +38,10 @@ void RaftNodeCmd::DoCmd(PClient* client) { DoCmdAdd(client); } else if (!strcasecmp(cmd.c_str(), "REMOVE")) { DoCmdRemove(client); - } else if (!strcasecmp(cmd.c_str(), "DSS")) { + } else if (!strcasecmp(cmd.c_str(), "DOSNAPSHOT")) { DoCmdSnapshot(client); } else { - client->SetRes(CmdRes::kErrOther, "RAFT.NODE supports ADD / REMOVE only"); + client->SetRes(CmdRes::kErrOther, "RAFT.NODE supports ADD / REMOVE / DOSNAPSHOT only"); } } @@ -180,4 +182,4 @@ void RaftClusterCmd::DoCmdJoin(PClient* client) { client->Clear(); } -} // namespace pikiwidb \ No newline at end of file +} // namespace pikiwidb diff --git a/src/cmd_raft.h b/src/cmd_raft.h index bf36467e2..abc42a685 100644 --- a/src/cmd_raft.h +++ b/src/cmd_raft.h @@ -79,4 +79,4 @@ class RaftClusterCmd : public BaseCmd { static constexpr std::string_view kJoinCmd = "JOIN"; }; -} // namespace pikiwidb \ No newline at end of file +} // namespace pikiwidb diff --git a/src/cmd_table_manager.cc b/src/cmd_table_manager.cc index e56299199..19bced6dc 100644 --- a/src/cmd_table_manager.cc +++ b/src/cmd_table_manager.cc @@ -5,6 +5,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#include "cmd_table_manager.h" + #include #include "cmd_admin.h" @@ -14,7 +16,6 @@ #include "cmd_list.h" #include "cmd_raft.h" #include "cmd_set.h" -#include "cmd_table_manager.h" #include "cmd_zset.h" namespace pikiwidb { diff --git a/src/db.cc b/src/db.cc index 2756047b8..02c9a8def 100644 --- a/src/db.cc +++ b/src/db.cc @@ -7,11 +7,10 @@ #include "db.h" -#include "praft/praft.h" -#include "pstd/log.h" - #include "checkpoint_manager.h" #include "config.h" +#include "praft/praft.h" +#include "pstd/log.h" extern pikiwidb::PConfig g_config; diff --git a/src/pikiwidb.cc b/src/pikiwidb.cc index 0b6558182..66b8bb326 100644 --- a/src/pikiwidb.cc +++ b/src/pikiwidb.cc @@ -8,6 +8,8 @@ // // PikiwiDB.cc +#include "pikiwidb.h" + #include #include #include @@ -21,7 +23,6 @@ #include "client.h" #include "config.h" #include "helper.h" -#include "pikiwidb.h" #include "pikiwidb_logo.h" #include "slow_log.h" #include "store.h" diff --git a/src/praft/praft.h b/src/praft/praft.h index 9e7c11a02..1670b2ccf 100644 --- a/src/praft/praft.h +++ b/src/praft/praft.h @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/src/storage/src/log_index.h b/src/storage/src/log_index.h index 44d486338..a2bfc9d40 100644 --- a/src/storage/src/log_index.h +++ b/src/storage/src/log_index.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include diff --git a/src/storage/src/storage.cc b/src/storage/src/storage.cc index 203ebc1bb..222045a13 100644 --- a/src/storage/src/storage.cc +++ b/src/storage/src/storage.cc @@ -125,7 +125,7 @@ Status Storage::CreateCheckpoint(const std::string& dump_path, int i) { // 3) Create a checkpoint std::unique_ptr checkpoint_guard(checkpoint); - s = checkpoint->CreateCheckpoint(tmp_dir, kFlush, nullptr); + s = checkpoint->CreateCheckpoint(tmp_dir, kNoFlush, nullptr); if (!s.ok()) { WARN("DB{}'s RocksDB {} create checkpoint failed!. Error: {}", db_id_, i, s.ToString()); return s; diff --git a/src/store.h b/src/store.h index e184d3123..3c60aee09 100644 --- a/src/store.h +++ b/src/store.h @@ -10,9 +10,9 @@ #define GLOG_NO_ABBREVIATED_SEVERITIES #include -#include #include #include + #include "db.h" namespace pikiwidb {