mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
orchestrator/kafka: force metadata refresh during tests
New versions of kadm cache metadata by default. Ask a refresh to avoid that.
This commit is contained in:
@@ -144,6 +144,7 @@ func TestTopicMorePartitions(t *testing.T) {
|
||||
|
||||
deadline := time.Now().Add(1 * time.Second)
|
||||
for {
|
||||
client.ForceMetadataRefresh()
|
||||
topics, err := adminClient.ListTopics(t.Context())
|
||||
if err != nil {
|
||||
t.Fatalf("ListTopics() error:\n%+v", err)
|
||||
@@ -177,11 +178,15 @@ func TestTopicMorePartitions(t *testing.T) {
|
||||
|
||||
deadline = time.Now().Add(1 * time.Second)
|
||||
for {
|
||||
client.ForceMetadataRefresh()
|
||||
topics, err := adminClient.ListTopics(t.Context())
|
||||
if err != nil {
|
||||
t.Fatalf("ListTopics() error:\n%+v", err)
|
||||
}
|
||||
topic := topics[expectedTopicName]
|
||||
topic, ok := topics[expectedTopicName]
|
||||
if !ok {
|
||||
t.Fatal("ListTopics() did not find the topic")
|
||||
}
|
||||
t.Logf("Topic configuration:\n%+v", topic)
|
||||
if len(topic.Partitions) != 4 || topic.Partitions.NumReplicas() != 1 {
|
||||
if time.Now().Before(deadline) {
|
||||
|
||||
@@ -82,6 +82,7 @@ func (c *Component) Start() error {
|
||||
return fmt.Errorf("unable to create topic %q: %w", c.kafkaTopic, err)
|
||||
}
|
||||
l.Info().Msg("topic created")
|
||||
client.ForceMetadataRefresh()
|
||||
} else {
|
||||
nbPartitions := len(topic.Partitions)
|
||||
if nbPartitions > int(c.config.TopicConfiguration.NumPartitions) {
|
||||
@@ -95,6 +96,7 @@ func (c *Component) Start() error {
|
||||
c.kafkaTopic, err)
|
||||
}
|
||||
l.Info().Msg("number of partitions increased")
|
||||
client.ForceMetadataRefresh()
|
||||
}
|
||||
if int(c.config.TopicConfiguration.ReplicationFactor) != topic.Partitions.NumReplicas() {
|
||||
// TODO: https://github.com/deviceinsight/kafkactl/blob/main/internal/topic/topic-operation.go
|
||||
@@ -136,6 +138,7 @@ func (c *Component) Start() error {
|
||||
c.kafkaTopic, err)
|
||||
}
|
||||
l.Info().Msg("topic updated")
|
||||
client.ForceMetadataRefresh()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user