def __init__(self): """__init__(): This is the initialization constructor for testbed config management """ self.testbed_id = getOpt('TESTBED_ID') self.testbed_xml = getOpt('TESTBED_XML') # Testbed xml file may be in the home directory self.testbed_config_file = os.environ['HOME'] + "/" + self.testbed_xml # Or it is expected to be in the current directory or be a full path if not os.path.isfile(self.testbed_config_file): self.testbed_config_file = self.testbed_xml print("Using testbed config: " + self.testbed_config_file + ' test_bed=<"' + str(self.testbed_id) + '">')
def testinit(profiles=['']): # Get the information out of the testbed file config_tree = organizer.TestBed() testbed_object = config_tree.get_config() # Find out what type of client they are using, linux or a device client_name = testbed_object.find(".//control_client[@id='" + str(1) + "']/name") if client_name == None: client_name = getOpt('CLIENT_NAME') if client_name == "": client_name="Linux" # Create a Test server object so we can control the server (stop/start/change logging level) test_server_object = test_server(testbed_object, 1, 1) # Create either a Linux or Device client object client_object = None client_device_object = None if client_name == "Linux": # Create a client object so we can control the client (stop/start/change config) # Specify that we will use client id 1 and it will attach to server id 1 # In the case of a device, this "client" will actually be the qtest command server client_object = test_client_linux(testbed_object, 1, 1, 1) else: # If we are running against a device, create a client device object # This object contains the IP of the Command Server and contains method for creating the command files on that IP client_device_object = testclient_device(testbed_object, 1, 1, 1) # Create a netem object so we can control the netem system netem_object = netem.netem(testbed_object, 1, 1) # See if they are running only some of the profiles if profiles != ['']: profileNameList = getOpt('PROFILES').split(',') if not profileNameList == ['']: allProfiles = profiles profiles = [] for profileName in profileNameList: added = 0 for profile in allProfiles: if profile['name'] == profileName: profiles.append(profile) added = 1 if not added: msg = profileName + " is not a valid profile name" log(msg) sys.exit(msg) log("") log("Running profiles:") for profile in profiles: log(profile['name']) log("") if getOpt('DEBUG'): log("Skipping clearing of netem due to DEBUG == 1") else: # Clear out any netem cruft on the systems in the testbed test_server_object.clear_netem() netem_object.clear_netem() if client_name == "Linux": client_object.clear_netem() if client_name == "Linux": log( "TestClient(" + client_object.data_ip + ") ==> Test Server(" + test_server_object.data_ip + ")") # Test the interfaces ping_test(client_object, test_server_object) else: log("Device Client(" + client_device_object.client_name + ") ==> Test Server(" + test_server_object.data_ip + ")") if getOpt('INSTALL'): # Install the server and client software oschk = test_server_object.run("lsb_release -a", perror=0) if getOpt('OS') and getOpt('OS') == "centos" and oschk == "CentOS": test_server_object.install(getOpt('BUILD'), getOpt('OS')) else: test_server_object.install(getOpt('BUILD')) log("CLIENT NAME : " +str(client_name)) if client_name == "Linux": client_object.install(getOpt('BUILD')) # the way we run tests from py.test this carries # for each def test reset it for one and done so # we do not reinstall for every test in the run setOpt('INSTALL', "0") # Start the server if it is not already running #test_server_object.start() if client_name == "Linux": # Create a file transfer object for linux client transfer_object = transfer(client_object) transfer_device_object = None # Get the client configuration into a known state client_object.set_default_config() else: # Create a file transfer object for devices transfer_device_object = transfer_device(client_device_object, test_server_object) transfer_object = None # Set up the report run_time = strftime("%Y%m%d_%H%M%S", gmtime()) report_object = report() # Get a shell on the content server content_ip = testbed_object.find(".//control_content[@id='" + str(1) + "']/ip").text content_shell = shell(content_ip) objects = {} objects['CLIENT'] = client_object objects['CLIENT_DEVICE'] = client_device_object objects['SERVER'] = test_server_object objects['NETEM'] = netem_object objects['TRANSFER'] = transfer_object objects['TRANSFER_DEVICE'] = transfer_device_object objects['TESTBED'] = testbed_object objects['REPORT'] = report_object objects['PROFILES'] = profiles objects['CONTENT'] = content_shell # Automatically cleanup and generate the report when we exit atexit.register(testfinish, objects) return objects
def testinit(profiles=['']): # Get the information out of the testbed file config_tree = organizer.TestBed() testbed_object = config_tree.get_config() # Find out what type of client they are using, linux or a device client_name = testbed_object.find(".//control_client[@id='" + str(1) + "']/name") if client_name == None: client_name = getOpt('CLIENT_NAME') if client_name == "": client_name = "Linux" # Create a Test server object so we can control the server (stop/start/change logging level) test_server_object = test_server(testbed_object, 1, 1) # Create either a Linux or Device client object client_object = None client_device_object = None if client_name == "Linux": # Create a client object so we can control the client (stop/start/change config) # Specify that we will use client id 1 and it will attach to server id 1 # In the case of a device, this "client" will actually be the qtest command server client_object = test_client_linux(testbed_object, 1, 1, 1) else: # If we are running against a device, create a client device object # This object contains the IP of the Command Server and contains method for creating the command files on that IP client_device_object = testclient_device(testbed_object, 1, 1, 1) # Create a netem object so we can control the netem system netem_object = netem.netem(testbed_object, 1, 1) # See if they are running only some of the profiles if profiles != ['']: profileNameList = getOpt('PROFILES').split(',') if not profileNameList == ['']: allProfiles = profiles profiles = [] for profileName in profileNameList: added = 0 for profile in allProfiles: if profile['name'] == profileName: profiles.append(profile) added = 1 if not added: msg = profileName + " is not a valid profile name" log(msg) sys.exit(msg) log("") log("Running profiles:") for profile in profiles: log(profile['name']) log("") if getOpt('DEBUG'): log("Skipping clearing of netem due to DEBUG == 1") else: # Clear out any netem cruft on the systems in the testbed test_server_object.clear_netem() netem_object.clear_netem() if client_name == "Linux": client_object.clear_netem() if client_name == "Linux": log("TestClient(" + client_object.data_ip + ") ==> Test Server(" + test_server_object.data_ip + ")") # Test the interfaces ping_test(client_object, test_server_object) else: log("Device Client(" + client_device_object.client_name + ") ==> Test Server(" + test_server_object.data_ip + ")") if getOpt('INSTALL'): # Install the server and client software oschk = test_server_object.run("lsb_release -a", perror=0) if getOpt('OS') and getOpt('OS') == "centos" and oschk == "CentOS": test_server_object.install(getOpt('BUILD'), getOpt('OS')) else: test_server_object.install(getOpt('BUILD')) log("CLIENT NAME : " + str(client_name)) if client_name == "Linux": client_object.install(getOpt('BUILD')) # the way we run tests from py.test this carries # for each def test reset it for one and done so # we do not reinstall for every test in the run setOpt('INSTALL', "0") # Start the server if it is not already running #test_server_object.start() if client_name == "Linux": # Create a file transfer object for linux client transfer_object = transfer(client_object) transfer_device_object = None # Get the client configuration into a known state client_object.set_default_config() else: # Create a file transfer object for devices transfer_device_object = transfer_device(client_device_object, test_server_object) transfer_object = None # Set up the report run_time = strftime("%Y%m%d_%H%M%S", gmtime()) report_object = report() # Get a shell on the content server content_ip = testbed_object.find(".//control_content[@id='" + str(1) + "']/ip").text content_shell = shell(content_ip) objects = {} objects['CLIENT'] = client_object objects['CLIENT_DEVICE'] = client_device_object objects['SERVER'] = test_server_object objects['NETEM'] = netem_object objects['TRANSFER'] = transfer_object objects['TRANSFER_DEVICE'] = transfer_device_object objects['TESTBED'] = testbed_object objects['REPORT'] = report_object objects['PROFILES'] = profiles objects['CONTENT'] = content_shell # Automatically cleanup and generate the report when we exit atexit.register(testfinish, objects) return objects