mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 11:18:03 +00:00
Changed station_profile to work with changes in realm, refactored cleanup methods
This commit is contained in:
@@ -42,7 +42,7 @@ class IPV4L4(LFCliBase):
|
||||
self.profile = realm.StationProfile(self.lfclient_url, ssid=self.ssid, ssid_pass=self.password,
|
||||
security=self.security, number_template_=self.prefix, mode=0, up=False,
|
||||
dhcp=True,
|
||||
debug_=False)
|
||||
debug_=False, local_realm=self.local_realm)
|
||||
self.cx_profile = realm.L4CXProfile(lfclient_host=self.host, lfclient_port=self.port,
|
||||
local_realm=self.local_realm, debug_=False)
|
||||
self.cx_profile.url = self.url
|
||||
@@ -68,7 +68,7 @@ class IPV4L4(LFCliBase):
|
||||
expected_passes += 1
|
||||
if new_list[item] > old_list[item]:
|
||||
passes += 1
|
||||
# print(item, new_list[item], old_list[item], passes, expected_passes)
|
||||
#print(item, new_list[item], old_list[item], passes, expected_passes)
|
||||
|
||||
if passes == expected_passes:
|
||||
return True
|
||||
@@ -111,7 +111,7 @@ class IPV4L4(LFCliBase):
|
||||
end_time = self.local_realm.parse_time(self.test_duration) + cur_time
|
||||
self.profile.admin_up(1)
|
||||
self.local_realm.wait_for_ip()
|
||||
self.__set_all_cx_state("RUNNING")
|
||||
self.cx_profile.start_cx()
|
||||
passes = 0
|
||||
expected_passes = 0
|
||||
while cur_time < end_time:
|
||||
@@ -144,48 +144,9 @@ class IPV4L4(LFCliBase):
|
||||
url = "json-cli/set_port"
|
||||
self.json_post(url, data)
|
||||
|
||||
def cleanup(self):
|
||||
layer4_list = self.json_get("layer4/list?fields=name")
|
||||
print(layer4_list)
|
||||
|
||||
if layer4_list is not None and 'endpoint' in layer4_list:
|
||||
if layer4_list['endpoint'] is not None:
|
||||
|
||||
for name in self.sta_list:
|
||||
req_url = "cli-json/rm_cx"
|
||||
data = {
|
||||
"test_mgr": "default_tm",
|
||||
"cx_name": "CX_" + name + "_l4"
|
||||
}
|
||||
self.json_post(req_url, data, True)
|
||||
|
||||
time.sleep(5)
|
||||
for endps in list(layer4_list['endpoint']):
|
||||
for name, info in endps.items():
|
||||
print(name)
|
||||
|
||||
req_url = "cli-json/rm_endp"
|
||||
data = {
|
||||
"endp_name": name
|
||||
}
|
||||
self.json_post(req_url, data, True)
|
||||
|
||||
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
|
||||
}
|
||||
self.json_post(req_url, data, self.debug)
|
||||
time.sleep(.05)
|
||||
def cleanup(self, sta_list):
|
||||
self.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)
|
||||
|
||||
@@ -193,11 +154,11 @@ class IPV4L4(LFCliBase):
|
||||
def main():
|
||||
lfjson_host = "localhost"
|
||||
lfjson_port = 8080
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=9, padding_number_=10000)
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000)
|
||||
ip_test = IPV4L4(lfjson_host, lfjson_port, ssid="jedway-wpa2-x2048-4-4", password="jedway-wpa2-x2048-4-4",
|
||||
security="open", station_list=station_list, url="dl http://10.40.0.1 /dev/null", test_duration="5m",
|
||||
requests_per_ten=600)
|
||||
ip_test.cleanup()
|
||||
ip_test.cleanup(station_list)
|
||||
ip_test.build()
|
||||
if not ip_test.passes():
|
||||
print(ip_test.get_fail_message())
|
||||
@@ -208,7 +169,7 @@ def main():
|
||||
print(ip_test.get_fail_message())
|
||||
exit(1)
|
||||
time.sleep(30)
|
||||
ip_test.cleanup()
|
||||
ip_test.cleanup(station_list)
|
||||
if ip_test.passes():
|
||||
print("Full test passed, all endpoints had increased bytes-rd throughout test duration")
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user