Skip to content

Commit 96efc0d

Browse files
committed
More fixes.
1 parent cadad71 commit 96efc0d

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- /go/pkg/mod
5757
- run:
5858
name: Wait for kafka
59-
command: COUNTER=0; nc -Z localhost 9092; until [ $? -eq 0 ] || [ "$COUNTER" -ge 60 ]; do let COUNTER=$COUNTER+1; sleep 1; echo "waiting $COUNTER"; nc -Z localhost 9092; done
59+
command: ./scripts/wait-for-kafka.sh
6060
- run:
6161
name: Test kafka-go
6262
command: go test -race -cover ./...

addoffsetstotxn_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ func TestClientAddOffsetsToTxn(t *testing.T) {
2222
defer shutdown()
2323

2424
err := clientCreateTopic(client, topic, 3)
25+
defer deleteTopic(t, topic)
2526
if err != nil {
2627
t.Fatal(err)
2728
}
2829

2930
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
31+
waitForTopic(ctx, t, topic)
3032
defer cancel()
3133
respc, err := waitForCoordinatorIndefinitely(ctx, client, &FindCoordinatorRequest{
3234
Addr: client.Addr,

reader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func waitForTopic(ctx context.Context, t *testing.T, topic string) {
365365
}
366366

367367
t.Logf("retrying after 1s")
368-
time.Sleep(time.Second)
368+
time.Sleep(100 * time.Second)
369369
continue
370370
}
371371
}

scripts/wait-for-kafka.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#/bin/bash
2+
3+
COUNTER=0;
4+
echo foo | nc localhost 9092
5+
STATUS=$?
6+
ATTEMPTS=60
7+
until [ ${STATUS} -eq 0 ] || [ "$COUNTER" -ge "${ATTEMPTS}" ];
8+
do
9+
let COUNTER=$COUNTER+1;
10+
sleep 1;
11+
echo "[$COUNTER] waiting for 9092 port to be open";
12+
echo foo | nc localhost 9092
13+
STATUS=$?
14+
done
15+
16+
if [ "${COUNTER}" -gt "${ATTEMPTS}" ];
17+
then
18+
echo "Kafka is not running, failing"
19+
exit 1
20+
fi

txnoffsetcommit_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func TestClientTxnOffsetCommit(t *testing.T) {
2121

2222
client, shutdown := newLocalClientWithTopic(topic, 1)
2323
defer shutdown()
24+
waitForTopic(context.TODO(), t, topic)
25+
defer deleteTopic(t, topic)
2426

2527
now := time.Now()
2628

0 commit comments

Comments
 (0)