-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathrun-conformance-tests.sh
More file actions
executable file
·91 lines (75 loc) · 3.02 KB
/
run-conformance-tests.sh
File metadata and controls
executable file
·91 lines (75 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# Runs the conformance tests from
# https://github.com/GoogleCloudPlatform/functions-framework-conformance
# That repository is included as a submodule already, under
# functions-framework-conformance
# This script checks that the submodule is already present, but
# does not assume it has already been built.
# It assumes that "go" is already in the path.
set -e
# Path to the root of the conformance repository. By default this
# is the submodule under functions-framework-dotnet, but it can be
# easily tweaked to simplify testing of local changes to the conformance
# tests.
CONFORMANCE_REPO=functions-framework-conformance
rm -rf tmp/conformance-test-output
mkdir -p tmp/conformance-test-output
if [[ ! -f $CONFORMANCE_REPO/README.md ]]
then
echo "Conformance test repo not found. Init and update submodules."
exit 1
fi
# Build the conformance test framework
echo "Building conformance test framework"
# Regenerate the events - normally a no-op, but it makes it
# simpler to update the events.
(cd $CONFORMANCE_REPO && go generate ./...)
# Build the conformance test client itself
(cd $CONFORMANCE_REPO/client && go build)
# Build the conformance functions up-front
echo "Building conformance functions"
dotnet build -nologo -clp:NoSummary -v quiet -c Release src/Google.Cloud.Functions.ConformanceTests
CLIENT_BINARY=$CONFORMANCE_REPO/client/client
if [[ $OSTYPE =~ ^win* || $OSTYPE =~ ^msys* || $OSTYPE =~ ^cygwin* ]]
then
CLIENT_BINARY=${CLIENT_BINARY}.exe
fi
# Run the Functions Framework once as a "warm-up", killing it after 5 seconds.
# This is necessary on MacOS for non-obvious reasons;
# it's possible that the conformance test runner just expects it to be
# ready a little bit earlier than it is.
# TODO: Remove this when we can.
echo "Running Functions Framework for 5 seconds as a warm-up step."
dotnet src/Google.Cloud.Functions.ConformanceTests/bin/Release/net8.0/Google.Cloud.Functions.ConformanceTests.dll HttpFunction &
DOTNETPID=$!
sleep 5
kill $DOTNETPID
# Note: we run the DLL directly rather than using "dotnet run" as this
# responds more correctly to being killed by the conformance test runner
# on Linux.
DOTNET_DLL=src/Google.Cloud.Functions.ConformanceTests/bin/Release/net8.0/Google.Cloud.Functions.ConformanceTests.dll
echo "Using conformance test runner binary: $CLIENT_BINARY"
echo "Using Functions Framework test binary: $DOTNET_DLL"
# Run the tests
run_test() {
TEST_TYPE=$1
DECLARATIVE_TYPE=$2
TEST_FUNCTION=$3
EXTRA_ARGS=$4
echo "Running '$TEST_TYPE' test with function '$TEST_FUNCTION'"
(cd tmp/conformance-test-output && \
mkdir $TEST_FUNCTION && \
cd $TEST_FUNCTION && \
../../../$CLIENT_BINARY \
-buildpacks=false \
-type=$TEST_TYPE \
-declarative-type=$DECLARATIVE_TYPE \
-cmd="dotnet ../../../$DOTNET_DLL $TEST_FUNCTION" \
$EXTRA_ARGS
)
}
run_test http http HttpFunction
run_test http typed TypedFunction
run_test cloudevent cloudevent UntypedCloudEventFunction
run_test http http ConcurrentHttpFunction -validate-concurrency=true
echo "Tests completed successfully"