Brought develop test structure and new tests to pandora_6.0 branch
This commit is contained in:
parent
ba9c3c5d84
commit
d97f13565e
|
@ -1,71 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
||||
from include.common_functions_60 import login, click_menu_element, refresh_N_times_until_find_element, gen_random_string
|
||||
from selenium import webdriver
|
||||
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
|
||||
|
||||
|
||||
class PAN3(PandoraWebDriverTestCase):
|
||||
|
||||
test_name = u'PAN_3'
|
||||
test_description = u'Creates a simple ICMP check against localhost and checks the result is 1'
|
||||
tickets_associated = []
|
||||
|
||||
def test_pan3(self):
|
||||
driver = self.driver
|
||||
login(driver,"admin","pandora",self.base_url)
|
||||
click_menu_element(driver,"Agent detail")
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
driver.find_element_by_id("text-agente").click()
|
||||
driver.find_element_by_id("text-agente").clear()
|
||||
driver.find_element_by_id("text-agente").send_keys(gen_random_string(10,preffix="PAN3_"))
|
||||
driver.find_element_by_id("text-direccion").click()
|
||||
driver.find_element_by_id("text-direccion").clear()
|
||||
driver.find_element_by_id("text-direccion").send_keys("127.0.0.1")
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
driver.find_element_by_css_selector("li.nomn.tab_godmode > a > img.forced_title").click()
|
||||
driver.find_element_by_id("moduletype").click()
|
||||
Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new network server module")
|
||||
driver.find_element_by_name("updbutton").click() #Alternative XPATH: //*[@class="datos"]/input
|
||||
driver.find_element_by_name("updbutton").click() #IMPORTANT! It's needed to click TWICE! One for leave the combo, and other for clicking the button
|
||||
driver.find_element_by_id("id_module_type").click()
|
||||
combo = driver.find_element_by_id("id_module_type")
|
||||
Select(combo).select_by_visible_text("Remote ICMP network agent, boolean data")
|
||||
combo.click()
|
||||
driver.find_element_by_id("text-name").clear()
|
||||
driver.find_element_by_id("text-name").send_keys("ping test")
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]//a[contains(@href,"ver_agente")]').click()
|
||||
|
||||
max_retries = 3
|
||||
i = 1
|
||||
element_text = ""
|
||||
|
||||
while (i <= max_retries): # Temporary workaround to weird StaleElementReferenceException exceptions due Javascript altering the DOM
|
||||
try:
|
||||
element_text = refresh_N_times_until_find_element(driver,5,"table1-1-7",how=By.ID).text
|
||||
self.assertEqual("1", element_text.lstrip().rstrip()) # The lstrip.rstrip is done because if not, this error is raised: "'1' != u'1 '"
|
||||
print "found it"
|
||||
break
|
||||
except StaleElementReferenceException as e_stale:
|
||||
i = i+1
|
||||
print "found stale"
|
||||
if i > max_retries:
|
||||
print "giving up"
|
||||
self.verificationErrors.append(str(e_stale))
|
||||
break
|
||||
else:
|
||||
print "retrying"
|
||||
next
|
||||
except AssertionError as e:
|
||||
print "assertion error"
|
||||
self.verificationErrors.append(str(e))
|
||||
break
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
||||
from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards, logout
|
||||
from include.module_functions import create_module
|
||||
from include.agent_functions import create_agent_group
|
||||
from include.policy_functions import *
|
||||
from selenium import webdriver
|
||||
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 NoSuchElementException
|
||||
from selenium.common.exceptions import NoAlertPresentException
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
import unittest, time, re
|
||||
|
||||
class PAN10(PandoraWebDriverTestCase):
|
||||
|
||||
test_name = u'PAN_10'
|
||||
test_description = u'Policy tests'
|
||||
tickets_associated = []
|
||||
|
||||
def test_1_create_policy(self):
|
||||
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
create_policy(driver,"policy_PAN_10","Applications",description="Policy for test PAN_10")
|
||||
|
||||
search_policy(driver,"policy_PAN_10",go_to_policy=False)
|
||||
|
||||
time.sleep(6)
|
||||
|
||||
try:
|
||||
element = driver.find_element_by_xpath('//a[contains(.,"policy_PAN_10")]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
except AssertionError as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
except NoSuchElementException as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
def test_2_add_module_policy(self):
|
||||
|
||||
driver = self.driver
|
||||
login(driver)
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
add_module_policy(driver,"policy_PAN_10","network_server",driver,module_name="PAN10",component_group="Network Management",network_component="Host Alive")
|
||||
|
||||
search_policy(driver,"policy_PAN_10")
|
||||
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[2]/a/img').click()
|
||||
|
||||
time.sleep(6)
|
||||
|
||||
try:
|
||||
element = driver.find_element_by_xpath('//a[contains(.,"PAN10")]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
except AssertionError as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
except NoSuchElementException as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
@ -8,6 +8,9 @@ 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
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.common.exceptions import NoAlertPresentException
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
import unittest, time, re
|
||||
|
||||
|
||||
|
@ -19,7 +22,7 @@ class PAN4(PandoraWebDriverTestCase):
|
|||
|
||||
def test_pan4(self):
|
||||
driver = self.driver
|
||||
login(driver,user="admin",passwd="pandora",pandora_url=self.base_url)
|
||||
login(driver,user="admin",passwd="pandora")
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
#Creates a user with Chief Operator - Applications profile
|
||||
|
@ -35,7 +38,7 @@ class PAN4(PandoraWebDriverTestCase):
|
|||
logout(driver,self.base_url)
|
||||
|
||||
#Login
|
||||
login(driver,user='PAN_4',passwd='PAN_4',pandora_url=self.base_url)
|
||||
login(driver,user='PAN_4',passwd='PAN_4')
|
||||
detect_and_pass_all_wizards(driver)
|
||||
|
||||
#Check that the report is visible
|
||||
|
@ -52,11 +55,22 @@ class PAN4(PandoraWebDriverTestCase):
|
|||
driver.find_element_by_id('text-search').send_keys("PAN_4_Servers")
|
||||
driver.find_element_by_id('submit-search_submit').click()
|
||||
|
||||
self.assertEqual("No data found." in driver.page_source,True)
|
||||
time.sleep(6)
|
||||
|
||||
try:
|
||||
element = driver.find_element_by_xpath('//td[contains(.,"No data found.")]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
except AssertionError as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
except NoSuchElementException as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
|
||||
#Delete reports
|
||||
logout(driver,self.base_url)
|
||||
login(driver,user="admin",passwd="pandora",pandora_url=self.base_url)
|
||||
login(driver,user="admin",passwd="pandora")
|
||||
|
||||
delete_report(driver,"PAN_4_Servers")
|
||||
delete_report(driver,"PAN_4_Applications")
|
||||
|
|
|
@ -11,6 +11,8 @@ 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, NoSuchElementException
|
||||
from selenium.common.exceptions import NoAlertPresentException
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
import unittest, time, re
|
||||
|
||||
class PAN5(PandoraWebDriverTestCase):
|
||||
|
@ -57,12 +59,16 @@ class PAN5(PandoraWebDriverTestCase):
|
|||
driver.find_element_by_id("submit-update").click()
|
||||
|
||||
#Check that there are japanese characters present on the event
|
||||
|
||||
try:
|
||||
self.assertEqual(True,u"Alert fired (Critical condition) assigned to (管理者ガイド)" in driver.page_source)
|
||||
element = driver.find_element_by_xpath(u'//a[contains(.,"Alert fired (Critical condition) assigned to (管理者ガイド)")]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
except AssertionError as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
except NoSuchElementException as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -7,6 +7,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
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
import unittest, time, re
|
||||
|
||||
class PAN7(PandoraWebDriverTestCase):
|
||||
|
@ -25,14 +26,17 @@ class PAN7(PandoraWebDriverTestCase):
|
|||
|
||||
logout(driver,self.base_url)
|
||||
login(driver)
|
||||
|
||||
|
||||
|
||||
try:
|
||||
|
||||
self.assertEqual("Event control filter" in driver.page_source,True)
|
||||
|
||||
element = driver.find_element_by_xpath('//a[contains(.,"Event control filter")]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
except AssertionError as e:
|
||||
|
||||
self.verificationErrors.append(str(e))
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
except NoSuchElementException as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
#Return this change
|
||||
|
||||
|
|
|
@ -10,6 +10,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
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
import unittest, time, re
|
||||
|
||||
class PAN9(PandoraWebDriverTestCase):
|
||||
|
@ -45,21 +46,27 @@ class PAN9(PandoraWebDriverTestCase):
|
|||
search_agent(driver,"PAN9_agent_B",go_to_agent=False)
|
||||
|
||||
time.sleep(6)
|
||||
|
||||
|
||||
try:
|
||||
driver.find_element_by_xpath('//td[contains(.,"PAN9_agent_B")]')
|
||||
self.assertEqual(True,u"PAN9_agent_B" in driver.page_source)
|
||||
element = driver.find_element_by_xpath('//a[contains(.,"PAN9_agent_B")]')
|
||||
self.assertIsInstance(element,WebElement)
|
||||
|
||||
except AssertionError as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
except NoSuchElementException as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
search_agent(driver,"PAN9_agent",go_to_agent=False)
|
||||
|
||||
time.sleep(6)
|
||||
|
||||
try:
|
||||
self.assertEqual(False,u"PAN9_agent_C" in driver.page_source)
|
||||
#self.assertEqual(False,u"PAN9_agent_C" in driver.page_source)
|
||||
element = driver.find_elements_by_xpath('//a[contains(.,"PAN9_agent_C")]')
|
||||
self.assertEqual(element,[])
|
||||
except AssertionError as e:
|
||||
self.verificationErrors.append(str(e))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -7,7 +7,6 @@ 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
|
||||
from module_functions import create_module
|
||||
import unittest, time, re
|
||||
|
||||
|
||||
|
@ -22,20 +21,3 @@ def create_policy(driver,policy_name,group,description=None):
|
|||
driver.find_element_by_id("textarea_description").send_keys(description)
|
||||
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
|
||||
|
||||
def search_policy(driver,policy_name,go_to_policy=True):
|
||||
click_menu_element(driver,"Manage policies")
|
||||
driver.find_element_by_id("text-text_search").clear()
|
||||
driver.find_element_by_id("text-text_search").send_keys(policy_name)
|
||||
driver.find_element_by_id("submit-submit").click()
|
||||
# If go_to_policy is True, this function enter in options of this policy
|
||||
|
||||
if go_to_policy == True:
|
||||
driver.find_element_by_xpath('//*[@id="policies_list-0-1"]/span/strong/a/span').click()
|
||||
|
||||
|
||||
def add_module_policy(driver,policy_name,module_type,*args,**kwargs):
|
||||
search_policy(driver,policy_name,go_to_policy=True)
|
||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[2]/a/img').click()
|
||||
create_module(module_type,*args,**kwargs)
|
||||
|
|
|
@ -3,15 +3,23 @@ from unittest import *
|
|||
from console.include.common_functions_60 import *
|
||||
from console.include.common_classes_60 import *
|
||||
from sauceclient import SauceClient
|
||||
from os import environ
|
||||
from os import environ, getenv
|
||||
import subprocess, time, sys
|
||||
|
||||
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]
|
||||
|
||||
#Run Enterprise tests
|
||||
is_enterprise = '1' == getenv('ENTERPRISE', False)
|
||||
|
||||
a = TestLoader()
|
||||
tests = a.discover(start_dir='console',pattern='PAN*.py')
|
||||
|
||||
if is_enterprise:
|
||||
tests = a.discover(start_dir='console',pattern='*.py')
|
||||
else:
|
||||
tests = a.discover(start_dir='console',pattern='PAN*.py')
|
||||
|
||||
c = ArticaTestResult()
|
||||
tests.run(c)
|
||||
|
||||
|
@ -21,14 +29,14 @@ 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.sauce_labs_job_id)
|
||||
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.sauce_labs_job_id)
|
||||
print "Could not annotate Sauce Labs job #%s" % str(test)
|
||||
next
|
||||
|
||||
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
from unittest import *
|
||||
from console import *
|
||||
from console.include.common_functions_60 import *
|
||||
from console.include.common_classes_60 import *
|
||||
from os import environ
|
||||
import subprocess, time, sys
|
||||
from console.PAN3 import *
|
||||
|
||||
|
||||
suite = TestSuite()
|
||||
for i in range(0,10):
|
||||
suite.addTest(PAN3('test_pan3'))
|
||||
|
||||
result = ArticaTestResult()
|
||||
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
|
||||
|
||||
if (len(result.failures)+len(result.errors)+len(result.skipped)) != 0:
|
||||
sys.exit(1)
|
||||
|
||||
else:
|
||||
sys.exit(0)
|
||||
|
Loading…
Reference in New Issue