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 2016/01/20 19:09:01 UTC
[5/5] mesos git commit: Added a filter to disable NetClsIsolator
tests.
Added a filter to disable NetClsIsolator tests.
We will disable the NetClsIsolator tests in case the net_cls cgroup
subsystem is disabled.
Review: https://reviews.apache.org/r/42211/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6af5f059
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6af5f059
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6af5f059
Branch: refs/heads/master
Commit: 6af5f059795bc38a0748a01cb0b55fbba353149c
Parents: 43b9454
Author: Avinash sridharan <av...@mesosphere.io>
Authored: Wed Jan 20 10:05:22 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jan 20 10:07:21 2016 -0800
----------------------------------------------------------------------
src/tests/environment.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/6af5f059/src/tests/environment.cpp
----------------------------------------------------------------------
diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp
index a6322f2..4de46bc 100644
--- a/src/tests/environment.cpp
+++ b/src/tests/environment.cpp
@@ -337,6 +337,63 @@ private:
};
+// This filter enables tests for the cgroups/net_cls isolator after
+// checking that net_cls cgroup subsystem has been enabled on the
+// system. We cannot rely on the generic cgroups test filter
+// ('CgroupsFilter') to enable the cgroups/net_cls isolator tests
+// since, although cgroups might be enabled on a linux distribution
+// the net_cls subsystem is not turned on, by default, on all
+// distributions.
+class NetClsCgroupsFilter : public TestFilter
+{
+public:
+ NetClsCgroupsFilter()
+ {
+ netClsError = true;
+#ifdef __linux__
+ Try<bool> netCls = cgroups::enabled("net_cls");
+
+ if (netCls.isError()) {
+ std::cerr
+ << "-------------------------------------------------------------\n"
+ << "Cannot enable NetClsIsolatorTest since we cannot determine \n"
+ << "the existence of the net_cls cgroup subsystem.\n"
+ << "-------------------------------------------------------------\n";
+ return;
+ }
+
+ if (netCls.isSome() && !netCls.get()) {
+ std::cerr
+ << "-------------------------------------------------------------\n"
+ << "Cannot enable NetClsIsolatorTest since net_cls cgroup \n"
+ << "subsystem is not enabled. Check instructions for your linux\n"
+ << "distrubtion to enable the net_cls cgroups on your system.\n"
+ << "-----------------------------------------------------------\n";
+ return;
+ }
+ netClsError = false;
+#else
+ std::cerr
+ << "-----------------------------------------------------------\n"
+ << "Cannot enable NetClsIsolatorTest since this platform does\n"
+ << "not support cgroups.\n"
+ << "-----------------------------------------------------------\n";
+#endif
+ }
+
+ bool disable(const ::testing::TestInfo* test) const
+ {
+ if (matches(test, "NetClsIsolatorTest")) {
+ return netClsError;
+ }
+ return false;
+ }
+
+private:
+ bool netClsError;
+};
+
+
class NetworkIsolatorTestFilter : public TestFilter
{
public:
@@ -554,6 +611,7 @@ Environment::Environment(const Flags& _flags) : flags(_flags)
filters.push_back(Owned<TestFilter>(new DockerFilter()));
filters.push_back(Owned<TestFilter>(new InternetFilter()));
filters.push_back(Owned<TestFilter>(new NetcatFilter()));
+ filters.push_back(Owned<TestFilter>(new NetClsCgroupsFilter()));
filters.push_back(Owned<TestFilter>(new NetworkIsolatorTestFilter()));
filters.push_back(Owned<TestFilter>(new PerfCPUCyclesFilter()));
filters.push_back(Owned<TestFilter>(new PerfFilter()));