feat(outbox): relay committed outbox events to Kafka
This commit is contained in:
1 parent
78f1651f6b
commit
6c3b34f73e
42 files changed
+3731
-45
No files matched your search
@@ -251,3 +251,56 @@ func TestLoadFromEnvRejectsKafkaBrokers(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadFromEnvKafkaTopicReplication(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
values map[string]string
|
||||
replication, minInsync int16
|
||||
}{
|
||||
{name: "broker defaults", values: nil, replication: -1, minInsync: 0},
|
||||
{name: "explicit broker default", values: map[string]string{"KAFKA_EVENTS_TOPIC_REPLICATION_FACTOR": "-1"}, replication: -1, minInsync: 0},
|
||||
{name: "production cluster", values: map[string]string{
|
||||
"KAFKA_EVENTS_TOPIC_REPLICATION_FACTOR": "3",
|
||||
"KAFKA_EVENTS_TOPIC_MIN_INSYNC_REPLICAS": " 2 ",
|
||||
}, replication: 3, minInsync: 2},
|
||||
{name: "min ISR with broker default replication", values: map[string]string{"KAFKA_EVENTS_TOPIC_MIN_INSYNC_REPLICAS": "2"}, replication: -1, minInsync: 2},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
settings, err := LoadFromEnv(testEnvironment(test.values))
|
||||
if err != nil {
|
||||
t.Fatalf("LoadFromEnv() error = %v", err)
|
||||
}
|
||||
if settings.KafkaEventsTopicReplicationFactor != test.replication || settings.KafkaEventsTopicMinInsyncReplicas != test.minInsync {
|
||||
t.Fatalf("replication = %d, min ISR = %d; want %d and %d", settings.KafkaEventsTopicReplicationFactor,
|
||||
settings.KafkaEventsTopicMinInsyncReplicas, test.replication, test.minInsync)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadFromEnvRejectsKafkaTopicReplication(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
values map[string]string
|
||||
want string
|
||||
}{
|
||||
{name: "negative replication other than -1", values: map[string]string{"KAFKA_EVENTS_TOPIC_REPLICATION_FACTOR": "-2"}, want: "Config.loadKafkaTopics - KAFKA_EVENTS_TOPIC_REPLICATION_FACTOR"},
|
||||
{name: "empty min ISR", values: map[string]string{"KAFKA_EVENTS_TOPIC_MIN_INSYNC_REPLICAS": ""}, want: "config.intOrDefault - KAFKA_EVENTS_TOPIC_MIN_INSYNC_REPLICAS"},
|
||||
{name: "zero min ISR", values: map[string]string{"KAFKA_EVENTS_TOPIC_MIN_INSYNC_REPLICAS": "0"}, want: "Config.loadKafkaTopics - KAFKA_EVENTS_TOPIC_MIN_INSYNC_REPLICAS"},
|
||||
{name: "min ISR too large", values: map[string]string{"KAFKA_EVENTS_TOPIC_MIN_INSYNC_REPLICAS": "32768"}, want: "Config.loadKafkaTopics - KAFKA_EVENTS_TOPIC_MIN_INSYNC_REPLICAS"},
|
||||
{name: "min ISR above replication", values: map[string]string{
|
||||
"KAFKA_EVENTS_TOPIC_REPLICATION_FACTOR": "2",
|
||||
"KAFKA_EVENTS_TOPIC_MIN_INSYNC_REPLICAS": "3",
|
||||
}, want: "Config.ValidateKafka - KAFKA_EVENTS_TOPIC_MIN_INSYNC_REPLICAS must not exceed"},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
_, err := LoadFromEnv(testEnvironment(test.values))
|
||||
if err == nil || !strings.HasPrefix(err.Error(), test.want) {
|
||||
t.Fatalf("LoadFromEnv() error = %v, want an error starting with %q", err, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user