diff --git a/e2e/topic.go b/e2e/topic.go index 13e70a3..031782d 100644 --- a/e2e/topic.go +++ b/e2e/topic.go @@ -27,14 +27,14 @@ func (s *Service) validateManagementTopic(ctx context.Context) error { return fmt.Errorf("validateManagementTopic cannot get metadata of e2e topic: %w", err) } - topicExists := false - if len(meta.Topics) == 1 { - err := kerr.ErrorForCode(meta.Topics[0].ErrorCode) - if err != nil { - return fmt.Errorf("failed to get metadata for end-to-end topic: %w", err) - } - - topicExists = true + // UnknownTopicOrPartition (Error code 3) means that the topic does not exist. + // If the topic exists, but there's an error, then this should result in a fail + // When the topic doesn't exist, continue to create it + err = kerr.TypedErrorForCode(meta.Topics[0].ErrorCode) + topicExists := err != kerr.UnknownTopicOrPartition + + if err != nil && topicExists { + return fmt.Errorf("failed to get metadata for end-to-end topic: %w", err) } // Create topic if it doesn't exist