Skip to content

Commit

Permalink
chore: enable concurrency conformance tests (#254)
Browse files Browse the repository at this point in the history
* chore: enable concurrency conformance tests

Tests that the framework can handle 10 requests to a function that
sleeps for 1s in about 1s.

* Use simpler function stub
  • Loading branch information
anniefu committed Aug 16, 2022
1 parent 017848c commit a887c9e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '^1.15.2'
go-version: '^1.16'

- name: Clear NuGet cache
run: dotnet nuget locals all --clear
Expand Down
7 changes: 5 additions & 2 deletions run-conformance-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,21 @@ echo "Using Functions Framework test binary: $DOTNET_DLL"
run_test() {
TEST_TYPE=$1
TEST_FUNCTION=$2
EXTRA_ARGS=$3
echo "Running '$TEST_TYPE' test with function '$TEST_FUNCTION'"
(cd tmp/conformance-test-output && \
mkdir $TEST_TYPE && \
cd $TEST_TYPE && \
mkdir $TEST_FUNCTION && \
cd $TEST_FUNCTION && \
../../../$CLIENT_BINARY \
-buildpacks=false \
-type=$TEST_TYPE \
-cmd="dotnet ../../../$DOTNET_DLL $TEST_FUNCTION" \
$EXTRA_ARGS
)
}

run_test http HttpFunction
run_test cloudevent UntypedCloudEventFunction
run_test http ConcurrentHttpFunction -validate-concurrency=true

echo "Tests completed successfully"
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2022, Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Google.Cloud.Functions.Framework;
using Microsoft.AspNetCore.Http;
using System.IO;
using System.Threading.Tasks;

// Note: no namespace, to make it simpler to run as part of conformance testing
public class ConcurrentHttpFunction : IHttpFunction
{
public Task HandleAsync(HttpContext context) => Task.Delay(1000);
}

0 comments on commit a887c9e

Please sign in to comment.