You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2014/01/23 00:09:09 UTC
[2/2] git commit: Added a test that verifies a non-voting replica
does not reply to promise/write requests.
Added a test that verifies a non-voting replica does not reply to
promise/write requests.
From: Jie Yu <yu...@gmail.com>
Review: https://reviews.apache.org/r/17203
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/de412dba
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/de412dba
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/de412dba
Branch: refs/heads/bmahler_subprocess
Commit: de412dba1b90dee3b1f55f6646120e008fadc793
Parents: 3960b20
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Wed Jan 22 15:08:26 2014 -0800
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Wed Jan 22 15:08:26 2014 -0800
----------------------------------------------------------------------
src/tests/log_tests.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/de412dba/src/tests/log_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/log_tests.cpp b/src/tests/log_tests.cpp
index 046e96f..e493af4 100644
--- a/src/tests/log_tests.cpp
+++ b/src/tests/log_tests.cpp
@@ -323,6 +323,49 @@ TEST_F(ReplicaTest, Restore)
}
+// This test verifies that a non-VOTING replica does not reply to
+// promise or write requests.
+TEST_F(ReplicaTest, NonVoting)
+{
+ const string path = os::getcwd() + "/.log";
+
+ Replica replica(path);
+
+ PromiseRequest promiseRequest;
+ promiseRequest.set_proposal(2);
+
+ Future<PromiseResponse> promiseResponse =
+ protocol::promise(replica.pid(), promiseRequest);
+
+ // Flush the event queue to make sure that if the replica could
+ // reply to the promise request, the future 'promiseResponse' would
+ // be satisfied before the pending check below.
+ Clock::pause();
+ Clock::settle();
+ Clock::resume();
+
+ EXPECT_TRUE(promiseResponse.isPending());
+
+ WriteRequest writeRequest;
+ writeRequest.set_proposal(3);
+ writeRequest.set_position(1);
+ writeRequest.set_type(Action::APPEND);
+ writeRequest.mutable_append()->set_bytes("hello world");
+
+ Future<WriteResponse> writeResponse =
+ protocol::write(replica.pid(), writeRequest);
+
+ // Flush the event queue to make sure that if the replica could
+ // reply to the write request, the future 'writeResponse' would be
+ // satisfied before the pending check below.
+ Clock::pause();
+ Clock::settle();
+ Clock::resume();
+
+ EXPECT_TRUE(writeResponse.isPending());
+}
+
+
class CoordinatorTest : public TemporaryDirectoryTest
{
protected: