diff --git a/IntegrationTests/tests_01_allocation_counters/test_01_allocation_counts.sh b/IntegrationTests/tests_01_allocation_counters/test_01_allocation_counts.sh index 74a823ca..080b8255 100644 --- a/IntegrationTests/tests_01_allocation_counters/test_01_allocation_counts.sh +++ b/IntegrationTests/tests_01_allocation_counters/test_01_allocation_counts.sh @@ -30,23 +30,28 @@ done for test in "${all_tests[@]}"; do cat "$tmp/output" # helps debugging - total_allocations=$(grep "^test_$test.total_allocations:" "$tmp/output" | cut -d: -f2 | sed 's/ //g') - not_freed_allocations=$(grep "^test_$test.remaining_allocations:" "$tmp/output" | cut -d: -f2 | sed 's/ //g') - max_allowed_env_name="MAX_ALLOCS_ALLOWED_$test" - info "$test: allocations not freed: $not_freed_allocations" - info "$test: total number of mallocs: $total_allocations" + while read -r test_case; do + test_case=${test_case#test_*} + total_allocations=$(grep "^test_$test_case.total_allocations:" "$tmp/output" | cut -d: -f2 | sed 's/ //g') + not_freed_allocations=$(grep "^test_$test_case.remaining_allocations:" "$tmp/output" | cut -d: -f2 | sed 's/ //g') + max_allowed_env_name="MAX_ALLOCS_ALLOWED_$test_case" - assert_less_than "$not_freed_allocations" 5 # allow some slack - assert_greater_than "$not_freed_allocations" -5 # allow some slack - assert_greater_than "$total_allocations" 1000 - if [[ -z "${!max_allowed_env_name+x}" ]]; then + info "$test_case: allocations not freed: $not_freed_allocations" + info "$test_case: total number of mallocs: $total_allocations" + + assert_less_than "$not_freed_allocations" 5 # allow some slack + assert_greater_than "$not_freed_allocations" -5 # allow some slack if [[ -z "${!max_allowed_env_name+x}" ]]; then - warn "no reference number of allocations set (set to \$$max_allowed_env_name)" - warn "to set current number:" - warn " export $max_allowed_env_name=$total_allocations" + if [[ -z "${!max_allowed_env_name+x}" ]]; then + warn "no reference number of allocations set (set to \$$max_allowed_env_name)" + warn "to set current number:" + warn " export $max_allowed_env_name=$total_allocations" + fi + else + max_allowed=${!max_allowed_env_name} + assert_less_than_or_equal "$total_allocations" "$max_allowed" + assert_greater_than "$total_allocations" "$(( max_allowed - 1000))" fi - else - assert_less_than_or_equal "$total_allocations" "${!max_allowed_env_name}" - fi + done < <(grep "^test_$test[^\W]*.total_allocations:" "$tmp/output" | cut -d: -f1 | cut -d. -f1 | sort | uniq) done diff --git a/IntegrationTests/tests_01_allocation_counters/test_01_resources/run-nio-http2-alloc-counter-tests.sh b/IntegrationTests/tests_01_allocation_counters/test_01_resources/run-nio-http2-alloc-counter-tests.sh index 15d85053..83c73040 100755 --- a/IntegrationTests/tests_01_allocation_counters/test_01_resources/run-nio-http2-alloc-counter-tests.sh +++ b/IntegrationTests/tests_01_allocation_counters/test_01_resources/run-nio-http2-alloc-counter-tests.sh @@ -18,18 +18,13 @@ here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" tmp_dir="/tmp" -function die() { - echo >&2 "ERROR: $*" - exit 1 -} - while getopts "t:" opt; do case "$opt" in t) tmp_dir="$OPTARG" ;; - \?) - die "unknown option $opt" + *) + exit 1 ;; esac done @@ -40,6 +35,14 @@ cd "$nio_checkout" git clone --depth 1 https://github.com/apple/swift-nio ) +shift $((OPTIND-1)) + +tests_to_run=("$here"/test_*.swift) + +if [[ $# -gt 0 ]]; then + tests_to_run=("$@") +fi + "$nio_checkout/swift-nio/IntegrationTests/allocation-counter-tests-framework/run-allocation-counter.sh" \ -p "$here/../../.." \ -m NIO \ @@ -47,4 +50,4 @@ git clone --depth 1 https://github.com/apple/swift-nio -m NIOHTTP2 \ -t "$tmp_dir" \ -d <( echo '.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),' ) \ - "$here"/test_*.swift + "${tests_to_run[@]}" diff --git a/docker/docker-compose.1604.51.yaml b/docker/docker-compose.1604.51.yaml index ee8ab7ff..6a88b100 100644 --- a/docker/docker-compose.1604.51.yaml +++ b/docker/docker-compose.1604.51.yaml @@ -16,10 +16,10 @@ services: integration-tests: image: swift-nio-http2:16.04-5.1 environment: - - MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000 - MAX_ALLOCS_ALLOWED_hpack_decoding=5050 - - MAX_ALLOCS_ALLOWED_client_server_request_response=378000 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000 + - MAX_ALLOCS_ALLOWED_client_server_request_response=338000 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=406000 performance-test: image: swift-nio-http2:16.04-5.1 @@ -30,10 +30,10 @@ services: test: image: swift-nio-http2:16.04-5.1 environment: - - MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000 - MAX_ALLOCS_ALLOWED_hpack_decoding=5050 - - MAX_ALLOCS_ALLOWED_client_server_request_response=378000 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000 + - MAX_ALLOCS_ALLOWED_client_server_request_response=338000 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=406000 - SANITIZER_ARG=--sanitize=thread shell: diff --git a/docker/docker-compose.1804.50.yaml b/docker/docker-compose.1804.50.yaml index a88f0fa2..ee35ace9 100644 --- a/docker/docker-compose.1804.50.yaml +++ b/docker/docker-compose.1804.50.yaml @@ -16,9 +16,9 @@ services: integration-tests: image: swift-nio-http2:18.04-5.0 environment: - - MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel=67000 - MAX_ALLOCS_ALLOWED_hpack_decoding=5050 - - MAX_ALLOCS_ALLOWED_client_server_request_response=384810 + - MAX_ALLOCS_ALLOWED_client_server_request_response=358000 - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=425000 performance-test: @@ -30,9 +30,9 @@ services: test: image: swift-nio-http2:18.04-5.0 environment: - - MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel=67000 - MAX_ALLOCS_ALLOWED_hpack_decoding=5050 - - MAX_ALLOCS_ALLOWED_client_server_request_response=384810 + - MAX_ALLOCS_ALLOWED_client_server_request_response=358000 - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=425000 shell: diff --git a/docker/docker-compose.1804.52.yaml b/docker/docker-compose.1804.52.yaml index cf6a78da..56846498 100644 --- a/docker/docker-compose.1804.52.yaml +++ b/docker/docker-compose.1804.52.yaml @@ -16,10 +16,10 @@ services: integration-tests: image: swift-nio-http2:18.04-5.2 environment: - - MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000 - MAX_ALLOCS_ALLOWED_hpack_decoding=5050 - - MAX_ALLOCS_ALLOWED_client_server_request_response=384810 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000 + - MAX_ALLOCS_ALLOWED_client_server_request_response=334000 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=403000 performance-test: image: swift-nio-http2:18.04-5.2 @@ -30,10 +30,10 @@ services: test: image: swift-nio-http2:18.04-5.2 environment: - - MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000 - MAX_ALLOCS_ALLOWED_hpack_decoding=5050 - - MAX_ALLOCS_ALLOWED_client_server_request_response=384810 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000 + - MAX_ALLOCS_ALLOWED_client_server_request_response=334000 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=403000 shell: diff --git a/docker/docker-compose.1804.53.yaml b/docker/docker-compose.1804.53.yaml index c1f6d4e7..7256e889 100644 --- a/docker/docker-compose.1804.53.yaml +++ b/docker/docker-compose.1804.53.yaml @@ -16,10 +16,10 @@ services: integration-tests: image: swift-nio-http2:18.04-5.3 environment: - - MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000 - MAX_ALLOCS_ALLOWED_hpack_decoding=5050 - - MAX_ALLOCS_ALLOWED_client_server_request_response=384810 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000 + - MAX_ALLOCS_ALLOWED_client_server_request_response=334000 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=403000 performance-test: image: swift-nio-http2:18.04-5.3 @@ -30,10 +30,10 @@ services: test: image: swift-nio-http2:18.04-5.3 environment: - - MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000 - MAX_ALLOCS_ALLOWED_hpack_decoding=5050 - - MAX_ALLOCS_ALLOWED_client_server_request_response=384810 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000 + - MAX_ALLOCS_ALLOWED_client_server_request_response=334000 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=403000 shell: image: swift-nio-http2:18.04-5.3 diff --git a/scripts/integration_tests.sh b/scripts/integration_tests.sh index 083c59bf..ca630bd7 100755 --- a/scripts/integration_tests.sh +++ b/scripts/integration_tests.sh @@ -13,5 +13,7 @@ ## ##===----------------------------------------------------------------------===## +set +ex + mkdir -p .build # for the junit.xml file -./IntegrationTests/run-tests.sh --junit-xml .build/junit-sh-tests.xml -i +./IntegrationTests/run-tests.sh --junit-xml .build/junit-sh-tests.xml -i $@