]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/net: add Connection::is_closed() for tests
authorYingxin Cheng <yingxin.cheng@intel.com>
Mon, 26 Aug 2019 03:35:55 +0000 (11:35 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Wed, 28 Aug 2019 02:16:39 +0000 (10:16 +0800)
Tests need to introspect whether the connection is closed correctly.
For normal users, ms_handle_reset() will notify them when a connection is
closed by messenger.

Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/net/Connection.h
src/crimson/net/Protocol.h
src/crimson/net/SocketConnection.cc
src/crimson/net/SocketConnection.h

index 328aca570d52808fdc1ab1f344271fd4b29a1ef0..66dbb1dd6690def4e4991f44149c8633236d96d2 100644 (file)
@@ -59,6 +59,10 @@ class Connection : public seastar::enable_shared_from_this<Connection> {
   /// true if the handshake has completed and no errors have been encountered
   virtual bool is_connected() const = 0;
 
+#ifdef UNIT_TESTS_BUILT
+  virtual bool is_closed() const = 0;
+#endif
+
   /// send a message over a connection that has completed its handshake
   virtual seastar::future<> send(MessageRef msg) = 0;
 
index f3a7443a12fd5ca6db9273e58aa0962c3139faa0..84c5f1f470c673653b753855239d4aece3628420 100644 (file)
@@ -24,6 +24,8 @@ class Protocol {
 
   bool is_connected() const;
 
+  bool is_closed() const { return closed; }
+
   // Reentrant closing
   seastar::future<> close();
 
index 452754b3a5532e6618202d5a3abe02453b8ca3d3..4d78cb13dfd9d45989fef96da8ae1183e905e4f3 100644 (file)
@@ -47,6 +47,14 @@ bool SocketConnection::is_connected() const
   return protocol->is_connected();
 }
 
+#ifdef UNIT_TESTS_BUILT
+bool SocketConnection::is_closed() const
+{
+  ceph_assert(seastar::engine().cpu_id() == shard_id());
+  return protocol->is_closed();
+}
+#endif
+
 seastar::future<> SocketConnection::send(MessageRef msg)
 {
   // Cannot send msg from another core now, its ref counter can be contaminated!
index 183fc81d94a036fb2bdc2dc1da887ec27ddd3083..0c49f621b883f38de76d2a1063bc5d3108c95ad6 100644 (file)
@@ -81,6 +81,10 @@ class SocketConnection : public Connection {
 
   bool is_connected() const override;
 
+#ifdef UNIT_TESTS_BUILT
+  bool is_closed() const override;
+#endif
+
   seastar::future<> send(MessageRef msg) override;
 
   seastar::future<> keepalive() override;