diff --git a/.gitignore b/.gitignore index d052c761..d3b918f8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,7 @@ bazel-* tmp launchSettings.json .cr/ +/gapic-showcase +/gapic-showcase.exe +/showcase.pid +/showcase.log diff --git a/runintegrationtests.sh b/runintegrationtests.sh new file mode 100755 index 00000000..1f903eb4 --- /dev/null +++ b/runintegrationtests.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# This script: +# - Builds the Generator solution in Release mode +# - Starts GAPIC Showcase +# - Runs integration tests for the Generator projects in Release mode +# - Tears down GAPIC Showcase on exit + +set -e + +cd "$(dirname "$0")" + +export DOTNET_NOLOGO=true + +CONFIG=Release +DOTNET_BUILD_ARGS="-c $CONFIG" +DOTNET_TEST_ARGS="--no-build $DOTNET_BUILD_ARGS" + +echo "Building the solution in $CONFIG mode" +dotnet build $DOTNET_BUILD_ARGS Generator.sln + +cleanup() { + echo "Tearing down GAPIC Showcase" + if [ -f showcase.pid ]; then + kill "$(cat showcase.pid)" 2>/dev/null || true + rm -f showcase.pid + fi + rm -f gapic-showcase gapic-showcase.exe +} +trap cleanup EXIT + +echo "Setup GAPIC Showcase for standard integration tests" +./startshowcase.sh --port :7469 + +export SHOWCASE_ENDPOINT=http://localhost:7469 +dotnet test $DOTNET_TEST_ARGS Google.Api.Generator.IntegrationTests + +echo "Setup GAPIC Showcase with TLS for PQC integration tests" +./startshowcase.sh --port :7469 --tls + +export SHOWCASE_ENDPOINT=https://localhost:7469 +dotnet test $DOTNET_TEST_ARGS Google.Api.Generator.IntegrationTests --filter "FullyQualifiedName~Pqc" + +echo "Integration testing completed" diff --git a/startshowcase.sh b/startshowcase.sh new file mode 100755 index 00000000..79fccae7 --- /dev/null +++ b/startshowcase.sh @@ -0,0 +1,52 @@ +#!/bin/bash +set -eo pipefail + +cd "$(dirname "$0")" + +if [[ "$OSTYPE" == "linux-gnu"* ]]; then OS="linux"; elif [[ "$OSTYPE" == "darwin"* ]]; then OS="darwin"; else OS="windows"; fi + +ARCH="amd64" +if [[ "$OS" == "darwin" && $(uname -m) == "arm64" ]]; then + ARCH="arm64" +fi + +# Clean up any previously running instance +if [ -f showcase.pid ]; then + kill "$(cat showcase.pid)" 2>/dev/null || true + rm -f showcase.pid +fi +pkill -f "gapic-showcase run" 2>/dev/null || true +sleep 1 + +if [ ! -f gapic-showcase ] && [ ! -f gapic-showcase.exe ]; then + echo "Resolving the latest GAPIC Showcase version for $OS-$ARCH..." + SHOWCASE_VERSION=$(curl -s https://api.github.com/repos/googleapis/gapic-showcase/releases/latest | sed -n 's/.*"tag_name": "v\([^"]*\)".*/\1/p' || true) + if [[ -z "$SHOWCASE_VERSION" ]]; then + # Fallback to known stable version if GitHub API rate limit is exceeded + SHOWCASE_VERSION="0.43.0" + echo "Warning: Failed to resolve latest GAPIC Showcase version from GitHub; falling back to v${SHOWCASE_VERSION}." >&2 + fi + + echo "Downloading gapic-showcase-${SHOWCASE_VERSION}-${OS}-${ARCH}..." + curl -sSL -f https://github.com/googleapis/gapic-showcase/releases/download/v${SHOWCASE_VERSION}/gapic-showcase-${SHOWCASE_VERSION}-${OS}-${ARCH}.tar.gz | tar -zx +fi + +if [ $# -eq 0 ]; then + set -- --port :7469 +fi + +if [[ "$OS" == "windows" ]]; then + ./gapic-showcase.exe run "$@" > showcase.log 2>&1 & +else + ./gapic-showcase run "$@" > showcase.log 2>&1 & +fi + +# Write the PID to a file so the caller can easily tear it down +echo $! > showcase.pid +echo "Showcase started with PID $!" +sleep 2 +if ! kill -0 "$!" 2>/dev/null; then + echo "gapic-showcase failed to start. Please check showcase.log for details." >&2 + cat showcase.log >&2 || true + exit 1 +fi