@@ -55,11 +55,6 @@ def __init__(self):
55
55
self .myip = test_params .get ('myip' , None )
56
56
self .peerip = test_params .get ('peerip' , None )
57
57
self .default_server_send_rate_limit_pps = test_params .get ('send_rate_limit' , 2000 )
58
-
59
- # For counter test
60
- self .expect_send_pkt_number = test_params .get ('sent_pkt_number' , None )
61
- self .send_duration = test_params .get ('send_duration' , None )
62
- self .is_counter_test = self .expect_send_pkt_number is not None and self .send_duration is not None
63
58
64
59
self .needPreSend = None
65
60
@@ -115,9 +110,6 @@ def copp_test(self, packet, send_intf, recv_intf):
115
110
'''
116
111
Pre-send some packets for a second to absorb the CBS capacity.
117
112
'''
118
- if self .is_counter_test :
119
- return self .copp_counter_test (packet , send_intf , recv_intf )
120
-
121
113
if self .needPreSend :
122
114
pre_send_count = 0
123
115
end_time = datetime .datetime .now () + datetime .timedelta (seconds = self .DEFAULT_PRE_SEND_INTERVAL_SEC )
@@ -186,67 +178,6 @@ def copp_test(self, packet, send_intf, recv_intf):
186
178
187
179
return send_count , recv_count , time_delta , time_delta_ms , tx_pps , rx_pps
188
180
189
- def copp_counter_test (self , packet , send_intf , recv_intf ):
190
- pre_test_ptf_tx_counter = self .dataplane .get_counters (* send_intf )
191
- pre_test_ptf_rx_counter = self .dataplane .get_counters (* recv_intf )
192
- pre_test_nn_tx_counter = self .dataplane .get_nn_counters (* send_intf )
193
- pre_test_nn_rx_counter = self .dataplane .get_nn_counters (* recv_intf )
194
-
195
- send_count = 0
196
- start_time = datetime .datetime .now ()
197
- send_window = float (self .send_duration ) / float (self .expect_send_pkt_number )
198
- while send_count < self .expect_send_pkt_number :
199
- begin = time .time ()
200
- testutils .send_packet (self , send_intf , packet )
201
- send_count += 1
202
- elapse = time .time () - begin
203
-
204
- # Depending on the server/platform combination it is possible for the server to
205
- # overwhelm the DUT, so we add an artificial delay here to rate-limit the server.
206
- if elapse > 0 :
207
- time .sleep (send_window - elapse )
208
-
209
- end_time = datetime .datetime .now ()
210
- time .sleep (self .DEFAULT_RECEIVE_WAIT_TIME ) # Wait a little bit for all the packets to make it through
211
- recv_count = testutils .count_matched_packets (self , packet , recv_intf [1 ], recv_intf [0 ])
212
-
213
- post_test_ptf_tx_counter = self .dataplane .get_counters (* send_intf )
214
- post_test_ptf_rx_counter = self .dataplane .get_counters (* recv_intf )
215
- post_test_nn_tx_counter = self .dataplane .get_nn_counters (* send_intf )
216
- post_test_nn_rx_counter = self .dataplane .get_nn_counters (* recv_intf )
217
-
218
- ptf_tx_count = int (post_test_ptf_tx_counter [1 ] - pre_test_ptf_tx_counter [1 ])
219
- nn_tx_count = int (post_test_nn_tx_counter [1 ] - pre_test_nn_tx_counter [1 ])
220
- ptf_rx_count = int (post_test_ptf_rx_counter [0 ] - pre_test_ptf_rx_counter [0 ])
221
- nn_rx_count = int (post_test_nn_rx_counter [0 ] - pre_test_nn_rx_counter [0 ])
222
-
223
- self .log ("" , True )
224
- self .log ("Counters before the test:" , True )
225
- self .log ("If counter (0, n): %s" % str (pre_test_ptf_tx_counter ), True )
226
- self .log ("NN counter (0, n): %s" % str (pre_test_nn_tx_counter ), True )
227
- self .log ("If counter (1, n): %s" % str (pre_test_ptf_rx_counter ), True )
228
- self .log ("NN counter (1, n): %s" % str (pre_test_nn_rx_counter ), True )
229
- self .log ("" , True )
230
- self .log ("Counters after the test:" , True )
231
- self .log ("If counter (0, n): %s" % str (post_test_ptf_tx_counter ), True )
232
- self .log ("NN counter (0, n): %s" % str (post_test_nn_tx_counter ), True )
233
- self .log ("If counter (1, n): %s" % str (post_test_ptf_rx_counter ), True )
234
- self .log ("NN counter (1, n): %s" % str (post_test_nn_rx_counter ), True )
235
- self .log ("" )
236
- self .log ("Sent through NN to local ptf_nn_agent: %d" % ptf_tx_count )
237
- self .log ("Sent through If to remote ptf_nn_agent: %d" % nn_tx_count )
238
- self .log ("Recv from If on remote ptf_nn_agent: %d" % ptf_rx_count )
239
- self .log ("Recv from NN on from remote ptf_nn_agent: %d" % nn_rx_count )
240
-
241
- time_delta = end_time - start_time
242
- self .log ("Sent out %d packets in %ds" % (send_count , time_delta .seconds ))
243
- time_delta_ms = (time_delta .microseconds + time_delta .seconds * 10 ** 6 ) / 1000
244
- tx_pps = int (send_count / (float (time_delta_ms ) / 1000 ))
245
- rx_pps = int (recv_count / (float (time_delta_ms ) / 1000 ))
246
-
247
- return send_count , recv_count , time_delta , time_delta_ms , tx_pps , rx_pps
248
-
249
-
250
181
def contruct_packet (self , port_number ):
251
182
raise NotImplementedError
252
183
@@ -283,22 +214,21 @@ def __init__(self):
283
214
self .needPreSend = False
284
215
285
216
def check_constraints (self , send_count , recv_count , time_delta_ms , rx_pps ):
286
- if not self .is_counter_test :
287
- pkt_rx_limit = send_count * 0.90
217
+ pkt_rx_limit = send_count * 0.90
288
218
289
- self .log ("" )
290
- self .log ("Checking constraints (NoPolicy):" )
291
- self .log (
292
- "rx_pps (%d) > NO_POLICER_LIMIT (%d): %s" %
293
- (int (rx_pps ), int (self .NO_POLICER_LIMIT ), str (rx_pps > self .NO_POLICER_LIMIT ))
294
- )
295
- self .log (
296
- "recv_count (%d) > pkt_rx_limit (%d): %s" %
297
- (int (recv_count ), int (pkt_rx_limit ), str (recv_count > pkt_rx_limit ))
298
- )
219
+ self .log ("" )
220
+ self .log ("Checking constraints (NoPolicy):" )
221
+ self .log (
222
+ "rx_pps (%d) > NO_POLICER_LIMIT (%d): %s" %
223
+ (int (rx_pps ), int (self .NO_POLICER_LIMIT ), str (rx_pps > self .NO_POLICER_LIMIT ))
224
+ )
225
+ self .log (
226
+ "recv_count (%d) > pkt_rx_limit (%d): %s" %
227
+ (int (recv_count ), int (pkt_rx_limit ), str (recv_count > pkt_rx_limit ))
228
+ )
299
229
300
- assert (rx_pps > self .NO_POLICER_LIMIT )
301
- assert (recv_count > pkt_rx_limit )
230
+ assert (rx_pps > self .NO_POLICER_LIMIT )
231
+ assert (recv_count > pkt_rx_limit )
302
232
303
233
304
234
class PolicyTest (ControlPlaneBaseTest ):
@@ -307,18 +237,17 @@ def __init__(self):
307
237
self .needPreSend = True
308
238
309
239
def check_constraints (self , send_count , recv_count , time_delta_ms , rx_pps ):
310
- if not self .is_counter_test :
311
- self .log ("" )
312
- self .log ("Checking constraints (PolicyApplied):" )
313
- self .log (
314
- "PPS_LIMIT_MIN (%d) <= rx_pps (%d) <= PPS_LIMIT_MAX (%d): %s" %
315
- (int (self .PPS_LIMIT_MIN ),
316
- int (rx_pps ),
317
- int (self .PPS_LIMIT_MAX ),
318
- str (self .PPS_LIMIT_MIN <= rx_pps <= self .PPS_LIMIT_MAX ))
319
- )
320
-
321
- assert (self .PPS_LIMIT_MIN <= rx_pps <= self .PPS_LIMIT_MAX )
240
+ self .log ("" )
241
+ self .log ("Checking constraints (PolicyApplied):" )
242
+ self .log (
243
+ "PPS_LIMIT_MIN (%d) <= rx_pps (%d) <= PPS_LIMIT_MAX (%d): %s" %
244
+ (int (self .PPS_LIMIT_MIN ),
245
+ int (rx_pps ),
246
+ int (self .PPS_LIMIT_MAX ),
247
+ str (self .PPS_LIMIT_MIN <= rx_pps <= self .PPS_LIMIT_MAX ))
248
+ )
249
+
250
+ assert (self .PPS_LIMIT_MIN <= rx_pps <= self .PPS_LIMIT_MAX )
322
251
323
252
324
253
# SONIC config contains policer CIR=600 for ARP
0 commit comments