This test verifies that standard resources (memory, CPU, ports etc) are automatically added if and only if they are not explicitly specified on the command line.
| 39 | // automatically added if and only if they are not explicitly specified on |
| 40 | // the command line. |
| 41 | TEST_F(ContainerizerResourcesTest, AutoResources) |
| 42 | { |
| 43 | slave::Flags flags = CreateSlaveFlags(); |
| 44 | // Use a resource string that contains the standard resources as |
| 45 | // substrings, to make sure they don't accidentally suppress the |
| 46 | // automatic values (regression test for MESOS-6821). |
| 47 | flags.resources = |
| 48 | "my.cpus:1000;cpus-suffix:3;memory(mem):1024" |
| 49 | ";things:{mem,disk,ports};diskports:[30000-35000]"; |
| 50 | |
| 51 | Try<Resources> resources = Containerizer::resources(flags); |
| 52 | ASSERT_SOME(resources); |
| 53 | |
| 54 | EXPECT_LT(0, resources->cpus().getOrElse(0)); |
| 55 | EXPECT_LT(Bytes(0), resources->mem().getOrElse(0)); |
| 56 | EXPECT_LT(Bytes(0), resources->disk().getOrElse(0)); |
| 57 | |
| 58 | EXPECT_EQ( |
| 59 | DEFAULT_PORTS, stringify(resources->ports().getOrElse(Value::Ranges()))); |
| 60 | } |
| 61 | |
| 62 | |
| 63 | // This test verifies that auto-detection of resources is suppressed by |