You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2013/03/04 23:27:02 UTC
svn commit: r1452570 - in /incubator/mesos/trunk/src: master/drf_sorter.cpp
tests/allocator_tests.cpp tests/gc_tests.cpp tests/master_tests.cpp
tests/utils.hpp
Author: vinodkone
Date: Mon Mar 4 22:27:02 2013
New Revision: 1452570
URL: http://svn.apache.org/r1452570
Log:
Fixed allocator, gc and master tests.
Review: https://reviews.apache.org/r/9690
Modified:
incubator/mesos/trunk/src/master/drf_sorter.cpp
incubator/mesos/trunk/src/tests/allocator_tests.cpp
incubator/mesos/trunk/src/tests/gc_tests.cpp
incubator/mesos/trunk/src/tests/master_tests.cpp
incubator/mesos/trunk/src/tests/utils.hpp
Modified: incubator/mesos/trunk/src/master/drf_sorter.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/drf_sorter.cpp?rev=1452570&r1=1452569&r2=1452570&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/drf_sorter.cpp (original)
+++ incubator/mesos/trunk/src/master/drf_sorter.cpp Mon Mar 4 22:27:02 2013
@@ -200,13 +200,15 @@ double DRFSorter::calculateShare(const s
if (resource.type() == Value::SCALAR) {
double total = resource.scalar().value();
- if (total > 0) {
- Value::Scalar none;
- const Value::Scalar& scalar = allocations[name].get(resource.name(), none);
- share = std::max(share, scalar.value() / total);
- }
+ if (total > 0) {
+ Value::Scalar none;
+ const Value::Scalar& scalar =
+ allocations[name].get(resource.name(), none);
+
+ share = std::max(share, scalar.value() / total);
}
}
+}
return share;
}
Modified: incubator/mesos/trunk/src/tests/allocator_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/allocator_tests.cpp?rev=1452570&r1=1452569&r2=1452570&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/allocator_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/allocator_tests.cpp Mon Mar 4 22:27:02 2013
@@ -154,8 +154,10 @@ TEST_F(DRFAllocatorTest, DRFAllocatorPro
Master m(&a, &files);
PID<Master> master = process::spawn(m);
- ProcessBasedIsolationModule isolationModule;
+ map<ExecutorID, Executor*> execs;
+ TestingIsolationModule isolationModule(execs);
+ setSlaveResources("cpus:2;mem:1024;disk:0");
Slave s(slaveFlags, true, &isolationModule, &files);
PID<Slave> slave1 = process::spawn(s);
@@ -197,7 +199,7 @@ TEST_F(DRFAllocatorTest, DRFAllocatorPro
WAIT_UNTIL(framework2Added);
- setSlaveResources("cpus:1;mem:512");
+ setSlaveResources("cpus:1;mem:512;disk:0");
Slave s2(slaveFlags, true, &isolationModule, &files);
PID<Slave> slave2 = process::spawn(s2);
@@ -207,7 +209,7 @@ TEST_F(DRFAllocatorTest, DRFAllocatorPro
EXPECT_THAT(offers2, OfferEq(1, 512));
- setSlaveResources("cpus:3;mem:2048");
+ setSlaveResources("cpus:3;mem:2048;disk:0");
Slave s3(slaveFlags, true, &isolationModule, &files);
PID<Slave> slave3 = process::spawn(s3);
BasicMasterDetector detector3(master, slave3, true);
@@ -231,7 +233,7 @@ TEST_F(DRFAllocatorTest, DRFAllocatorPro
WAIT_UNTIL(framework3Added);
- setSlaveResources("cpus:4;mem:4096");
+ setSlaveResources("cpus:4;mem:4096;disk:0");
Slave s4(slaveFlags, true, &isolationModule, &files);
PID<Slave> slave4 = process::spawn(s4);
BasicMasterDetector detector4(master, slave4, true);
@@ -316,7 +318,11 @@ TYPED_TEST(AllocatorTest, MockAllocator)
Master m(this->a, &files);
PID<Master> master = process::spawn(&m);
- ProcessBasedIsolationModule isolationModule;
+ MockExecutor exec;
+ map<ExecutorID, Executor*> execs;
+ execs[DEFAULT_EXECUTOR_ID] = &exec;
+
+ TestingIsolationModule isolationModule(execs);
Slave s(this->slaveFlags, true, &isolationModule, &files);
PID<Slave> slave = process::spawn(&s);
@@ -393,7 +399,16 @@ TYPED_TEST(AllocatorTest, ResourcesUnuse
Master m(this->a, &files);
PID<Master> master = process::spawn(m);
- ProcessBasedIsolationModule isolationModule;
+ MockExecutor exec;
+ trigger shutdownCall;
+
+ EXPECT_CALL(exec, shutdown(_))
+ .WillOnce(Trigger(&shutdownCall));
+
+ map<ExecutorID, Executor*> execs;
+ execs[DEFAULT_EXECUTOR_ID] = &exec;
+
+ TestingIsolationModule isolationModule(execs);
Slave s(this->slaveFlags, true, &isolationModule, &files);
PID<Slave> slave1 = process::spawn(s);
@@ -438,6 +453,8 @@ TYPED_TEST(AllocatorTest, ResourcesUnuse
WAIT_UNTIL(frameworkRemovedTrigger);
+ WAIT_UNTIL(shutdownCall); // Ensures MockExecutor can be deallocated.
+
process::terminate(slave1);
process::wait(slave1);
@@ -506,7 +523,9 @@ TYPED_TEST(AllocatorTest, OutOfOrderDisp
Master m(this->a, &files);
PID<Master> master = process::spawn(&m);
- ProcessBasedIsolationModule isolationModule;
+ map<ExecutorID, Executor*> execs;
+
+ TestingIsolationModule isolationModule(execs);
Slave s(this->slaveFlags, true, &isolationModule, &files);
PID<Slave> slave = process::spawn(&s);
@@ -930,7 +949,7 @@ TYPED_TEST(AllocatorTest, SlaveLost)
WAIT_UNTIL(slaveRemovedTrigger1);
- ProcessBasedIsolationModule isolationModule2;
+ TestingIsolationModule isolationModule2(execs);
this->setSlaveResources("cpus:3;mem:256");
Slave s2(this->slaveFlags, true, &isolationModule2, &files);
@@ -1244,7 +1263,6 @@ TYPED_TEST(AllocatorTest, WhitelistSlave
PID<Master> master = process::spawn(&m);
MockExecutor exec;
-
map<ExecutorID, Executor*> execs;
execs[DEFAULT_EXECUTOR_ID] = &exec;
Modified: incubator/mesos/trunk/src/tests/gc_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/gc_tests.cpp?rev=1452570&r1=1452569&r2=1452570&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/gc_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/gc_tests.cpp Mon Mar 4 22:27:02 2013
@@ -317,17 +317,6 @@ TEST_F(GarbageCollectorTest, ExitedExecu
// Kill the executor and inform the slave.
isolationModule->killExecutor(frameworkId, DEFAULT_EXECUTOR_ID);
- // We need to explicitly send this message because we don't spawn
- // a real executor process in this test.
- process::dispatch(
- slave,
- &Slave::executorTerminated,
- frameworkId,
- DEFAULT_EXECUTOR_ID,
- 0,
- false,
- "Killed executor");
-
// In order to make sure the slave has scheduled the executor
// directory to get garbage collected we need to wait until the
// slave has sent the ExecutorExited message. TODO(benh): We really
@@ -411,17 +400,6 @@ TEST_F(GarbageCollectorTest, DiskUsage)
// Kill the executor and inform the slave.
isolationModule->killExecutor(frameworkId, DEFAULT_EXECUTOR_ID);
- // We need to explicitly send this message because we don't spawn
- // a real executor process in this test.
- process::dispatch(
- slave,
- &Slave::executorTerminated,
- frameworkId,
- DEFAULT_EXECUTOR_ID,
- 0,
- false,
- "Killed executor");
-
// In order to make sure the slave has scheduled the executor
// directory to get garbage collected we need to wait until the
// slave has sent the ExecutorExited message. TODO(benh): We really
Modified: incubator/mesos/trunk/src/tests/master_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/master_tests.cpp?rev=1452570&r1=1452569&r2=1452570&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/master_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/master_tests.cpp Mon Mar 4 22:27:02 2013
@@ -478,7 +478,7 @@ TEST_F(MasterTest, RecoverResources)
TestingIsolationModule isolationModule(execs);
- setSlaveResources("cpus:2;mem:1024;ports:[1-10, 20-30]");
+ setSlaveResources("cpus:2;mem:1024;disk:1024;ports:[1-10, 20-30]");
Slave s(slaveFlags, true, &isolationModule, &files);
PID<Slave> slave = process::spawn(&s);
@@ -569,17 +569,9 @@ TEST_F(MasterTest, RecoverResources)
driver.declineOffer(offer.id());
- // Now simulate an executorExited call to the slave.
- // We need to explicitly send this message because we don't spawn
- // a real executor process in this test.
- process::dispatch(
- slave,
- &Slave::executorTerminated,
- offer.framework_id(),
- executorInfo.executor_id(),
- 0,
- false,
- "Killed executor");
+ // Kill the executor.
+ isolationModule.killExecutor(
+ offer.framework_id(), executorInfo.executor_id());
// Scheduler should get an offer for the complete slave resources.
WAIT_UNTIL(resourceOffersCall3);
Modified: incubator/mesos/trunk/src/tests/utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/utils.hpp?rev=1452570&r1=1452569&r2=1452570&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/utils.hpp (original)
+++ incubator/mesos/trunk/src/tests/utils.hpp Mon Mar 4 22:27:02 2013
@@ -114,7 +114,7 @@ protected:
// For locating killtree.sh.
os::setenv("MESOS_SOURCE_DIR",tests::flags.source_dir);
- setSlaveResources("cpus:2;mem:1024");
+ setSlaveResources("cpus:2;mem:1024;disk:1024;ports:[31000-32000]");
}
virtual void TearDown()
@@ -693,6 +693,14 @@ public:
os::unsetenv("MESOS_SLAVE_PID");
os::unsetenv("MESOS_FRAMEWORK_ID");
os::unsetenv("MESOS_EXECUTOR_ID");
+
+ process::dispatch(
+ slave,
+ &slave::Slave::executorStarted,
+ frameworkId,
+ executorInfo.executor_id(),
+ -1);
+
} else {
FAIL() << "Cannot launch executor";
}
@@ -707,6 +715,15 @@ public:
driver->join();
delete driver;
drivers.erase(executorId);
+
+ process::dispatch(
+ slave,
+ &slave::Slave::executorTerminated,
+ frameworkId,
+ executorId,
+ 0,
+ false,
+ "Killed executor");
} else {
FAIL() << "Cannot kill executor";
}