MCPcopy Create free account
hub / github.com/apache/mesos / SetUp

Method SetUp

src/tests/containerizer/port_mapping_tests.cpp:226–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224
225protected:
226 virtual void SetUp()
227 {
228 TemporaryDirectoryTest::SetUp();
229
230 flags = CreateSlaveFlags();
231
232 // Guess the name of the public interface.
233 Result<string> _eth0 = link::eth0();
234 ASSERT_SOME(_eth0) << "Failed to guess the name of the public interface";
235
236 eth0 = _eth0.get();
237
238 LOG(INFO) << "Using " << eth0 << " as the public interface";
239
240 // Guess the name of the loopback interface.
241 Result<string> _lo = link::lo();
242 ASSERT_SOME(_lo) << "Failed to guess the name of the loopback interface";
243
244 lo = _lo.get();
245
246 LOG(INFO) << "Using " << lo << " as the loopback interface";
247
248 // Clean up qdiscs and veth devices.
249 cleanup(eth0, lo);
250
251 // Get host IP address.
252 Result<net::IP::Network> hostIPNetwork =
253 net::IP::Network::fromLinkDevice(eth0, AF_INET);
254
255 ASSERT_SOME(hostIPNetwork)
256 << "Failed to retrieve the host public IP network from " << eth0 << ": "
257 << hostIPNetwork.error();
258
259 hostIP = hostIPNetwork->address();
260
261 // Get all the external name servers for tests that need to talk
262 // to an external host, e.g., ping, DNS.
263 Try<string> read = os::read("/etc/resolv.conf");
264 ASSERT_SOME(read);
265
266 foreach (const string& line, strings::split(read.get(), "\n")) {
267 if (!strings::startsWith(line, "nameserver")) {
268 continue;
269 }
270
271 vector<string> tokens = strings::split(line, " ");
272 ASSERT_LE(2u, tokens.size()) << "Unexpected format in '/etc/resolv.conf'";
273 if (tokens[1] != "127.0.0.1") {
274 nameServers.push_back(tokens[1]);
275 }
276 }
277
278 container1Ready = path::join(os::getcwd(), "container1_ready");
279 container2Ready = path::join(os::getcwd(), "container2_ready");
280 trafficViaLoopback = path::join(os::getcwd(), "traffic_via_loopback");
281 trafficViaPublic = path::join(os::getcwd(), "traffic_via_public");
282 exitStatus = path::join(os::getcwd(), "exit_status");
283 }

Callers

nothing calls this directly

Calls 12

eth0Function · 0.85
loFunction · 0.85
startsWithFunction · 0.85
splitFunction · 0.85
cleanupFunction · 0.70
errorMethod · 0.65
readFunction · 0.50
joinFunction · 0.50
getcwdFunction · 0.50
getMethod · 0.45
addressMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected