Change in vdsm[master]: tests: Make unit tests the default

nsoffer at redhat.com nsoffer at redhat.com
Wed Apr 6 09:14:19 UTC 2016


Nir Soffer has uploaded a new change for review.

Change subject: tests: Make unit tests the default
......................................................................

tests: Make unit tests the default

Switch the way new unit tests are marked - instead of marking testing as
type='unit', mark integration tests as type='integration'.

Remove the now unneeded check-unit - the check target should run only
unit tests. To run all the tests, use the check-all target. We may like
to add separate targets for integration tests in another patch.

Finally, update travis configuration to run "make check", running all
vdsm tests instead of only the new network tests.

We have about 2000 tests - some of them are not unit tests and will
probably fail on travis. We will mark them as integration tests in the
following patch.

Change-Id: I94751f8f3e3d4849f61ea11718afda5b1484c28f
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M .travis.yml
M Makefile.am
M tests/Makefile.am
M tests/network/conf_persistence_test.py
M tests/network/conf_test.py
M tests/network/config_network_test.py
M tests/network/connectivity_test.py
M tests/network/ip_test.py
M tests/network/iproute2_test.py
M tests/network/ipwrapper_test.py
M tests/network/link_test.py
M tests/network/models_test.py
M tests/network/netinfo_test.py
M tests/network/qos_test.py
M tests/network/sourcerouting_test.py
M tests/network/tc_test.py
M tests/network/unified_persistence_test.py
M tests/run_tests_local.sh.in
18 files changed, 20 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/28/55728/1

diff --git a/.travis.yml b/.travis.yml
index 8974bbb..9f66925 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,4 +12,4 @@
   - docker pull edwardhaas/ovirt-vdsm-dev
 
 script:
-  - docker run --rm=true -it -v `pwd`:/vdsm:rw edwardhaas/ovirt-vdsm-dev /bin/bash -c "cd /vdsm && ./autogen.sh --system && make; make check-unit"
+  - docker run --rm=true -it -v `pwd`:/vdsm:rw edwardhaas/ovirt-vdsm-dev /bin/bash -c "cd /vdsm && ./autogen.sh --system && make; make check"
diff --git a/Makefile.am b/Makefile.am
index 4ce5ec5..d6d7c62 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -131,11 +131,7 @@
 
 .PHONY: check-all
 check-all:
-	$(MAKE) check NOSE_STRESS_TESTS=1 NOSE_SLOW_TESTS=1
-
-.PHONY: check-unit
-check-unit:
-	$(MAKE) -C tests/ check args='-a type=unit'
+	$(MAKE) check NOSE_STRESS_TESTS=1 NOSE_SLOW_TESTS=1 NOSE_EVAL_ATTR=""
 
 all-local: \
 	vdsm.spec
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 446dcfa..657c13f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -268,8 +268,8 @@
 check-local:
 	@echo '*** Running tests.  To skip this step place NOSE_EXCLUDE=.* ***'
 	@echo '*** into your environment.  Do not submit untested code!    ***'
-	$(top_srcdir)/tests/run_tests_local.sh $(args) crossImportsTests.py
-	$(top_srcdir)/tests/run_tests_local.sh $(args) $(run_modules)
+	$(top_srcdir)/tests/run_tests_local.sh crossImportsTests.py
+	$(top_srcdir)/tests/run_tests_local.sh $(run_modules)
 	if [ "$(PYTHON3_SUPPORT)" == "1" ]; then \
 	    PYTHON_EXE="$(PYTHON3)" $(top_srcdir)/tests/run_tests_local.sh \
 	        $(test_modules_py3); \
diff --git a/tests/network/conf_persistence_test.py b/tests/network/conf_persistence_test.py
index f5abad1..a7b7c84 100644
--- a/tests/network/conf_persistence_test.py
+++ b/tests/network/conf_persistence_test.py
@@ -26,8 +26,6 @@
 from shutil import rmtree
 import tempfile
 
-from nose.plugins.attrib import attr
-
 from vdsm.netconfpersistence import Config
 from vdsm.utils import rmFile
 
