Skip to content

Commit

Permalink
chore(test): Allow running tests with epoll proactor (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
romange authored Oct 6, 2022
1 parent d93eb8a commit fbdfe58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cxx_link(dragonfly_lib dfly_transaction dfly_facade redis_lib strings_lib html_l
absl::random_random TRDP::jsoncons)

add_library(dfly_test_lib test_utils.cc)
cxx_link(dfly_test_lib dragonfly_lib facade_test gtest_main_ext)
cxx_link(dfly_test_lib dragonfly_lib epoll_fiber_lib facade_test gtest_main_ext)

cxx_test(dragonfly_test dfly_test_lib LABELS DFLY)
cxx_test(generic_family_test dfly_test_lib LABELS DFLY)
Expand Down
9 changes: 8 additions & 1 deletion src/server/test_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ extern "C" {
#include "base/stl_util.h"
#include "facade/dragonfly_connection.h"
#include "util/uring/uring_pool.h"
#include "util/epoll/epoll_pool.h"

using namespace std;

ABSL_DECLARE_FLAG(string, dbfilename);
ABSL_FLAG(bool, force_epoll, false, "If true, uses epoll api instead iouring to run tests");


namespace dfly {

Expand Down Expand Up @@ -123,7 +126,11 @@ void BaseFamilyTest::SetUpTestSuite() {
}

void BaseFamilyTest::SetUp() {
pp_.reset(new uring::UringPool(16, num_threads_));
if (absl::GetFlag(FLAGS_force_epoll)) {
pp_.reset(new epoll::EpollPool(num_threads_));
} else {
pp_.reset(new uring::UringPool(16, num_threads_));
}
pp_->Run();
service_.reset(new Service{pp_.get()});

Expand Down

0 comments on commit fbdfe58

Please sign in to comment.