|
| 1 | +#!/bin/bash |
| 2 | +# Runs the conformance tests locally from https://github.com/GoogleCloudPlatform/functions-framework-conformance |
| 3 | +# |
| 4 | +# Servers may fail to shutdown between tests on error, leaving port 8080 bound. |
| 5 | +# You can see what's running on port 8080 by running `lsof -i :8080`. You can |
| 6 | +# run `kill -9 <PID>` to terminate a process. |
| 7 | +# |
| 8 | +# USAGE: |
| 9 | +# ./run_conformance_tests.sh [client_version] |
| 10 | +# |
| 11 | +# client_version (optional): |
| 12 | +# The version of the conformance tests client to use, formatted as "vX.X.X". |
| 13 | +# Defaults to the latest version of the repo, which may be ahead of the |
| 14 | +# latest release. |
| 15 | + |
| 16 | +CLIENT_VERSION=$1 |
| 17 | +if [ $CLIENT_VERSION ]; then |
| 18 | + CLIENT_VERSION="@$CLIENT_VERSION" |
| 19 | +else |
| 20 | + echo "Defaulting to latest client." |
| 21 | + echo "Use './run_conformance_tests vX.X.X' to specify a specific release version." |
| 22 | + CLIENT_VERSION="@latest" |
| 23 | +fi |
| 24 | + |
| 25 | +function print_header() { |
| 26 | + echo |
| 27 | + echo "========== $1 ==========" |
| 28 | +} |
| 29 | + |
| 30 | +# Fail if any command fails |
| 31 | +set -e |
| 32 | + |
| 33 | +# Navigate to the conformance tests and install the local FF. |
| 34 | +cd test/conformance; |
| 35 | +npm i; |
| 36 | + |
| 37 | +print_header "INSTALLING CLIENT$CLIENT_VERSION" |
| 38 | +echo "Note: only works with Go 1.16+ by default, see run_conformance_tests.sh for more information." |
| 39 | +# Go install @version only works on go 1.16+, if using a lower Go version |
| 40 | +# replace command with: |
| 41 | +# go get github.com/GoogleCloudPlatform/functions-framework-conformance/client$CLIENT_VERSION && go install github.com/GoogleCloudPlatform/functions-framework-conformance/client |
| 42 | +go install github.com/GoogleCloudPlatform/functions-framework-conformance/client$CLIENT_VERSION |
| 43 | +echo "Done installing client$CLIENT_VERSION" |
| 44 | + |
| 45 | +print_header "HTTP CONFORMANCE TESTS" |
| 46 | +client -buildpacks=false -type=http -cmd='npm start -- --target=writeHttp --signature-type=http' -start-delay 5 -validate-mapping=true |
| 47 | + |
| 48 | +print_header "BACKGROUND EVENT CONFORMANCE TESTS" |
| 49 | +client -buildpacks=false -type=legacyevent -cmd='npm start -- --target=writeLegacyEvent --signature-type=event' -start-delay 5 -validate-mapping=true |
| 50 | + |
| 51 | +print_header "CLOUDEVENT CONFORMANCE TESTS" |
| 52 | +client -buildpacks=false -type=cloudevent -cmd='npm start -- --target=writeCloudEvent --signature-type=cloudevent' -start-delay 5 -validate-mapping=true |
| 53 | + |
| 54 | +print_header "DECLARATIVE HTTP CONFORMANCE TESTS" |
| 55 | +client -buildpacks=false -cmd='npm start -- --target=writeHttpDeclarative' -start-delay 5 -validate-mapping=true |
| 56 | + |
| 57 | +print_header "DECLARATIVE CLOUDEVENT CONFORMANCE TESTS" |
| 58 | +client -buildpacks=false -type=cloudevent -cmd='npm start -- --target=writeCloudEventDeclarative' -start-delay 5 -validate-mapping=true |
0 commit comments