Skip to content

Commit

Permalink
test: backoff and retry on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
fraidev committed Dec 10, 2024
1 parent 0eb0d43 commit 5fca44c
Showing 1 changed file with 58 additions and 9 deletions.
67 changes: 58 additions & 9 deletions tests/auto-offset-management.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ load './bats-helpers/bats-assert/load'
load './bats-helpers/tools_check.bash'

setup_file() {
CDK_BIN=${CDK_BIN:-cdk}
export CDK_BIN
FLUVIO_BIN=${FLUVIO_BIN:-fluvio}
export FLUVIO_BIN
TEST_DIR="$(mktemp -d -t auto-offset-mngt-test.XXXXX)"
export TEST_DIR
}
Expand All @@ -20,7 +24,7 @@ setup() {
./target/debug/tiny-http-server & disown
MOCK_PID=$!

fluvio topic create $TOPIC
$FLUVIO_BIN topic create $TOPIC
}

@test "Read stream from the beginning" {
Expand All @@ -44,10 +48,10 @@ http:
interval: 3s
EOF

echo "RecordOne" | fluvio produce $TOPIC
echo "RecordTwo" | fluvio produce $TOPIC
echo "RecordOne" | $FLUVIO_BIN produce $TOPIC
echo "RecordTwo" | $FLUVIO_BIN produce $TOPIC

cdk deploy -p http-sink start --config $CONFIG_PATH --log-level info
$CDK_BIN deploy -p http-sink start --config $CONFIG_PATH --log-level info

wait_for_line_in_file "monitoring started" $LOG_PATH 30

Expand Down Expand Up @@ -75,23 +79,68 @@ http:
interval: 3s
EOF

cdk deploy -p http-sink start --config $CONFIG_PATH --log-level info
$CDK_BIN deploy -p http-sink start --config $CONFIG_PATH --log-level info

wait_for_line_in_file "monitoring started" $LOG_PATH 30

echo "RecordOne" | fluvio produce $TOPIC
echo "RecordOne" | $FLUVIO_BIN produce $TOPIC
sleep 15
echo "RecordTwo" | fluvio produce $TOPIC
echo "RecordTwo" | $FLUVIO_BIN produce $TOPIC

wait_for_line_in_file "RecordOne" $LOGGER_FILENAME 30
wait_for_line_in_file "RecordTwo" $LOGGER_FILENAME 30

OFFSET=$(fluvio consumer list -O json | jq ".[] | select(.consumer_id == \"$CONNECTOR_NAME\") | .offset")
OFFSET=$($FLUVIO_BIN consumer list -O json | jq ".[] | select(.consumer_id == \"$CONNECTOR_NAME\") | .offset")
assert [ ! -z $OFFSET ]

}

@test "Backoff and retry on failure" {
CONFIG_PATH="$TEST_DIR/$TOPIC.yaml"
cat <<EOF >$CONFIG_PATH
apiVersion: 0.2.0
meta:
version: 0.1.0
name: $CONNECTOR_NAME
type: http-sink
topic:
meta:
name: $TOPIC
consumer:
id: $CONNECTOR_NAME
offset:
strategy: auto
start: beginning
http:
endpoint: http://localhost:8080
interval: 3s
EOF

echo "RecordOne" | $FLUVIO_BIN produce $TOPIC
echo "RecordTwo" | $FLUVIO_BIN produce $TOPIC

$CDK_BIN deploy -p http-sink start --config $CONFIG_PATH --log-level info

wait_for_line_in_file "monitoring started" $LOG_PATH 30

wait_for_line_in_file "RecordOne" $LOGGER_FILENAME 30
wait_for_line_in_file "RecordTwo" $LOGGER_FILENAME 30

kill $MOCK_PID

echo "RecordThree" | $FLUVIO_BIN produce $TOPIC
echo "RecordFour" | $FLUVIO_BIN produce $TOPIC

sleep 20

./target/debug/tiny-http-server & disown
MOCK_PID=$!

wait_for_line_in_file "RecordThree" $LOGGER_FILENAME 30
wait_for_line_in_file "RecordFour" $LOGGER_FILENAME 30
}

teardown() {
cdk deploy shutdown --name $CONNECTOR_NAME
$CDK_BIN deploy shutdown --name $CONNECTOR_NAME
kill $MOCK_PID
}

0 comments on commit 5fca44c

Please sign in to comment.