Skip to content

Commit 51d6503

Browse files
authored
ci: add run conformance command (GoogleCloudPlatform#124)
Adds command to run conformance tests. - Adds `run_conformance_tests.sh` - Adds detailed docs about setting up Java and contributing to this repo Very similar to the Go setup, with a few minor modifications. <details><summary>FULL LOGS</summary> <p> ``` ./run_conformance_tests.sh Defaulting to v1.2.0 client. Use './run_conformance_tests vX.X.X' to specify a specific release version. ========== INSTALLING CLIENT@v1.2.0 ========== Note: only works with Go 1.16+ by default, see run_conformance_tests.sh for more information. Done installing client@v1.2.0 ========== HTTP CONFORMANCE TESTS ========== 2021/10/26 17:29:46 Validating for http... 2021/10/26 17:29:46 Framework server started. 2021/10/26 17:29:51 HTTP validation started... 2021/10/26 17:29:51 HTTP validation passed! 2021/10/26 17:29:51 Framework server shut down. Wrote logs to /var/folders/27/9q8h1w651z91hycvdf4qf0h0009rgz/T/serverlog_stdout.txt and /var/folders/27/9q8h1w651z91hycvdf4qf0h0009rgz/T/serverlog_stderr.txt. 2021/10/26 17:29:51 All validation passed! ========== BACKGROUND EVENT CONFORMANCE TESTS ========== 2021/10/26 17:29:51 Validating for legacyevent... 2021/10/26 17:29:51 Framework server started. 2021/10/26 17:29:56 Legacy event validation with legacy event requests... 2021/10/26 17:29:56 Events tried: - firebase-auth (PASSED) - firebase-db1 (PASSED) - firebase-db2 (PASSED) - firebase-db3 (PASSED) - firebase-db4 (PASSED) - firebase-db5 (PASSED) - firebase-db6 (PASSED) - firebase-db7 (PASSED) - firebase-db8 (PASSED) - firebase-dbdelete1 (PASSED) - firebase-dbdelete2 (PASSED) - firestore_complex (PASSED) - firestore_simple (PASSED) - legacy_pubsub (PASSED) - pubsub_binary (PASSED) - pubsub_text (PASSED) - storage (PASSED) 2021/10/26 17:29:56 Legacy event validation passed! 2021/10/26 17:29:56 Framework server shut down. Wrote logs to /var/folders/27/9q8h1w651z91hycvdf4qf0h0009rgz/T/serverlog_stdout.txt and /var/folders/27/9q8h1w651z91hycvdf4qf0h0009rgz/T/serverlog_stderr.txt. 2021/10/26 17:29:56 All validation passed! ========== CLOUDEVENT CONFORMANCE TESTS ========== 2021/10/26 17:29:56 Validating for cloudevent... 2021/10/26 17:29:56 Framework server started. 2021/10/26 17:30:01 CloudEvent validation with CloudEvent requests... 2021/10/26 17:30:01 Events tried: - firebase-auth (PASSED) - firebase-db1 (PASSED) - firebase-db2 (PASSED) - firebase-db3 (PASSED) - firebase-db4 (PASSED) - firebase-db5 (PASSED) - firebase-db6 (PASSED) - firebase-db7 (PASSED) - firebase-db8 (PASSED) - firebase-dbdelete1 (PASSED) - firebase-dbdelete2 (PASSED) - firestore_complex (PASSED) - firestore_simple (PASSED) - legacy_pubsub (PASSED) - pubsub_binary (PASSED) - pubsub_text (PASSED) - storage (PASSED) 2021/10/26 17:30:01 CloudEvent validation passed! 2021/10/26 17:30:01 Framework server shut down. Wrote logs to /var/folders/27/9q8h1w651z91hycvdf4qf0h0009rgz/T/serverlog_stdout.txt and /var/folders/27/9q8h1w651z91hycvdf4qf0h0009rgz/T/serverlog_stderr.txt. 2021/10/26 17:30:01 All validation passed! ``` </p> </details>
1 parent 565f07e commit 51d6503

File tree

2 files changed

+63
-7
lines changed

2 files changed

+63
-7
lines changed

CONTRIBUTING.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ Guidelines](https://opensource.google.com/conduct/).
3131

3232
This project is divided into multiple packages, primarily:
3333

34-
- [`functions-framework-api`](./functions-framework-api)
35-
- `core`
36-
- `testfunction`
37-
- `function-maven-plugin`
38-
- `conformance`
34+
- [`functions-framework-api`](./functions-framework-api) – The interfaces for functions.
3935
- [`java-function-invoker`](./invoker)
36+
- `core` - The function invoker
37+
- `testfunction` - A set of test functions
38+
- `function-maven-plugin` - The Maven plugin for building functions
39+
- `conformance` - A set of functions used for conformance testing
4040

4141
### Setup JDK 11 / 17
4242

4343
Install JDK 11 and 17. One way to install these is through [SDK man](https://sdkman.io/).
4444

4545
```sh
4646
sdk install java 11.0.2-open
47-
sdk install java 17
48-
sdk use java 17
47+
sdk install java 17-open
48+
sdk use java 17-open
4949
sdk use java 11.0.2-open
5050
```
5151

@@ -72,3 +72,11 @@ formatting tool locally using one of the options provided at
7272
cd invoker;
7373
mvn test;
7474
```
75+
76+
### Running Conformance Tests Locally
77+
78+
First, install Go 1.16+, then run the conformance tests with this script:
79+
80+
```
81+
./run_conformance_tests.sh
82+
```

run_conformance_tests.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 v1.2.0 client."
21+
echo "Use './run_conformance_tests vX.X.X' to specify a specific release version."
22+
CLIENT_VERSION="@v1.2.0"
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+
print_header "INSTALLING CLIENT$CLIENT_VERSION"
34+
echo "Note: only works with Go 1.16+ by default, see run_conformance_tests.sh for more information."
35+
# Go install @version only works on go 1.16+, if using a lower Go version
36+
# replace command with:
37+
# go get github.com/GoogleCloudPlatform/functions-framework-conformance/client$CLIENT_VERSION && go install github.com/GoogleCloudPlatform/functions-framework-conformance/client
38+
go install github.com/GoogleCloudPlatform/functions-framework-conformance/client$CLIENT_VERSION
39+
echo "Done installing client$CLIENT_VERSION"
40+
41+
print_header "HTTP CONFORMANCE TESTS"
42+
client -buildpacks=false -type=http -cmd='mvn -f invoker/conformance/pom.xml function:run -Drun.functionTarget=com.google.cloud.functions.conformance.HttpConformanceFunction' -start-delay 5
43+
44+
print_header "BACKGROUND EVENT CONFORMANCE TESTS"
45+
client -buildpacks=false -type=legacyevent -cmd='mvn -f invoker/conformance/pom.xml function:run -Drun.functionTarget=com.google.cloud.functions.conformance.BackgroundEventConformanceFunction' -start-delay 5 -validate-mapping=false
46+
47+
print_header "CLOUDEVENT CONFORMANCE TESTS"
48+
client -buildpacks=false -type=cloudevent -cmd='mvn -f invoker/conformance/pom.xml function:run -Drun.functionTarget=com.google.cloud.functions.conformance.CloudEventsConformanceFunction' -start-delay 5 -validate-mapping=false

0 commit comments

Comments
 (0)