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

Function TEST_F

src/tests/containerizer/nvidia_gpu_isolator_tests.cpp:93–191  ·  view source on GitHub ↗

This test verifies that we are able to enable the Nvidia GPU isolator and launch tasks with restricted access to GPUs. We first launch a task with access to 0 GPUs and verify that a call to `nvidia-smi` fails. We then launch a task with 1 GPU and verify that a call to `nvidia-smi` both succeeds and reports exactly 1 GPU available.

Source from the content-addressed store, hash-verified

91// and verify that a call to `nvidia-smi` both succeeds and
92// reports exactly 1 GPU available.
93TEST_F(NvidiaGpuTest, ROOT_CGROUPS_NVIDIA_GPU_VerifyDeviceAccess)
94{
95 Try<Owned<cluster::Master>> master = StartMaster();
96 ASSERT_SOME(master);
97
98 // Turn on Nvidia GPU isolation.
99 // Assume at least one GPU is available for isolation.
100 slave::Flags flags = CreateSlaveFlags();
101 flags.isolation = "filesystem/linux,cgroups/devices,gpu/nvidia";
102 flags.resources = "cpus:1"; // To override the default with gpus:0.
103
104 Owned<MasterDetector> detector = master.get()->createDetector();
105
106 Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), flags);
107 ASSERT_SOME(slave);
108
109 MockScheduler sched;
110
111 FrameworkInfo frameworkInfo = DEFAULT_FRAMEWORK_INFO;
112 frameworkInfo.add_capabilities()->set_type(
113 FrameworkInfo::Capability::GPU_RESOURCES);
114
115 MesosSchedulerDriver driver(
116 &sched, frameworkInfo, master.get()->pid, DEFAULT_CREDENTIAL);
117
118 Future<Nothing> schedRegistered;
119 EXPECT_CALL(sched, registered(_, _, _))
120 .WillOnce(FutureSatisfy(&schedRegistered));
121
122 Future<vector<Offer>> offers1, offers2;
123 EXPECT_CALL(sched, resourceOffers(_, _))
124 .WillOnce(FutureArg<1>(&offers1))
125 .WillOnce(FutureArg<1>(&offers2))
126 .WillRepeatedly(Return()); // Ignore subsequent offers.
127
128 driver.start();
129
130 AWAIT_READY(schedRegistered);
131
132 // Launch a task requesting no GPUs and
133 // verify that running `nvidia-smi` fails.
134 AWAIT_READY(offers1);
135 EXPECT_EQ(1u, offers1->size());
136
137 TaskInfo task1 = createTask(
138 offers1.get()[0].slave_id(),
139 Resources::parse("cpus:0.1;mem:128").get(),
140 "nvidia-smi");
141
142 Future<TaskStatus> statusStarting1, statusRunning1, statusFailed1;
143 EXPECT_CALL(sched, statusUpdate(_, _))
144 .WillOnce(FutureArg<1>(&statusStarting1))
145 .WillOnce(FutureArg<1>(&statusRunning1))
146 .WillOnce(FutureArg<1>(&statusFailed1));
147
148 driver.launchTasks(offers1.get()[0].id(), {task1});
149
150 AWAIT_READY(statusStarting1);

Callers

nothing calls this directly

Calls 15

FutureSatisfyFunction · 0.85
failureFunction · 0.85
createExecutorInfoFunction · 0.85
randomFunction · 0.85
NoneClass · 0.85
isTerminalStateFunction · 0.85
createCallAcceptFunction · 0.85
LAUNCH_GROUPFunction · 0.85
createTaskGroupInfoFunction · 0.85
SecondsClass · 0.85
isAvailableFunction · 0.85
deviceGetCountFunction · 0.85

Tested by

no test coverage detected