def init_test(total_tests, config, hostname, build): isinstance(config, dict) integrationTestCase.version = build integrationTestCase.total_tests = total_tests # Web browser integrationTestCase.remoteWebBrowser = config.get("remotewebbrowser", None) integrationTestCase.browser = config.get("browser", None) # MCU Computers integrationTestCase.managedClient = config.get("managedclient", None) # QPM Computers integrationTestCase.qpms_server = config.get("qpmserver", None) integrationTestCase.qpmu_server = config.get("qpmuserver", None) # QAS Computer integrationTestCase.qas_computer = config.get("qascomputer", None) # Users integrationTestCase.linuxUser = config.get("linuxUser", "root") integrationTestCase.password = config.get("password", "test123") integrationTestCase.winUser = config.get("winuser", "Administrator") integrationTestCase.loginuserpasswd = config.get("loginuserpasswd", "test123") integrationTestCase.winPassword = config.get("winpassword", "test123") username = config.get("username", "root") password = config.get("password", "test123") integrationTestCase.logger = logging.getLogger(hostname) integrationTestCase.spath = config.get("scriptpath","/mnt/qpm4u/smoke/") integrationTestCase.previousBuild = config.get("previousVersion", "5.6.0.040") integrationTestCase.devb = config.get("devb", "/mnt/qpm4u/dev-builds") # QAS Stuff integrationTestCase.upnMode = config.get("upnmode", False) integrationTestCase.mount = config.get("mount", True) # Test Group integrationTestCase.testgroup = config.get("testgroup", "Integration - {}".format(build)) # Logging and debug integrationTestCase.logDirectory = config.get("logdirectory", "/var/www/MCU") integrationTestCase.runWithDebug = config.get("runwithdebug", True) # Domain integrationTestCase.domain = config.get("domain", "h.qas") integrationTestCase.defaultDomain = domain_ext(integrationTestCase.domain) # install Path integrationTestCase.install_sh_path = config.get("installshpath", "/mnt/integratedIso/dev-builds") integrationTestCase.install_sh_build_path = "{}/{}".format(integrationTestCase.install_sh_path, integrationTestCase.version) integrationTestCase.mcuInstalledjvm = config.get("mcuinstalledjvm","32-bit") computer_list = [] computer_list.append(hostname) computer_list.append(config.get("qpmserver")) computer_list.append(config.get("qpmuserver")) computer_list.append(config.get("qascomputer")) sorted_list = set(computer_list) mcu_comp = False qas_comp = False qpms_comp = False qpmu_comp = None # Find out what computers we have integrationTestCase.open_computers = [] for comp in sorted_list: # We should always have at least this computer # MCU | Open connections to mcu computers ---------------------------------------------------------------------- if comp == hostname: mcu_comp = hostname integrationTestCase.mcu_computer = _open_and_setup_computer(mcu_comp, username, password, integrationComputer, integrationTestCase.defaultDomain) # QPM4S | Open connections to QPM4S computer ---------------------------------------------------------------------- elif comp == config.get("qpmserver"): qpms_comp = config.get("qpmserver") integrationTestCase.qpms_server = _open_and_setup_computer(qpms_comp, "root", "test123", integrationComputer, integrationTestCase.defaultDomain) # QPM4U | Open connections to QPM4U computer ---------------------------------------------------------------------- elif comp == config.get("qpmuserver"): qpmu_comp = config.get("qpmuserver") integrationTestCase.qpmu_server = _open_and_setup_computer(qpmu_comp, "root", "test123", integrationComputer, integrationTestCase.defaultDomain) # QAS | Open connections to QPM4U computer ---------------------------------------------------------------------- elif comp == config.get("qascomputer"): qas_comp = config.get("qascomputer") integrationTestCase.qas_computer = _open_and_setup_computer(qas_comp, "root", "test123", integrationComputer, integrationTestCase.defaultDomain) # Now we need to assign other computers that did not get opened if not qas_comp: for comp in integrationTestCase.open_computers: if comp.hostname == config.get("qascomputer"): integrationTestCase.qas_computer = comp break if not qpms_comp: for comp in integrationTestCase.open_computers: if comp.hostname == config.get("qpmserver"): integrationTestCase.qpms_server = comp break if not qpmu_comp: for comp in integrationTestCase.open_computers: if comp.hostname == config.get("qpmuserver"): integrationTestCase.qpmu_server = comp break # Run this to set the env variables. if integrationTestCase.qpms_server.hostname == integrationTestCase.qpmu_server.hostname: # If they are the same computer then we only need to run it once set_devb(integrationTestCase.qpmu_server, integrationTestCase.devb) else: # If they are different then run on each box. set_devb(integrationTestCase.qpms_server, integrationTestCase.devb) set_devb(integrationTestCase.qpmu_server, integrationTestCase.devb) # WEB Browser | Open a web browser for testing ---------------------------------------------------------------------- if integrationTestCase.browser != None: integrationTestCase.logger.info("\nOpening up internet browser | {}".format(integrationTestCase.browser)) integrationTestCase.logger.info("-----------------------------------------------") integrationTestCase.mcuConsole = pagehandler.mcuPage.mcuPage(integrationTestCase.remoteWebBrowser, integrationTestCase.mcu_computer.hostname, integrationTestCase.browser, integrationTestCase.logDirectory, integrationTestCase.logger, integrationTestCase.version) assert integrationTestCase.mcuConsole.page != None, 'Did not open a browser' integrationTestCase.webdriverVersion = selenium.__version__ return integrationComputer
def init_test(config, hostname, build): isinstance(config, dict) QpmTestCase.version = build QpmTestCase.logger = logging.getLogger(hostname) QpmTestCase.server = config.get("server") QpmTestCase.secondary = config.get("secondary") QpmTestCase.client = config.get("client") QpmTestCase.spath = config.get("scriptpath","/mnt/qpm4u/smoke/") QpmTestCase.previousBuild = config.get("previousVersion", "5.6.0.040") QpmTestCase.devb = config.get("devb", "/mnt/qpm4u/dev-builds") osinfo = eval(config.get('osinfo','{}')) serverinfo = eval(config.get('serverinfo')) username = config.get("username", "root") password = config.get("password", "test123") # Domain QpmTestCase.domain = config.get("domain", "h.qas") QpmTestCase.defaultDomain = domain_ext(QpmTestCase.domain) # Open connections to test computer and peers QpmTestCase.computer = create_computer_with_hostname(hostname, username, password, QpmComputer, domain=QpmTestCase.defaultDomain, **osinfo) assert QpmTestCase.computer.is_connected, 'There was a problem trying to connect to computer' # Check Mount after opening computer QpmTestCase.computer.check_and_mount_custom("hal9000.vintela.com:/automation/packages", "/mnt/packages") # Lock computer after mounts are setup QpmTestCase.computer.lock_on_computer() set_devb(QpmTestCase.computer, QpmTestCase.devb) # Setup PATH run(QpmTestCase.computer, "PATH=$PATH:/opt/quest/bin:/opt/quest/sbin; export PATH"); # See if testing is using the box dont_smoke = "/tmp/.dont_smoke" counter = 0 while QpmTestCase.computer.fileExists(dont_smoke): QpmTestCase.computer.logger.info("There is a lock file from testing: {}".format(dont_smoke)) if counter % 3600 == 0: QpmTestCase.computer.remoteShell.run("echo Please wrap it up so smoke can run. Remove {} | wall".format(dont_smoke)) counter+=120 if counter % 10800 == 0: QpmTestCase.computer.remoteShell.run("rm -f {0}; echo Done waiting, removing file {0}. Smoke will resume in 120 seconds | wall".format(dont_smoke)) time.sleep(120) QpmTestCase.computer.remoteShell.run("echo QPM4S Smoke has been ordered to run | wall".format(dont_smoke)) QpmTestCase.servercomp = create_computer_with_hostname(username="******", password="******", computerclass=QpmComputer, **serverinfo) assert QpmTestCase.servercomp.is_connected, 'There was a problem trying to connect to the computer' QpmTestCase.servercomp.check_and_mount_custom("hal9000.vintela.com:/automation/packages", "/mnt/packages") QpmTestCase.servercomp.lock_on_computer() set_devb(QpmTestCase.servercomp, QpmTestCase.devb) # Setup PATH run(QpmTestCase.servercomp, "PATH=$PATH:/opt/quest/bin:/opt/quest/sbin; export PATH"); # Clean the the server beforehand QpmTestCase.logger.info("\n\nCleaning {}. Cleaning off the server, agent and client".format(QpmTestCase.servercomp.hostname)) QpmTestCase.servercomp.remoteShell.run(QpmTestCase.spath + "clean-server.sh", timeout=500) QpmTestCase.servercomp.remoteShell.run(QpmTestCase.spath + "clean-agent.sh", timeout=500) QpmTestCase.servercomp.remoteShell.run(QpmTestCase.spath + "clean-client.sh", timeout=500) # Prep the peers QpmTestCase.logger.info("\n\n{} | Installing and configuring server...".format(QpmTestCase.servercomp.hostname)) QpmTestCase.servercomp.remoteShell.run(QpmTestCase.spath + "install-server.sh {}".format(build), timeout=500) QpmTestCase.servercomp.remoteShell.run(QpmTestCase.spath + "config-server-001.sh -f {}".format(QpmTestCase.spath + "sudoers/default"), timeout=500) # Cleanup test computer QpmTestCase.logger.info("\n\nCleaning test computer: {}".format(QpmTestCase.computer.hostname)) QpmTestCase.computer.remoteShell.run(QpmTestCase.spath + "clean-server.sh", timeout=500) QpmTestCase.computer.remoteShell.run(QpmTestCase.spath + "clean-client.sh", timeout=500) QpmTestCase.computer.remoteShell.run(QpmTestCase.spath + "clean-agent.sh", timeout=500) return QpmTestCase