diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index adad237..badebfc 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -7,7 +7,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, macos-10.15, macos-11.0] + os: [ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11.0] etcd: [v3.2.26, v3.3.11, v3.4.13] steps: - uses: actions/checkout@v2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9784e16..b067cbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,8 +61,6 @@ if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror -Wno-string-compare -std=c++11") endif() -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) add_subdirectory(src) diff --git a/README.md b/README.md index 6fc79d0..1b621af 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ i.e., `ETCDCTL_API=3`. ### Supported OS environments + **Linux** - - Ubuntu 18.04, requires upgrade boost and grpc libraries. + - Ubuntu 18.04, requires upgrade grpc libraries (has been tested with 1.27.x). - Ubuntu 20.04 + **MacOS** - MacOS 10.15 diff --git a/etcd/KeepAlive.hpp b/etcd/KeepAlive.hpp index 9a90a5f..1bba3f1 100644 --- a/etcd/KeepAlive.hpp +++ b/etcd/KeepAlive.hpp @@ -6,7 +6,12 @@ #include "etcd/Client.hpp" #include "etcd/Response.hpp" +#include +#if BOOST_VERSION >= 106600 #include +#else +#include +#endif #include #include @@ -55,7 +60,11 @@ namespace etcd int ttl; int64_t lease_id; bool continue_next; +#if BOOST_VERSION >= 106600 boost::asio::io_context context; +#else + boost::asio::io_service context; +#endif std::unique_ptr keepalive_timer_; }; } diff --git a/src/KeepAlive.cpp b/src/KeepAlive.cpp index f15701a..3685260 100644 --- a/src/KeepAlive.cpp +++ b/src/KeepAlive.cpp @@ -1,3 +1,5 @@ +#include + #include "etcd/KeepAlive.hpp" #include "etcd/v3/AsyncLeaseAction.hpp" @@ -70,7 +72,7 @@ void etcd::KeepAlive::refresh() } #endif keepalive_timer_.reset(new boost::asio::steady_timer( - context, boost::asio::chrono::seconds(keepalive_ttl))); + context, std::chrono::seconds(keepalive_ttl))); keepalive_timer_->async_wait([this](const boost::system::error_code& error) { if (error) { #ifndef NDEBUG diff --git a/tst/WatcherTest.cpp b/tst/WatcherTest.cpp index 44edcda..625babd 100644 --- a/tst/WatcherTest.cpp +++ b/tst/WatcherTest.cpp @@ -32,17 +32,17 @@ TEST_CASE("create watcher with cancel") watcher_called = 0; etcd::Watcher watcher(etcd_uri, "/test", printResponse, true); - std::this_thread::sleep_for(std::chrono::seconds(1)); + std::this_thread::sleep_for(std::chrono::seconds(3)); etcd.set("/test/key", "42"); etcd.set("/test/key", "43"); etcd.rm("/test/key"); etcd.set("/test/key", "44"); - std::this_thread::sleep_for(std::chrono::seconds(1)); + std::this_thread::sleep_for(std::chrono::seconds(3)); CHECK(4 == watcher_called); watcher.Cancel(); etcd.set("/test/key", "50"); etcd.set("/test/key", "51"); - std::this_thread::sleep_for(std::chrono::seconds(1)); + std::this_thread::sleep_for(std::chrono::seconds(3)); CHECK(4 == watcher_called); etcd.rmdir("/test", true); @@ -57,11 +57,11 @@ TEST_CASE("create watcher") watcher_called = 0; { etcd::Watcher watcher(etcd_uri, "/test", printResponse, true); - std::this_thread::sleep_for(std::chrono::seconds(1)); + std::this_thread::sleep_for(std::chrono::seconds(3)); etcd.set("/test/key", "42"); etcd.set("/test/key", "43"); + std::this_thread::sleep_for(std::chrono::seconds(3)); } - CHECK(2 == watcher_called); etcd.rmdir("/test", true).error_code(); }