You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2016/08/30 21:24:46 UTC

[2/2] mesos git commit: Added 'HierarchicalAllocatorTest.ResourceMetricsUninitialized' test.

Added 'HierarchicalAllocatorTest.ResourceMetricsUninitialized' test.

To test the fix (https://reviews.apache.org/r/51529/) for a
CHECK failure in HierarchicalAllocatorProcess due to uninitialized
sorter pointers.

Review: https://reviews.apache.org/r/51528


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1364aa56
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1364aa56
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1364aa56

Branch: refs/heads/master
Commit: 1364aa5617743f052f25b278d9ba931b9bb806da
Parents: f4e9631
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Tue Aug 30 09:35:06 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Tue Aug 30 13:59:36 2016 -0700

----------------------------------------------------------------------
 src/tests/hierarchical_allocator_tests.cpp | 26 +++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1364aa56/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index ddd4869..ad0d6f8 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -2690,6 +2690,32 @@ TEST_F(HierarchicalAllocatorTest, ResourceMetrics)
 }
 
 
+// The allocator is not fully initialized until `allocator->initialize(...)`
+// is called (e.g., from `Master::initialize()` or
+// `HierarchicalAllocatorTestBase::initialize(...)`). This test
+// verifies that metrics collection works but returns empty results
+// when the allocator is uninitialized. In reality this can happen if
+// the metrics endpoint is polled before the master is initialized.
+TEST_F(HierarchicalAllocatorTest, ResourceMetricsUninitialized)
+{
+  JSON::Value metrics = Metrics();
+
+  JSON::Object expected;
+
+  // Nothing is added to the allocator or allocated.
+  expected.values = {
+      {"allocator/mesos/resources/cpus/total", 0},
+      {"allocator/mesos/resources/mem/total",  0},
+      {"allocator/mesos/resources/disk/total", 0},
+      {"allocator/mesos/resources/cpus/offered_or_allocated", 0},
+      {"allocator/mesos/resources/mem/offered_or_allocated",  0},
+      {"allocator/mesos/resources/disk/offered_or_allocated", 0},
+  };
+
+  EXPECT_TRUE(metrics.contains(expected));
+}
+
+
 // This test checks that the number of times the allocation
 // algorithm has run is correctly reflected in the metric.
 TEST_F(HierarchicalAllocatorTest, AllocationRunsMetric)