Skip to content

Commit

Permalink
splunk integration test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
pszkamruk-splunk committed Sep 22, 2023
1 parent 37a3ac7 commit 3465cea
Show file tree
Hide file tree
Showing 11 changed files with 825 additions and 45 deletions.
9 changes: 8 additions & 1 deletion ui_tests/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ def get_execution_type():


EXECUTION_TYPE_LOCAL = "local"
# EXECUTION_TYPE_LOCAL = "remote"
EXECUTION_TYPE = get_execution_type()

UI_URL = "http://10.202.2.199:30001/"
EVENT_INDEX = "netops"
LOGS_INDEX = "em_logs"

DEVICE_SIMULATOR_HOST = "10.202.1.48"
# SIM_HOST = "10.202.5.170" # old not exists anymore


# timers
IMPLICIT_WAIT_TIMER = 10
IMPLICIT_WAIT_TIMER = 15
38 changes: 11 additions & 27 deletions ui_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
import time

import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import config.config as config
# from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager

from webdriver.webriver_factory import WebDriverFactory
from logger.logger import Logger

logger = Logger().get_logger()


# @pytest.fixture(scope="function")
# def driver():
# logger.info(f"Execution type: {config.EXECUTION_TYPE}")
# chrome_options = Options()
# if config.EXECUTION_TYPE != "local":
# chrome_options.add_argument("--headless")
# chrome_options.add_argument("--disable-gpu")
# chrome_options.add_argument("--window-size=1920x1080")
# # web_driver = webdriver.Chrome(options=chrome_options)
#
# web_driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=chrome_options)
#
# if config.EXECUTION_TYPE != "local":
# web_driver.maximize_window()
# url = "http://10.202.2.199:30001/"
# web_driver.get(url)
# time.sleep(5)
# return web_driver
@pytest.fixture(scope="function")
def setup(request):
config = {}
host = request.config.getoption("--splunk-host")
config["splunkd_url"] = "https://" + host + ":8089"
config["splunk_user"] = request.config.getoption("--splunk-user")
config["splunk_password"] = request.config.getoption("--splunk-password")

return config


def pytest_unconfigure():
logger.info("Closing Web Driver")
WebDriverFactory.close_driver()

28 changes: 27 additions & 1 deletion ui_tests/pages/header_page.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import time

from webdriver.webriver_factory import WebDriverFactory
Expand Down Expand Up @@ -28,4 +29,29 @@ def switch_to_inventory(self):
xpath_profiles_button = "//button[@data-test='sc4snmp:inventory-tab']"
tab = driver.find_element(By.XPATH, xpath_profiles_button)
tab.click()
time.sleep(3)
time.sleep(3)

def apply_changes(self):
logger.info("Apply changes")
apply_changes_button_xpath = "//button[@data-test='sc4snmp:apply-changes-button']"
apply_btn = driver.find_element(By.XPATH, apply_changes_button_xpath)
apply_btn.click()
time.sleep(3)

def close_configuration_applied_notification_popup(self):
logger.info("Close configuration applied popup")
popup_xpath = "//button[@data-test='sc4snmp:errors-modal:cancel-button']"
close_popup_button = driver.find_element(By.XPATH, popup_xpath)
close_popup_button.click()
time.sleep(3)

def get_time_to_upgrade(self):
logger.info("Get time to upgrade")
popup_text_xpath = "//div[@data-test='modal']//div//p"
popup_txt_element = driver.find_element(By.XPATH, popup_text_xpath)
text = popup_txt_element.text
matches = re.search(r'\d+', text)
number = int(matches.group())
logger.info(f"Extracted number: {number}")
time.sleep(3)
return number
17 changes: 14 additions & 3 deletions ui_tests/pages/inventory_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def check_if_entry_is_on_list(self, host_ip):
logger.info(f"Checking if host/group entry is configured (is on list)")
entries_on_list_xpath = "//td[@data-test='sc4snmp:inventory-address']"
entries = driver.find_elements(By.XPATH, entries_on_list_xpath)
logger.info(f"SPRAWDZAM {len(entries)}")
logger.info(f"list length: {len(entries)}")
for el in entries:
logger.info(f"entry name > |{el.text}|") # debug
if host_ip == el.text:
Expand Down Expand Up @@ -205,11 +205,12 @@ def select_profiles(self, profiles, edit=False):
options = driver.find_elements(By.XPATH, profile_options_xpath)
for option in options:
option.click()
time.sleep(2)
time.sleep(0.5)
time.sleep(1)
for profile in profiles:
profile_input.send_keys(profile)
profile_input.send_keys(Keys.ENTER)
time.sleep(1)
time.sleep(2)

def _get_inventory_data(self, host, field):
if field == 'snmp_version':
Expand Down Expand Up @@ -264,3 +265,13 @@ def get_profiles_for_entry(self, host):
def get_smart_profiles_for_entry(self, host):
logger.info(f"get {host} inventory -> smart_profiles")
return self._get_inventory_data(host, "smart_profiles")

def clear_inventory(self):
logger.info(f"remove all inventory entries")
delete_btn_for_group_with_name_xpath = f"//button[@data-test='sc4snmp:inventory-row-delete']"
delete_btns = driver.find_elements(By.XPATH, delete_btn_for_group_with_name_xpath)
for btn in delete_btns:
btn.click()
time.sleep(1)
self.confirm_delete()
self.close_delete_popup()
15 changes: 14 additions & 1 deletion ui_tests/pages/profiles_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,14 @@ def delete_profile_from_list(self, profile_name):
delete_btn = driver.find_element(By.XPATH, delete_btn_for_profile_with_name_xpath)
delete_btn.click()
time.sleep(1)
self._confirm_delete_profile()
self.close_profile_delete_popup()

def _confirm_delete_profile(self):
confirm_delete_xpath = "//button[@data-test='sc4snmp:delete-modal:delete-button']"
confirm_btn = driver.find_element(By.XPATH, confirm_delete_xpath)
confirm_btn.click()
time.sleep(1)
self.close_profile_delete_popup()

def close_profile_delete_popup(self):
logger.info(f"Closing profile delete popup")
Expand Down Expand Up @@ -229,3 +232,13 @@ def get_profile_varbind(self, profile_name):
"mindex": int(mindex.text)
}
return varBind

def clear_profiles(self):
logger.info(f"remove all profiles")
profile_delete_btn_xpath = f"//button[@data-test='sc4snmp:profile-row-delete']"
delete_btns = driver.find_elements(By.XPATH, profile_delete_btn_xpath)
for btn in delete_btns:
btn.click()
time.sleep(1)
self._confirm_delete_profile()
self.close_profile_delete_popup()
7 changes: 4 additions & 3 deletions ui_tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[pytest]
addopts = -rfps --durations=10 --disable-pytest-warnings --continue-on-collection-errors
;log_level = INFO
log_level = DEBUG
log_level = INFO
;addopts = -rfps --durations=10 --disable-pytest-warnings --continue-on-collection-errors

;log_level = DEBUG
Loading

0 comments on commit 3465cea

Please sign in to comment.