diff --git a/tests/console/Collections.py b/tests/console/Collections.py index 59156dae4d..e68e4c64dc 100644 --- a/tests/console/Collections.py +++ b/tests/console/Collections.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from include.common_classes_60 import PandoraWebDriverTestCase -from include.common_functions_60 import click_menu_element, detect_and_pass_all_wizards, gen_random_string, is_enterprise, enterprise_class +from include.common_functions_60 import click_menu_element, detect_and_pass_all_wizards, gen_random_string, is_enterprise from include.module_functions import create_module from include.agent_functions import create_agent_group from include.policy_functions import * @@ -14,7 +14,7 @@ from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webelement import WebElement import unittest, time, re -@enterprise_class + class Collections(PandoraWebDriverTestCase): test_name = u'Collections' @@ -24,6 +24,7 @@ class Collections(PandoraWebDriverTestCase): collection_name = gen_random_string(6) new_collection_name = gen_random_string(6) + @is_enterprise def test_A_create_collection(self): driver = self.driver @@ -37,6 +38,7 @@ class Collections(PandoraWebDriverTestCase): element = driver.find_element_by_xpath('//a[contains(.,self.collection_name)]') self.assertIsInstance(element,WebElement) + @is_enterprise def test_B_edit_collection(self): driver = self.driver @@ -49,6 +51,7 @@ class Collections(PandoraWebDriverTestCase): element = driver.find_element_by_xpath('//a[contains(.,self.new_collection_name)]') self.assertIsInstance(element,WebElement) + @is_enterprise def test_C_create_text_collection(self): driver = self.driver @@ -59,6 +62,7 @@ class Collections(PandoraWebDriverTestCase): element = driver.find_element_by_xpath('//a[contains(.,"file_collectionPAN11")]') self.assertIsInstance(element,WebElement) + @is_enterprise def test_D_directory_collection(self): driver = self.driver @@ -69,6 +73,7 @@ class Collections(PandoraWebDriverTestCase): element = driver.find_element_by_xpath('//a[contains(.,"directory_collectionPAN11")]') self.assertIsInstance(element,WebElement) + @is_enterprise def test_E_delete_collection(self): driver = self.driver diff --git a/tests/console/Policies.py b/tests/console/Policies.py index a9b0aa135e..40d0f327ee 100644 --- a/tests/console/Policies.py +++ b/tests/console/Policies.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from include.common_classes_60 import PandoraWebDriverTestCase -from include.common_functions_60 import detect_and_pass_all_wizards, gen_random_string, is_enterprise, enterprise_class +from include.common_functions_60 import detect_and_pass_all_wizards, gen_random_string, is_enterprise from include.policy_functions import * from include.agent_functions import * from include.collection_functions import * @@ -13,7 +13,6 @@ from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webelement import WebElement import unittest, time, re -@enterprise_class class Policies(PandoraWebDriverTestCase): test_name = u'Policies' @@ -24,6 +23,7 @@ class Policies(PandoraWebDriverTestCase): network_server_module_name = gen_random_string(6) + @is_enterprise def test_A_create_policy(self): u""" @@ -41,6 +41,7 @@ class Policies(PandoraWebDriverTestCase): self.assertIsInstance(element,WebElement) + @is_enterprise def test_B_add_network_server_module_to_policy(self): u""" @@ -55,6 +56,7 @@ class Policies(PandoraWebDriverTestCase): self.assertIsInstance(element,WebElement) + @is_enterprise def test_C_add_collection_to_policy(self): u""" @@ -79,6 +81,7 @@ class Policies(PandoraWebDriverTestCase): + @is_enterprise def test_D_Apply_policy_to_agents(self): u""" diff --git a/tests/console/Quiet_functionality.py b/tests/console/Quiet_functionality.py index be38d56a79..5b58421c4c 100644 --- a/tests/console/Quiet_functionality.py +++ b/tests/console/Quiet_functionality.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from include.common_classes_60 import PandoraWebDriverTestCase -from include.common_functions_60 import click_menu_element, detect_and_pass_all_wizards, gen_random_string, enterprise_class +from include.common_functions_60 import click_menu_element, detect_and_pass_all_wizards, gen_random_string from include.planned_downtime_functions import * from include.alert_functions import * from include.module_functions import * @@ -15,6 +15,7 @@ from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webelement import WebElement import unittest, time, re, datetime + class QuietTest(PandoraWebDriverTestCase): test_name = u'Planned downtime quiet type test' diff --git a/tests/console/include/common_functions_60.py b/tests/console/include/common_functions_60.py index 650db2573a..b852a43edd 100644 --- a/tests/console/include/common_functions_60.py +++ b/tests/console/include/common_functions_60.py @@ -25,24 +25,6 @@ def is_enterprise(func): raise unittest.SkipTest("Skipping test") return inner -def enterprise_class(cls): - u""" - This decorator is intended to be used for Enterprise tests only - """ - def inner(*args,**kwargs): - is_enterprise = 0 - try: - is_enterprise = args[0].is_enterprise == '1' - except: - pass - - if is_enterprise: - return cls - else: - return object - return inner - - def gen_random_string(size,preffix=None): random_string = ''.join(random.SystemRandom().choice(string.ascii_uppercase+string.digits) for _ in range(size)) diff --git a/tests/run_console_tests.py b/tests/run_console_tests.py index d658f8e1a8..a0cc394361 100755 --- a/tests/run_console_tests.py +++ b/tests/run_console_tests.py @@ -23,29 +23,33 @@ class ArticaTestLoader(TestLoader): super(ArticaTestLoader, self).__init__(*args,**kwargs) -def split_suite_into_chunks(n, suite): - import math - - # Keep n to a reasonable number of threads - if n < 0: - n = 1 - if n > 8: - n = 8 - # Compute n such that the number of threads does not exceed the value passed to the function - n = math.ceil(suite.countTestCases() / n) +""" Splits a Test Suite so that no more than 'n' threads will execute the tests """ +def split_suite_into_chunks(num_threads, suite): + # Compute num_threads such that the number of threads does not exceed the value passed to the function + # Keep num_threads to a reasonable number of threads + if num_threads < 0: num_threads = 1 + if num_threads > 8: num_threads = 8 + num_tests = suite.countTestCases() + print "num_tests: "+str(num_tests) s = [] - i = 0 s_tmp = ArticaTestSuite() + n = round(num_tests / num_threads) for case in suite: - if i < n: - s_tmp.addTest(case) - i += 1 - if i == n: + if n <= 0 and s_tmp.countTestCases() > 0: s.append([s_tmp, None]) - i = 0 + num_threads -= 1 + num_tests -= s_tmp.countTestCases() s_tmp = ArticaTestSuite() - if (i > 0): - s.append([s_tmp, None]) + print "num_tests: "+str(num_tests) + print "num_threads: "+str(num_threads) + n = round(num_tests / num_threads) + s_tmp.addTest(case) + n -= 1 + if s_tmp.countTestCases() > 0: + if s_tmp.countTestCases() > 0: s.append([s_tmp, None]) + num_tests -= s_tmp.countTestCases() + if num_tests != 0: print("Error: num_tests should be 0 but is %s!" % num_tests) + print "The length of s is: "+str(len(s)) return s class TracingStreamResult(testtools.StreamResult): @@ -91,8 +95,10 @@ print str(tests.countTestCases())+" tests found" print "Using "+str(num_threads)+" threads" concurrent_suite = testtools.ConcurrentStreamTestSuite(lambda: (split_suite_into_chunks(num_threads, tests))) +#concurrent_suite = testtools.ConcurrentStreamTestSuite(tests) result = TracingStreamResult() + try: result.startTestRun() finally: