Changed station_profile to work with changes in realm, refactored cleanup methods

This commit is contained in:
Logan Lipke
2020-07-09 17:26:39 -07:00
parent 69eeff15d8
commit dfaf8f643b
2 changed files with 18 additions and 110 deletions

View File

@@ -38,27 +38,14 @@ class IPV4VariableTime(LFCliBase):
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
self.station_profile = realm.StationProfile(self.lfclient_url, ssid=self.ssid, ssid_pass=self.password,
security=self.security, number_template_=self.number_template,
mode=0, up=True, dhcp=True, debug_=False)
mode=0, up=True, dhcp=True, debug_=False,
local_realm=self.local_realm)
self.cx_profile = realm.L3CXProfile(self.host, self.port, self.local_realm, name_prefix_=self.name_prefix,
side_a_min_bps=side_a_min_rate, side_a_max_bps=side_a_max_rate,
side_b_min_bps=side_b_min_rate, side_b_max_bps=side_b_max_rate,
debug_=False)
self.test_duration = test_duration
def __set_all_cx_state(self, state, sleep_time=5):
print("Setting CX States to %s" % state)
cx_list = list(self.local_realm.cx_list())
for cx_name in cx_list:
if cx_name != 'handler' or cx_name != 'uri':
req_url = "cli-json/set_cx_state"
data = {
"test_mgr": "default_tm",
"cx_name": cx_name,
"cx_state": state
}
self.json_post(req_url, data)
time.sleep(sleep_time)
def __get_rx_values(self):
cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=True)
#print("==============\n", cx_list, "\n==============")
@@ -94,7 +81,7 @@ class IPV4VariableTime(LFCliBase):
cur_time = datetime.datetime.now()
old_cx_rx_values = self.__get_rx_values()
end_time = self.local_realm.parse_time(self.test_duration) + cur_time
self.__set_all_cx_state("RUNNING")
self.cx_profile.start_cx()
passes = 0
expected_passes = 0
while cur_time < end_time:
@@ -121,55 +108,15 @@ class IPV4VariableTime(LFCliBase):
self._pass("PASS: All tests passed", print_pass)
def stop(self):
self.__set_all_cx_state("STOPPED")
self.cx_profile.stop_cx()
for sta_name in self.sta_list:
data = LFUtils.portDownRequest(1, sta_name)
url = "json-cli/set_port"
self.json_post(url, data)
def cleanup(self):
print("Cleaning up stations")
port_list = self.local_realm.station_list()
sta_list = []
for item in list(port_list):
# print(list(item))
if "sta" in list(item)[0]:
sta_list.append(self.local_realm.name_to_eid(list(item)[0])[2])
for sta_name in sta_list:
req_url = "cli-json/rm_vlan"
data = {
"shelf": 1,
"resource": self.resource,
"port": sta_name
}
# print(data)
self.json_post(req_url, data)
cx_list = list(self.local_realm.cx_list())
if cx_list is not None:
print("Cleaning up cxs")
for cx_name in cx_list:
if cx_name != 'handler' or cx_name != 'uri':
req_url = "cli-json/rm_cx"
data = {
"test_mgr": "default_tm",
"cx_name": cx_name
}
self.json_post(req_url, data)
print("Cleaning up endps")
endp_list = self.json_get("/endp")
if endp_list is not None:
endp_list = list(endp_list['endpoint'])
for endp_name in range(len(endp_list)):
name = list(endp_list[endp_name])[0]
req_url = "cli-json/rm_endp"
data = {
"endp_name": name
}
self.json_post(req_url, data)
def cleanup(self, sta_list):
self.station_profile.cleanup(self.resource, sta_list)
self.cx_profile.cleanup()
LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list,
debug=self.debug)
@@ -199,7 +146,7 @@ def main():
resource=1,
security="open", test_duration="5m",
side_a_min_rate=256, side_b_min_rate=256)
ip_var_test.cleanup()
ip_var_test.cleanup(station_list)
ip_var_test.build()
if not ip_var_test.passes():
print(ip_var_test.get_fail_message())
@@ -210,7 +157,7 @@ def main():
print(ip_var_test.get_fail_message())
exit(1)
time.sleep(30)
ip_var_test.cleanup()
ip_var_test.cleanup(station_list)
if ip_var_test.passes():
print("Full test passed, all connections increased rx bytes")