You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2017/04/24 10:14:53 UTC
[7/7] mesos git commit: Hardened HTTP check tests.
Hardened HTTP check tests.
Introduce 1s delay to ensure the task (HTTP server) has enough time
to start and start serving request.
Review: https://reviews.apache.org/r/58194
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/12a01d92
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/12a01d92
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/12a01d92
Branch: refs/heads/master
Commit: 12a01d925b6c605d5a55f09634f7bced4beae0c9
Parents: 26e135d
Author: Alexander Rukletsov <al...@apache.org>
Authored: Wed Apr 5 00:04:27 2017 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Mon Apr 24 12:06:24 2017 +0200
----------------------------------------------------------------------
src/tests/check_tests.cpp | 58 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 55 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/12a01d92/src/tests/check_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/check_tests.cpp b/src/tests/check_tests.cpp
index 67ca6fb..ec0d5ee 100644
--- a/src/tests/check_tests.cpp
+++ b/src/tests/check_tests.cpp
@@ -113,7 +113,7 @@ namespace tests {
#endif // !__WINDOWS__
-// Tests for checks support in built in executors. Logically the tests
+// Tests for checks support in built-in executors. Logically the tests
// are elements of the cartesian product `executor-type` x `check-type`
// and are split into groups by `executor-type`:
// * command executor tests,
@@ -860,7 +860,33 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(CommandExecutorCheckTest, HTTPCheckDelivered)
EXPECT_EQ(taskInfo.task_id(), checkResult.task_id());
EXPECT_TRUE(checkResult.has_check_status());
EXPECT_TRUE(checkResult.check_status().http().has_status_code());
- EXPECT_EQ(200, checkResult.check_status().http().status_code());
+
+ // Since it takes some time for the HTTP server to start serving requests,
+ // the first several HTTP checks may not return 200. However we still expect
+ // a successful HTTP check and hence an extra status update.
+ if (checkResult.check_status().http().status_code() != 200)
+ {
+ // Inject an expectation for the extra status update we expect.
+ Future<v1::scheduler::Event::Update> updateCheckResult2;
+ EXPECT_CALL(*scheduler, update(_, _))
+ .WillOnce(FutureArg<1>(&updateCheckResult2))
+ .RetiresOnSaturation();
+
+ // Acknowledge (to be able to get the next update).
+ acknowledge(&mesos, frameworkId, checkResult);
+
+ AWAIT_READY(updateCheckResult2);
+ const v1::TaskStatus& checkResult2 = updateCheckResult2->status();
+
+ ASSERT_EQ(TASK_RUNNING, checkResult2.state());
+ ASSERT_EQ(
+ v1::TaskStatus::REASON_TASK_CHECK_STATUS_UPDATED,
+ checkResult2.reason());
+ EXPECT_EQ(taskInfo.task_id(), checkResult2.task_id());
+ EXPECT_TRUE(checkResult2.has_check_status());
+ EXPECT_TRUE(checkResult2.check_status().http().has_status_code());
+ EXPECT_EQ(200, checkResult2.check_status().http().status_code());
+ }
}
@@ -1849,7 +1875,33 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(DefaultExecutorCheckTest, HTTPCheckDelivered)
EXPECT_EQ(taskInfo.task_id(), checkResult.task_id());
EXPECT_TRUE(checkResult.has_check_status());
EXPECT_TRUE(checkResult.check_status().http().has_status_code());
- EXPECT_EQ(200, checkResult.check_status().http().status_code());
+
+ // Since it takes some time for the HTTP server to start serving requests,
+ // the first several HTTP checks may not return 200. However we still expect
+ // a successful HTTP check and hence an extra status update.
+ if (checkResult.check_status().http().status_code() != 200)
+ {
+ // Inject an expectation for the extra status update we expect.
+ Future<v1::scheduler::Event::Update> updateCheckResult2;
+ EXPECT_CALL(*scheduler, update(_, _))
+ .WillOnce(FutureArg<1>(&updateCheckResult2))
+ .RetiresOnSaturation();
+
+ // Acknowledge (to be able to get the next update).
+ acknowledge(&mesos, frameworkId, checkResult);
+
+ AWAIT_READY(updateCheckResult2);
+ const v1::TaskStatus& checkResult2 = updateCheckResult2->status();
+
+ ASSERT_EQ(TASK_RUNNING, checkResult2.state());
+ ASSERT_EQ(
+ v1::TaskStatus::REASON_TASK_CHECK_STATUS_UPDATED,
+ checkResult2.reason());
+ EXPECT_EQ(taskInfo.task_id(), checkResult2.task_id());
+ EXPECT_TRUE(checkResult2.has_check_status());
+ EXPECT_TRUE(checkResult2.check_status().http().has_status_code());
+ EXPECT_EQ(200, checkResult2.check_status().http().status_code());
+ }
}