This test verifies that the ResourceEstimator is able to fetch ResourceUsage statistics about running executor.
| 182 | // This test verifies that the ResourceEstimator is able to fetch |
| 183 | // ResourceUsage statistics about running executor. |
| 184 | TEST_F(OversubscriptionTest, FetchResourceUsage) |
| 185 | { |
| 186 | Try<Owned<cluster::Master>> master = StartMaster(); |
| 187 | ASSERT_SOME(master); |
| 188 | |
| 189 | MockExecutor exec(DEFAULT_EXECUTOR_ID); |
| 190 | TestContainerizer containerizer(&exec); |
| 191 | |
| 192 | const ResourceStatistics statistics = createResourceStatistics(); |
| 193 | |
| 194 | // Make sure that containerizer will report stub statistics. |
| 195 | EXPECT_CALL(containerizer, usage(_)) |
| 196 | .WillOnce(Return(statistics)); |
| 197 | |
| 198 | MockResourceEstimator resourceEstimator; |
| 199 | |
| 200 | Future<lambda::function<Future<ResourceUsage>()>> usageCallback; |
| 201 | |
| 202 | // Catching callback which is passed to the ResourceEstimator. |
| 203 | EXPECT_CALL(resourceEstimator, initialize(_)) |
| 204 | .WillOnce(DoAll(FutureArg<0>(&usageCallback), Return(Nothing()))); |
| 205 | |
| 206 | Owned<MasterDetector> detector = master.get()->createDetector(); |
| 207 | |
| 208 | Try<Owned<cluster::Slave>> slave = StartSlave( |
| 209 | detector.get(), |
| 210 | &containerizer, |
| 211 | &resourceEstimator, |
| 212 | CreateSlaveFlags()); |
| 213 | ASSERT_SOME(slave); |
| 214 | |
| 215 | MockScheduler sched; |
| 216 | MesosSchedulerDriver driver( |
| 217 | &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL); |
| 218 | |
| 219 | EXPECT_CALL(sched, registered(&driver, _, _)); |
| 220 | |
| 221 | Future<vector<Offer>> offers; |
| 222 | EXPECT_CALL(sched, resourceOffers(&driver, _)) |
| 223 | .WillOnce(FutureArg<1>(&offers)) |
| 224 | .WillRepeatedly(Return()); // Ignore subsequent offers. |
| 225 | |
| 226 | driver.start(); |
| 227 | |
| 228 | AWAIT_READY(offers); |
| 229 | ASSERT_FALSE(offers->empty()); |
| 230 | |
| 231 | TaskInfo task = createTask(offers.get()[0], "sleep 10", DEFAULT_EXECUTOR_ID); |
| 232 | task.mutable_labels()->add_labels()->CopyFrom( |
| 233 | createLabel("key1", "value1")); |
| 234 | task.mutable_executor()->mutable_labels()->add_labels()->CopyFrom( |
| 235 | createLabel("key2", "value2")); |
| 236 | |
| 237 | Future<TaskStatus> status; |
| 238 | EXPECT_CALL(sched, statusUpdate(&driver, _)) |
| 239 | .WillOnce(FutureArg<1>(&status)) |
| 240 | .WillRepeatedly(Return()); // Ignore subsequent updates. |
| 241 |
nothing calls this directly
no test coverage detected