Skip to content

Commit

Permalink
datasync: Robust kafkat_test
Browse files Browse the repository at this point in the history
  • Loading branch information
blukat29 committed May 13, 2024
1 parent e76faae commit 8a1748f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions datasync/chaindatafetcher/kafka/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,15 @@ func (s *KafkaSuite) TestKafka_CreateAndDeleteTopic() {
// deleted a topic successfully
s.Nil(s.kfk.DeleteTopic(s.topic))

topics, err := s.kfk.ListTopics()
if _, exist := topics[s.topic]; exist {
s.Fail("topic must not exist")
for i := 0; i < 10; i++ {
topics, err := s.kfk.ListTopics()
s.NoError(err)
if _, exist := topics[s.topic]; !exist {
return // success
}
time.Sleep(time.Second)
}
s.Fail("topic must not exist")
}

type kafkaData struct {
Expand Down Expand Up @@ -466,7 +471,7 @@ func (s *KafkaSuite) TestKafka_PubSubWithSegements_BufferOverflow() {
}()

// checkout the returned error is buffer overflow error
timeout := time.NewTimer(3 * time.Second)
timeout := time.NewTimer(5 * time.Second)
select {
case <-timeout.C:
s.Fail("timeout")
Expand Down Expand Up @@ -501,7 +506,7 @@ func (s *KafkaSuite) TestKafka_PubSubWithSegments_ErrCallBack() {
}()

// checkout the returned error is callback error
timeout := time.NewTimer(3 * time.Second)
timeout := time.NewTimer(5 * time.Second)
select {
case <-timeout.C:
s.Fail("timeout")
Expand Down Expand Up @@ -543,7 +548,7 @@ func (s *KafkaSuite) TestKafka_PubSubWithSegments_MessageTimeout() {
}()

// checkout the returned error is callback error
timeout := time.NewTimer(3 * time.Second)
timeout := time.NewTimer(5 * time.Second)
select {
case <-timeout.C:
s.Fail("timeout")
Expand Down Expand Up @@ -580,6 +585,5 @@ func (s *KafkaSuite) TestKafka_Consumer_AddTopicAndHandler_Error() {
}

func TestKafkaSuite(t *testing.T) {
// TODO: revive after CircleCI image fix
// suite.Run(t, new(KafkaSuite))
suite.Run(t, new(KafkaSuite))
}

0 comments on commit 8a1748f

Please sign in to comment.