Skip to content

Commit

Permalink
run-test-plan.py: Run in parallel where possible
Browse files Browse the repository at this point in the history
Use python's asyncio / await / async to run modules within one test plan
in parallel if they don't have an alias, and to run plans in parallel
where they use no / different aliases.

The parallelism of tests within a plan should speed up the CIBA tests
and OIDC test modules where we use dcr can hence can proceed without
any alias. Unfortunately the CIBA tests had to have parallelism
disabled because Authlete's CIBA simulated authentication device
doesn't seem to cope with multiple parallel.

Reduces the time to run oidcc-basic-certification-test-plan from 313
seconds to 63 seconds on my local machine - most of which comes from
the test that sleeps for 30 seconds before reusing an auth code.

The ability to run plans with different aliases in parallel means we
can run some of the FAPI tests in parallel with other tests. There may
be further potential to speed this up by tweaking the aliases and
redirect urls we use in (say) half of the FAPI tests.

There was some hassle with python modules/node, I tried switching away
from alpine for the reasons given here, where we were seeing issues
installing the aiohttp module:

https://pythonspeed.com/articles/alpine-docker-python/

but ending up switching back because the version of node (10) in Debian
buster is ancient and doesn't support some of the crypto Fillip's
client needs. Luckily the aiohttp module is one of the ones that can
relatively easily be made to work on alpine.

We add a retrying http client, as it seems either the parallelisation
or something about the asyncio http client ends up giving weird http
errors - I think we're running into the same bug as here:

aio-libs/aiohttp#4581

Switching to https://www.python-httpx.org might be an option to avoid
that, but that's still in beta.

part of #783

# Conflicts:
#	scripts/run-test-plan.py
  • Loading branch information
jogu committed Jun 8, 2021
1 parent dee8609 commit 7d65c1a
Show file tree
Hide file tree
Showing 6 changed files with 331 additions and 167 deletions.
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ stop_normal:
.deployment_test: &deployment_test
stage: test
interruptible: true
image: python:alpine
image: python:3.9-alpine
only:
refs:
- branches
Expand Down Expand Up @@ -516,8 +516,7 @@ local_test:

function install_test_dependencies() {
echo "Installing extra dependencies"
apk add -U openssh-client git
apk add --update nodejs nodejs-npm
apk add openssh-client git gcc musl-dev bash
eval $(ssh-agent -s)
echo "$SSH_PRIVATE_KEY" | ssh-add -
cd ..
Expand All @@ -527,10 +526,11 @@ local_test:

function set_up_for_running_test_plan() {
install_test_dependencies
pip install requests
pip install aiohttp aiofiles aiohttp-retry
}

function run_client_test_plan() {
apk add nodejs npm
echo "Running automated tests against $CONFORMANCE_SERVER"
../conformance-suite/.gitlab-ci/run-tests.sh --client-tests-only
}
Expand Down
27 changes: 13 additions & 14 deletions .gitlab-ci/local-provider-oidcc-conformance-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"alias": "local-oidcc",
"description": "oidc-provider OIDC",
"server": {
"discoveryUrl": "https://oidcc-provider:3000/.well-known/openid-configuration"
Expand Down Expand Up @@ -54,7 +53,7 @@
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/callback*",
"match": "*/test/*/callback*",
"commands": [
[
"wait",
Expand Down Expand Up @@ -88,14 +87,14 @@
[
"wait",
"contains",
"/test/a/local-oidcc/post",
"/test/*/post",
10
]
]
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/post*"
"match": "*/test/*/post*"
}
]
}
Expand Down Expand Up @@ -155,7 +154,7 @@
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/callback*",
"match": "*/test/*/callback*",
"commands": [
[
"wait",
Expand Down Expand Up @@ -223,7 +222,7 @@
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/callback*",
"match": "*/test/*/callback*",
"commands": [
[
"wait",
Expand Down Expand Up @@ -450,7 +449,7 @@
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/callback*",
"match": "*/test/*/callback*",
"commands": [
[
"wait",
Expand Down Expand Up @@ -529,7 +528,7 @@
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/callback*",
"match": "*/test/*/callback*",
"commands": [
[
"wait",
Expand Down Expand Up @@ -608,7 +607,7 @@
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/callback*",
"match": "*/test/*/callback*",
"commands": [
[
"wait",
Expand Down Expand Up @@ -687,7 +686,7 @@
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/callback*",
"match": "*/test/*/callback*",
"commands": [
[
"wait",
Expand Down Expand Up @@ -766,7 +765,7 @@
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/callback*",
"match": "*/test/*/callback*",
"commands": [
[
"wait",
Expand Down Expand Up @@ -845,7 +844,7 @@
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/callback*",
"match": "*/test/*/callback*",
"commands": [
[
"wait",
Expand Down Expand Up @@ -935,7 +934,7 @@
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/callback*",
"match": "*/test/*/callback*",
"commands": [
[
"wait",
Expand Down Expand Up @@ -1025,7 +1024,7 @@
},
{
"task": "Verify Complete",
"match": "*/test/a/local-oidcc/callback*",
"match": "*/test/*/callback*",
"commands": [
[
"wait",
Expand Down
8 changes: 5 additions & 3 deletions .gitlab-ci/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

set -e
cleanup() {
Expand Down Expand Up @@ -32,8 +32,8 @@ EXPECTED_FAILURES_FILE="../conformance-suite/.gitlab-ci/expected-failures-server
EXPECTED_SKIPS_FILE="../conformance-suite/.gitlab-ci/expected-skips-server.json|../conformance-suite/.gitlab-ci/expected-skips-ciba.json|../conformance-suite/.gitlab-ci/expected-skips-client.json"

makeClientTest() {
. node-client-setup.sh
. node-core-client-setup.sh
. ./node-client-setup.sh
. ./node-core-client-setup.sh

# client FAPI1-ADVANCED
TESTS="${TESTS} fapi1-advanced-final-client-test-plan[client_auth_type=private_key_jwt][fapi_profile=plain_fapi][fapi_auth_request_method=by_value][fapi_response_mode=plain_response][fapi_jarm_type=oidc] automated-ob-client-test.json"
Expand Down Expand Up @@ -280,6 +280,7 @@ elif [ "$#" -eq 1 ] && [ "$1" = "--client-tests-only" ]; then
TESTS="${TESTS} --expected-skips-file ${EXPECTED_SKIPS_FILE}"
TESTS="${TESTS} --show-untested-test-modules client"
TESTS="${TESTS} --export-dir ../conformance-suite"
TESTS="${TESTS} --no-parallel" # there seemed to be a lot of "Server disconnected" failures trying to run these in parallel
echo "Run client tests"
makeClientTest
elif [ "$#" -eq 1 ] && [ "$1" = "--server-tests-only" ]; then
Expand All @@ -299,6 +300,7 @@ elif [ "$#" -eq 1 ] && [ "$1" = "--ciba-tests-only" ]; then
TESTS="${TESTS} --expected-skips-file ${EXPECTED_SKIPS_FILE}"
TESTS="${TESTS} --show-untested-test-modules ciba"
TESTS="${TESTS} --export-dir ../conformance-suite"
TESTS="${TESTS} --no-parallel" # the authlete authentication device simulator doesn't seem to support parallel authorizations
echo "Run ciba tests"
makeCIBATest
elif [ "$#" -eq 1 ] && [ "$1" = "--local-provider-tests" ]; then
Expand Down
Loading

0 comments on commit 7d65c1a

Please sign in to comment.