blob: 253be0873375252bf0ef0747743427ae5cd9baeb [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>Apache Mesos: src/tests/utils.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Apache Mesos
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&#160;List</span></a></li>
<li><a href="globals.html"><span>File&#160;Members</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_d93a1d4020dea85bb71b237545b5e722.html">tests</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">utils.hpp</div> </div>
</div><!--header-->
<div class="contents">
<a href="src_2tests_2utils_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;<span class="comment">// Licensed to the Apache Software Foundation (ASF) under one</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="comment">// or more contributor license agreements. See the NOTICE file</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<span class="comment">// distributed with this work for additional information</span></div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;<span class="comment">// regarding copyright ownership. The ASF licenses this file</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160;<span class="comment">// to you under the Apache License, Version 2.0 (the</span></div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<span class="comment">// &quot;License&quot;); you may not use this file except in compliance</span></div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;<span class="comment">// with the License. You may obtain a copy of the License at</span></div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;<span class="comment">// Unless required by applicable law or agreed to in writing, software</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="comment">// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="comment">// See the License for the specific language governing permissions and</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="comment">// limitations under the License.</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;</div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="preprocessor">#ifndef __TESTS_UTILS_HPP__</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define __TESTS_UTILS_HPP__</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="preprocessor">#include &lt;stdint.h&gt;</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;</div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;</div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="3rdparty_2stout_2include_2stout_2ip_8hpp.html">stout/ip.hpp</a>&gt;</span></div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="json_8hpp.html">stout/json.hpp</a>&gt;</span></div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="try_8hpp.html">stout/try.hpp</a>&gt;</span></div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;</div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;<span class="keyword">namespace </span>mesos {</div>
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160;<span class="keyword">namespace </span>internal {</div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160;<span class="keyword">namespace </span>tests {</div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160;</div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160;<span class="comment">// Get the metrics snapshot.</span></div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160;<span class="comment">// TODO(vinod): Move this into a libprocess utility header.</span></div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160;<a class="code" href="structJSON_1_1Object.html">JSON::Object</a> <a class="code" href="namespacemesos_1_1internal_1_1tests.html#ace210c8852d8ef1f0f67ec3af06281f6">Metrics</a>();</div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160;</div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160;<span class="comment">// Path finding utilities.</span></div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160;<span class="comment">// Various tests need to access paths to load files or libraries. Normally,</span></div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160;<span class="comment">// these paths are located within the build directory, often in the .libs</span></div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160;<span class="comment">// directories generated by Automake. However, if the Mesos tests were built</span></div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160;<span class="comment">// with --enable-tests-install, we may be running the tests from an installed</span></div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160;<span class="comment">// version of the test suite. In this case, we should always find paths in the</span></div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160;<span class="comment">// installation tree and never the build directory. If the build directory is</span></div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160;<span class="comment">// still present, you can force these helpers to ignore it by passing the</span></div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160;<span class="comment">// --build_dir=/none option to the test suite.</span></div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160;<span class="comment">// The path helpers below all check for a build directory path, then fall back</span></div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160;<span class="comment">// to an installation path only if --enable-tests-install was specified at</span></div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160;<span class="comment">// configuration time.</span></div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160;</div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160;<span class="comment">// Get the path to a named Mesos module.</span></div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160;std::string <a class="code" href="namespacemesos_1_1internal_1_1tests.html#af101a3213477cad5b645f2a875ab5cf1">getModulePath</a>(<span class="keyword">const</span> std::string&amp; <a class="code" href="namespaceos_1_1Shell.html#acfe16ef2b1146ad49a8651c0a457ce46">name</a>);</div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160;</div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160;<span class="comment">// Get the path to libmesos-$(VERSION).so</span></div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160;std::string <a class="code" href="namespacemesos_1_1internal_1_1tests.html#a87fa60a054d95ffe5bc906f86a1630f4">getLibMesosPath</a>();</div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160;</div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160;<span class="comment">// Get the launcher directory for mesos-executor, mesos-containerizer, etc.</span></div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160;std::string <a class="code" href="namespacemesos_1_1internal_1_1tests.html#aca69978cd8f378896cf3e2dd3bdc0d41">getLauncherDir</a>();</div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160;</div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160;<span class="comment">// Get the path to a named test helper.</span></div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160;std::string <a class="code" href="namespacemesos_1_1internal_1_1tests.html#ad97957d87749b129987a73a30210d0a6">getTestHelperPath</a>(<span class="keyword">const</span> std::string&amp; <a class="code" href="namespaceos_1_1Shell.html#acfe16ef2b1146ad49a8651c0a457ce46">name</a>);</div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160;</div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160;<span class="comment">// Get the path to a named test script. In the Mesos source tree,</span></div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160;<span class="comment">// these live in $MESOS_SOURCE_DIR/src/tests. In a tests install</span></div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160;<span class="comment">// they live in $TESTLIBEXECDIR.</span></div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160;std::string <a class="code" href="namespacemesos_1_1internal_1_1tests.html#a5d1a4247404bd5bc7bcb1b1bd77a612f">getTestScriptPath</a>(<span class="keyword">const</span> std::string&amp; <a class="code" href="namespaceos_1_1Shell.html#acfe16ef2b1146ad49a8651c0a457ce46">name</a>);</div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160;<span class="comment">// Get the path to the directory where test helpers are installed.</span></div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160;std::string <a class="code" href="namespacemesos_1_1internal_1_1tests.html#a843ef16a15d05c6c484cf8b52f041668">getTestHelperDir</a>();</div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160;</div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160;<span class="comment">// Get the path to the directory where executables that require super-</span></div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160;<span class="comment">// user privileges are installed.</span></div>
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160;std::string <a class="code" href="namespacemesos_1_1internal_1_1tests.html#aabff32283caaab2a1fff455d8501a73a">getSbinDir</a>();</div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160;</div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160;<span class="comment">// Get the path to the directory of the webui files/assets.</span></div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160;std::string <a class="code" href="namespacemesos_1_1internal_1_1tests.html#a9fde23c25c5ac80169e660e4b3deccf3">getWebUIDir</a>();</div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160;</div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160;<span class="comment">// Get a random unused port.</span></div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160;<span class="comment">// NOTE: While we make sure that the port returned by this function is</span></div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160;<span class="comment">// unused when this function returns, it might become used before the</span></div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>&#160;<span class="comment">// caller can bind to it.</span></div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>&#160;<a class="code" href="classTry.html">Try&lt;uint16_t&gt;</a> <a class="code" href="namespacemesos_1_1internal_1_1tests.html#a211b38db9f9e4bb59a2404a42cf7fb38">getFreePort</a>();</div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160;</div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160;<span class="comment">// Get a non-loopback IP available on this host.</span></div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160;<a class="code" href="classTry.html">Try&lt;net::IPNetwork&gt;</a> <a class="code" href="namespacemesos_1_1internal_1_1tests.html#abc67b81851f938a1927a11d458b7d128">getNonLoopbackIP</a>();</div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160;</div>
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160;} <span class="comment">// namespace tests {</span></div>
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160;} <span class="comment">// namespace internal {</span></div>
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160;} <span class="comment">// namespace mesos {</span></div>
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160;</div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160;<span class="preprocessor">#endif // __TESTS_UTILS_HPP__</span></div>
<div class="ttc" id="namespacemesos_1_1internal_1_1tests_html_a211b38db9f9e4bb59a2404a42cf7fb38"><div class="ttname"><a href="namespacemesos_1_1internal_1_1tests.html#a211b38db9f9e4bb59a2404a42cf7fb38">mesos::internal::tests::getFreePort</a></div><div class="ttdeci">Try&lt; uint16_t &gt; getFreePort()</div></div>
<div class="ttc" id="classTry_html"><div class="ttname"><a href="classTry.html">Try</a></div><div class="ttdef"><b>Definition:</b> try.hpp:34</div></div>
<div class="ttc" id="3rdparty_2stout_2include_2stout_2ip_8hpp_html"><div class="ttname"><a href="3rdparty_2stout_2include_2stout_2ip_8hpp.html">ip.hpp</a></div></div>
<div class="ttc" id="namespacemesos_1_1internal_1_1tests_html_abc67b81851f938a1927a11d458b7d128"><div class="ttname"><a href="namespacemesos_1_1internal_1_1tests.html#abc67b81851f938a1927a11d458b7d128">mesos::internal::tests::getNonLoopbackIP</a></div><div class="ttdeci">Try&lt; net::IPNetwork &gt; getNonLoopbackIP()</div></div>
<div class="ttc" id="namespacemesos_1_1internal_1_1tests_html_aabff32283caaab2a1fff455d8501a73a"><div class="ttname"><a href="namespacemesos_1_1internal_1_1tests.html#aabff32283caaab2a1fff455d8501a73a">mesos::internal::tests::getSbinDir</a></div><div class="ttdeci">std::string getSbinDir()</div></div>
<div class="ttc" id="json_8hpp_html"><div class="ttname"><a href="json_8hpp.html">json.hpp</a></div></div>
<div class="ttc" id="namespacemesos_1_1internal_1_1tests_html_a843ef16a15d05c6c484cf8b52f041668"><div class="ttname"><a href="namespacemesos_1_1internal_1_1tests.html#a843ef16a15d05c6c484cf8b52f041668">mesos::internal::tests::getTestHelperDir</a></div><div class="ttdeci">std::string getTestHelperDir()</div></div>
<div class="ttc" id="structJSON_1_1Object_html"><div class="ttname"><a href="structJSON_1_1Object.html">JSON::Object</a></div><div class="ttdef"><b>Definition:</b> json.hpp:151</div></div>
<div class="ttc" id="namespacemesos_1_1internal_1_1tests_html_aca69978cd8f378896cf3e2dd3bdc0d41"><div class="ttname"><a href="namespacemesos_1_1internal_1_1tests.html#aca69978cd8f378896cf3e2dd3bdc0d41">mesos::internal::tests::getLauncherDir</a></div><div class="ttdeci">std::string getLauncherDir()</div></div>
<div class="ttc" id="namespacemesos_1_1internal_1_1tests_html_a87fa60a054d95ffe5bc906f86a1630f4"><div class="ttname"><a href="namespacemesos_1_1internal_1_1tests.html#a87fa60a054d95ffe5bc906f86a1630f4">mesos::internal::tests::getLibMesosPath</a></div><div class="ttdeci">std::string getLibMesosPath()</div></div>
<div class="ttc" id="try_8hpp_html"><div class="ttname"><a href="try_8hpp.html">try.hpp</a></div></div>
<div class="ttc" id="namespacemesos_1_1internal_1_1tests_html_a5d1a4247404bd5bc7bcb1b1bd77a612f"><div class="ttname"><a href="namespacemesos_1_1internal_1_1tests.html#a5d1a4247404bd5bc7bcb1b1bd77a612f">mesos::internal::tests::getTestScriptPath</a></div><div class="ttdeci">std::string getTestScriptPath(const std::string &amp;name)</div></div>
<div class="ttc" id="namespacemesos_1_1internal_1_1tests_html_a9fde23c25c5ac80169e660e4b3deccf3"><div class="ttname"><a href="namespacemesos_1_1internal_1_1tests.html#a9fde23c25c5ac80169e660e4b3deccf3">mesos::internal::tests::getWebUIDir</a></div><div class="ttdeci">std::string getWebUIDir()</div></div>
<div class="ttc" id="namespacemesos_1_1internal_1_1tests_html_af101a3213477cad5b645f2a875ab5cf1"><div class="ttname"><a href="namespacemesos_1_1internal_1_1tests.html#af101a3213477cad5b645f2a875ab5cf1">mesos::internal::tests::getModulePath</a></div><div class="ttdeci">std::string getModulePath(const std::string &amp;name)</div></div>
<div class="ttc" id="namespacemesos_1_1internal_1_1tests_html_ace210c8852d8ef1f0f67ec3af06281f6"><div class="ttname"><a href="namespacemesos_1_1internal_1_1tests.html#ace210c8852d8ef1f0f67ec3af06281f6">mesos::internal::tests::Metrics</a></div><div class="ttdeci">JSON::Object Metrics()</div></div>
<div class="ttc" id="namespacemesos_1_1internal_1_1tests_html_ad97957d87749b129987a73a30210d0a6"><div class="ttname"><a href="namespacemesos_1_1internal_1_1tests.html#ad97957d87749b129987a73a30210d0a6">mesos::internal::tests::getTestHelperPath</a></div><div class="ttdeci">std::string getTestHelperPath(const std::string &amp;name)</div></div>
<div class="ttc" id="namespaceos_1_1Shell_html_acfe16ef2b1146ad49a8651c0a457ce46"><div class="ttname"><a href="namespaceos_1_1Shell.html#acfe16ef2b1146ad49a8651c0a457ce46">os::Shell::name</a></div><div class="ttdeci">constexpr const char * name</div><div class="ttdef"><b>Definition:</b> shell.hpp:41</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.5
</small></address>
</body>
</html>