Skip to content

Commit 64d5bde

Browse files
committed
fix tests
1 parent b2f6e85 commit 64d5bde

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

tests/hb_tracker/hb_tracker_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tx_queue
33
import (
44
"aardappel/internal/hb_tracker"
55
"aardappel/internal/types"
6+
"context"
67
"testing"
78
)
89

@@ -18,8 +19,9 @@ func CreateDummyMap() hb_tracker.TopicPartsCount {
1819
}
1920

2021
func TestNotAllPart(t *testing.T) {
22+
ctx := context.Background()
2123
tracker := hb_tracker.NewHeartBeatTracker(CreateDummyMap())
22-
_ = tracker.AddHb(types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 0}, Step: 0})
24+
_ = tracker.AddHb(ctx, types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 0}, Step: 0})
2325

2426
_, ready := tracker.GetQuorum()
2527
if ready {
@@ -28,6 +30,7 @@ func TestNotAllPart(t *testing.T) {
2830
}
2931

3032
func TestGetLowestHb(t *testing.T) {
33+
ctx := context.Background()
3134
tracker := hb_tracker.NewHeartBeatTracker(CreateDummyMap())
3235
var c1, c2, c3, c4, c5, c6, c7 bool
3336
f1 := func() error { c1 = true; return nil }
@@ -37,15 +40,15 @@ func TestGetLowestHb(t *testing.T) {
3740
f5 := func() error { c5 = true; return nil }
3841
f6 := func() error { c6 = true; return nil }
3942
f7 := func() error { c7 = true; return nil }
40-
_ = tracker.AddHb(types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 0}, Step: 3, CommitTopic: f1})
41-
_ = tracker.AddHb(types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 0}, Step: 5, CommitTopic: f2})
42-
_ = tracker.AddHb(types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 0}, Step: 6, CommitTopic: f3})
43+
_ = tracker.AddHb(ctx, types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 0}, Step: 3, CommitTopic: f1})
44+
_ = tracker.AddHb(ctx, types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 0}, Step: 5, CommitTopic: f2})
45+
_ = tracker.AddHb(ctx, types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 0}, Step: 6, CommitTopic: f3})
4346

44-
_ = tracker.AddHb(types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 1}, Step: 2, CommitTopic: f4})
45-
_ = tracker.AddHb(types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 1}, Step: 7, CommitTopic: f5})
47+
_ = tracker.AddHb(ctx, types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 1}, Step: 2, CommitTopic: f4})
48+
_ = tracker.AddHb(ctx, types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 0, PartitionId: 1}, Step: 7, CommitTopic: f5})
4649

47-
_ = tracker.AddHb(types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 1, PartitionId: 1}, Step: 4, CommitTopic: f6})
48-
_ = tracker.AddHb(types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 1, PartitionId: 0}, Step: 5, CommitTopic: f7})
50+
_ = tracker.AddHb(ctx, types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 1, PartitionId: 1}, Step: 4, CommitTopic: f6})
51+
_ = tracker.AddHb(ctx, types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 1, PartitionId: 0}, Step: 5, CommitTopic: f7})
4952

5053
hb, ready := tracker.GetQuorum()
5154
if !ready {
@@ -65,7 +68,7 @@ func TestGetLowestHb(t *testing.T) {
6568
t.Error("Expect ready status - we haven't add heartbeat for each part")
6669
}
6770

68-
_ = tracker.AddHb(types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 1, PartitionId: 1}, Step: 5})
71+
_ = tracker.AddHb(ctx, types.HbData{StreamId: types.ElementaryStreamId{ReaderId: 1, PartitionId: 1}, Step: 5})
6972

7073
hb, ready = tracker.GetQuorum()
7174
if !ready {

0 commit comments

Comments
 (0)