You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2018/08/11 20:35:10 UTC
[mesos] branch master updated: Re-enabled the flaky CNI port mapper
test.
This is an automated email from the ASF dual-hosted git repository.
jieyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push:
new 3d947c4 Re-enabled the flaky CNI port mapper test.
3d947c4 is described below
commit 3d947c46b7015a50af373f78bcf6cec5f344c78b
Author: Jie Yu <yu...@gmail.com>
AuthorDate: Fri Aug 10 09:37:21 2018 -0700
Re-enabled the flaky CNI port mapper test.
On some platforms, the iptables command is too old. This patch add a
test filter for checking that. Also, used `executorTerminated` as a way
to wait for the termination of the executor, instead of using gc
schedule signal.
---
src/tests/containerizer/cni_isolator_tests.cpp | 11 +++---
src/tests/environment.cpp | 52 ++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 6 deletions(-)
diff --git a/src/tests/containerizer/cni_isolator_tests.cpp b/src/tests/containerizer/cni_isolator_tests.cpp
index cae2c19..cb22e73 100644
--- a/src/tests/containerizer/cni_isolator_tests.cpp
+++ b/src/tests/containerizer/cni_isolator_tests.cpp
@@ -1871,7 +1871,7 @@ public:
};
-TEST_F(CniIsolatorPortMapperTest, DISABLED_ROOT_NC_PortMapper)
+TEST_F(CniIsolatorPortMapperTest, ROOT_IPTABLES_NC_PortMapper)
{
constexpr size_t NUM_CONTAINERS = 3;
@@ -1998,10 +1998,9 @@ TEST_F(CniIsolatorPortMapperTest, DISABLED_ROOT_NC_PortMapper)
// Wait for the executor to exit. We are using 'gc.schedule' as a
// proxy event to monitor the exit of the executor.
- vector<Future<Nothing>> gcSchedules(NUM_CONTAINERS);
+ vector<Future<Nothing>> executorTerminations(NUM_CONTAINERS);
for (size_t i = 0; i < NUM_CONTAINERS; i++) {
- gcSchedules[i] = FUTURE_DISPATCH(
- _, &slave::GarbageCollectorProcess::schedule);
+ executorTerminations[i] = FUTURE_DISPATCH(_, &Slave::executorTerminated);
}
// Try connecting to each nc server on the given container port
@@ -2016,7 +2015,7 @@ TEST_F(CniIsolatorPortMapperTest, DISABLED_ROOT_NC_PortMapper)
Duration waited = Duration::zero();
do {
Try<string> connect = os::shell(
- "echo foo | nc " + stringify(hostNetwork->address()) +
+ "echo foo | nc -w 1 " + stringify(hostNetwork->address()) +
" " + stringify(hostPorts[i]));
if (connect.isSome()) {
@@ -2032,7 +2031,7 @@ TEST_F(CniIsolatorPortMapperTest, DISABLED_ROOT_NC_PortMapper)
}
AWAIT_READY(collect(statusesFinished));
- AWAIT_READY(collect(gcSchedules));
+ AWAIT_READY(collect(executorTerminations));
// Make sure the iptables chain `MESOS-TEST-PORT-MAPPER-CHAIN`
// doesn't have any iptable rules once the task is killed. The only
diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp
index 784f8fa..8c6ec58 100644
--- a/src/tests/environment.cpp
+++ b/src/tests/environment.cpp
@@ -544,6 +544,57 @@ private:
};
+class IPTablesFilter : public TestFilter
+{
+public:
+ IPTablesFilter()
+ {
+#ifdef __linux__
+ // Check iptables -w option
+ //
+ if (os::which("iptables").isNone()) {
+ std::cerr
+ << "-------------------------------------------------------------\n"
+ << "No 'iptables' command found so no tests depending\n"
+ << "on 'iptables' will be run\n"
+ << "-------------------------------------------------------------"
+ << std::endl;
+
+ iptablesError = Error("iptables command not found");
+ return;
+ }
+
+ if (::geteuid() != 0) {
+ iptablesError = Error("iptables command requires root");
+ return;
+ }
+
+ Try<string> iptables = os::shell("iptables -w -n -L OUTPUT");
+ if (iptables.isError()) {
+ std::cerr
+ << "-------------------------------------------------------------\n"
+ << "'iptables' command does not support '-w' option\n"
+ << "-------------------------------------------------------------"
+ << std::endl;
+
+ iptablesError = Error("iptables command does not support -w option");
+ return;
+ }
+#else
+ iptablesError = Error("Unsupported platform");
+#endif
+ }
+
+ bool disable(const ::testing::TestInfo* test) const override
+ {
+ return iptablesError.isSome() && matches(test, "IPTABLES_");
+ }
+
+private:
+ Option<Error> iptablesError;
+};
+
+
class LogrotateFilter : public TestFilter
{
public:
@@ -933,6 +984,7 @@ Environment::Environment(const Flags& _flags)
std::make_shared<DockerFilter>(),
std::make_shared<DtypeFilter>(),
std::make_shared<InternetFilter>(),
+ std::make_shared<IPTablesFilter>(),
std::make_shared<LogrotateFilter>(),
std::make_shared<NetcatFilter>(),
std::make_shared<NetClsCgroupsFilter>(),