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

ci: import braft actions #274

Merged
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
58 changes: 58 additions & 0 deletions .github/workflows/import_braft.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions cmake/braft.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
16 changes: 8 additions & 8 deletions src/cmd_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
*/

#include "cmd_admin.h"
#include "store.h"
#include "braft/raft.h"
#include "praft.h"

#include "praft/praft.h"

namespace pikiwidb {

Expand Down Expand Up @@ -80,7 +79,7 @@ void SelectCmd::DoCmd(PClient* client) {
client->SetRes(CmdRes::kOK);
}

InfoCmd::InfoCmd(const std::string& name, int16_t arity)
InfoCmd::InfoCmd(const std::string& name, int16_t arity)
: BaseCmd(name, arity, kCmdFlagsAdmin | kCmdFlagsReadonly, kAclCategoryAdmin) {}

bool InfoCmd::DoInitial(PClient* client) { return true; }
Expand Down Expand Up @@ -127,7 +126,7 @@ void InfoCmd::DoCmd(PClient* client) {
message += "raft_state:up\r\n";
} else {
message += "raft_state:down\r\n";
}
}
message += "raft_role:" + std::string(braft::state2str(node_status.state)) + "\r\n";
// message += "raft_is_voting:" + node_status.is_voting + "\r\n";
message += "raft_leader_id:" + node_status.leader_id.to_string() + "\r\n";
Expand All @@ -141,9 +140,10 @@ void InfoCmd::DoCmd(PClient* client) {
if (!status.ok()) {
return client->SetRes(CmdRes::kErrOther, status.error_str());
}

for (int i = 0; i < peers.size(); i++) {
message += "raft_node" + std::to_string(i) + ":addr=" + butil::ip2str(peers[i].addr.ip).c_str() + ",port=" + std::to_string(peers[i].addr.port) + "\r\n";
message += "raft_node" + std::to_string(i) + ":addr=" + butil::ip2str(peers[i].addr.ip).c_str() +
",port=" + std::to_string(peers[i].addr.port) + "\r\n";
}
}

Expand All @@ -153,4 +153,4 @@ void InfoCmd::DoCmd(PClient* client) {
}
}

} // namespace pikiwidb
} // namespace pikiwidb
12 changes: 6 additions & 6 deletions src/cmd_admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ class SelectCmd : public BaseCmd {
};

class InfoCmd : public BaseCmd {
public:
InfoCmd(const std::string& name, int16_t arity);
public:
InfoCmd(const std::string& name, int16_t arity);

protected:
bool DoInitial(PClient* client) override;
protected:
bool DoInitial(PClient* client) override;

private:
void DoCmd(PClient* client) override;
private:
void DoCmd(PClient* client) override;
};

} // namespace pikiwidb
2 changes: 1 addition & 1 deletion src/cmd_raft.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace pikiwidb {
* :<new node id>
* :<dbid>
*
* RAFT.NODE REMOVE [id]
* RAFT.NODE REMOVE [id]
* Remove an existing node from the cluster.
* Reply:
* -NOCLUSTER ||
Expand Down
7 changes: 3 additions & 4 deletions src/cmd_table_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/

#include <memory>
#include "cmd_table_manager.h"

#include "cmd_admin.h"
#include "cmd_hash.h"
#include "cmd_keys.h"
#include "cmd_kv.h"
#include "cmd_list.h"
#include "cmd_set.h"
#include "cmd_raft.h"
#include "cmd_table_manager.h"
#include "cmd_set.h"
#include "cmd_zset.h"

namespace pikiwidb {
Expand Down Expand Up @@ -46,7 +45,7 @@ void CmdTableManager::InitCmdTable() {

// info
ADD_COMMAND(Info, -1);

// raft
ADD_COMMAND(RaftCluster, -1);
ADD_COMMAND(RaftNode, -2);
Expand Down
2 changes: 1 addition & 1 deletion src/pikiwidb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include <thread>

#include "praft/praft.h"
#include "pstd/pstd_util.h"
#include "pstd/log.h"
#include "pstd/pstd_util.h"

#include "client.h"
#include "config.h"
Expand Down
1 change: 1 addition & 0 deletions src/storage/src/log_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#pragma once

#include <array>
#include <atomic>
#include <deque>
#include <functional>
Expand Down
Loading