mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 18:58:01 +00:00 
			
		
		
		
	added self.debug if statements for less output, 1k just about finished - just thorough testing left
This commit is contained in:
		| @@ -555,7 +555,8 @@ class Realm(LFCliBase): | |||||||
|         return not wait_more |         return not wait_more | ||||||
|  |  | ||||||
|     def get_curr_num_ips(self,num_sta_with_ips=0,station_list=None, ipv4=True, ipv6=False, debug=False): |     def get_curr_num_ips(self,num_sta_with_ips=0,station_list=None, ipv4=True, ipv6=False, debug=False): | ||||||
|         print("checking number of stations with ips...") |         if debug: | ||||||
|  |             print("checking number of stations with ips...") | ||||||
|         waiting_states = ["0.0.0.0", "NA", ""] |         waiting_states = ["0.0.0.0", "NA", ""] | ||||||
|         if (station_list is None) or (len(station_list) < 1): |         if (station_list is None) or (len(station_list) < 1): | ||||||
|             raise ValueError("check for num curr ips expects non-empty list of ports") |             raise ValueError("check for num curr ips expects non-empty list of ports") | ||||||
| @@ -621,8 +622,6 @@ class Realm(LFCliBase): | |||||||
|             raise ValueError("time_string must be of type str. Type %s provided" % type(time_string)) |             raise ValueError("time_string must be of type str. Type %s provided" % type(time_string)) | ||||||
|         return duration_sec |         return duration_sec | ||||||
|  |  | ||||||
|         pass |  | ||||||
|  |  | ||||||
|     def parse_time(self, time_string): |     def parse_time(self, time_string): | ||||||
|         if isinstance(time_string, str): |         if isinstance(time_string, str): | ||||||
|             pattern = re.compile("^(\d+)([dhms]$)") |             pattern = re.compile("^(\d+)([dhms]$)") | ||||||
| @@ -1014,7 +1013,8 @@ class L3CXProfile(LFCliBase): | |||||||
|     def start_cx(self): |     def start_cx(self): | ||||||
|         print("Starting CXs...") |         print("Starting CXs...") | ||||||
|         for cx_name in self.created_cx.keys(): |         for cx_name in self.created_cx.keys(): | ||||||
|             print("cx-name: %s"%(cx_name)) |             if self.debug: | ||||||
|  |                 print("cx-name: %s"%(cx_name)) | ||||||
|             self.json_post("/cli-json/set_cx_state", { |             self.json_post("/cli-json/set_cx_state", { | ||||||
|                 "test_mgr": "default_tm", |                 "test_mgr": "default_tm", | ||||||
|                 "cx_name": cx_name, |                 "cx_name": cx_name, | ||||||
| @@ -1037,12 +1037,14 @@ class L3CXProfile(LFCliBase): | |||||||
|         print("Cleaning up cxs and endpoints") |         print("Cleaning up cxs and endpoints") | ||||||
|         if len(self.created_cx) != 0: |         if len(self.created_cx) != 0: | ||||||
|             for cx_name in self.created_cx.keys(): |             for cx_name in self.created_cx.keys(): | ||||||
|                 print("Cleaning cx: %s"%(cx_name)) |                 if self.debug: | ||||||
|  |                     print("Cleaning cx: %s"%(cx_name)) | ||||||
|                 self.local_realm.rm_cx(cx_name) |                 self.local_realm.rm_cx(cx_name) | ||||||
|  |  | ||||||
|                 for side in range(len(self.created_cx[cx_name])): |                 for side in range(len(self.created_cx[cx_name])): | ||||||
|                     ename = self.created_cx[cx_name][side] |                     ename = self.created_cx[cx_name][side] | ||||||
|                     print("Cleaning endpoint: %s"%(ename)) |                     if self.debug: | ||||||
|  |                         print("Cleaning endpoint: %s"%(ename)) | ||||||
|                     self.local_realm.rm_endp(self.created_cx[cx_name][side]) |                     self.local_realm.rm_endp(self.created_cx[cx_name][side]) | ||||||
|  |  | ||||||
|     def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False, tos=None): |     def create(self, endp_type, side_a, side_b, sleep_time=0.03, suppress_related_commands=None, debug_=False, tos=None): | ||||||
|   | |||||||
| @@ -65,6 +65,7 @@ class Test1KClients(LFCliBase): | |||||||
|         self.cx_profile.side_a_max_bps = side_a_max_rate |         self.cx_profile.side_a_max_bps = side_a_max_rate | ||||||
|         self.cx_profile.side_b_min_bps = side_b_min_rate |         self.cx_profile.side_b_min_bps = side_b_min_rate | ||||||
|         self.cx_profile.side_b_max_bps = side_b_max_rate |         self.cx_profile.side_b_max_bps = side_b_max_rate | ||||||
|  |         | ||||||
|  |  | ||||||
|         self.station_profile_map = {} |         self.station_profile_map = {} | ||||||
|     def build(self): |     def build(self): | ||||||
| @@ -117,7 +118,6 @@ class Test1KClients(LFCliBase): | |||||||
|                 expected_passes += 1 |                 expected_passes += 1 | ||||||
|                 if new_list[item] > old_list[item]: |                 if new_list[item] > old_list[item]: | ||||||
|                     passes += 1 |                     passes += 1 | ||||||
|                 # print(item, new_list[item], old_list[item], passes, expected_passes) |  | ||||||
|  |  | ||||||
|             if passes == expected_passes: |             if passes == expected_passes: | ||||||
|                 return True |                 return True | ||||||
| @@ -128,10 +128,10 @@ class Test1KClients(LFCliBase): | |||||||
|  |  | ||||||
|     def start(self): |     def start(self): | ||||||
|         print("Bringing stations up...") |         print("Bringing stations up...") | ||||||
|         prev_ip_num=0 |         prev_ip_num=0       | ||||||
|         total_num_sta=6*self.num_sta       |  | ||||||
|         for (radio, station_profile) in self.station_profile_map.items(): |         for (radio, station_profile) in self.station_profile_map.items(): | ||||||
|             station_profile.admin_up() |             station_profile.admin_up() | ||||||
|  |             total_num_sta=6*self.num_sta | ||||||
|             self.local_realm.wait_for_ip(station_list=self.station_radio_map[radio], debug=self.debug, timeout_sec=30) |             self.local_realm.wait_for_ip(station_list=self.station_radio_map[radio], debug=self.debug, timeout_sec=30) | ||||||
|             curr_ip_num = self.local_realm.get_curr_num_ips(num_sta_with_ips=prev_ip_num,station_list=self.station_radio_map[radio], debug=self.debug) |             curr_ip_num = self.local_realm.get_curr_num_ips(num_sta_with_ips=prev_ip_num,station_list=self.station_radio_map[radio], debug=self.debug) | ||||||
|             while ((prev_ip_num < curr_ip_num) and (curr_ip_num < total_num_sta)): |             while ((prev_ip_num < curr_ip_num) and (curr_ip_num < total_num_sta)): | ||||||
| @@ -146,26 +146,24 @@ class Test1KClients(LFCliBase): | |||||||
|              |              | ||||||
|          |          | ||||||
|         old_cx_rx_values = self.__get_rx_values()  |         old_cx_rx_values = self.__get_rx_values()  | ||||||
|         print("Test duration is %s", self.test_duration) |         self.cx_profile.start_cx() | ||||||
|         #for loop through all and start all cross-connects |  | ||||||
|         for (radio, station_profile) in self.station_profile_map.items(): |  | ||||||
|             self.cx_profile.start_cx() |  | ||||||
|  |  | ||||||
|         passes = 0 |         passes = 0 | ||||||
|         expected_passes = 0 |         expected_passes = 0 | ||||||
|         cur_time = datetime.datetime.now() |         curr_time = datetime.datetime.now() | ||||||
|         end_time = self.local_realm.parse_time(self.test_duration) + cur_time |         end_time = self.local_realm.parse_time(self.test_duration) + curr_time | ||||||
|         sleep_interval = self.local_realm.parse_time(self.test_duration) // 3 |         sleep_interval = self.local_realm.parse_time(self.test_duration) // 3 | ||||||
|  |  | ||||||
|         while cur_time < end_time: |         while curr_time < end_time: | ||||||
|  |  | ||||||
|             time.sleep(sleep_interval.total_seconds()) |             time.sleep(sleep_interval.total_seconds()) | ||||||
|  |  | ||||||
|             new_cx_rx_values = self.__get_rx_values() |             new_cx_rx_values = self.__get_rx_values() | ||||||
|             print(old_cx_rx_values, new_cx_rx_values) |             if self.debug: | ||||||
|             print("\n-----------------------------------") |                 print(old_cx_rx_values, new_cx_rx_values) | ||||||
|             print(cur_time, end_time, cur_time + datetime.timedelta(minutes=1)) |                 print("\n-----------------------------------") | ||||||
|             print("-----------------------------------\n") |                 print(curr_time, end_time) | ||||||
|  |                 print("-----------------------------------\n") | ||||||
|             expected_passes += 1 |             expected_passes += 1 | ||||||
|             if self.__compare_vals(old_cx_rx_values, new_cx_rx_values): |             if self.__compare_vals(old_cx_rx_values, new_cx_rx_values): | ||||||
|                 passes += 1 |                 passes += 1 | ||||||
| @@ -174,23 +172,30 @@ class Test1KClients(LFCliBase): | |||||||
|                 self.exit_fail() |                 self.exit_fail() | ||||||
|  |  | ||||||
|             old_cx_rx_values = new_cx_rx_values |             old_cx_rx_values = new_cx_rx_values | ||||||
|             cur_time = datetime.datetime.now() |             curr_time = datetime.datetime.now() | ||||||
|  |  | ||||||
|         if passes == expected_passes: |         if passes == expected_passes: | ||||||
|             self._pass("PASS: All tests passed") |             self._pass("PASS: All tests passed") | ||||||
|  |  | ||||||
|  |  | ||||||
|     def stop(self): |     def stop(self): | ||||||
|         for (radio, station_profile) in self.station_profile_map.items(): |         self.cx_profile.stop_cx() | ||||||
|             self.cx_profile.stop_cx() |  | ||||||
|  |  | ||||||
|     def cleanup(self): |     def pre_cleanup(self): | ||||||
|         #self.cx_profile.cleanup_prefix() |         self.cx_profile.cleanup_prefix() | ||||||
|         for (radio, name_series) in self.station_radio_map.items(): |         for (radio, name_series) in self.station_radio_map.items(): | ||||||
|             sta_list= self.station_radio_map[radio] |             sta_list= self.station_radio_map[radio] | ||||||
|             for sta in sta_list: |             for sta in sta_list: | ||||||
|                 self.local_realm.rm_port(sta, check_exists=True) |                 self.local_realm.rm_port(sta, check_exists=True) | ||||||
|  |  | ||||||
|  |     def post_cleanup(self): | ||||||
|  |         self.cx_profile.cleanup() | ||||||
|  |         for (radio, name_series) in self.station_radio_map.items(): | ||||||
|  |             sta_list= self.station_radio_map[radio] | ||||||
|  |             for sta in sta_list: | ||||||
|  |                 self.local_realm.rm_port(sta, check_exists=True) | ||||||
|  |  | ||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
|     num_sta=200 |     num_sta=200 | ||||||
|     lfjson_host = "localhost" |     lfjson_host = "localhost" | ||||||
| @@ -227,7 +232,7 @@ def main(): | |||||||
|                               num_sta_=args.sta_per_radio, |                               num_sta_=args.sta_per_radio, | ||||||
|                               _debug_on=args.debug) |                               _debug_on=args.debug) | ||||||
|  |  | ||||||
|     kilo_test.cleanup() |     kilo_test.pre_cleanup() | ||||||
|     kilo_test.build() |     kilo_test.build() | ||||||
|     if not kilo_test.passes(): |     if not kilo_test.passes(): | ||||||
|         kilo_test.exit_failed() |         kilo_test.exit_failed() | ||||||
| @@ -237,7 +242,9 @@ def main(): | |||||||
|     kilo_test.stop() |     kilo_test.stop() | ||||||
|     if not kilo_test.passes(): |     if not kilo_test.passes(): | ||||||
|          kilo_test.exit_failed() |          kilo_test.exit_failed() | ||||||
|     kilo_test.cleanup() |     time.sleep(60) | ||||||
|  |     kilo_test.post_cleanup() | ||||||
|  |     kilo_test.exit_success() | ||||||
|  |  | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|     main() |     main() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Dipti
					Dipti