You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2017/12/09 02:36:08 UTC
[06/11] mesos git commit: Replaced manual URI creation with
`uri::from_path()`.
Replaced manual URI creation with `uri::from_path()`.
Especially on Windows, this ensures that the URI is well-formed (uses
forward slash as a path separator, and idempotently prefixes with
`file://`). On Windows, the path separator is a backslash, and so
manually creating a URI by doing `"file://" + path` does not work.
Review: https://reviews.apache.org/r/60623
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/edfe3f5e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/edfe3f5e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/edfe3f5e
Branch: refs/heads/master
Commit: edfe3f5eba93b0d62cab4ca638e95126b93793f1
Parents: 07ca330
Author: Jeff Coffler <je...@taltos.com>
Authored: Thu Jun 1 16:04:32 2017 -0700
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Dec 8 16:35:40 2017 -0800
----------------------------------------------------------------------
src/tests/credentials_tests.cpp | 8 ++++++--
src/tests/fetcher_tests.cpp | 3 ++-
src/tests/master_contender_detector_tests.cpp | 4 ++--
src/tests/script.cpp | 5 +++--
4 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/edfe3f5e/src/tests/credentials_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/credentials_tests.cpp b/src/tests/credentials_tests.cpp
index 4ecb977..8fa26df 100644
--- a/src/tests/credentials_tests.cpp
+++ b/src/tests/credentials_tests.cpp
@@ -18,6 +18,8 @@
#include <gmock/gmock.h>
+#include <stout/uri.hpp>
+
#include <process/gmock.hpp>
#include <process/owned.hpp>
#include <process/pid.hpp>
@@ -91,7 +93,8 @@ TEST_F(CredentialsTest, AuthenticatedSlaveText)
ASSERT_SOME(os::close(fd.get()));
- map<string, Option<string>> values{{"credentials", Some("file://" + path)}};
+ map<string, Option<string>> values{
+ {"credentials", Some(uri::from_path(path))}};
master::Flags masterFlags = CreateMasterFlags();
masterFlags.load(values, true);
@@ -144,7 +147,8 @@ TEST_F(CredentialsTest, AuthenticatedSlaveJSON)
ASSERT_SOME(os::close(fd.get()));
- map<string, Option<string>> values{{"credentials", Some("file://" + path)}};
+ map<string, Option<string>> values{
+ {"credentials", Some(uri::from_path(path))}};
master::Flags masterFlags = CreateMasterFlags();
masterFlags.load(values, true);
http://git-wip-us.apache.org/repos/asf/mesos/blob/edfe3f5e/src/tests/fetcher_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/fetcher_tests.cpp b/src/tests/fetcher_tests.cpp
index df9d2d9..b81b14b 100644
--- a/src/tests/fetcher_tests.cpp
+++ b/src/tests/fetcher_tests.cpp
@@ -37,6 +37,7 @@
#include <stout/path.hpp>
#include <stout/strings.hpp>
#include <stout/try.hpp>
+#include <stout/uri.hpp>
#include <stout/os/permissions.hpp>
@@ -114,7 +115,7 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(FetcherTest, FileURI)
CommandInfo commandInfo;
CommandInfo::URI* uri = commandInfo.add_uris();
- uri->set_value("file://" + testFile);
+ uri->set_value(uri::from_path(testFile));
Fetcher fetcher(flags);
http://git-wip-us.apache.org/repos/asf/mesos/blob/edfe3f5e/src/tests/master_contender_detector_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_contender_detector_tests.cpp b/src/tests/master_contender_detector_tests.cpp
index f499136..015d310 100644
--- a/src/tests/master_contender_detector_tests.cpp
+++ b/src/tests/master_contender_detector_tests.cpp
@@ -37,6 +37,7 @@
#include <stout/nothing.hpp>
#include <stout/path.hpp>
#include <stout/try.hpp>
+#include <stout/uri.hpp>
#include "common/protobuf_utils.hpp"
@@ -109,8 +110,7 @@ TEST_F(MasterContenderDetectorTest, File)
const string& path = path::join(flags.work_dir, "master");
ASSERT_SOME(os::write(path, stringify(master.get()->pid)));
- Try<MasterDetector*> _detector =
- MasterDetector::create("file://" + path);
+ Try<MasterDetector*> _detector = MasterDetector::create(uri::from_path(path));
ASSERT_SOME(_detector);
http://git-wip-us.apache.org/repos/asf/mesos/blob/edfe3f5e/src/tests/script.cpp
----------------------------------------------------------------------
diff --git a/src/tests/script.cpp b/src/tests/script.cpp
index 9823e33..a03b6bc 100644
--- a/src/tests/script.cpp
+++ b/src/tests/script.cpp
@@ -26,6 +26,7 @@
#include <stout/path.hpp>
#include <stout/stringify.hpp>
#include <stout/strings.hpp>
+#include <stout/uri.hpp>
#include <stout/os/realpath.hpp>
@@ -134,7 +135,7 @@ void execute(const string& script)
CHECK_SOME(os::write(credentialsPath, credentials))
<< "Failed to write credentials to '" << credentialsPath << "'";
- os::setenv("MESOS_CREDENTIALS", "file://" + credentialsPath);
+ os::setenv("MESOS_CREDENTIALS", uri::from_path(credentialsPath));
// We set test credentials here for example frameworks to use.
os::setenv("DEFAULT_PRINCIPAL", DEFAULT_CREDENTIAL.principal());
@@ -173,7 +174,7 @@ void execute(const string& script)
CHECK_SOME(os::write(aclsPath, stringify(JSON::protobuf(acls))))
<< "Failed to write ACLs to '" << aclsPath << "'";
- os::setenv("MESOS_ACLS", "file://" + aclsPath);
+ os::setenv("MESOS_ACLS", uri::from_path(aclsPath));
// Now execute the script.
execl(path->c_str(), path->c_str(), (char*) nullptr);