]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/seastar/tests/unit/sharded_test.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / seastar / tests / unit / sharded_test.cc
index f243d7fc0ec1f8f919e22bc2ab42475e458b652d..25266f273ca4cdcc4a4ab24960b620cfe159c786 100644 (file)
@@ -50,6 +50,27 @@ SEASTAR_THREAD_TEST_CASE(invoke_on_during_stop_test) {
     s.stop().get();
 }
 
+class peering_counter : public peering_sharded_service<peering_counter> {
+public:
+    future<int> count() const {
+        return container().map_reduce(adder<int>(), [] (auto& pc) { return 1; });
+    }
+
+    future<int> count_from(int base) const {
+        return container().map_reduce0([] (auto& pc) { return 1; }, base, std::plus<int>());
+    }
+};
+
+SEASTAR_THREAD_TEST_CASE(test_const_map_reduces) {
+    sharded<peering_counter> c;
+    c.start().get();
+
+    BOOST_REQUIRE_EQUAL(c.local().count().get0(), smp::count);
+    BOOST_REQUIRE_EQUAL(c.local().count_from(1).get0(), smp::count + 1);
+
+    c.stop().get();
+}
+
 class mydata {
 public:
     int x = 1;