@@ -41,7 +39,6 @@
 BONDING_ATTRIBUTES = {'options': 'mode=4 miimon=100', 'nics': ['eth0', 'eth1']}
 
 
- at attr(type='unit')
 class NetConfPersistenceTests(TestCaseBase):
     def setUp(self):
         self.tempdir = tempfile.mkdtemp()
diff --git a/tests/network/conf_test.py b/tests/network/conf_test.py
index 9b3e69b..fca1e50 100644
--- a/tests/network/conf_test.py
+++ b/tests/network/conf_test.py
@@ -38,7 +38,6 @@
 from testlib import VdsmTestCase as TestCaseBase
 
 
- at attr(type='unit')
 class ifcfgConfigWriterTests(TestCaseBase):
     INITIAL_CONTENT = '123-testing'
     SOME_GARBAGE = '456'
diff --git a/tests/network/config_network_test.py b/tests/network/config_network_test.py
index f1e62d3..abc559a 100644
--- a/tests/network/config_network_test.py
+++ b/tests/network/config_network_test.py
@@ -22,8 +22,6 @@
 
 from __future__ import absolute_import
 
-from nose.plugins.attrib import attr
-
 from vdsm import netinfo
 from vdsm.netinfo import mtus
 from vdsm.netinfo.mtus import DEFAULT_MTU
@@ -48,7 +46,6 @@
                         'testing.')
 
 
- at attr(type='unit')
 class TestConfigNetwork(TestCaseBase):
 
     def _addNetworkWithExc(self, netName, opts, errCode):
diff --git a/tests/network/connectivity_test.py b/tests/network/connectivity_test.py
index 7fee447..9694e5f 100644
--- a/tests/network/connectivity_test.py
+++ b/tests/network/connectivity_test.py
@@ -23,8 +23,6 @@
 import os
 from time import time
 
-from nose.plugins.attrib import attr
-
 from vdsm.network import connectivity
 from vdsm.network.errors import ConfigNetworkError
 
@@ -40,7 +38,6 @@
     return namedtuple('st', ['st_mtime'])(0)
 
 
- at attr(type='unit')
 class TestConnectivity(VdsmTestCase):
 
     def test_check_disabled(self):
diff --git a/tests/network/ip_test.py b/tests/network/ip_test.py
index 8dc328e..9fbdf5d 100644
--- a/tests/network/ip_test.py
+++ b/tests/network/ip_test.py
@@ -18,14 +18,11 @@
 #
 from __future__ import absolute_import
 
-from nose.plugins.attrib import attr
-
 from testlib import VdsmTestCase
 
 from vdsm.network.ip import address
 
 
- at attr(type='unit')
 class TestAddressIP(VdsmTestCase):
 
     def test_ipv4_clean_init(self):
diff --git a/tests/network/iproute2_test.py b/tests/network/iproute2_test.py
index a36a448..647872f 100644
--- a/tests/network/iproute2_test.py
+++ b/tests/network/iproute2_test.py
@@ -21,6 +21,8 @@
 from __future__ import absolute_import
 from subprocess import Popen, PIPE
 
+from nose.plugins.attrib import attr
+
 from testlib import VdsmTestCase as TestCaseBase
 from testValidation import ValidateRunningAsRoot
 
@@ -30,6 +32,7 @@
 from .nettestlib import Bridge, requires_brctl
 
 
+ at attr(type='integration')
 class TestBridgeOverwrite(TestCaseBase):
     _bridge = Bridge()
 
diff --git a/tests/network/ipwrapper_test.py b/tests/network/ipwrapper_test.py
index 32d1a93..239ebc8 100644
--- a/tests/network/ipwrapper_test.py
+++ b/tests/network/ipwrapper_test.py
@@ -37,7 +37,6 @@
     pass
 
 
- at attr(type='unit')
 class TestIpwrapper(TestCaseBase):
     def testRouteFromText(self):
         _getRouteAttrs = lambda x: (x.network, x.via, x.device, x.table)
@@ -98,6 +97,7 @@
             self.assertRaises(ValueError, Rule.fromText, text)
 
 
