diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 00000000..86e87a77 --- /dev/null +++ b/.testr.conf @@ -0,0 +1,7 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ + ${PYTHON:-python} -m subunit.run discover savannadashboard/tests $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list \ No newline at end of file diff --git a/savannadashboard/tests/README.rst b/savannadashboard/tests/README.rst index 7c590897..2f156905 100644 --- a/savannadashboard/tests/README.rst +++ b/savannadashboard/tests/README.rst @@ -32,10 +32,10 @@ Information about installation and start of savanna and horizon can be found on sudo apt-get update sudo apt-get install firefox libstdc++5 -5. To run ui tests you should use the corresponding tox env: `tox -e tests`. +5. To run ui tests you should use the corresponding tox env: `tox -e uitests`. If need to run only one test module, use: - tox -e tests -- -a tags='' + tox -e uitests -- '' may be equal 'cluster', 'cluster_template', 'image_registry', 'node_group_template', 'image_registry', 'vanilla', 'hdp' It's full list of actual modules. diff --git a/savannadashboard/tests/base.py b/savannadashboard/tests/base.py index ba04ce71..d81baf72 100644 --- a/savannadashboard/tests/base.py +++ b/savannadashboard/tests/base.py @@ -18,12 +18,10 @@ import os import time import traceback -import nose.plugins.attrib import selenium.common.exceptions as selenim_except from selenium import webdriver import selenium.webdriver.common.by as by from swiftclient import client as swift_client -import testtools import unittest2 import savannadashboard.tests.configs.config as cfg @@ -33,18 +31,6 @@ logger = logging.getLogger('swiftclient') logger.setLevel(logging.WARNING) -def attr(*args, **kwargs): - def decorator(f): - if 'type' in kwargs and isinstance(kwargs['type'], str): - f = testtools.testcase.attr(kwargs['type'])(f) - elif 'type' in kwargs and isinstance(kwargs['type'], list): - for attr in kwargs['type']: - f = testtools.testcase.attr(attr)(f) - return nose.plugins.attrib.attr(*args, **kwargs)(f) - - return decorator - - class UITestCase(unittest2.TestCase): @classmethod @@ -267,7 +253,7 @@ class UITestCase(unittest2.TestCase): "//select[@id='id_job_binary_savanna_internal']/option[text()" "='%s']" % savanna_binary).click() if savanna_binary == '*Upload a new file': - file = '%s/tests/resources/%s' % ( + file = '%s/savannadashboard/tests/resources/%s' % ( os.getcwd(), parameters_of_storage['filename']) driver.find_element_by_id('id_job_binary_file').send_keys(file) diff --git a/savannadashboard/tests/cluster_template_tests/negative_tests.py b/savannadashboard/tests/cluster_template_tests/negative_tests.py index 4ed55b63..3f9114e3 100644 --- a/savannadashboard/tests/cluster_template_tests/negative_tests.py +++ b/savannadashboard/tests/cluster_template_tests/negative_tests.py @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import testtools +from testtools import testcase +import unittest2 from savannadashboard.tests import base import savannadashboard.tests.configs.config as cfg @@ -21,9 +22,9 @@ import savannadashboard.tests.configs.config as cfg class UINegativeCreateClusterTemplateTest(base.UITestCase): - @base.attr(tags=['cluster_template', 'vanilla']) - @testtools.skip - @testtools.skipIf(cfg.vanilla.skip_plugin_tests, + @testcase.attr('cluster_template', 'vanilla') + @unittest2.skip + @unittest2.skipIf(cfg.vanilla.skip_plugin_tests, 'tests for vanilla plugin skipped') def test_create_vanilla_cluster_template_with_wrong_fields(self): self.create_node_group_template('selenium-master', ["NN", "JT"], diff --git a/savannadashboard/tests/cluster_template_tests/test_create_cluster_template.py b/savannadashboard/tests/cluster_template_tests/test_create_cluster_template.py index 39fb6448..7a125d2e 100644 --- a/savannadashboard/tests/cluster_template_tests/test_create_cluster_template.py +++ b/savannadashboard/tests/cluster_template_tests/test_create_cluster_template.py @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import testtools +from testtools import testcase +import unittest2 from savannadashboard.tests import base import savannadashboard.tests.configs.config as cfg @@ -21,8 +22,8 @@ import savannadashboard.tests.configs.config as cfg class UICreateClusterTemplate(base.UITestCase): - @base.attr(tags=['cluster_template', 'vanilla']) - @testtools.skipIf(cfg.vanilla.skip_plugin_tests, + @testcase.attr('cluster_template', 'vanilla') + @unittest2.skipIf(cfg.vanilla.skip_plugin_tests, 'tests for vanilla plugin skipped') def test_create_cluster_template_for_vanilla(self): self.create_node_group_template('selenium-master', ["NN", "JT"], @@ -52,8 +53,8 @@ class UICreateClusterTemplate(base.UITestCase): self.delete_node_group_templates(["selenium-master", "selenium-worker"]) - @base.attr(tags=['cluster_template', 'hdp']) - @testtools.skipIf(cfg.hdp.skip_plugin_tests, + @testcase.attr('cluster_template', 'hdp') + @unittest2.skipIf(cfg.hdp.skip_plugin_tests, 'tests for hdp plugin skipped') def test_create_cluster_template_for_hdp(self): self.create_node_group_template( diff --git a/savannadashboard/tests/cluster_tests/test_clusters.py b/savannadashboard/tests/cluster_tests/test_clusters.py index 71ef932e..beb072d6 100644 --- a/savannadashboard/tests/cluster_tests/test_clusters.py +++ b/savannadashboard/tests/cluster_tests/test_clusters.py @@ -15,8 +15,10 @@ import random import string -import testtools +from testtools import testcase import traceback +import unittest2 + from savannadashboard.tests import base import savannadashboard.tests.configs.config as cfg @@ -24,8 +26,8 @@ import savannadashboard.tests.configs.config as cfg class UICreateCluster(base.UITestCase): - @base.attr(tags=['cluster', 'vanilla'], speed='slow') - @testtools.skipIf(cfg.vanilla.skip_plugin_tests, + @testcase.attr('cluster', 'vanilla') + @unittest2.skipIf(cfg.vanilla.skip_plugin_tests, 'tests for vanilla plugin skipped') def test_create_vanilla_cluster(self): @@ -133,7 +135,8 @@ class UICreateCluster(base.UITestCase): 'storage_type': 'Savanna internal database', 'Savanna binary': '*Create a script', 'script_name': 'edp-job.pig', - 'script_text': open('tests/resources/edp-job.pig').read()} + 'script_text': open('savannadashboard/tests/resources/' + 'edp-job.pig').read()} self.create_job_binary('edp-job.pig', parameters_of_storage) diff --git a/savannadashboard/tests/configs/config.py b/savannadashboard/tests/configs/config.py index e0c484bc..436bcce8 100644 --- a/savannadashboard/tests/configs/config.py +++ b/savannadashboard/tests/configs/config.py @@ -130,7 +130,8 @@ def register_config(config, config_group, config_opts): config.register_group(config_group) config.register_opts(config_opts, config_group) -path = os.path.join("%s/tests/configs/config.conf" % os.getcwd()) +path = os.path.join("%s/savannadashboard/tests/configs/config.conf" + % os.getcwd()) if os.path.exists(path): cfg.CONF([], project='savannadashboard', default_config_files=[path]) diff --git a/savannadashboard/tests/image_registry_tests/test_for_image_registry.py b/savannadashboard/tests/image_registry_tests/test_for_image_registry.py index b28e5abe..00b3e71d 100644 --- a/savannadashboard/tests/image_registry_tests/test_for_image_registry.py +++ b/savannadashboard/tests/image_registry_tests/test_for_image_registry.py @@ -13,13 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +from testtools import testcase + from savannadashboard.tests import base import savannadashboard.tests.configs.config as cfg class UIImageRegistry(base.UITestCase): - @base.attr(tags='image_registry') + @testcase.attr('image_registry') def test_edit_tags_for_image(self): self.edit_tags_by_image_name(cfg.common.image_name_for_edit, tags_to_add=[ @@ -30,7 +32,7 @@ class UIImageRegistry(base.UITestCase): tags_to_add=[{'custom_tag': 'qweqwe'}], tags_to_remove=['qweqwe', 'blabla']) - @base.attr(tags='image_registry') + @testcase.attr('image_registry') def test_registry_vanilla_image(self): self.image_registry(cfg.common.image_name_for_register, user_name='cloud_user', diff --git a/savannadashboard/tests/node_group_template_tests/negative_tests.py b/savannadashboard/tests/node_group_template_tests/negative_tests.py index 2847f24e..716e07c4 100644 --- a/savannadashboard/tests/node_group_template_tests/negative_tests.py +++ b/savannadashboard/tests/node_group_template_tests/negative_tests.py @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import testtools +from testtools import testcase +import unittest2 from savannadashboard.tests import base import savannadashboard.tests.configs.config as cfg @@ -21,8 +22,8 @@ import savannadashboard.tests.configs.config as cfg class UINegativeCreateNodeGroupTemplate(base.UITestCase): - @base.attr(tags=['node_group_template', 'vanilla']) - @testtools.skipIf(cfg.vanilla.skip_plugin_tests, + @testcase.attr('node_group_template', 'vanilla') + @unittest2.skipIf(cfg.vanilla.skip_plugin_tests, 'tests for vanilla plugin skipped') def test_create_vanilla_node_group_template_with_wrong_parameters(self): self.create_node_group_template( @@ -38,8 +39,8 @@ class UINegativeCreateNodeGroupTemplate(base.UITestCase): 'MapReduce Parameters:io.sort.mb:' 'Enter a whole number.') - @base.attr(tags=['node_group_template', 'vanilla']) - @testtools.skipIf(cfg.vanilla.skip_plugin_tests, + @testcase.attr('node_group_template', 'vanilla') + @unittest2.skipIf(cfg.vanilla.skip_plugin_tests, 'tests for vanilla plugin skipped') def test_create_vanilla_node_group_template_with_missing_parameters(self): self.create_node_group_template( diff --git a/savannadashboard/tests/node_group_template_tests/test_create_node_group_template.py b/savannadashboard/tests/node_group_template_tests/test_create_node_group_template.py index 15df2544..a1b3214c 100644 --- a/savannadashboard/tests/node_group_template_tests/test_create_node_group_template.py +++ b/savannadashboard/tests/node_group_template_tests/test_create_node_group_template.py @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import testtools +from testtools import testcase +import unittest2 from savannadashboard.tests import base import savannadashboard.tests.configs.config as cfg @@ -21,8 +22,8 @@ import savannadashboard.tests.configs.config as cfg class UICreateNodeGroupTemplate(base.UITestCase): - @base.attr(tags=['node_group_template', 'vanilla']) - @testtools.skipIf(cfg.vanilla.skip_plugin_tests, + @testcase.attr('node_group_template', 'vanilla') + @unittest2.skipIf(cfg.vanilla.skip_plugin_tests, 'tests for vanilla plugin skipped') def test_create_node_group_template_vanilla(self): self.create_node_group_template( @@ -44,8 +45,8 @@ class UICreateNodeGroupTemplate(base.UITestCase): message=msg) self.delete_node_group_templates(['selenium-vanilla']) - @base.attr(tags=['node_group_template', 'hdp']) - @testtools.skipIf(cfg.hdp.skip_plugin_tests, + @testcase.attr('node_group_template', 'hdp') + @unittest2.skipIf(cfg.hdp.skip_plugin_tests, 'tests for hdp plugin skipped') def test_create_node_group_template_hdp(self): self.create_node_group_template( diff --git a/setup.cfg b/setup.cfg index 94349eb5..522d78e1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,14 +23,3 @@ setup-hooks = pbr.hooks.setup_hook [files] packages = savannadashboard - -[nosetests] -cover-package=savanna -cover-html=true -cover-xml=true -cover-xml-file=coverage.xml -cover-erase=true -cover-inclusive=true -verbosity=3 -detailed-errors=1 -where=savannadashboard/ diff --git a/test-requirements.txt b/test-requirements.txt index 92eb3d9d..3863d82a 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,12 +1,12 @@ hacking>=0.8.0,<0.9 coverage>=3.6 +discover mock>=1.0 -nose -openstack.nose_plugin>=0.7 -python-swiftclient>=1.5 -pylint==0.25.2 -unittest2 -selenium -testtools>=0.9.32 oslo.config>=1.2.0 +pylint==0.25.2 +python-swiftclient>=1.5 +selenium +testrepository>=0.0.17 +testtools>=0.9.32 +unittest2 diff --git a/tox.ini b/tox.ini index 7d45b8dd..611317c7 100644 --- a/tox.ini +++ b/tox.ini @@ -8,31 +8,15 @@ usedevelop = True install_command = pip install -U {opts} {packages} setenv = VIRTUAL_ENV={envdir} - NOSE_WITH_OPENSTACK=1 - NOSE_OPENSTACK_COLOR=1 - NOSE_OPENSTACK_RED=0.05 - NOSE_OPENSTACK_YELLOW=0.025 - NOSE_OPENSTACK_SHOW_ELAPSED=1 - NOSE_OPENSTACK_STDOUT=1 - NOSE_XUNIT=1 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt [testenv:uitests] -setenv = - VIRTUAL_ENV={envdir} - NOSE_WITH_OPENSTACK=1 - NOSE_OPENSTACK_COLOR=1 - NOSE_OPENSTACK_RED=200 - NOSE_OPENSTACK_YELLOW=150 - NOSE_OPENSTACK_SHOW_ELAPSED=1 - NOSE_OPENSTACK_STDOUT=1 - NOSE_XUNIT=1 -commands = nosetests -w tests -x {posargs} +commands = python setup.py testr --slowest --testr-args="--concurrency 1 {posargs}" [testenv:cover] -setenv = NOSE_WITH_COVERAGE=1 +commands = python setup.py testr --coverage --testr-args='--concurrency 1 {posargs}' [tox:jenkins] downloadcache = ~/cache/pip