Apache Mesos
flags.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __TESTS_FLAGS_HPP__
18 #define __TESTS_FLAGS_HPP__
19 
20 #include <string>
21 
22 #include <mesos/type_utils.hpp>
23 
24 #include <stout/check.hpp>
25 #include <stout/flags.hpp>
26 #include <stout/os.hpp>
27 
28 #include <stout/os/realpath.hpp>
29 
30 #include "common/parse.hpp"
31 
32 #include "logging/logging.hpp"
33 
34 #include "master/constants.hpp"
35 
36 #include "messages/messages.hpp"
37 
38 #include "slave/constants.hpp"
39 
40 namespace mesos {
41 namespace internal {
42 namespace tests {
43 
44 class Flags : public virtual logging::Flags
45 {
46 public:
48  {
49  // We log to stderr by default, but when running tests we'd prefer
50  // less junk to fly by, so force one to specify the verbosity.
52  "verbose",
53  "Log all severity levels to stderr",
54  false);
55 
57  "benchmark",
58  "Run the benchmark tests (and skip other tests)",
59  false);
60 
61  // We determine the defaults for 'source_dir' and 'build_dir' from
62  // preprocessor definitions (at the time this comment was written
63  // these were set via '-DSOURCE_DIR=...' and '-DBUILD_DIR=...' in
64  // src/Makefile.am).
65  Result<std::string> path = os::realpath(SOURCE_DIR);
66  CHECK_SOME(path);
68  "source_dir",
69  "Where to find the source directory",
70  path.get());
71 
72  path = os::realpath(BUILD_DIR);
73  CHECK_SOME(path);
74 
76  "build_dir",
77  "Where to find the build directory",
78  path.get());
79 
81  "docker",
82  "Where to find docker executable",
83  "docker");
84 
86  "docker_socket",
87  "Resource used by the agent and the executor to provide CLI access\n"
88  "to the Docker daemon. On Unix, this is typically a path to a\n"
89  "socket, such as '/var/run/docker.sock'. On Windows this must be a\n"
90  "named pipe, such as '//./pipe/docker_engine'. NOTE: This must be\n"
91  "the path used by the Docker image used to run the agent.\n",
93 
94  // This help message for --modules flag is the same for
95  // {master,slave,sched,tests}/flags.[ch]pp and should always be kept in
96  // sync.
97  // TODO(karya): Remove the JSON example and add reference to the
98  // doc file explaining the --modules flag.
100  "modules",
101  "List of modules to be loaded and be available to the internal\n"
102  "subsystems.\n"
103  "\n"
104  "Use --modules=filepath to specify the list of modules via a\n"
105  "file containing a JSON-formatted string. 'filepath' can be\n"
106  "of the form 'file:///path/to/file' or '/path/to/file'.\n"
107  "\n"
108  "Use --modules=\"{...}\" to specify the list of modules inline.\n"
109  "\n"
110  "Example:\n"
111  "{\n"
112  " \"libraries\": [\n"
113  " {\n"
114  " \"file\": \"/path/to/libfoo.so\",\n"
115  " \"modules\": [\n"
116  " {\n"
117  " \"name\": \"org_apache_mesos_bar\",\n"
118  " \"parameters\": [\n"
119  " {\n"
120  " \"key\": \"X\",\n"
121  " \"value\": \"Y\"\n"
122  " }\n"
123  " ]\n"
124  " },\n"
125  " {\n"
126  " \"name\": \"org_apache_mesos_baz\"\n"
127  " }\n"
128  " ]\n"
129  " },\n"
130  " {\n"
131  " \"name\": \"qux\",\n"
132  " \"modules\": [\n"
133  " {\n"
134  " \"name\": \"org_apache_mesos_norf\"\n"
135  " }\n"
136  " ]\n"
137  " }\n"
138  " ]\n"
139  "}");
140 
141  // This help message for --modules_dir flag is the same for
142  // {master,slave,sched,tests}/flags.[ch]pp and should always be kept in
143  // sync.
145  "modules_dir",
146  "Directory path of the module manifest files.\n"
147  "The manifest files are processed in alphabetical order.\n"
148  "(See --modules for more information on module manifest files).\n"
149  "Cannot be used in conjunction with --modules.\n");
150 
151  // This help message is duplicated from slave/flags.hpp and
152  // should always be kept in sync with that.
154  "isolation",
155  "Isolation mechanisms to use, e.g., 'posix/cpu,posix/mem', or\n"
156  "'cgroups/cpu,cgroups/mem', or network/port_mapping\n"
157  "(configure with flag: --with-network-isolator to enable),\n"
158  "or 'external', or load an alternate isolator module using\n"
159  "the --modules flag.");
160 
161  // This help message is duplicated from master/flags.hpp and
162  // should always be kept in sync with that.
164  "authenticators",
165  "Authenticator implementation to use when authenticating frameworks\n"
166  "and/or agents. Use the default '" +
167  std::string(master::DEFAULT_AUTHENTICATOR) + "', or\n"
168  "load an alternate authenticator module using --modules.",
170  }
171 
172  bool verbose;
173  bool benchmark;
174  std::string source_dir;
175  std::string build_dir;
176  std::string docker;
177  std::string docker_socket;
181  std::string authenticators;
182 };
183 
184 // Global flags for running the tests.
185 extern Flags flags;
186 
187 } // namespace tests {
188 } // namespace internal {
189 } // namespace mesos {
190 
191 #endif // __TESTS_FLAGS_HPP__
Option< Modules > modules
Definition: flags.hpp:178
std::string build_dir
Definition: flags.hpp:175
std::string authenticators
Definition: flags.hpp:181
Definition: flags.hpp:29
Result< std::string > realpath(const std::string &path)
Definition: realpath.hpp:24
constexpr char DEFAULT_DOCKER_HOST_RESOURCE[]
Definition: constants.hpp:120
Definition: result.hpp:40
Flags()
Definition: flags.hpp:47
Option< std::string > modulesDir
Definition: flags.hpp:179
#define CHECK_SOME(expression)
Definition: check.hpp:44
Definition: flags.hpp:44
const T & get() const
Definition: result.hpp:115
Option< std::string > isolation
Definition: flags.hpp:180
constexpr char DEFAULT_AUTHENTICATOR[]
Definition: constants.hpp:128
void add(T1 Flags::*t1, const Name &name, const Option< Name > &alias, const std::string &help, const T2 *t2, F validate)
Definition: flags.hpp:333
bool verbose
Definition: flags.hpp:172
std::string docker_socket
Definition: flags.hpp:177
std::string docker
Definition: flags.hpp:176
std::string source_dir
Definition: flags.hpp:174
bool benchmark
Definition: flags.hpp:173