You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ti...@apache.org on 2016/02/04 10:35:24 UTC
[1/2] mesos git commit: Update OversubscriptionTest to not assume
dynamic dlopen search.
Repository: mesos
Updated Branches:
refs/heads/master da99c8468 -> f9393e2d6
Update OversubscriptionTest to not assume dynamic dlopen search.
Review: https://reviews.apache.org/r/39780/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/253a0e6f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/253a0e6f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/253a0e6f
Branch: refs/heads/master
Commit: 253a0e6fd65e62b097b583809e6bb21cafd7b932
Parents: da99c84
Author: James Peach <jp...@apache.org>
Authored: Thu Feb 4 09:53:25 2016 +0100
Committer: Till Toenshoff <to...@me.com>
Committed: Thu Feb 4 09:53:25 2016 +0100
----------------------------------------------------------------------
src/tests/oversubscription_tests.cpp | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/253a0e6f/src/tests/oversubscription_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/oversubscription_tests.cpp b/src/tests/oversubscription_tests.cpp
index 6f43103..c857c2b 100644
--- a/src/tests/oversubscription_tests.cpp
+++ b/src/tests/oversubscription_tests.cpp
@@ -85,14 +85,6 @@ protected:
virtual void SetUp()
{
MesosTest::SetUp();
-
- // Get the current value of LD_LIBRARY_PATH.
- originalLDLibraryPath = os::libraries::paths();
-
- // Append our library path to LD_LIBRARY_PATH so that dlopen can
- // search the library directory for module libraries.
- os::libraries::appendPaths(
- path::join(tests::flags.build_dir, "src", ".libs"));
}
virtual void TearDown()
@@ -106,16 +98,17 @@ protected:
}
}
- // Restore LD_LIBRARY_PATH environment variable.
- os::libraries::setPaths(originalLDLibraryPath);
-
MesosTest::TearDown();
}
void loadFixedResourceEstimatorModule(const string& resources)
{
+ string libraryPath = path::join(tests::flags.build_dir, "src", ".libs",
+ os::libraries::expandName("fixed_resource_estimator"));
+
Modules::Library* library = modules.add_libraries();
library->set_name("fixed_resource_estimator");
+ library->set_file(libraryPath);
Modules::Library::Module* module = library->add_modules();
module->set_name(FIXED_RESOURCE_ESTIMATOR_NAME);
@@ -176,7 +169,6 @@ protected:
}
private:
- string originalLDLibraryPath;
Modules modules;
};
[2/2] mesos git commit: Update ModuleTest to not assume dynamic
dlopen search.
Posted by ti...@apache.org.
Update ModuleTest to not assume dynamic dlopen search.
Review: https://reviews.apache.org/r/39781/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f9393e2d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f9393e2d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f9393e2d
Branch: refs/heads/master
Commit: f9393e2d60e4acad1895d72ab54ed6b60a798dd0
Parents: 253a0e6
Author: James Peach <jp...@apache.org>
Authored: Thu Feb 4 10:14:53 2016 +0100
Committer: Till Toenshoff <to...@me.com>
Committed: Thu Feb 4 10:28:17 2016 +0100
----------------------------------------------------------------------
src/tests/module_tests.cpp | 105 ++++++++++++++++++++--------------------
1 file changed, 52 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f9393e2d/src/tests/module_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/module_tests.cpp b/src/tests/module_tests.cpp
index a3271a3..7b3e98b 100644
--- a/src/tests/module_tests.cpp
+++ b/src/tests/module_tests.cpp
@@ -49,33 +49,21 @@ const char* DEFAULT_MODULE_NAME = "org_apache_mesos_TestModule";
class ModuleTest : public MesosTest
{
protected:
- // During the one-time setup of the test cases, we do the
- // following:
- // 1. set LD_LIBRARY_PATH to also point to the src/.libs directory.
- // The original LD_LIBRARY_PATH is restored at the end of all
- // tests.
- // 2. dlopen() examplemodule library and retrieve the pointer to
- // ModuleBase for the test module. This pointer is later used to
- // reset the Mesos and module API versions during per-test
- // teardown.
+ // During the one-time setup of the test cases, we dlopen() the examplemodule
+ // library and retrieve the pointer to ModuleBase for the test module. This
+ // pointer is later used to reset the Mesos and module API versions during
+ // per-test teardown.
static void SetUpTestCase()
{
libraryDirectory = path::join(tests::flags.build_dir, "src", ".libs");
- // Get the current value of LD_LIBRARY_PATH.
- originalLdLibraryPath = os::libraries::paths();
-
- // Append our library path to LD_LIBRARY_PATH so that dlopen can
- // search the library directory for module libraries.
- os::libraries::appendPaths(libraryDirectory);
-
- EXPECT_SOME(dynamicLibrary.open(
- os::libraries::expandName(DEFAULT_MODULE_LIBRARY_NAME)));
+ EXPECT_SOME(dynamicLibrary.open(path::join(libraryDirectory,
+ os::libraries::expandName(DEFAULT_MODULE_LIBRARY_NAME))));
Try<void*> symbol = dynamicLibrary.loadSymbol(DEFAULT_MODULE_NAME);
EXPECT_SOME(symbol);
- moduleBase = (ModuleBase*) symbol.get();
+ moduleBase = static_cast<ModuleBase*>(symbol.get());
}
static void TearDownTestCase()
@@ -84,9 +72,6 @@ protected:
// Close the module library.
dynamicLibrary.close();
-
- // Restore LD_LIBRARY_PATH environment variable.
- os::libraries::setPaths(originalLdLibraryPath);
}
ModuleTest()
@@ -124,35 +109,38 @@ protected:
static DynamicLibrary dynamicLibrary;
static ModuleBase* moduleBase;
- static string originalLdLibraryPath;
static string libraryDirectory;
};
DynamicLibrary ModuleTest::dynamicLibrary;
ModuleBase* ModuleTest::moduleBase = NULL;
-string ModuleTest::originalLdLibraryPath;
string ModuleTest::libraryDirectory;
-static Modules getModules(const string& libraryName, const string& moduleName)
+Modules getModules(
+ const string& libraryDirectory,
+ const string& libraryName,
+ const string& moduleName)
{
Modules modules;
Modules::Library* library = modules.add_libraries();
- library->set_file(os::libraries::expandName(libraryName));
+ library->set_file(
+ path::join(libraryDirectory, os::libraries::expandName(libraryName)));
Modules::Library::Module* module = library->add_modules();
module->set_name(moduleName);
return modules;
}
-static Modules getModules(
+Modules getModules(
+ const string& libraryDirectory,
const string& libraryName,
const string& moduleName,
const string& parameterKey,
const string& parameterValue)
{
- Modules modules = getModules(libraryName, moduleName);
+ Modules modules = getModules(libraryDirectory, libraryName, moduleName);
Modules::Library* library = modules.mutable_libraries(0);
Modules::Library::Module* module = library->mutable_modules(0);
Parameter* parameter = module->add_parameters();
@@ -162,17 +150,21 @@ static Modules getModules(
}
-static Try<Modules> getModulesFromJson(
+Try<Modules> getModulesFromJson(
+ const string& libraryDirectory,
const string& libraryName,
const string& moduleName,
const string& parameterKey,
const string& parameterValue)
{
+ string libraryFile =
+ path::join(libraryDirectory, os::libraries::expandName(libraryName));
+
string jsonString =
"{\n"
" \"libraries\": [\n"
" {\n"
- " \"file\": \"" + os::libraries::expandName(libraryName) + "\",\n"
+ " \"file\": \"" + libraryFile + "\",\n"
" \"modules\": [\n"
" {\n"
" \"name\": \"" + moduleName + "\",\n"
@@ -217,6 +209,7 @@ TEST_F(ModuleTest, ExampleModuleLoadTest)
TEST_F(ModuleTest, ParameterWithoutValue)
{
Modules modules = getModules(
+ libraryDirectory,
DEFAULT_MODULE_LIBRARY_NAME,
DEFAULT_MODULE_NAME,
"operation",
@@ -232,6 +225,7 @@ TEST_F(ModuleTest, ParameterWithoutValue)
TEST_F(ModuleTest, ParameterWithInvalidValue)
{
Modules modules = getModules(
+ libraryDirectory,
DEFAULT_MODULE_LIBRARY_NAME,
DEFAULT_MODULE_NAME,
"operation",
@@ -246,8 +240,12 @@ TEST_F(ModuleTest, ParameterWithInvalidValue)
// Test passing parameter without key.
TEST_F(ModuleTest, ParameterWithoutKey)
{
- Modules modules =
- getModules(DEFAULT_MODULE_LIBRARY_NAME, DEFAULT_MODULE_NAME, "", "sum");
+ Modules modules = getModules(
+ libraryDirectory,
+ DEFAULT_MODULE_LIBRARY_NAME,
+ DEFAULT_MODULE_NAME,
+ "",
+ "sum");
EXPECT_SOME(ModuleManager::load(modules));
module = ModuleManager::create<TestModule>(DEFAULT_MODULE_NAME);
@@ -261,8 +259,12 @@ TEST_F(ModuleTest, ParameterWithoutKey)
// Test passing parameter with invalid key.
TEST_F(ModuleTest, ParameterWithInvalidKey)
{
- Modules modules =
- getModules(DEFAULT_MODULE_LIBRARY_NAME, DEFAULT_MODULE_NAME, "X", "sum");
+ Modules modules = getModules(
+ libraryDirectory,
+ DEFAULT_MODULE_LIBRARY_NAME,
+ DEFAULT_MODULE_NAME,
+ "X",
+ "sum");
EXPECT_SOME(ModuleManager::load(modules));
module = ModuleManager::create<TestModule>(DEFAULT_MODULE_NAME);
@@ -277,6 +279,7 @@ TEST_F(ModuleTest, ParameterWithInvalidKey)
TEST_F(ModuleTest, ValidParameters)
{
Modules modules = getModules(
+ libraryDirectory,
DEFAULT_MODULE_LIBRARY_NAME,
DEFAULT_MODULE_NAME,
"operation",
@@ -294,6 +297,7 @@ TEST_F(ModuleTest, ValidParameters)
TEST_F(ModuleTest, OverrideJson)
{
Modules modules = getModules(
+ libraryDirectory,
DEFAULT_MODULE_LIBRARY_NAME,
DEFAULT_MODULE_NAME,
"operation",
@@ -321,6 +325,7 @@ TEST_F(ModuleTest, OverrideJson)
TEST_F(ModuleTest, JsonParseTest)
{
Try<Modules> modules = getModulesFromJson(
+ libraryDirectory,
DEFAULT_MODULE_LIBRARY_NAME,
DEFAULT_MODULE_NAME,
"operation",
@@ -393,20 +398,8 @@ TEST_F(ModuleTest, LibraryNameWithoutExtension)
Modules modules;
Modules::Library* library = modules.add_libraries();
library->set_name(DEFAULT_MODULE_LIBRARY_NAME);
- Modules::Library::Module* module = library->add_modules();
- module->set_name(DEFAULT_MODULE_NAME);
-
- EXPECT_SOME(ModuleManager::load(modules));
-}
-
-
-// Test that a module library gets loaded with just library name if
-// found in LD_LIBRARY_PATH.
-TEST_F(ModuleTest, LibraryNameWithExtension)
-{
- Modules modules;
- Modules::Library* library = modules.add_libraries();
- library->set_file(os::libraries::expandName(DEFAULT_MODULE_LIBRARY_NAME));
+ library->set_file(path::join(libraryDirectory,
+ os::libraries::expandName(DEFAULT_MODULE_LIBRARY_NAME)));
Modules::Library::Module* module = library->add_modules();
module->set_name(DEFAULT_MODULE_NAME);
@@ -417,7 +410,10 @@ TEST_F(ModuleTest, LibraryNameWithExtension)
// Test that module library loading fails when filename is empty.
TEST_F(ModuleTest, EmptyLibraryFilename)
{
- Modules modules = getModules("", "org_apache_mesos_TestModule");
+ Modules modules = getModules(
+ libraryDirectory,
+ "",
+ "org_apache_mesos_TestModule");
EXPECT_ERROR(ModuleManager::load(modules));
}
@@ -425,7 +421,7 @@ TEST_F(ModuleTest, EmptyLibraryFilename)
// Test that module library loading fails when module name is empty.
TEST_F(ModuleTest, EmptyModuleName)
{
- Modules modules = getModules("examplemodule", "");
+ Modules modules = getModules(libraryDirectory, "examplemodule", "");
EXPECT_ERROR(ModuleManager::load(modules));
}
@@ -433,7 +429,10 @@ TEST_F(ModuleTest, EmptyModuleName)
// Test that module library loading fails when given an unknown path.
TEST_F(ModuleTest, UnknownLibraryTest)
{
- Modules modules = getModules("unknown", "org_apache_mesos_TestModule");
+ Modules modules = getModules(
+ libraryDirectory,
+ "unknown",
+ "org_apache_mesos_TestModule");
EXPECT_ERROR(ModuleManager::load(modules));
}
@@ -442,7 +441,7 @@ TEST_F(ModuleTest, UnknownLibraryTest)
// the commandline.
TEST_F(ModuleTest, UnknownModuleTest)
{
- Modules modules = getModules("examplemodule", "unknown");
+ Modules modules = getModules(libraryDirectory, "examplemodule", "unknown");
EXPECT_ERROR(ModuleManager::load(modules));
}
@@ -461,7 +460,7 @@ TEST_F(ModuleTest, NonModuleLibrary)
{
// Trying to load libmesos.so (libmesos.dylib on OS X) as a module
// library should fail.
- Modules modules = getModules("mesos", DEFAULT_MODULE_NAME);
+ Modules modules = getModules(libraryDirectory, "mesos", DEFAULT_MODULE_NAME);
EXPECT_ERROR(ModuleManager::load(modules));
}