+ at attr(type='integration')
 class TestLinks(TestCaseBase):
 
     @ValidateRunningAsRoot
@@ -117,6 +117,7 @@
         self.assertEqual(link.name, self._bridge.devName)
 
 
+ at attr(type='integration')
 class TestDrvinfo(TestCaseBase):
 
     @ValidateRunningAsRoot
@@ -149,6 +150,7 @@
                          "Could not disable promiscuous mode.")
 
 
+ at attr(type='integration')
 class TestUnicodeDrvinfo(TestCaseBase):
 
     @ValidateRunningAsRoot
diff --git a/tests/network/link_test.py b/tests/network/link_test.py
index 6336c35..1fd7013 100644
--- a/tests/network/link_test.py
+++ b/tests/network/link_test.py
@@ -23,6 +23,8 @@
 import threading
 import time
 
+from nose.plugins.attrib import attr
+
 from functional.networkTests import IP_ADDRESS, IP_CIDR
 from .nettestlib import Dummy
 from vdsm.netlink import monitor
@@ -33,6 +35,7 @@
 from testlib import VdsmTestCase as TestCaseBase
 
 
+ at attr(type='integration')
 class NetlinkEventMonitorTests(TestCaseBase):
 
     TIMEOUT = 1
@@ -172,6 +175,7 @@
                           '\n'.join([str(_simplify_event(d))
                                      for d in _caught])))
 
+    @attr(type='unit')
     def test_timeout(self):
         with self.assertRaises(monitor.MonitorError):
             try:
@@ -184,6 +188,7 @@
 
         self.assertTrue(mon.is_stopped())
 
+    @attr(type='unit')
     def test_timeout_silent(self):
         with monitor.Monitor(timeout=.01, silent_timeout=True) as mon:
             for event in mon:
@@ -205,6 +210,7 @@
         self.assertTrue((monotonic_time() - time_start) <= self.TIMEOUT)
         self.assertTrue(mon.is_stopped())
 
+    @attr(type='unit')
     def test_passing_invalid_groups(self):
         with self.assertRaises(AttributeError):
             monitor.Monitor(groups=('blablabla',))
diff --git a/tests/network/models_test.py b/tests/network/models_test.py
index 61e182d..d586077 100644
--- a/tests/network/models_test.py
+++ b/tests/network/models_test.py
@@ -22,8 +22,6 @@
 from __future__ import absolute_import
 import os
 
-from nose.plugins.attrib import attr
-
 from vdsm.netinfo import bonding, mtus
 from vdsm.netinfo.cache import CachingNetInfo
 from vdsm.network import errors
@@ -36,7 +34,6 @@
 from monkeypatch import MonkeyPatch, MonkeyClass
 
 
- at attr(type='unit')
 @MonkeyClass(bonding, 'BONDING_DEFAULTS', bonding.BONDING_DEFAULTS
              if os.path.exists(bonding.BONDING_DEFAULTS)
              else '../vdsm/bonding-defaults.json')
diff --git a/tests/network/netinfo_test.py b/tests/network/netinfo_test.py
index c8395dd..9053375 100644
--- a/tests/network/netinfo_test.py
+++ b/tests/network/netinfo_test.py
@@ -45,7 +45,6 @@
 ETHTOOL_SPEEDS = set([10, 100, 1000, 2500, 10000])
 
 
- at attr(type='unit')
 class TestNetinfo(TestCaseBase):
 
     def testGetHostNameservers(self):
diff --git a/tests/network/qos_test.py b/tests/network/qos_test.py
index 4ecd13c..bd148d0 100644
--- a/tests/network/qos_test.py
+++ b/tests/network/qos_test.py
@@ -18,7 +18,6 @@
 #
 
 from __future__ import absolute_import
-from nose.plugins.attrib import attr
 
 from testlib import VdsmTestCase as TestCaseBase
 
@@ -26,7 +25,6 @@
 from vdsm.tc import cls
 
 
