You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by dm...@apache.org on 2015/02/25 20:51:29 UTC
mesos git commit: Resolve TODO and remove METRICS_SNAPSHOT macro
Repository: mesos
Updated Branches:
refs/heads/master 7c0770b10 -> 68f54aa4e
Resolve TODO and remove METRICS_SNAPSHOT macro
Review: https://reviews.apache.org/r/31424
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/68f54aa4
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/68f54aa4
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/68f54aa4
Branch: refs/heads/master
Commit: 68f54aa4e3b5f938d3d7f610b91584e37376bbc8
Parents: 7c0770b
Author: Dominic Hamon <dm...@twitter.com>
Authored: Wed Feb 25 11:42:44 2015 -0800
Committer: Dominic Hamon <dm...@twitter.com>
Committed: Wed Feb 25 11:51:08 2015 -0800
----------------------------------------------------------------------
src/tests/mesos.hpp | 2 +-
src/tests/rate_limiting_tests.cpp | 55 ++++++++++++----------------------
2 files changed, 20 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/68f54aa4/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 6b9656b..14f5d39 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -181,7 +181,7 @@ protected:
virtual void ShutdownSlaves();
// Get the metrics snapshot.
- // TODO(vinod): Move this into "tests/utils.hpp".
+ // TODO(vinod): Move this into a libprocess "tests/utils.hpp".
JSON::Object Metrics() const;
Cluster cluster;
http://git-wip-us.apache.org/repos/asf/mesos/blob/68f54aa4/src/tests/rate_limiting_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/rate_limiting_tests.cpp b/src/tests/rate_limiting_tests.cpp
index e4fa8f0..c65001a 100644
--- a/src/tests/rate_limiting_tests.cpp
+++ b/src/tests/rate_limiting_tests.cpp
@@ -52,23 +52,6 @@ namespace mesos {
namespace internal {
namespace tests {
-// Query Mesos metrics snapshot endpoint and return a JSON::Object
-// result.
-// TODO(dhamon): Kill this in favour of Metrics() in mesos.hpp
-#define METRICS_SNAPSHOT \
- ({ Future<process::http::Response> response = \
- process::http::get(MetricsProcess::instance()->self(), "snapshot"); \
- AWAIT_READY(response); \
- \
- EXPECT_SOME_EQ( \
- "application/json", \
- response.get().headers.get("Content-Type")); \
- \
- Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body); \
- ASSERT_SOME(parse); \
- \
- parse.get(); })
-
// This test case covers tests related to framework API rate limiting
// which includes metrics exporting for API call rates.
@@ -123,7 +106,7 @@ TEST_F(RateLimitingTest, NoRateLimiting)
// Message counters not present before the framework registers.
{
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
EXPECT_EQ(
0u,
@@ -174,7 +157,7 @@ TEST_F(RateLimitingTest, NoRateLimiting)
// Verify that one message is received and processed (after
// registration).
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
const string& messages_received =
"frameworks/" + DEFAULT_CREDENTIAL.principal() + "/messages_received";
@@ -205,7 +188,7 @@ TEST_F(RateLimitingTest, NoRateLimiting)
// Message counters removed after the framework is unregistered.
{
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
EXPECT_EQ(
0u,
@@ -277,7 +260,7 @@ TEST_F(RateLimitingTest, RateLimitingEnabled)
// Verify that one message is received and processed (after
// registration).
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
const string& messages_received =
"frameworks/" + DEFAULT_CREDENTIAL.principal() + "/messages_received";
@@ -306,7 +289,7 @@ TEST_F(RateLimitingTest, RateLimitingEnabled)
Clock::settle();
{
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
const string& messages_received =
"frameworks/" + DEFAULT_CREDENTIAL.principal() + "/messages_received";
@@ -327,7 +310,7 @@ TEST_F(RateLimitingTest, RateLimitingEnabled)
AWAIT_READY(duplicateFrameworkRegisteredMessage);
// Verify counters after processing of the message.
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
const string& messages_received =
"frameworks/" + DEFAULT_CREDENTIAL.principal() + "/messages_received";
@@ -481,7 +464,7 @@ TEST_F(RateLimitingTest, DifferentPrincipalFrameworks)
{
// Verify counters also indicate that messages are received but
// not processed.
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
EXPECT_EQ(
1u, metrics.values.count("frameworks/framework1/messages_received"));
@@ -518,7 +501,7 @@ TEST_F(RateLimitingTest, DifferentPrincipalFrameworks)
// Framework1's message is processed and framework2's is not
// because it's throttled at a lower rate.
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
EXPECT_EQ(
2,
metrics.values["frameworks/framework1/messages_processed"]
@@ -536,7 +519,7 @@ TEST_F(RateLimitingTest, DifferentPrincipalFrameworks)
// 2. Counters confirm that both frameworks' messages are processed.
{
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
EXPECT_EQ(
1u, metrics.values.count("frameworks/framework1/messages_received"));
@@ -585,7 +568,7 @@ TEST_F(RateLimitingTest, DifferentPrincipalFrameworks)
// Advance for Metrics rate limiting.
Clock::advance(Milliseconds(501));
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
EXPECT_EQ(
0u, metrics.values.count("frameworks/framework1/messages_received"));
@@ -675,7 +658,7 @@ TEST_F(RateLimitingTest, SamePrincipalFrameworks)
// Message counters added after both frameworks are registered.
{
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
EXPECT_EQ(
1u,
@@ -713,7 +696,7 @@ TEST_F(RateLimitingTest, SamePrincipalFrameworks)
Clock::advance(Milliseconds(501));
{
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
// Two messages received and one processed.
const string& messages_received =
@@ -753,7 +736,7 @@ TEST_F(RateLimitingTest, SamePrincipalFrameworks)
Clock::advance(Milliseconds(501));
{
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
EXPECT_EQ(
1u,
@@ -834,7 +817,7 @@ TEST_F(RateLimitingTest, SchedulerFailover)
Clock::settle();
// Verify the message counters.
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
// One message received and processed after the framework is
// registered.
@@ -904,7 +887,7 @@ TEST_F(RateLimitingTest, SchedulerFailover)
Clock::advance(Milliseconds(501));
{
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
// Verify that counters correctly indicates the message is
// received but not processed.
@@ -928,7 +911,7 @@ TEST_F(RateLimitingTest, SchedulerFailover)
Clock::advance(Milliseconds(501));
{
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
// Another message after sched2 is reregistered plus the one from
// the sched1.
@@ -1020,7 +1003,7 @@ TEST_F(RateLimitingTest, CapacityReached)
// Verify that one message is received and processed (after
// registration).
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
const string& messages_received =
"frameworks/" + DEFAULT_CREDENTIAL.principal() + "/messages_received";
@@ -1075,7 +1058,7 @@ TEST_F(RateLimitingTest, CapacityReached)
Clock::advance(Milliseconds(501));
{
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
const string& messages_received =
"frameworks/" + DEFAULT_CREDENTIAL.principal() + "/messages_received";
@@ -1097,7 +1080,7 @@ TEST_F(RateLimitingTest, CapacityReached)
// Counters are not removed because the scheduler is not
// unregistered and the master expects it to failover.
- JSON::Object metrics = METRICS_SNAPSHOT;
+ JSON::Object metrics = Metrics();
const string& messages_received =
"frameworks/" + DEFAULT_CREDENTIAL.principal() + "/messages_received";