From ec352d16e17f1e42cb8aabb5f0163951be1bfb5e Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Mon, 19 Sep 2016 15:14:01 +0200 Subject: [PATCH] Run console tests inside the Docker image. --- .travis.yml | 18 ------------------ tests/console/ACL.py | 4 ++-- tests/console/Bulk_operations.py | 4 ++-- tests/console/Collections.py | 4 ++-- tests/console/Misc.py | 4 ++-- tests/console/Network_server.py | 4 ++-- tests/console/Planned_downtime.py | 4 ++-- tests/console/Policies.py | 4 ++-- tests/console/Services.py | 4 ++-- tests/console/Users.py | 4 ++-- tests/console/include/api_functions.py | 2 +- tests/console/include/common_classes_60.py | 4 ++-- tests/console/include/common_functions_60.py | 4 ++-- tests/console/include/policy_functions.py | 2 +- tests/run_console_tests.py | 4 ++-- tests/utils/selenium_ci_tester/PAN3_testing.py | 4 ++-- tests/utils/selenium_ci_tester/testpan3.py | 2 +- 17 files changed, 29 insertions(+), 47 deletions(-) diff --git a/.travis.yml b/.travis.yml index 153c3b9a06..cfb4588f95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,8 @@ sudo: required -language: python -python: - - 2.7 - -addons: - firefox: "latest" - services: - docker -before_install: - - sudo apt-get install xvfb - -install: - - pip install selenium PyVirtualDisplay testtools - -before_script: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - - sleep 3 # give xvfb some time to start - script: - docker run --name pandorafms -h pandorafms -dt -v "$TRAVIS_BUILD_DIR:/tmp/pandorafms" -p 127.0.0.1:8080:80 pandorafms/pandorafms-base tail -f /var/log/messages - docker exec -t pandorafms /tmp/pandorafms/tests/test.sh diff --git a/tests/console/ACL.py b/tests/console/ACL.py index 9c659e0ac5..99ddb25539 100644 --- a/tests/console/ACL.py +++ b/tests/console/ACL.py @@ -12,7 +12,7 @@ from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webelement import WebElement -import unittest, time, re +import unittest2, time, re class ACLPropagation(PandoraWebDriverTestCase): @@ -177,4 +177,4 @@ class ACLTags(PandoraWebDriverTestCase): self.assertEqual(modules,[]) if __name__ == "__main__": - unittest.main() + unittest2.main() diff --git a/tests/console/Bulk_operations.py b/tests/console/Bulk_operations.py index 3427f833a0..36278e2082 100644 --- a/tests/console/Bulk_operations.py +++ b/tests/console/Bulk_operations.py @@ -13,7 +13,7 @@ from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webelement import WebElement -import unittest, time, re +import unittest2, time, re class Bulk_operations(PandoraWebDriverTestCase): @@ -268,4 +268,4 @@ class Bulk_operations(PandoraWebDriverTestCase): self.assertIsInstance(element,WebElement) if __name__ == "__main__": - unittest.main() + unittest2.main() diff --git a/tests/console/Collections.py b/tests/console/Collections.py index 17bbefc82b..2b45e0827a 100644 --- a/tests/console/Collections.py +++ b/tests/console/Collections.py @@ -12,7 +12,7 @@ from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webelement import WebElement -import unittest, time, re +import unittest2, time, re class Collections(PandoraWebDriverTestCase): @@ -82,4 +82,4 @@ class Collections(PandoraWebDriverTestCase): self.assertEqual(element,[]) if __name__ == "__main__": - unittest.main() + unittest2.main() diff --git a/tests/console/Misc.py b/tests/console/Misc.py index d48a414c24..f2fbb19dd6 100644 --- a/tests/console/Misc.py +++ b/tests/console/Misc.py @@ -14,7 +14,7 @@ from selenium.webdriver.support.ui import Select from selenium.common.exceptions import StaleElementReferenceException, NoSuchElementException from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webelement import WebElement -import unittest, time, re +import unittest2, time, re class Miscellaneous (PandoraWebDriverTestCase): @@ -62,5 +62,5 @@ class Miscellaneous (PandoraWebDriverTestCase): self.assertIsInstance(element,WebElement) if __name__ == "__main__": - unittest.main() + unittest2.main() diff --git a/tests/console/Network_server.py b/tests/console/Network_server.py index 2d38552e3e..c883dece2c 100644 --- a/tests/console/Network_server.py +++ b/tests/console/Network_server.py @@ -9,7 +9,7 @@ from selenium.webdriver.support.ui import Select from selenium.common.exceptions import StaleElementReferenceException from include.module_functions import * -import unittest, time, re +import unittest2, time, re class Network_server_module(PandoraWebDriverTestCase): @@ -54,5 +54,5 @@ class Network_server_module(PandoraWebDriverTestCase): break if __name__ == "__main__": - unittest.main() + unittest2.main() diff --git a/tests/console/Planned_downtime.py b/tests/console/Planned_downtime.py index 4d14d089ad..a017ef0465 100644 --- a/tests/console/Planned_downtime.py +++ b/tests/console/Planned_downtime.py @@ -13,7 +13,7 @@ from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webelement import WebElement -import unittest, time, re, datetime +import unittest2, time, re, datetime class PAN13(PandoraWebDriverTestCase): @@ -162,4 +162,4 @@ class PAN13(PandoraWebDriverTestCase): self.assertNotEqual(event_who_should_be_present_b,[]) if __name__ == "__main__": - unittest.main() + unittest2.main() diff --git a/tests/console/Policies.py b/tests/console/Policies.py index 1cf76c93e8..2805e31416 100644 --- a/tests/console/Policies.py +++ b/tests/console/Policies.py @@ -11,7 +11,7 @@ from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webelement import WebElement -import unittest, time, re +import unittest2, time, re class Policies(PandoraWebDriverTestCase): @@ -130,4 +130,4 @@ class Policies(PandoraWebDriverTestCase): if __name__ == "__main__": - unittest.main() + unittest2.main() diff --git a/tests/console/Services.py b/tests/console/Services.py index e6db79182c..8a37bc01a6 100644 --- a/tests/console/Services.py +++ b/tests/console/Services.py @@ -14,7 +14,7 @@ from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webelement import WebElement -import unittest, time, re +import unittest2, time, re class SimpleService(PandoraWebDriverTestCase): @@ -275,4 +275,4 @@ class ManualService(PandoraWebDriverTestCase): if __name__ == "__main__": - unittest.main() + unittest2.main() diff --git a/tests/console/Users.py b/tests/console/Users.py index 067da3bfdf..392c278d50 100644 --- a/tests/console/Users.py +++ b/tests/console/Users.py @@ -9,7 +9,7 @@ from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException from selenium.webdriver.remote.webelement import WebElement -import unittest, time, re +import unittest2, time, re class Users(PandoraWebDriverTestCase): @@ -41,5 +41,5 @@ class Users(PandoraWebDriverTestCase): if __name__ == "__main__": - unittest.main() + unittest2.main() diff --git a/tests/console/include/api_functions.py b/tests/console/include/api_functions.py index 30c77d351c..67e38fdf90 100644 --- a/tests/console/include/api_functions.py +++ b/tests/console/include/api_functions.py @@ -8,7 +8,7 @@ from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException -import unittest, time, re +import unittest2, time, re def activate_api(driver,api_pwd): diff --git a/tests/console/include/common_classes_60.py b/tests/console/include/common_classes_60.py index c309ed5f11..9dd0a74875 100644 --- a/tests/console/include/common_classes_60.py +++ b/tests/console/include/common_classes_60.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from unittest import TestResult, TestCase +from unittest2 import TestResult, TestCase from common_functions_60 import * from datetime import datetime from pyvirtualdisplay import Display @@ -52,7 +52,7 @@ class PandoraWebDriverTestCase(TestCase): cls.display = Display(visible=0, size=(800, 600)) cls.display.start() cls.driver = webdriver.Firefox() - cls.base_url = "http://127.0.0.1:8080/" + cls.base_url = "http://127.0.0.1/" @classmethod def tearDownClass(cls): diff --git a/tests/console/include/common_functions_60.py b/tests/console/include/common_functions_60.py index efe54839e3..d8f8649c3f 100644 --- a/tests/console/include/common_functions_60.py +++ b/tests/console/include/common_functions_60.py @@ -6,7 +6,7 @@ from selenium.webdriver.support import expected_conditions as EC import random, time import string -import unittest +import unittest2 def is_enterprise(func): u""" @@ -22,7 +22,7 @@ def is_enterprise(func): if is_enterprise: return func(*args,**kwargs) else: - raise unittest.SkipTest("Skipping test") + raise unittest2.SkipTest("Skipping test") return inner diff --git a/tests/console/include/policy_functions.py b/tests/console/include/policy_functions.py index 7ec9a34280..eaf03476f7 100644 --- a/tests/console/include/policy_functions.py +++ b/tests/console/include/policy_functions.py @@ -8,7 +8,7 @@ from module_functions import create_module from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException -import unittest, time, re +import unittest2, time, re def create_policy(driver,policy_name,group,description=None): diff --git a/tests/run_console_tests.py b/tests/run_console_tests.py index ae7f7ec658..a46d506dce 100755 --- a/tests/run_console_tests.py +++ b/tests/run_console_tests.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from unittest import * +from unittest2 import * from console.include.common_functions_60 import * from console.include.common_classes_60 import * #from sauceclient import SauceClient @@ -15,7 +15,7 @@ is_enterprise = '1' == getenv('ENTERPRISE', False) a = TestLoader() -tests = a.discover(start_dir='console',pattern='*.py') +tests = a.discover(start_dir='console',pattern='ACL.py') c = ArticaTestResult() tests.run(c) diff --git a/tests/utils/selenium_ci_tester/PAN3_testing.py b/tests/utils/selenium_ci_tester/PAN3_testing.py index 429d695c64..70271d3971 100644 --- a/tests/utils/selenium_ci_tester/PAN3_testing.py +++ b/tests/utils/selenium_ci_tester/PAN3_testing.py @@ -6,7 +6,7 @@ from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import StaleElementReferenceException -import unittest, time, re +import unittest2, time, re class PAN3(PandoraWebDriverTestCase): @@ -67,5 +67,5 @@ class PAN3(PandoraWebDriverTestCase): break if __name__ == "__main__": - unittest.main() + unittest2.main() diff --git a/tests/utils/selenium_ci_tester/testpan3.py b/tests/utils/selenium_ci_tester/testpan3.py index 0bb3c696f8..c17f393257 100755 --- a/tests/utils/selenium_ci_tester/testpan3.py +++ b/tests/utils/selenium_ci_tester/testpan3.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from unittest import * +from unittest2 import * from console import * from console.include.common_functions_60 import * from console.include.common_classes_60 import *