8000 [R2] Log Multiplexer by maierlars · Pull Request #14667 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

[R2] Log Multiplexer #14667

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use async mock log only when required.
  • Loading branch information
maierlars committed Aug 20, 2021
commit aa3e3f126b7530fb4cb115bab23af46cc752f2d5
4 changes: 2 additions & 2 deletions tests/Replication2/Streams/MultiplexerConcurrencyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ struct LogMultiplexerConcurrencyTest : LogMultiplexerTestBase {
};

TEST_F(LogMultiplexerConcurrencyTest, test) {
auto followerLog = createReplicatedLog(LogId{1});
auto leaderLog = createReplicatedLog(LogId{2});
auto followerLog = createAsyncReplicatedLog(LogId{1});
auto leaderLog = createAsyncReplicatedLog(LogId{2});

auto follower = followerLog->becomeFollower("follower", LogTerm{1}, "leader");
auto asyncFollower = std::make_shared<AsyncFollower>(follower);
Expand Down
24 changes: 14 additions & 10 deletions tests/Replication2/Streams/TestLogSpecification.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

#include <gtest/gtest.h>

#include <velocypack/Slice.h>
#include <velocypack/Builder.h>
#include <velocypack/Slice.h>

#include <Replication2/Streams/StreamSpecification.h>
#include <Replication2/Streams/LogMultiplexer.h>
#include <Replication2/Streams/StreamSpecification.h>

#include <Replication2/Mocks/FakeReplicatedLog.h>
#include <Replication2/Mocks/PersistedLog.h>
Expand All @@ -38,23 +38,28 @@ namespace arangodb::replication2::test {

struct LogMultiplexerTestBase : ::testing::Test {
static auto createReplicatedLog(LogId id = LogId{0})
-> std::shared_ptr<replication2::replicated_log::ReplicatedLog> {
return createReplicatedLogImpl<replicated_log::ReplicatedLog>(id);
-> std::shared_ptr<replication2::replicated_log::ReplicatedLog> {
return createReplicatedLogImpl<replicated_log::ReplicatedLog, test::MockLog>(id);
}

static auto createAsyncReplicatedLog(LogId id = LogId{0})
-> std::shared_ptr<replication2::replicated_log::ReplicatedLog> {
return createReplicatedLogImpl<replicated_log::ReplicatedLog, test::AsyncMockLog>(id);
}

static auto createFakeReplicatedLog(LogId id = LogId{0})
-> std::shared_ptr<replication2::test::TestReplicatedLog> {
return createReplicatedLogImpl<replication2::test::TestReplicatedLog>(id);
-> std::shared_ptr<replication2::test::TestReplicatedLog> {
return createReplicatedLogImpl<replication2::test::TestReplicatedLog, test::MockLog>(id);
}

private:
template <typename Impl>
template <typename Impl, typename MockLog>
static auto createReplicatedLogImpl(LogId id) -> std::shared_ptr<Impl> {
auto persisted = std::make_shared<test::MockLog>(id);
auto persisted = std::make_shared<MockLog>(id);
auto core = std::make_unique<replicated_log::LogCore>(persisted);
auto metrics = std::make_shared<ReplicatedLogMetricsMock>();
return std::make_shared<Impl>(std::move(core), metrics,
LoggerContext(Logger::REPLICATION2));
LoggerContext(Logger::REPLICATION2));
}
};

Expand All @@ -72,7 +77,6 @@ struct default_serializer {
}
};


inline constexpr auto my_int_stream_id = streams::StreamId{1};
inline constexpr auto my_string_stream_id = streams::StreamId{8};
inline constexpr auto my_string2_stream_id = streams::StreamId{9};
Expand Down
0