- at attr(type='unit')
 class TestConversions(TestCaseBase):
     def test_qos_to_str(self):
         data = (({'ls': {'m1': 100, 'd': 10, 'm2': 300},
diff --git a/tests/network/sourcerouting_test.py b/tests/network/sourcerouting_test.py
index 5322f22..179d18a 100644
--- a/tests/network/sourcerouting_test.py
+++ b/tests/network/sourcerouting_test.py
@@ -21,8 +21,6 @@
 from __future__ import absolute_import
 import os
 
-from nose.plugins.attrib import attr
-
 from testlib import VdsmTestCase as TestCaseBase
 from monkeypatch import MonkeyPatch
 
@@ -38,7 +36,6 @@
         return tabFile.readlines()
 
 
- at attr(type='unit')
 class TestFilters(TestCaseBase):
     @MonkeyPatch(sourceroute, 'routeShowTable', _routeShowTableAll)
     def test_source_route_retrieval(self):
diff --git a/tests/network/tc_test.py b/tests/network/tc_test.py
index dee2484..0633c85 100644
--- a/tests/network/tc_test.py
+++ b/tests/network/tc_test.py
@@ -49,6 +49,7 @@
 from vdsm import tc
 
 
+ at attr(type='integration')
 class TestQdisc(TestCaseBase):
 
     @ValidateRunningAsRoot
@@ -89,7 +90,6 @@
                           "__nosuchiface__", 'ingress')
 
 
- at attr(type='unit')
 class TestFilters(TestCaseBase):
     def test_filter_objs(self):
         dirName = os.path.dirname(os.path.realpath(__file__))
@@ -269,6 +269,7 @@
             self.assertEqual(parsed, correct)
 
 
+ at attr(type='integration')
 class TestPortMirror(TestCaseBase):
 
     """
@@ -396,6 +397,7 @@
 TcFilters = namedtuple('TcFilters', 'untagged_filters, tagged_filters')
 
 
+ at attr(type='integration')
 @MonkeyClass(libvirtconnection, 'get', Connection)
 @expandPermutations
 class TestConfigureOutbound(TestCaseBase):
diff --git a/tests/network/unified_persistence_test.py b/tests/network/unified_persistence_test.py
index 878e16d..faafa58 100644
--- a/tests/network/unified_persistence_test.py
+++ b/tests/network/unified_persistence_test.py
@@ -24,8 +24,6 @@
 import os
 import six
 
-from nose.plugins.attrib import attr
-
 from vdsm.netinfo import misc
 from vdsm.tool import unified_persistence
 
@@ -139,7 +137,6 @@
         yield temp_dir
 
 
- at attr(type='unit')
 class unfiedPersistenceTests(TestCaseBase):
 
     def test_getNetInfo(self):
diff --git a/tests/run_tests_local.sh.in b/tests/run_tests_local.sh.in
index 4721152..afa585b 100644
--- a/tests/run_tests_local.sh.in
+++ b/tests/run_tests_local.sh.in
@@ -3,4 +3,4 @@
     PYTHON_EXE="@PYTHON@"
 fi
 
-PYTHONDONTWRITEBYTECODE=1 LC_ALL=C NOSE_VERBOSE=${NOSE_VERBOSE:-3} PYTHONPATH="@top_srcdir@/lib:@top_srcdir@/vdsm:@top_srcdir@/client:@top_srcdir@/vdsm_api:$PYTHONPATH" "$PYTHON_EXE" @top_srcdir@/tests/testrunner.py --local-modules $@
+PYTHONDONTWRITEBYTECODE=1 LC_ALL=C NOSE_VERBOSE=${NOSE_VERBOSE:-3} NOSE_EVAL_ATTR=${NOSE_EVAL_ATTR:-"type!='integration'"} PYTHONPATH="@top_srcdir@/lib:@top_srcdir@/vdsm:@top_srcdir@/client:@top_srcdir@/vdsm_api:$PYTHONPATH" "$PYTHON_EXE" @top_srcdir@/tests/testrunner.py --local-modules $@


-- 
To view, visit https://gerrit.ovirt.org/55728
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I94751f8f3e3d4849f61ea11718afda5b1484c28f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list