forked from GoogleCloudPlatform/functions-framework-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun-conformance-tests.sh
executable file
·85 lines (69 loc) · 2.75 KB
/
run-conformance-tests.sh
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
#!/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/OpenFunction.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/OpenFunction.ConformanceTests/bin/Release/net6.0/OpenFunction.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/OpenFunction.ConformanceTests/bin/Release/net6.0/OpenFunction.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
TEST_FUNCTION=$2
echo "Running '$TEST_TYPE' test with function '$TEST_FUNCTION'"
(cd tmp/conformance-test-output && \
mkdir $TEST_TYPE && \
cd $TEST_TYPE && \
../../../$CLIENT_BINARY \
-buildpacks=false \
-type=$TEST_TYPE \
-cmd="dotnet ../../../$DOTNET_DLL $TEST_FUNCTION" \
)
}
run_test http HttpFunction
run_test cloudevent UntypedCloudEventFunction
echo "Tests completed successfully"