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

Function TEST_P

src/tests/resources_tests.cpp:2595–2670  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2593
2594
2595TEST_P(DiskResourcesSourceTest, SourceIdentity)
2596{
2597 auto parameters = GetParam();
2598
2599 Resource::DiskInfo::Source::Type type = std::get<0>(parameters);
2600 bool hasVendor = std::get<1>(parameters);
2601 bool hasIdentity = std::get<2>(parameters);
2602 bool hasProfile = std::get<3>(parameters);
2603
2604 // Create a disk, possibly with an id to signify identity.
2605 Resource::DiskInfo::Source source;
2606 source.set_type(type);
2607
2608 if (hasVendor) {
2609 source.set_vendor("vendor");
2610 }
2611
2612 if (hasIdentity) {
2613 source.set_id("id");
2614 }
2615
2616 if (hasProfile) {
2617 source.set_profile("profile");
2618 }
2619
2620 // Create two disk resources with the created source.
2621 Resource disk1 = Resources::parse("disk", "1", "*").get();
2622 disk1.mutable_disk()->mutable_source()->CopyFrom(source);
2623 const Resources r1 = disk1;
2624
2625 EXPECT_TRUE(r1.contains(r1));
2626
2627 Resource disk2 = Resources::parse("disk", "2", "*").get();
2628 disk2.mutable_disk()->mutable_source()->CopyFrom(source);
2629 const Resources r2 = disk2;
2630
2631 // We perform three checks here: checks involving `r1` and `r2`
2632 // test subtraction semantics while tests of the size of the
2633 // resources test addition semantics.
2634 switch (type) {
2635 case Resource::DiskInfo::Source::RAW: {
2636 if (hasIdentity) {
2637 // `RAW` resources with source identity cannot be added or split.
2638 EXPECT_FALSE(r2.contains(r1));
2639 EXPECT_NE(r2, r1 + r1);
2640 EXPECT_EQ(2u, (r1 + r1).size());
2641 } else {
2642 // `RAW` resources without source identity can be added and split.
2643 EXPECT_TRUE(r2.contains(r1));
2644 EXPECT_EQ(r2, r1 + r1);
2645 EXPECT_EQ(1u, (r1 + r1).size());
2646 }
2647 break;
2648 }
2649 case Resource::DiskInfo::Source::BLOCK:
2650 case Resource::DiskInfo::Source::MOUNT: {
2651 // `BLOCK` or `MOUNT` resources cannot be added or split,
2652 // regardless of identity.

Callers

nothing calls this directly

Calls 15

abbreviateFunction · 0.85
createRangeFunction · 0.85
createPortsFunction · 0.85
CopyFromMethod · 0.80
elapsedMethod · 0.80
startMethod · 0.65
stopMethod · 0.65
parseFunction · 0.50
stringifyFunction · 0.50
joinFunction · 0.50
getMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected