Updated tests to set '--executor_secret_key' as a path. This patch updates the test code to generate a secret key file and set the agent '--executor_secret_key' flag with its path.
Review: https://reviews.apache.org/r/58328/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8bbe7004 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8bbe7004 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8bbe7004 Branch: refs/heads/master Commit: 8bbe700411298b7b17219f9521820b9dcc7ef2c8 Parents: 0b7a401 Author: Greg Mann <g...@mesosphere.io> Authored: Thu Apr 13 15:44:28 2017 -0700 Committer: Vinod Kone <vinodk...@gmail.com> Committed: Thu Apr 13 15:44:28 2017 -0700 ---------------------------------------------------------------------- src/tests/mesos.cpp | 20 +++++++++++++++++++- src/tests/mesos.hpp | 5 +++++ 2 files changed, 24 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/8bbe7004/src/tests/mesos.cpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.cpp b/src/tests/mesos.cpp index 099ec37..27cfcab 100644 --- a/src/tests/mesos.cpp +++ b/src/tests/mesos.cpp @@ -212,7 +212,25 @@ slave::Flags MesosTest::CreateSlaveFlags() // Executor authentication currently has SSL as a dependency, so we // cannot enable it if Mesos was not built with SSL support. flags.authenticate_http_executors = true; - flags.executor_secret_key = "secret_key"; + + { + // Create a secret key for executor authentication. + const string path = path::join(directory.get(), "executor_secret_key"); + + Try<int_fd> fd = os::open( + path, + O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, + S_IRUSR | S_IWUSR | S_IRGRP); + + CHECK_SOME(fd); + + CHECK_SOME(os::write(fd.get(), DEFAULT_EXECUTOR_SECRET_KEY)) + << "Failed to write executor secret key to '" << path << "'"; + + CHECK_SOME(os::close(fd.get())); + + flags.executor_secret_key = path; + } #endif // USE_SSL_SOCKET { http://git-wip-us.apache.org/repos/asf/mesos/blob/8bbe7004/src/tests/mesos.hpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index fe897c1..3cff0e7 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -99,6 +99,11 @@ namespace tests { constexpr char READONLY_HTTP_AUTHENTICATION_REALM[] = "test-readonly-realm"; constexpr char READWRITE_HTTP_AUTHENTICATION_REALM[] = "test-readwrite-realm"; constexpr char DEFAULT_TEST_ROLE[] = "default-role"; +constexpr char DEFAULT_EXECUTOR_SECRET_KEY[] = + "72kUKUFtghAjNbIOvLzfF2RxNBfeM64Bri8g9WhpyaunwqRB/yozHAqSnyHbddAV" + "PcWRQlrJAt871oWgSH+n52vMZ3aVI+AFMzXSo8+sUfMk83IGp0WJefhzeQsjDlGH" + "GYQgCAuGim0BE2X5U+lEue8s697uQpAO8L/FFRuDH2s"; + // Forward declarations. class MockExecutor;