Skip to content

Commit

Permalink
fix: misc changes to fulfill make test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-gang committed Sep 5, 2024
1 parent a24be23 commit 0873dae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
12 changes: 11 additions & 1 deletion internal/stages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package internal

import (
"os"
"regexp"
"testing"

tester_utils_testing "github.com/codecrafters-io/tester-utils/testing"
Expand All @@ -22,7 +23,16 @@ func TestStages(t *testing.T) {

tester_utils_testing.TestTesterOutput(t, testerDefinition, testCases)
}

func normalizeTesterOutput(testerOutput []byte) []byte {
replacements := map[string][]*regexp.Regexp{
"": {regexp.MustCompile(`Failed to connect to broker .*`)},
}

for replacement, regexes := range replacements {
for _, regex := range regexes {
testerOutput = regex.ReplaceAll(testerOutput, []byte(replacement))
}
}

return testerOutput
}
10 changes: 5 additions & 5 deletions internal/test_helpers/pass_all/your_program.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
echo "Starting Kafka using KRaft (Kafka Raft Metadata)"
# For fresh start
# KAFKA_CLUSTER_ID="$(./bin/kafka-storage.sh random-uuid)"
# /kafka/bin/kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c config/kraft/server.properties
/usr/local/kafka/bin/kafka-server-start.sh ./internal/test_helpers/pass_all/kraft.server.properties --override log.dirs=./internal/test_helpers/pass_all/kraft-combined-logs > /dev/null 2>&1
# echo "Starting Kafka using KRaft (Kafka Raft Metadata)"

SCRIPT_DIR=$(dirname "$(realpath "$0")")

/usr/local/kafka/bin/kafka-server-start.sh $SCRIPT_DIR/kraft.server.properties --override log.dirs=$SCRIPT_DIR/kraft-combined-logs > /dev/null 2>&1
3 changes: 2 additions & 1 deletion protocol/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ func (b *Broker) ConnectWithRetries(executable *kafka_executable.KafkaExecutable

// Don't print errors in the first second
if retries > 2 {
logger.Infof("Failed to connect to broker at %s, retrying in 1s", b.addr)
// ToDo: fixtures fail
// logger.Infof("Failed to connect to broker at %s, retrying in 1s", b.addr)
}

retries += 1
Expand Down

0 comments on commit 0873dae

Please sign in to comment.