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 c67bc95
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 61 deletions.
110 changes: 57 additions & 53 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,60 @@ jobs:
timeout-minutes: 5
run: cat /tmp/flv_sc.log

mirroring_smoke_test:
runs-on: ubuntu-latest
needs:
- build_primary_binaries
- config
strategy:
matrix:
run-mode: [local, local-k8]
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-x86_64-unknown-linux-musl
path: ~/bin
- name: Download artifact - fluvio-run
uses: actions/download-artifact@v4
with:
name: fluvio-run-x86_64-unknown-linux-musl
path: ~/extensions

- name: Setup K8s Cluster
if: matrix.run-mode == 'local-k8'
run: |
curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | TAG=${{ env.K3D_VERSION }} bash
./k8-util/cluster/reset-k3d.sh
- name: Wait 15s for K3D Reset
if: matrix.run-mode == 'local-k8'
run: sleep 15

- run: |
chmod +x ~/bin/fluvio
chmod +x ~/extensions/fluvio-run
mkdir -p ~/.fluvio/bin
mkdir -p ~/.fluvio/extensions
mv ~/bin/fluvio ~/.fluvio/bin/fluvio
mv ~/extensions/fluvio-run ~/.fluvio/extensions/fluvio-run
echo "~/.fluvio/bin" >> $GITHUB_PATH
- name: Start cluster
run: fluvio cluster start --${{ matrix.run-mode }}
- name: Run Fluvio mirroring tests
run: make FLUVIO_BIN=~/.fluvio/bin/fluvio cli-fluvio-mirroring-smoke

- name: Print SC logs
if: ${{ !success() }}
timeout-minutes: 5
run: cat /tmp/flv_sc.log
mirroring_smoke_test:
runs-on: ubuntu-latest
needs:
Expand Down Expand Up @@ -1323,15 +1377,8 @@ jobs:
timeout-minutes: 5
run: cat /tmp/flv_sc.log

mirroring_smoke_test_e2e:
cli_backward_compatibility:
runs-on: ${{ matrix.os }}
env:
REMOTE_2_SC_PUB_ADDR: "127.0.0.1:9103"
REMOTE_2_SC_PRIV_ADDR: "0.0.0.0:9104"
REMOTE_2_SPU_ID: 6001
REMOTE_2_SPU_PUB_ADDR: "0.0.0.0:9020"
REMOTE_2_SPU_PRIV_ADDR: "0.0.0.0:9021"
REMOTE_2_BASE_DIR: "~/.fluvio_2"
needs:
- build_image
- config
Expand Down Expand Up @@ -1362,12 +1409,6 @@ jobs:
with:
name: fluvio-test-${{ matrix.rust-target }}
path: ~/extensions
- name: Download Docker Image as Artifact
uses: actions/download-artifact@v4
with:
name: infinyon-fluvio-${{ matrix.rust-target }}.tar
path: /tmp

- name: Set up Fluvio binaries
run: |
chmod +x ~/bin/fluvio
Expand All @@ -1383,46 +1424,9 @@ jobs:
- name: Print version
run: fluvio version && fluvio-test -h

- name: Load Fluvio Docker Image
run: |
ls -la /tmp
docker image load --input /tmp/infinyon-fluvio-${{ matrix.rust-target }}.tar
docker image tag infinyon/fluvio:${{ github.sha }}-${{ matrix.rust-target }} infinyon/fluvio:${{ github.sha }}
docker image ls -a
- name: Export Docker Image to tarball
run: docker image save infinyon/fluvio:${{ github.sha }} --output /tmp/infinyon-fluvio.tar
- name: Install K3d
run: |
curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | TAG=${{ env.K3D_VERSION }} bash
./k8-util/cluster/reset-k3d.sh
- name: Load image to K3d
run: |
k3d image import -k /tmp/infinyon-fluvio.tar -c fluvio
- name: Create k8 namespace
run: |
kubectl create ns fluvio-test
- name: Start edge cluster remote 1
timeout-minutes: 10
run: fluvio cluster start --local

- name: Start edge cluster remote 2
timeout-minutes: 10
run: |
fluvio profile add local2 ${REMOTE_2_SC_PUB_ADDR} local
fluvio cluster start --skip-profile-creation --skip-checks --spu 0 --sc-pub-addr ${REMOTE_2_SC_PUB_ADDR} --sc-priv-addr ${REMOTE_2_SC_PRIV_ADDR} --data-dir ${REMOTE_2_BASE_DIR}
fluvio cluster spu register --id ${REMOTE_2_SPU_ID} -p ${REMOTE_2_SPU_PUB_ADDR} -v ${REMOTE_2_SPU_PRIV_ADDR}
fluvio run spu -i ${REMOTE_2_SPU_ID} -p ${REMOTE_2_SPU_PUB_ADDR} -v ${REMOTE_2_SPU_PRIV_ADDR} --sc-addr ${REMOTE_2_SC_PRIV_ADDR} --log-base-dir ${REMOTE_2_BASE_DIR}/data &
- name: Start home cluster in k8
timeout-minutes: 10
run: fluvio cluster start --k8 --develop --namespace fluvio-test --use-k8-port-forwarding

- name: Run Fluvio mirroring tests
- name: Run backward compatibility tests
timeout-minutes: 10
run: make FLUVIO_BIN=~/.fluvio/bin/fluvio cli-fluvio-mirroring-smoke-e2e
run: ./tests/cli/cli-backward-compatibility.bash

- name: Print SC logs
if: ${{ !success() }}
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

# Use jq to 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 c67bc95

Please sign in to comment.