MCPcopy Create free account
hub / github.com/apache/mesos / TEST_F

Function TEST_F

src/tests/slave_authorization_tests.cpp:698–769  ·  view source on GitHub ↗

This test verifies that a task group is launched on the agent if the executor provides a valid authentication token specifying its own ContainerID.

Source from the content-addressed store, hash-verified

696// This test verifies that a task group is launched on the agent if the executor
697// provides a valid authentication token specifying its own ContainerID.
698TEST_F(ExecutorAuthorizationTest, RunTaskGroup)
699{
700 Try<Owned<cluster::Master>> master = StartMaster();
701 ASSERT_SOME(master);
702
703 // Start an agent with permissive ACLs so that a task can be launched.
704 ACLs acls;
705 acls.set_permissive(true);
706
707 slave::Flags flags = CreateSlaveFlags();
708 flags.acls = acls;
709
710 Owned<MasterDetector> detector = master.get()->createDetector();
711 Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), flags);
712 ASSERT_SOME(slave);
713
714 FrameworkInfo frameworkInfo = DEFAULT_FRAMEWORK_INFO;
715
716 MockScheduler sched;
717 MesosSchedulerDriver driver(
718 &sched, frameworkInfo, master.get()->pid, DEFAULT_CREDENTIAL);
719
720 Future<FrameworkID> frameworkId;
721 EXPECT_CALL(sched, registered(&driver, _, _))
722 .WillOnce(FutureArg<1>(&frameworkId));
723
724 Future<vector<Offer>> offers;
725 EXPECT_CALL(sched, resourceOffers(&driver, _))
726 .WillOnce(FutureArg<1>(&offers))
727 .WillRepeatedly(Return()); // Ignore subsequent offers.
728
729 driver.start();
730
731 AWAIT_READY(frameworkId);
732
733 AWAIT_READY(offers);
734 ASSERT_FALSE(offers->empty());
735
736 Offer offer = offers.get()[0];
737
738 TaskInfo task = createTask(
739 offer.slave_id(),
740 Resources::parse("cpus:0.5;mem:32").get(),
741 "sleep 1000");
742
743 Future<TaskStatus> status;
744
745 EXPECT_CALL(sched, statusUpdate(&driver, _))
746 .WillOnce(FutureArg<1>(&status));
747
748 Resources executorResources =
749 allocatedResources(Resources::parse("cpus:0.1;mem:32;disk:32").get(), "*");
750
751 ExecutorInfo executor;
752 executor.mutable_executor_id()->set_value("default");
753 executor.set_type(ExecutorInfo::DEFAULT);
754 executor.mutable_framework_id()->CopyFrom(frameworkId.get());
755 executor.mutable_resources()->CopyFrom(executorResources);

Callers

nothing calls this directly

Calls 15

allocatedResourcesFunction · 0.85
LAUNCH_GROUPFunction · 0.85
FutureSatisfyFunction · 0.85
createCallSubscribeFunction · 0.85
randomFunction · 0.85
NoneClass · 0.85
generateFunction · 0.85
errorFunction · 0.85
ForbiddenClass · 0.85
shutdownFunction · 0.85
createDetectorMethod · 0.80
CopyFromMethod · 0.80

Tested by

no test coverage detected