MCPcopy Create free account
hub / github.com/FDio/vpp / test_ring_buffer_sequence_consistency

Method test_ring_buffer_sequence_consistency

test/test_ring_buffer.py:321–343  ·  view source on GitHub ↗

Test sequence number consistency across reads

(self)

Source from the content-addressed store, hash-verified

319 assert isinstance(data, list), "Thread 0 should return list"
320
321 def test_ring_buffer_sequence_consistency(self):
322 """Test sequence number consistency across reads"""
323 ring_name = "/test/ring_buffer_seq"
324
325 # Step 1: Create ring buffer
326 cli_cmd = (
327 f"test stats ring-buffer-gen {ring_name} 10 {INTERVAL_USEC} {RING_SIZE}"
328 )
329 result = self.vapi.cli(cli_cmd)
330 assert "Generated" in result, f"CLI failed: {result}"
331
332 # Step 2: Get ring buffer
333 ring_buffer = self.statistics.get_ring_buffer(f"{ring_name}")
334
335 # Step 3: Read metadata multiple times to check consistency
336 metadata1 = ring_buffer._get_thread_metadata(0)
337 time.sleep(0.01) # Small delay
338 metadata2 = ring_buffer._get_thread_metadata(0)
339
340 # Sequence numbers should be consistent (same or increasing)
341 assert (
342 metadata2["sequence"] >= metadata1["sequence"]
343 ), "Sequence should be monotonically increasing"
344
345 def test_ring_buffer_polling_with_callback(self):
346 """Test ring buffer polling with callback function"""

Callers

nothing calls this directly

Calls 4

get_ring_bufferMethod · 0.80
_get_thread_metadataMethod · 0.80
cliMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected