Skip to content

Commit

Permalink
test: add cli backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fraidev committed Nov 8, 2024
1 parent 81df54c commit 823094e
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 8 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,61 @@ jobs:
timeout-minutes: 5
run: cat /tmp/flv_sc.log

cli_backward_compatibility:
runs-on: ${{ matrix.os }}
needs:
- build_image
- config
strategy:
matrix:
os: [ubuntu-latest]
rust-target: [x86_64-unknown-linux-musl]
steps:
- uses: actions/checkout@v4
- name: Setup BATS
uses: mig4/setup-bats@v1
with:
bats-version: ${{ env.BATS_VERSION }}

# Download artifacts from development build
- name: Download artifact - fluvio
uses: actions/download-artifact@v4
with:
name: fluvio-${{ matrix.rust-target }}
path: ~/bin
- name: Download artifact - fluvio-run
uses: actions/download-artifact@v4
with:
name: fluvio-run-${{ matrix.rust-target }}
path: ~/extensions
- name: Download artifact - fluvio-test
uses: actions/download-artifact@v4
with:
name: fluvio-test-${{ matrix.rust-target }}
path: ~/extensions
- name: Set up Fluvio binaries
run: |
chmod +x ~/bin/fluvio
chmod +x ~/extensions/fluvio-run
chmod +x ~/extensions/fluvio-test
mkdir -p ~/.fluvio/bin
mkdir -p ~/.fluvio/extensions
mv ~/bin/fluvio ~/.fluvio/bin/fluvio
mv ~/extensions/fluvio-run ~/.fluvio/bin/fluvio-run
mv ~/extensions/fluvio-test ~/.fluvio/bin/fluvio-test
echo "~/.fluvio/bin" >> $GITHUB_PATH
- name: Print version
run: fluvio version && fluvio-test -h

- name: Run backward compatibility tests
timeout-minutes: 10
run: make cli-backward-compatibility-test

- name: Print SC logs
if: ${{ !success() }}
timeout-minutes: 5
run: cat /tmp/flv_sc.log

# Runs tests on `tests/cli/partition_test`
partition_test:
Expand Down
1 change: 1 addition & 0 deletions crates/fluvio-sc-schema/src/objects/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ where

impl Request for ObjectApiWatchRequest {
const API_KEY: u16 = AdminPublicApiKey::Watch as u16;
const MIN_API_VERSION: i16 = 15;
const DEFAULT_API_VERSION: i16 = COMMON_VERSION;
type Response = ObjectApiWatchResponse;
}
Expand Down
3 changes: 3 additions & 0 deletions makefiles/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ longevity-test: build-test
$(TEST_BIN) longevity --expect-timeout -- $(VERBOSE_FLAG) --runtime-seconds=60
endif

cli-backward-compatibility-test:
./tests/cli/cli-backward-compatibility.bash

cli-platform-cross-version-test:
bats -t ./tests/cli/cli-platform-cross-version.bats

Expand Down
39 changes: 39 additions & 0 deletions tests/cli/cli-backward-compatibility.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# Set the repository owner and name
OWNER="infinyon"
REPO="fluvio"

BACKWARD_SINCE_VERSION="0.11.10"

# Fetch releases using GitHub API
response=$(curl -s "https://api.github.com/repos/$OWNER/$REPO/releases")

# Check if the response is empty or an error occurred
if [ -z "$response" ]; then
echo "Failed to fetch releases."
exit 1
fi

# Filter only non-prerelease releases
versions=$(echo "$response" | jq -r '.[] | select(.prerelease == false) | .tag_name')

$FLUVIO_BIN cluster delete --force

for version in $versions; do
# remove v prefix
version=$(echo $version | sed 's/v//')
echo "Running tests for version: $version"

# Install current version on the cluster
$FLUVIO_BIN cluster start
# Install old version of the CLI
curl -fsS https://hub.infinyon.cloud/install/install.sh?ctx=ci | VERSION=$version bash
# Run the tests
CLI_VERSION=$version SKIP_SETUP=true CI=false bats cli-platform-cross-version.bats
$HOME/.fvm/versions/$CLI_VERSION/fluvio version >&3


if [[ $version == $BACKWARD_SINCE_VERSION ]]; then
break
fi
done
15 changes: 8 additions & 7 deletions tests/cli/cli-platform-cross-version.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ setup_file() {

CLI_VERSION="${CLI_VERSION:-latest}"
export CLI_VERSION

FLUVIO_CLIENT_BIN="${FLUVIO_CLIENT_BIN:-$HOME/.fvm/versions/$CLI_VERSION/fluvio}"
export FLUVIO_CLIENT_BIN

PAYLOAD_SIZE="${PAYLOAD_SIZE:-100}"
export PAYLOAD_SIZE
Expand All @@ -34,7 +37,7 @@ setup_file() {
if [[ -z "$CI" ]];
then
echo "# Deleting cluster" >&3
"$FLUVIO_BIN" cluster delete --force"
"$FLUVIO_BIN" cluster delete --force
else
echo "# [CI MODE] Skipping initial cleanup" >&3
fi;
Expand All @@ -57,32 +60,30 @@ teardown_file() {
if [[ -z "$SKIP_CLEANUP" ]];
then
echo "# Deleting cluster" >&3
"$FLUVIO_BIN" cluster delete --force"
"$FLUVIO_BIN" cluster delete --force
else
echo "# Skipping cleanup" >&3
fi

#run timeout 15s "$FLUVIO_BIN" topic delete "$TOPIC_NAME"
}

# Create topic
@test "Create a topic: $TOPIC_NAME" {
debug_msg "topic: $TOPIC_NAME"
run timeout 15s "$FLUVIO_BIN" topic create "$TOPIC_NAME"
run timeout 15s "$FLUVIO_CLIENT_BIN" topic create "$TOPIC_NAME"
assert_success
}

# Produce message
@test "Produce message" {
run bash -c 'echo "$MESSAGE" | timeout 15s "$FLUVIO_BIN" produce "$TOPIC_NAME"'
run bash -c 'echo "$MESSAGE" | timeout 15s "$FLUVIO_CLIENT_BIN" produce "$TOPIC_NAME"'

assert_success
}

# Consume message and compare message
# Warning: Adding anything extra to the `debug_msg` skews the message comparison
@test "Consume message" {
run timeout 15s "$FLUVIO_BIN" consume "$TOPIC_NAME" -B -d
run timeout 15s "$FLUVIO_CLIENT_BIN" consume "$TOPIC_NAME" -B -d

assert_output --partial "$MESSAGE"
assert_success
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_helper/fluvio_dev.bash
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ function setup_fluvio_cli() {
CLI_VERSION=${1:-latest}
echo "Installing CLI @ VERSION: $CLI_VERSION" >&3
curl -fsS https://hub.infinyon.cloud/install/install.sh?ctx=ci | VERSION=$CLI_VERSION bash
$FLUVIO_BIN version >&3
$HOME/.fvm/versions/$CLI_VERSION/fluvio version >&3
}

0 comments on commit 823094e

Please sign in to comment.