MockSlaveUsage(int executors) : results(ResourceUsage()) { for (int i = 0; i < executors; i++) { ResourceHelper::addExecutor( results, CREATE_EXECUTOR_INFO(std::to_string(i + 1), "exit 1"), Resources(), ResourceHelper::createStatistics()); } }
// Test that the environment decorator hook adds a new environment // variable to the executor runtime. // Test hook adds a new environment variable "FOO" to the executor // with a value "bar". We validate the hook by verifying the value // of this environment variable. TEST_F(HookTest, VerifySlaveExecutorEnvironmentDecorator) { const string& directory = os::getcwd(); // We're inside a temporary sandbox. Fetcher fetcher; Try<MesosContainerizer*> containerizer = MesosContainerizer::create(CreateSlaveFlags(), false, &fetcher); ASSERT_SOME(containerizer); ContainerID containerId; containerId.set_value("test_container"); // Test hook adds a new environment variable "FOO" to the executor // with a value "bar". A '0' (success) exit status for the following // command validates the hook. process::Future<bool> launch = containerizer.get()->launch( containerId, CREATE_EXECUTOR_INFO("executor", "test $FOO = 'bar'"), directory, None(), SlaveID(), process::PID<Slave>(), false); AWAIT_READY(launch); ASSERT_TRUE(launch.get()); // Wait on the container. process::Future<containerizer::Termination> wait = containerizer.get()->wait(containerId); AWAIT_READY(wait); // Check the executor exited correctly. EXPECT_TRUE(wait.get().has_status()); EXPECT_EQ(0, wait.get().status()); delete containerizer.get(); }