You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2015/07/14 20:22:22 UTC
mesos git commit: Added test for passing total slave's resources in
ResourceUsage.
Repository: mesos
Updated Branches:
refs/heads/master 4de848281 -> 1b70debfd
Added test for passing total slave's resources in ResourceUsage.
Review: https://reviews.apache.org/r/36314
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1b70debf
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1b70debf
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1b70debf
Branch: refs/heads/master
Commit: 1b70debfda1b699359074f0d626c030d5089f5d6
Parents: 4de8482
Author: Bartek Plotka <bw...@gmail.com>
Authored: Tue Jul 14 11:22:05 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Jul 14 11:22:06 2015 -0700
----------------------------------------------------------------------
src/tests/slave_tests.cpp | 96 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/1b70debf/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index ea0ddf3..89cc7f6 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -2247,6 +2247,102 @@ TEST_F(SlaveTest, ExecutorEnvironmentVariables)
Shutdown();
}
+
+// This test verifies that the slave should properly show total slave
+// resources.
+TEST_F(SlaveTest, TotalSlaveResourcesIncludedInUsage)
+{
+ Try<PID<Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ TestContainerizer containerizer;
+ StandaloneMasterDetector detector(master.get());
+
+ slave::Flags flags = CreateSlaveFlags();
+ flags.resources = "cpus:2;mem:1024;disk:1024;ports:[31000-32000]";
+
+ MockSlave slave(flags, &detector, &containerizer);
+ spawn(slave);
+
+ Clock::pause();
+
+ // Wait for slave to be initialized.
+ Clock::settle();
+
+ // We expect that the slave will return ResourceUsage with
+ // total resources reported.
+ Future<ResourceUsage> usage = slave.usage();
+
+ AWAIT_READY(usage);
+
+ // Total resources should match the resources from flag.resources.
+ EXPECT_EQ(Resources(usage.get().total()),
+ Resources::parse(flags.resources.get()).get());
+
+ terminate(slave);
+ wait(slave);
+
+ Shutdown();
+}
+
+
+// This test verifies that the slave should properly show total slave
+// resources with checkpointed resources applied.
+TEST_F(SlaveTest, CheckpointedResourcesIncludedInUsage)
+{
+ Try<PID<Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ TestContainerizer containerizer;
+ StandaloneMasterDetector detector(master.get());
+
+ slave::Flags flags = CreateSlaveFlags();
+ flags.resources = "cpus:2;cpus(role1):3;mem:1024;disk:1024;disk(role1):64;"
+ "ports:[31000-32000]";
+
+ MockSlave slave(flags, &detector, &containerizer);
+ spawn(slave);
+
+ Clock::pause();
+
+ // Wait for slave to be initialized.
+ Clock::settle();
+
+ Resource dynamicReservation = Resources::parse("cpus", "1", "role1").get();
+ dynamicReservation.mutable_reservation()->CopyFrom(
+ createReservationInfo("principal"));
+
+ Resource persistentVolume = createPersistentVolume(
+ Megabytes(64),
+ "role1",
+ "id1",
+ "path1");
+
+ vector<Resource> checkpointedResources =
+ {dynamicReservation, persistentVolume};
+
+ // Add checkpointed resources.
+ slave.checkpointResources(checkpointedResources);
+
+ // We expect that the slave will return ResourceUsage with
+ // total and checkpointed slave resources reported.
+ Future<ResourceUsage> usage = slave.usage();
+
+ AWAIT_READY(usage);
+
+ Resources usageTotalResources(usage.get().total());
+
+ // Reported total field should contain persistent volumes and dynamic
+ // reservations.
+ EXPECT_EQ(usageTotalResources.persistentVolumes(), persistentVolume);
+ EXPECT_TRUE(usageTotalResources.contains(dynamicReservation));
+
+ terminate(slave);
+ wait(slave);
+
+ Shutdown();
+}
+
} // namespace tests {
} // namespace internal {
} // namespace mesos {