Skip to content

Commit f86fe12

Browse files
authored
fix: compatibility issues with old versions (#4247)
* test: add cli backward compatibility * fix: compatibility issues with old versions
1 parent 81df54c commit f86fe12

File tree

6 files changed

+101
-8
lines changed

6 files changed

+101
-8
lines changed

.github/workflows/ci.yml

+49
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,55 @@ jobs:
14291429
timeout-minutes: 5
14301430
run: cat /tmp/flv_sc.log
14311431

1432+
cli_backward_compatibility:
1433+
runs-on: ${{ matrix.os }}
1434+
env:
1435+
FLUVIO_BIN: "~/bin/fluvio"
1436+
needs:
1437+
- build_image
1438+
- config
1439+
strategy:
1440+
matrix:
1441+
os: [ubuntu-latest]
1442+
rust-target: [x86_64-unknown-linux-musl]
1443+
steps:
1444+
- uses: actions/checkout@v4
1445+
- name: Setup BATS
1446+
uses: mig4/setup-bats@v1
1447+
with:
1448+
bats-version: ${{ env.BATS_VERSION }}
1449+
1450+
# Download artifacts from development build
1451+
- name: Download artifact - fluvio
1452+
uses: actions/download-artifact@v4
1453+
with:
1454+
name: fluvio-${{ matrix.rust-target }}
1455+
path: ~/bin
1456+
1457+
- name: Download artifact - fluvio-run
1458+
uses: actions/download-artifact@v4
1459+
with:
1460+
name: fluvio-run-${{ matrix.rust-target }}
1461+
path: ~/.fluvio/extensions
1462+
1463+
- name: Set up Fluvio Binaries
1464+
run: |
1465+
chmod +x ~/bin/fluvio ~/.fluvio/extensions/fluvio-run
1466+
echo "~/bin" >> $GITHUB_PATH
1467+
FLUVIO_BIN=~/bin/fluvio
1468+
echo "FLUVIO_BIN=${FLUVIO_BIN}" >> $GITHUB_ENV
1469+
1470+
- name: Print version
1471+
run: fluvio version
1472+
1473+
- name: Run backward compatibility tests
1474+
timeout-minutes: 10
1475+
run: make cli-backward-compatibility-test
1476+
1477+
- name: Print SC logs
1478+
if: ${{ !success() }}
1479+
timeout-minutes: 5
1480+
run: cat /tmp/flv_sc.log
14321481

14331482
# Runs tests on `tests/cli/partition_test`
14341483
partition_test:

crates/fluvio-sc-schema/src/objects/watch.rs

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ where
5656

5757
impl Request for ObjectApiWatchRequest {
5858
const API_KEY: u16 = AdminPublicApiKey::Watch as u16;
59+
const MIN_API_VERSION: i16 = 15;
5960
const DEFAULT_API_VERSION: i16 = COMMON_VERSION;
6061
type Response = ObjectApiWatchResponse;
6162
}

makefiles/test.mk

+3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ longevity-test: build-test
214214
$(TEST_BIN) longevity --expect-timeout -- $(VERBOSE_FLAG) --runtime-seconds=60
215215
endif
216216

217+
cli-backward-compatibility-test:
218+
./tests/cli/cli-backward-compatibility.bash
219+
217220
cli-platform-cross-version-test:
218221
bats -t ./tests/cli/cli-platform-cross-version.bats
219222

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
set -e # Exit immediately if a command exits with a non-zero status
3+
4+
# Set the repository owner and name
5+
OWNER="infinyon"
6+
REPO="fluvio"
7+
8+
# The oldest version we want to test backward compatibility with
9+
BACKWARD_SINCE_VERSION="0.11.10"
10+
11+
# Fetch releases using GitHub API
12+
response=$(curl -s "https://api.github.com/repos/$OWNER/$REPO/releases")
13+
14+
# Check if the response is empty or an error occurred
15+
if [ -z "$response" ]; then
16+
echo "Failed to fetch releases."
17+
exit 1
18+
fi
19+
20+
# Filter only non-prerelease releases
21+
versions=$(echo "$response" | jq -r '.[] | select(.prerelease == false) | .tag_name')
22+
23+
for version in $versions; do
24+
# remove v prefix
25+
version=$(echo $version | sed 's/v//')
26+
echo "Running tests for version: $version"
27+
28+
# Install current version on the cluster
29+
$FLUVIO_BIN cluster start
30+
# Install old version of the CLI
31+
curl -fsS https://hub.infinyon.cloud/install/install.sh?ctx=ci | VERSION=$version bash
32+
# Run the tests
33+
CLI_VERSION=$version SKIP_SETUP=true CI=false make cli-platform-cross-version-test
34+
35+
# Check if we have reached the version we want to stop at
36+
if [[ $version == $BACKWARD_SINCE_VERSION ]]; then
37+
break
38+
fi
39+
done

tests/cli/cli-platform-cross-version.bats

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ setup_file() {
1414

1515
CLI_VERSION="${CLI_VERSION:-latest}"
1616
export CLI_VERSION
17+
18+
FLUVIO_CLIENT_BIN="${FLUVIO_CLIENT_BIN:-$HOME/.fvm/versions/$CLI_VERSION/fluvio}"
19+
export FLUVIO_CLIENT_BIN
1720

1821
PAYLOAD_SIZE="${PAYLOAD_SIZE:-100}"
1922
export PAYLOAD_SIZE
@@ -34,7 +37,7 @@ setup_file() {
3437
if [[ -z "$CI" ]];
3538
then
3639
echo "# Deleting cluster" >&3
37-
"$FLUVIO_BIN" cluster delete --force"
40+
"$FLUVIO_BIN" cluster delete --force
3841
else
3942
echo "# [CI MODE] Skipping initial cleanup" >&3
4043
fi;
@@ -57,32 +60,30 @@ teardown_file() {
5760
if [[ -z "$SKIP_CLEANUP" ]];
5861
then
5962
echo "# Deleting cluster" >&3
60-
"$FLUVIO_BIN" cluster delete --force"
63+
"$FLUVIO_BIN" cluster delete --force
6164
else
6265
echo "# Skipping cleanup" >&3
6366
fi
64-
65-
#run timeout 15s "$FLUVIO_BIN" topic delete "$TOPIC_NAME"
6667
}
6768

6869
# Create topic
6970
@test "Create a topic: $TOPIC_NAME" {
7071
debug_msg "topic: $TOPIC_NAME"
71-
run timeout 15s "$FLUVIO_BIN" topic create "$TOPIC_NAME"
72+
run timeout 15s "$FLUVIO_CLIENT_BIN" topic create "$TOPIC_NAME"
7273
assert_success
7374
}
7475

7576
# Produce message
7677
@test "Produce message" {
77-
run bash -c 'echo "$MESSAGE" | timeout 15s "$FLUVIO_BIN" produce "$TOPIC_NAME"'
78+
run bash -c 'echo "$MESSAGE" | timeout 15s "$FLUVIO_CLIENT_BIN" produce "$TOPIC_NAME"'
7879

7980
assert_success
8081
}
8182

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

8788
assert_output --partial "$MESSAGE"
8889
assert_success

tests/cli/test_helper/fluvio_dev.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,5 @@ function setup_fluvio_cli() {
7474
CLI_VERSION=${1:-latest}
7575
echo "Installing CLI @ VERSION: $CLI_VERSION" >&3
7676
curl -fsS https://hub.infinyon.cloud/install/install.sh?ctx=ci | VERSION=$CLI_VERSION bash
77-
$FLUVIO_BIN version >&3
77+
$HOME/.fvm/versions/$CLI_VERSION/fluvio version >&3
7878
}

0 commit comments

Comments
 (0)