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

Method SetUp

src/tests/mesos.cpp:661–750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

659
660
661void ContainerizerTest<slave::MesosContainerizer>::SetUp()
662{
663 MesosTest::SetUp();
664
665 Try<std::set<string>> supportedSubsystems = cgroups::subsystems();
666 ASSERT_SOME(supportedSubsystems);
667
668 subsystems = supportedSubsystems.get();
669
670 Result<string> user = os::user();
671 EXPECT_SOME(user);
672
673 if (cgroups::enabled() && user.get() == "root") {
674 // Determine the base hierarchy.
675 foreach (const string& subsystem, subsystems) {
676 Result<string> hierarchy = cgroups::hierarchy(subsystem);
677 ASSERT_FALSE(hierarchy.isError());
678
679 if (hierarchy.isSome()) {
680 Try<string> _baseHierarchy = Path(hierarchy.get()).dirname();
681 ASSERT_SOME(_baseHierarchy)
682 << "Failed to get the base of hierarchy '" << hierarchy.get() << "'";
683
684 if (baseHierarchy.empty()) {
685 baseHierarchy = _baseHierarchy.get();
686 } else {
687 ASSERT_EQ(baseHierarchy, _baseHierarchy.get())
688 << "-------------------------------------------------------------\n"
689 << "Multiple cgroups base hierarchies detected:\n"
690 << " '" << baseHierarchy << "'\n"
691 << " '" << _baseHierarchy.get() << "'\n"
692 << "Mesos does not support multiple cgroups base hierarchies.\n"
693 << "Please unmount the corresponding (or all) subsystems.\n"
694 << "-------------------------------------------------------------";
695 }
696 }
697 }
698
699 if (baseHierarchy.empty()) {
700 baseHierarchy = TEST_CGROUPS_HIERARCHY;
701 }
702
703 // Mount the subsystem if necessary.
704 foreach (const string& subsystem, subsystems) {
705 const string& hierarchy = path::join(baseHierarchy, subsystem);
706
707 Try<bool> mounted = cgroups::mounted(hierarchy, subsystem);
708 ASSERT_SOME(mounted);
709
710 if (!mounted.get()) {
711 ASSERT_SOME(cgroups::mount(hierarchy, subsystem))
712 << "-------------------------------------------------------------\n"
713 << "We cannot run any cgroups tests that require\n"
714 << "a hierarchy with subsystem '" << subsystem << "'\n"
715 << "because we failed to find an existing hierarchy\n"
716 << "or create a new one (tried '" << hierarchy << "').\n"
717 << "You can either remove all existing\n"
718 << "hierarchies, or disable this test case\n"

Callers

nothing calls this directly

Calls 5

subsystemsFunction · 0.85
userFunction · 0.50
enabledFunction · 0.50
getMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected