fix kafka message persistence completion
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/segmentio/kafka-go"
|
||||
"github.com/tinode/chat/server/store"
|
||||
"github.com/tinode/chat/server/store/types"
|
||||
)
|
||||
|
||||
@@ -253,3 +254,30 @@ func TestRunKafkaMessageSingleRetriesStopsOnSuccess(t *testing.T) {
|
||||
t.Fatalf("calls operation=%d failed=%d, want 3/2", operationCalls, markFailedCalls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFinishKafkaMessagePersistTreatsMissingConsumeStateAsSucceeded(t *testing.T) {
|
||||
oldInfrastructure := store.HTTPInfrastructure
|
||||
oldKafkaBus := kafkaBus
|
||||
defer func() {
|
||||
store.HTTPInfrastructure = oldInfrastructure
|
||||
kafkaBus = oldKafkaBus
|
||||
}()
|
||||
|
||||
store.HTTPInfrastructure = &testHTTPInfrastructureStore{markSucceededErr: types.ErrNotFound}
|
||||
kafkaBus = &kafkaRuntime{config: kafkaConfig{ConsumerGroup: "test-consumer"}}
|
||||
|
||||
err := finishKafkaMessagePersist(context.Background(), &kafkaMessagePersistItem{
|
||||
envelope: kafkaEnvelope{EventID: "msg.persist.8.p2pA.1"},
|
||||
tenantID: types.TenantID(8),
|
||||
payload: kafkaMessagePersistPayload{
|
||||
MessageKind: "p2p",
|
||||
Message: types.Message{
|
||||
Topic: "p2pA",
|
||||
SeqId: 1,
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("finishKafkaMessagePersist() error = %v, want nil", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user