Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compatibility issues with old versions #4247

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,55 @@ jobs:
timeout-minutes: 5
run: cat /tmp/flv_sc.log

cli_backward_compatibility:
runs-on: ${{ matrix.os }}
env:
FLUVIO_BIN: "~/bin/fluvio"
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: ~/.fluvio/extensions

- name: Set up Fluvio Binaries
run: |
chmod +x ~/bin/fluvio ~/.fluvio/extensions/fluvio-run
echo "~/bin" >> $GITHUB_PATH
FLUVIO_BIN=~/bin/fluvio
echo "FLUVIO_BIN=${FLUVIO_BIN}" >> $GITHUB_ENV

- name: Print version
run: fluvio version

- 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 -e # Exit immediately if a command exits with a non-zero status

# Set the repository owner and name
OWNER="infinyon"
REPO="fluvio"

# The oldest version we want to test backward compatibility with
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')

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 make cli-platform-cross-version-test

# Check if we have reached the version we want to stop at
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
}
Loading