Test fetchInitialOffset retry on ErrOffsetsLoadInProgress
(t *testing.T)
| 519 | |
| 520 | // Test fetchInitialOffset retry on ErrOffsetsLoadInProgress |
| 521 | func 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 |
nothing calls this directly
no test coverage detected