From 0767d8738732a29d8791ed89442e48d5a8ffbed7 Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Wed, 15 Apr 2026 14:39:00 -0700 Subject: [PATCH] test: add github actions functional tests for posix sidecar option Enough people are making use of sidecar that we need to add a CI test to make sure we have some coverage with this mode. This add a couple small functional test fixes found wtih enabling sidecar tests as well. --- .github/workflows/functional-sidecar.yml | 31 ++++++++++++++++++++++++ Makefile | 7 +++++- runtests.sh | 26 ++++++++++++++++---- tests/integration/concurrency.go | 15 +++++++++--- tests/integration/utils.go | 7 +++--- 5 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/functional-sidecar.yml diff --git a/.github/workflows/functional-sidecar.yml b/.github/workflows/functional-sidecar.yml new file mode 100644 index 00000000..5cf0a896 --- /dev/null +++ b/.github/workflows/functional-sidecar.yml @@ -0,0 +1,31 @@ +name: functional tests (sidecar) +permissions: {} +on: pull_request + +jobs: + build: + name: RunTests + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: 'stable' + id: go + + - name: Get Dependencies + run: | + go mod download + + - name: Build and Run + run: | + make testbin + ./runtests.sh --sidecar + + - name: Coverage Report + run: | + go tool covdata percent -i=/tmp/covdata diff --git a/Makefile b/Makefile index 0250e001..6da6d45f 100644 --- a/Makefile +++ b/Makefile @@ -100,5 +100,10 @@ up-app: # Run the host-style tests in docker containers .PHONY: test-host-style test-host-style: - docker compose -f tests/host-style-tests/docker-compose.yml up --build --abort-on-container-exit --exit-code-from test + @compose_file=tests/host-style-tests/docker-compose.yml; \ + COMPOSE_MENU=false docker compose -f "$$compose_file" down -v --remove-orphans >/dev/null 2>&1 || true; \ + COMPOSE_MENU=false docker compose -f "$$compose_file" up --build --abort-on-container-exit --exit-code-from test; \ + status=$$?; \ + COMPOSE_MENU=false docker compose -f "$$compose_file" down -v --remove-orphans; \ + exit $$status diff --git a/runtests.sh b/runtests.sh index 02cf0a24..f0afff56 100755 --- a/runtests.sh +++ b/runtests.sh @@ -1,5 +1,21 @@ #!/bin/bash +# parse options +USE_SIDECAR=false +for arg in "$@"; do + case "$arg" in + --sidecar) USE_SIDECAR=true ;; + esac +done + +# build sidecar flag for versitygw invocations +SIDECAR_FLAG="" +if $USE_SIDECAR; then + rm -rf /tmp/sidecar + mkdir /tmp/sidecar + SIDECAR_FLAG="--sidecar /tmp/sidecar" +fi + # make temp dirs rm -rf /tmp/gw mkdir /tmp/gw @@ -26,7 +42,7 @@ openssl req -new -x509 -key key.pem -out cert.pem -days 365 -subj "/C=US/ST=Cali ECHO "Running the sdk test over http" # run server in background not versioning-enabled # port: 7070(default) -GOCOVERDIR=/tmp/covdata ./versitygw -a user -s pass --iam-dir /tmp/gw posix /tmp/gw & +GOCOVERDIR=/tmp/covdata ./versitygw -a user -s pass --iam-dir /tmp/gw posix $SIDECAR_FLAG /tmp/gw & GW_PID=$! sleep 1 @@ -63,7 +79,7 @@ ECHO "Running the sdk test over https" # run server in background with TLS certificate # port: 7071(default) -GOCOVERDIR=/tmp/https.covdata ./versitygw --cert "$PWD/cert.pem" --key "$PWD/key.pem" -p :7071 -a user -s pass --iam-dir /tmp/gw posix /tmp/gw & +GOCOVERDIR=/tmp/https.covdata ./versitygw --cert "$PWD/cert.pem" --key "$PWD/key.pem" -p :7071 -a user -s pass --iam-dir /tmp/gw posix $SIDECAR_FLAG /tmp/gw & GW_HTTPS_PID=$! sleep 1 @@ -99,7 +115,7 @@ kill $GW_HTTPS_PID ECHO "Running the sdk test over http against the versioning-enabled gateway" # run server in background versioning-enabled # port: 7072 -GOCOVERDIR=/tmp/versioning.covdata ./versitygw -p :7072 -a user -s pass --iam-dir /tmp/gw posix --versioning-dir /tmp/versioningdir /tmp/gw & +GOCOVERDIR=/tmp/versioning.covdata ./versitygw -p :7072 -a user -s pass --iam-dir /tmp/gw posix $SIDECAR_FLAG --versioning-dir /tmp/versioningdir /tmp/gw & GW_VS_PID=$! # wait a second for server to start up @@ -131,7 +147,7 @@ kill $GW_VS_PID ECHO "Running the sdk test over https against the versioning-enabled gateway" # run server in background versioning-enabled # port: 7073 -GOCOVERDIR=/tmp/versioning.https.covdata ./versitygw --cert "$PWD/cert.pem" --key "$PWD/key.pem" -p :7073 -a user -s pass --iam-dir /tmp/gw posix --versioning-dir /tmp/versioningdir /tmp/gw & +GOCOVERDIR=/tmp/versioning.https.covdata ./versitygw --cert "$PWD/cert.pem" --key "$PWD/key.pem" -p :7073 -a user -s pass --iam-dir /tmp/gw posix $SIDECAR_FLAG --versioning-dir /tmp/versioningdir /tmp/gw & GW_VS_HTTPS_PID=$! # wait a second for server to start up @@ -163,7 +179,7 @@ kill $GW_VS_HTTPS_PID ECHO "Running No ACL integration tests" # run server in background versioning-enabled # port: 7073 -GOCOVERDIR=/tmp/noacl.covdata ./versitygw -p :7074 -a user -s pass -noacl --iam-dir /tmp/gw posix /tmp/gw & +GOCOVERDIR=/tmp/noacl.covdata ./versitygw -p :7074 -a user -s pass -noacl --iam-dir /tmp/gw posix $SIDECAR_FLAG /tmp/gw & GW_NO_ACL_PID=$! # wait a second for server to start up diff --git a/tests/integration/concurrency.go b/tests/integration/concurrency.go index f9b0f5f3..9e6c5d7c 100644 --- a/tests/integration/concurrency.go +++ b/tests/integration/concurrency.go @@ -37,8 +37,12 @@ func NewTestState(ctx context.Context, conf *S3Conf, parallel bool) *TestState { parallel: parallel, } - // Start background test processor (only used in parallel mode) - go ts.process() + // Start background test processor (only used in parallel mode). + // Track it in the WaitGroup so Wait() doesn't return until process() + // has drained mainCh and all launched goroutines have finished. + ts.wg.Go(func() { + ts.process() + }) return ts } @@ -99,9 +103,12 @@ func (ct *TestState) process() { // Wait blocks until all queued parallel tests complete, then runs all // synchronous tests. It also ensures proper cleanup of the test channel. func (ct *TestState) Wait() { - // Wait for all parallel tests to finish - ct.wg.Wait() + // Close the channel first so process() drains remaining items and exits. + // This must happen before wg.Wait() to avoid a race where wg.Wait() + // returns while process() still has buffered tests yet to start. close(ct.mainCh) + // Wait for process() goroutine and all test goroutines to finish. + ct.wg.Wait() // Run all synchronous tests sequentially for _, fn := range ct.syncTests { diff --git a/tests/integration/utils.go b/tests/integration/utils.go index dd992453..f30d847b 100644 --- a/tests/integration/utils.go +++ b/tests/integration/utils.go @@ -127,9 +127,10 @@ func teardown(s *S3Conf, bucket string) error { for attempts < maxRetryAttempts { ctx, cancel := context.WithTimeout(context.Background(), shortTimeout) _, err = s3client.DeleteObject(ctx, &s3.DeleteObjectInput{ - Bucket: bucket, - Key: key, - VersionId: versionId, + Bucket: bucket, + Key: key, + VersionId: versionId, + BypassGovernanceRetention: aws.Bool(true), }) cancel() if err == nil {