-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/usr/bin/env bats | ||
|
||
TEST_HELPER_DIR="$BATS_TEST_DIRNAME/../../test_helper" | ||
export TEST_HELPER_DIR | ||
|
||
load "$TEST_HELPER_DIR"/tools_check.bash | ||
load "$TEST_HELPER_DIR"/fluvio_dev.bash | ||
load "$TEST_HELPER_DIR"/bats-support/load.bash | ||
load "$TEST_HELPER_DIR"/bats-assert/load.bash | ||
|
||
setup_file() { | ||
CURRENT_DATE=$(date +%Y-%m) | ||
export CURRENT_DATE | ||
|
||
REMOTE_NAME=user1 | ||
export REMOTE_NAME | ||
debug_msg "Topic name: $REMOTE_NAME" | ||
|
||
MESSAGE="$(random_string 7)" | ||
export MESSAGE | ||
debug_msg "$MESSAGE" | ||
|
||
TOPIC_NAME=mirror-topic | ||
export TOPIC_NAME | ||
debug_msg "Topic name: $TOPIC_NAME" | ||
|
||
REMOTE_PROFILE=local | ||
export REMOTE_PROFILE | ||
debug_msg "Remote profile: $REMOTE_PROFILE" | ||
|
||
HOME_PROFILE=$($FLUVIO_BIN profile) | ||
export HOME_PROFILE | ||
debug_msg "Home profile: $HOME_PROFILE" | ||
} | ||
|
||
@test "Can register an remote cluster" { | ||
run timeout 15s "$FLUVIO_BIN" remote register "$REMOTE_NAME" | ||
|
||
assert_output "remote cluster \"$REMOTE_NAME\" was registered" | ||
assert_success | ||
} | ||
|
||
@test "Export remote" { | ||
run timeout 15s "$FLUVIO_BIN" remote export "$REMOTE_NAME" --file remote.json | ||
assert_output "" | ||
assert_success | ||
|
||
run jq -r .home.id remote.json | ||
assert_output "home" | ||
assert_success | ||
|
||
run jq -r .home.remoteId remote.json | ||
assert_output "$REMOTE_NAME" | ||
assert_success | ||
|
||
run jq -r .home.publicEndpoint remote.json | ||
assert_output --partial ":30003" | ||
assert_success | ||
} | ||
|
||
@test "Can create a mirror topic" { | ||
REMOTE_NAME=user1 echo "[\"$REMOTE_NAME\"]" > remotes.json | ||
run timeout 15s "$FLUVIO_BIN" topic create "$TOPIC_NAME" --mirror-apply remotes.json | ||
|
||
assert_output "topic \"$TOPIC_NAME\" created" | ||
assert_success | ||
} | ||
|
||
|
||
@test "Can switch to remote cluster" { | ||
run timeout 15s "$FLUVIO_BIN" profile switch "$REMOTE_PROFILE" | ||
assert_output "" | ||
assert_success | ||
} | ||
|
||
@test "Can connect to the home cluster" { | ||
run timeout 15s "$FLUVIO_BIN" home connect --file remote.json | ||
|
||
assert_output "connecting with \"home\" cluster" | ||
assert_success | ||
} | ||
|
||
@test "Can produce message to mirror topic" { | ||
sleep 5 | ||
run bash -c 'echo 1 | timeout 15s "$FLUVIO_BIN" produce "$TOPIC_NAME"' | ||
assert_success | ||
run bash -c 'echo a | timeout 15s "$FLUVIO_BIN" produce "$TOPIC_NAME"' | ||
assert_success | ||
run bash -c 'echo 2 | timeout 15s "$FLUVIO_BIN" produce "$TOPIC_NAME"' | ||
assert_success | ||
run bash -c 'echo b | timeout 15s "$FLUVIO_BIN" produce "$TOPIC_NAME"' | ||
assert_success | ||
} | ||
|
||
@test "Can switch back to home cluster" { | ||
run timeout 15s "$FLUVIO_BIN" profile switch "$HOME_PROFILE" | ||
assert_output "" | ||
assert_success | ||
} | ||
|
||
@test "Can consume message from mirror topic" { | ||
sleep 5 | ||
run timeout 15s "$FLUVIO_BIN" consume "$TOPIC_NAME" -B -d | ||
|
||
assert_output 1$'\n'a$'\n'2$'\n'b | ||
assert_success | ||
} | ||
|
File renamed without changes.