Apache Mesos
utils.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_UTILS_HPP__
18 #define __TESTS_UTILS_HPP__
19 
20 #include <stdint.h>
21 
22 #include <string>
23 
24 #include <stout/ip.hpp>
25 #include <stout/json.hpp>
26 #include <stout/try.hpp>
27 
28 namespace mesos {
29 namespace internal {
30 namespace tests {
31 
32 // Get the metrics snapshot.
33 // TODO(vinod): Move this into a libprocess utility header.
35 
36 // Path finding utilities.
37 //
38 // Various tests need to access paths to load files or libraries. Normally,
39 // these paths are located within the build directory, often in the .libs
40 // directories generated by Automake. However, if the Mesos tests were built
41 // with --enable-tests-install, we may be running the tests from an installed
42 // version of the test suite. In this case, we should always find paths in the
43 // installation tree and never the build directory. If the build directory is
44 // still present, you can force these helpers to ignore it by passing the
45 // --build_dir=/none option to the test suite.
46 //
47 // The path helpers below all check for a build directory path, then fall back
48 // to an installation path only if --enable-tests-install was specified at
49 // configuration time.
50 
51 // Get the path to a named Mesos module.
52 std::string getModulePath(const std::string& name);
53 
54 // Get the path to libmesos-$(VERSION).so
55 std::string getLibMesosPath();
56 
57 // Get the launcher directory for mesos-executor, mesos-containerizer, etc.
58 std::string getLauncherDir();
59 
60 // Get the path to a named test helper.
61 std::string getTestHelperPath(const std::string& name);
62 
63 // Get the path to a named test script. In the Mesos source tree,
64 // these live in $MESOS_SOURCE_DIR/src/tests. In a tests install
65 // they live in $TESTLIBEXECDIR.
66 std::string getTestScriptPath(const std::string& name);
67 
68 // Get the path to the directory where test helpers are installed.
69 std::string getTestHelperDir();
70 
71 // Get the path to the directory where executables that require super-
72 // user privileges are installed.
73 std::string getSbinDir();
74 
75 // Get the path to the directory of the webui files/assets.
76 std::string getWebUIDir();
77 
78 // Get a random unused port.
79 //
80 // NOTE: While we make sure that the port returned by this function is
81 // unused when this function returns, it might become used before the
82 // caller can bind to it.
84 
85 // Get a non-loopback IP available on this host.
87 
88 } // namespace tests {
89 } // namespace internal {
90 } // namespace mesos {
91 
92 #endif // __TESTS_UTILS_HPP__
Try< uint16_t > getFreePort()
Definition: check.hpp:33
std::string getSbinDir()
std::string getTestHelperDir()
Definition: json.hpp:158
Try< net::IP::Network > getNonLoopbackIP()
Definition: spec.hpp:30
std::string getLauncherDir()
std::string getLibMesosPath()
Definition: attributes.hpp:24
std::string getTestScriptPath(const std::string &name)
std::string getWebUIDir()
std::string getModulePath(const std::string &name)
JSON::Object Metrics()
std::string getTestHelperPath(const std::string &name)
constexpr const char * name
Definition: shell.hpp:43