src/tests/slave_tests.cpp
TEST_F(SlaveTest, GetExecutorInfoForTaskWithContainer)
{
  TestContainerizer containerizer;
  StandaloneMasterDetector detector;

  MockSlave slave(CreateSlaveFlags(), &detector, &containerizer);

  // Launch a task with the command executor and ContainerInfo with
  // NetworkInfo.
  TaskInfo task;
  task.set_name("task");
  task.mutable_task_id()->set_value("1");
  task.mutable_slave_id()->set_value(
      "20141010-221431-251662764-60288-12345-0001");
  task.mutable_resources()->MergeFrom(
      Resources::parse("cpus:0.1;mem:32").get());

  CommandInfo command;
  command.set_shell(false);
  command.set_value("/bin/echo");
  command.add_arguments("/bin/echo");
  command.add_arguments("--author");

  task.mutable_command()->MergeFrom(command);

  ContainerInfo *container = task.mutable_container();
  container->set_type(ContainerInfo::MESOS);

  NetworkInfo *network = container->add_network_infos();
  network->set_ip_address("4.3.2.1");
  network->add_groups("public");

  FrameworkInfo frameworkInfo;
  frameworkInfo.mutable_id()->set_value(
      "20141010-221431-251662764-60288-12345-0000");
  const ExecutorInfo& executor = slave.getExecutorInfo(frameworkInfo, task);

  // Now assert that the executor has both the command and ContainerInfo
  EXPECT_TRUE(executor.command().shell());
  // CommandInfo.container is not included. In this test the ContainerInfo
  // must be included in Executor.container (copied from TaskInfo.container).
  EXPECT_TRUE(executor.has_container());

  EXPECT_EQ("4.3.2.1", executor.container().network_infos(0).ip_address());
  EXPECT_EQ(1, executor.container().network_infos(0).groups_size());
  EXPECT_EQ("public", executor.container().network_infos(0).groups(0));
}
// Ensure getExecutorInfo for mesos-executor gets the ContainerInfo,
// if present. This ensures the MesosContainerizer can get the
// NetworkInfo even when using the command executor.
Ensure getExecutorInfo for mesos-executor gets the ContainerInfo,
if present. This ensures the MesosContainerizer can get the
NetworkInfo even when using the command executor.
Ensure getExecutorInfo for mesos - executor gets the ContainerInfo if present . This ensures the MesosContainerizer can get the NetworkInfo even when using the command executor .
TEST_F(SlaveTest, GetExecutorInfoForTaskWithContainer)
{
  TestContainerizer containerizer;
  StandaloneMasterDetector detector;
  MockSlave slave(CreateSlaveFlags(), &detector, &containerizer);
  TaskInfo task;
  task.set_name("task");
  task.mutable_task_id()->set_value("1");
  task.mutable_slave_id()->set_value(
      "20141010-221431-251662764-60288-12345-0001");
  task.mutable_resources()->MergeFrom(
      Resources::parse("cpus:0.1;mem:32").get());
  CommandInfo command;
  command.set_shell(false);
  command.set_value("/bin/echo");
  command.add_arguments("/bin/echo");
  command.add_arguments("--author");
  task.mutable_command()->MergeFrom(command);
  ContainerInfo *container = task.mutable_container();
  container->set_type(ContainerInfo::MESOS);
  NetworkInfo *network = container->add_network_infos();
  network->set_ip_address("4.3.2.1");
  network->add_groups("public");
  FrameworkInfo frameworkInfo;
  frameworkInfo.mutable_id()->set_value(
      "20141010-221431-251662764-60288-12345-0000");
  const ExecutorInfo& executor = slave.getExecutorInfo(frameworkInfo, task);
  EXPECT_TRUE(executor.command().shell());
  EXPECT_TRUE(executor.has_container());
  EXPECT_EQ("4.3.2.1", executor.container().network_infos(0).ip_address());
  EXPECT_EQ(1, executor.container().network_infos(0).groups_size());
  EXPECT_EQ("public", executor.container().network_infos(0).groups(0));
}
TEST_F ( SlaveTest , GetExecutorInfoForTaskWithContainer ) { TestContainerizer containerizer ; StandaloneMasterDetector detector ; MockSlave slave ( CreateSlaveFlags ( ) , & detector , & containerizer ) ; TaskInfo task ; task . set_name ( " " ) ; task . mutable_task_id ( ) -> set_value ( " " ) ; task . mutable_slave_id ( ) -> set_value ( " " ) ; task . mutable_resources ( ) -> MergeFrom ( Resources :: parse ( " " ) . get ( ) ) ; CommandInfo command ; command . set_shell ( false ) ; command . set_value ( " " ) ; command . add_arguments ( " " ) ; command . add_arguments ( " " ) ; task . mutable_command ( ) -> MergeFrom ( command ) ; ContainerInfo * container = task . mutable_container ( ) ; container -> set_type ( ContainerInfo :: MESOS ) ; NetworkInfo * network = container -> add_network_infos ( ) ; network -> set_ip_address ( " " ) ; network -> add_groups ( " " ) ; FrameworkInfo frameworkInfo ; frameworkInfo . mutable_id ( ) -> set_value ( " " ) ; const ExecutorInfo & executor = slave . getExecutorInfo ( frameworkInfo , task ) ; EXPECT_TRUE ( executor . command ( ) . shell ( ) ) ; EXPECT_TRUE ( executor . has_container ( ) ) ; EXPECT_EQ ( " " , executor . container ( ) . network_infos ( 0 ) . ip_address ( ) ) ; EXPECT_EQ ( 1 , executor . container ( ) . network_infos ( 0 ) . groups_size ( ) ) ; EXPECT_EQ ( " " , executor . container ( ) . network_infos ( 0 ) . groups ( 0 ) ) ; }
Ensure getExecutorInfo for mesos-executor gets the ContainerInfo,
if present.
Ensure getExecutorInfo for mesos - executor gets the ContainerInfo if present .
// Launch a task with the command executor and ContainerInfo with // NetworkInfo. // Now assert that the executor has both the command and ContainerInfo // CommandInfo.container is not included. In this test the ContainerInfo // must be included in Executor.container (copied from TaskInfo.container).