MCPcopy Create free account
hub / github.com/IBM/sarama / TestOffsetManagerFetchInitialLoadInProgress

Function TestOffsetManagerFetchInitialLoadInProgress

offset_manager_test.go:521–561  ·  view source on GitHub ↗

Test fetchInitialOffset retry on ErrOffsetsLoadInProgress

(t *testing.T)

Source from the content-addressed store, hash-verified

519
520// Test fetchInitialOffset retry on ErrOffsetsLoadInProgress
521func TestOffsetManagerFetchInitialLoadInProgress(t *testing.T) {
522 var retryCount atomic.Int32
523 backoff := func(retries, maxRetries int) time.Duration {
524 retryCount.Add(1)
525 return 0
526 }
527 om, testClient, broker, coordinator := initOffsetManagerWithBackoffFunc(t, 0, backoff, NewTestConfig())
528 defer broker.Close()
529 defer coordinator.Close()
530
531 // Error on first fetchInitialOffset call
532 responseBlock := OffsetFetchResponseBlock{
533 Err: ErrOffsetsLoadInProgress,
534 Offset: 5,
535 Metadata: "test_meta",
536 }
537
538 fetchResponse := new(OffsetFetchResponse)
539 fetchResponse.AddBlock("my_topic", 0, &responseBlock)
540 coordinator.Returns(fetchResponse)
541
542 // Second fetchInitialOffset call is fine
543 fetchResponse2 := new(OffsetFetchResponse)
544 responseBlock2 := responseBlock
545 responseBlock2.Err = ErrNoError
546 fetchResponse2.AddBlock("my_topic", 0, &responseBlock2)
547 coordinator.Returns(fetchResponse2)
548
549 pom, err := om.ManagePartition("my_topic", 0)
550 if err != nil {
551 t.Error(err)
552 }
553
554 safeClose(t, pom)
555 safeClose(t, om)
556 safeClose(t, testClient)
557
558 if retryCount.Load() == 0 {
559 t.Fatal("Expected at least one retry")
560 }
561}
562
563// fetchInitialOffset must retry when OffsetFetchResponse v2+ surfaces a
564// retriable coordinator error at the top level with no per-partition blocks

Callers

nothing calls this directly

Calls 10

ReturnsMethod · 0.80
FatalMethod · 0.80
NewTestConfigFunction · 0.70
safeCloseFunction · 0.70
CloseMethod · 0.65
ManagePartitionMethod · 0.65
ErrorMethod · 0.65
AddMethod · 0.45
AddBlockMethod · 0.45

Tested by

no test coverage detected