Reverted parallel tests features until further notice

This commit is contained in:
axl89 2016-08-10 12:15:47 +02:00
parent 9ec8858e13
commit a6cf6276f9
4 changed files with 28 additions and 88 deletions

View File

@ -24,7 +24,6 @@ RUN yum install -y \
firefox \
python-pip \
xorg-x11-server-Xvfb; yum clean all;
RUN pip install --upgrade setuptools
RUN pip install pyvirtualdisplay
RUN pip install selenium
RUN pip install testtools

View File

@ -24,7 +24,6 @@ class Policies(PandoraWebDriverTestCase):
driver = self.driver
self.login()
detect_and_pass_all_wizards(driver)
create_policy(driver,self.policy_name,"Applications",description="Policy for test")
@ -36,6 +35,7 @@ class Policies(PandoraWebDriverTestCase):
def test_2_add_network_server_module_to_policy(self):
driver = self.driver
detect_and_pass_all_wizards(driver)
add_module_policy(driver,self.policy_name,"network_server",driver,module_name=self.network_server_module_name,component_group="Network Management",network_component="Host Alive")

View File

@ -54,22 +54,6 @@ class PandoraWebDriverTestCase(TestCase):
@classmethod
def tearDownClass(cls):
cls.driver.quit()
if cls.is_development == False:
try:
sauce_client = SauceClient(cls.sauce_username, cls.sauce_access_key)
if len(cls.verificationErrors)>0:
sauce_client.jobs.update_job(cls.sauce_labs_job_id, passed=False,tags=[environ["TRAVIS_BRANCH"]],build_num=environ["TRAVIS_JOB_NUMBER"],name=str(environ["TRAVIS_COMMIT"])+"_"+str(cls.sauce_labs_job_id))
else:
sauce_client.jobs.update_job(cls.sauce_labs_job_id, passed=True,tags=[environ["TRAVIS_BRANCH"]],build_num=environ["TRAVIS_JOB_NUMBER"],name=str(environ["TRAVIS_COMMIT"])+"_"+str(cls.sauce_labs_job_id))
except Exception as e:
print "EXCEPTION"
print e
print "Could not annotate Sauce Labs job #%s" % str(cls.sauce_labs_job_id)
print "Additional information about this error can be found below."
print "The job ID is: "+str(cls.id())
def setUp(self):
self.time_started = datetime.now()

View File

@ -3,7 +3,6 @@ from unittest import *
from console.include.common_functions_60 import *
from console.include.common_classes_60 import *
from sauceclient import SauceClient
import testtools
from os import environ, getenv
import subprocess, time, sys
@ -11,59 +10,6 @@ def get_test_file(test_list):
#return [test[0].split(' ')[0].split('.')[0].split('<')[1] for test in test_list]
return [test[0].test_name for test in test_list]
""" 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()
s = []
s_tmp = TestSuite()
n = round(num_tests / num_threads)
for case in suite:
if n <= 0 and s_tmp.countTestCases() > 0:
s.append([s_tmp, None])
num_threads -= 1
num_tests -= s_tmp.countTestCases()
s_tmp = TestSuite()
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)
return s
def add_test_case_to_suite(suite, tc_name):
# Creates a Test Suite with each Test Case added n times
n = 1
for i in range(0, n):
suite.addTest(tc_name)
class TracingStreamResult(testtools.StreamResult):
failures = []
success = []
skipped = []
errors = []
def status(self, test_status, test_id, *args, **kwargs):
if test_status=='inprogress':
print "Running "+str(test_id)
elif test_status=='xfail' or test_status=='fail' or test_status=='exists':
self.failures.append(test_id)
elif test_status=='uxsuccess' or test_status=='success':
self.success.append(test_id)
elif test_status=='exists':
self.errors.append(test_id)
elif test_status=='skip':
self.skipped.append('test_id')
#Run Enterprise tests
is_enterprise = '1' == getenv('ENTERPRISE', False)
@ -73,24 +19,35 @@ if is_enterprise:
tests = a.discover(start_dir='console',pattern='*.py')
else:
tests = a.discover(start_dir='console',pattern='PAN*.py')
if is_enterprise:
num_threads = 2
else:
num_threads = 3
suite = tests
concurrent_suite = testtools.ConcurrentStreamTestSuite(lambda: (split_suite_into_chunks(num_threads, suite)))
result = TracingStreamResult()
try:
result.startTestRun()
finally:
concurrent_suite.run(result)
print "Tests failed: %s" % result.failures
print "Tests succeeded: %s" % result.success
print "Tests skipped: %s" % result.skipped
print "Tests with errors: %s" % result.errors
c = ArticaTestResult()
tests.run(c)
if (len(result.failures)+len(result.errors)+len(result.skipped)) != 0:
#Update Saouce Labs jobs
sauce_client = SauceClient(environ["SAUCE_USERNAME"], environ["SAUCE_ACCESS_KEY"])
for test,error_msg in c.failures+c.skipped+c.errors:
try:
sauce_client.jobs.update_job(test.sauce_labs_job_id, passed=False,tags=[environ["TRAVIS_BRANCH"],test.id()],build_num=environ["TRAVIS_JOB_NUMBER"],name=str(environ["TRAVIS_COMMIT"])+"_"+str(test.id().split('.')[1]))
except:
print "Could not annotate Sauce Labs job #%s" % str(test)
next
for test,error_msg in c.success:
try:
sauce_client.jobs.update_job(test.sauce_labs_job_id, passed=True,tags=[environ["TRAVIS_BRANCH"],test.id()],build_num=environ["TRAVIS_JOB_NUMBER"],name=str(environ["TRAVIS_COMMIT"])+"_"+str(test.id().split('.')[1]))
except:
print "Could not annotate Sauce Labs job #%s" % str(test)
next
print "Tests failed: %s" % c.failures
print "Tests succeeded: %s" % c.success
print "Tests skipped: %s" % c.skipped
print "Tests with errors: %s" % c.errors
if (len(c.failures)+len(c.errors)+len(c.skipped)) != 0:
sys.exit(1)
else:
sys.exit(0)