apple / swift-nio-http2

HTTP/2 support for SwiftNIO
https://swiftpackageindex.com/apple/swift-nio-http2/main/documentation/niohttp2
Apache License 2.0
462 stars 82 forks source link

Use explicit 64-bit UInt64 to support 32-bit platforms #430

Closed simonjbeaumont closed 9 months ago

simonjbeaumont commented 9 months ago

Motivation

This project doesn't currently build for watchOS because some tests make use of 64-bit integer literals.

IntegerCodingTests.swift:161:115: Integer literal '9151314442816848127' overflows when stored into 'Int'

Beyond the test code, the integer encoding logic makes use of UInt, which will be UInt64 on some platforms and UInt32 on others, e.g. some Apple Watch versions.

Modifications

Result

Code can now build for watchOS.

simonjbeaumont commented 9 months ago

@FranzBusch @glbrntt dunno what's up with nightly pipeline but unlikely related to this. Should we merge over it?

glbrntt commented 9 months ago

It looks like the allocation tests failed:

09:54:18 Running test 'test_01_allocation_counts.sh'... FAILURE (245)
09:54:18 --- OUTPUT BEGIN ---
09:54:18 + set -o pipefail
09:54:18 + test=/code/IntegrationTests/tests_01_allocation_counters/test_01_allocation_counts.sh
09:54:18 + tmp=/tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw
09:54:18 + root=/code/IntegrationTests/..
09:54:18 + g_show_info=true
09:54:18 +++ dirname /code/IntegrationTests/run-single-test.sh
09:54:18 ++ cd /code/IntegrationTests
09:54:18 ++ pwd
09:54:18 + here=/code/IntegrationTests
09:54:18 + source /code/IntegrationTests/test_functions.sh
09:54:18 ++ g_has_previously_infoed=false
09:54:18 + source /code/IntegrationTests/tests_01_allocation_counters/test_01_allocation_counts.sh
09:54:18 ++ source defines.sh
09:54:18 ++ set -eu
09:54:18 ++++ dirname /code/IntegrationTests/tests_01_allocation_counters/test_01_allocation_counts.sh
09:54:18 +++ cd /code/IntegrationTests/tests_01_allocation_counters
09:54:18 +++ pwd
09:54:18 ++ here=/code/IntegrationTests/tests_01_allocation_counters
09:54:18 ++ all_tests=()
09:54:18 ++ for file in "$here/test_01_resources/"test_*.swift
09:54:18 +++ basename /code/IntegrationTests/tests_01_allocation_counters/test_01_resources/test_1k_requests.swift
09:54:18 ++ test_name=test_1k_requests.swift
09:54:18 ++ test_name=1k_requests.swift
09:54:18 ++ test_name=1k_requests
09:54:18 ++ all_tests+=("$test_name")
09:54:18 ++ for file in "$here/test_01_resources/"test_*.swift
09:54:18 +++ basename /code/IntegrationTests/tests_01_allocation_counters/test_01_resources/test_client_server_h1_request_response.swift
09:54:18 ++ test_name=test_client_server_h1_request_response.swift
09:54:18 ++ test_name=client_server_h1_request_response.swift
09:54:18 ++ test_name=client_server_h1_request_response
09:54:18 ++ all_tests+=("$test_name")
09:54:18 ++ for file in "$here/test_01_resources/"test_*.swift
09:54:18 +++ basename /code/IntegrationTests/tests_01_allocation_counters/test_01_resources/test_client_server_request_response.swift
09:54:18 ++ test_name=test_client_server_request_response.swift
09:54:18 ++ test_name=client_server_request_response.swift
09:54:18 ++ test_name=client_server_request_response
09:54:18 ++ all_tests+=("$test_name")
09:54:18 ++ for file in "$here/test_01_resources/"test_*.swift
09:54:18 +++ basename /code/IntegrationTests/tests_01_allocation_counters/test_01_resources/test_create_client_stream_channel.swift
09:54:18 ++ test_name=test_create_client_stream_channel.swift
09:54:18 ++ test_name=create_client_stream_channel.swift
09:54:18 ++ test_name=create_client_stream_channel
09:54:18 ++ all_tests+=("$test_name")
09:54:18 ++ for file in "$here/test_01_resources/"test_*.swift
09:54:18 +++ basename /code/IntegrationTests/tests_01_allocation_counters/test_01_resources/test_get_100000_headers_canonical_form.swift
09:54:18 ++ test_name=test_get_100000_headers_canonical_form.swift
09:54:18 ++ test_name=get_100000_headers_canonical_form.swift
09:54:18 ++ test_name=get_100000_headers_canonical_form
09:54:18 ++ all_tests+=("$test_name")
09:54:18 ++ for file in "$here/test_01_resources/"test_*.swift
09:54:18 +++ basename /code/IntegrationTests/tests_01_allocation_counters/test_01_resources/test_hpack_decoding.swift
09:54:18 ++ test_name=test_hpack_decoding.swift
09:54:18 ++ test_name=hpack_decoding.swift
09:54:18 ++ test_name=hpack_decoding
09:54:18 ++ all_tests+=("$test_name")
09:54:18 ++ for file in "$here/test_01_resources/"test_*.swift
09:54:18 +++ basename /code/IntegrationTests/tests_01_allocation_counters/test_01_resources/test_stream_teardown_100_concurrent.swift
09:54:18 ++ test_name=test_stream_teardown_100_concurrent.swift
09:54:18 ++ test_name=stream_teardown_100_concurrent.swift
09:54:18 ++ test_name=stream_teardown_100_concurrent
09:54:18 ++ all_tests+=("$test_name")
09:54:18 ++ /code/IntegrationTests/tests_01_allocation_counters/test_01_resources/run-nio-http2-alloc-counter-tests.sh -t /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw
09:54:18 Cloning into 'swift-nio'...
09:54:18 hint: Using 'master' as the name for the initial branch. This default branch name
09:54:18 hint: is subject to change. To configure the initial branch name to use in all
09:54:18 hint: of your new repositories, which will suppress this warning, call:
09:54:18 hint: 
09:54:18 hint:  git config --global init.defaultBranch <name>
09:54:18 hint: 
09:54:18 hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
09:54:18 hint: 'development'. The just-created branch can be renamed via this command:
09:54:18 hint: 
09:54:18 hint:  git branch -m <name>
09:54:18 Switched to a new branch 'main'
09:54:18 hint: Using 'master' as the name for the initial branch. This default branch name
09:54:18 hint: is subject to change. To configure the initial branch name to use in all
09:54:18 hint: of your new repositories, which will suppress this warning, call:
09:54:18 hint: 
09:54:18 hint:  git config --global init.defaultBranch <name>
09:54:18 hint: 
09:54:18 hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
09:54:18 hint: 'development'. The just-created branch can be renamed via this command:
09:54:18 hint: 
09:54:18 hint:  git branch -m <name>
09:54:18 Switched to a new branch 'main'
09:54:18 hint: Using 'master' as the name for the initial branch. This default branch name
09:54:18 hint: is subject to change. To configure the initial branch name to use in all
09:54:18 hint: of your new repositories, which will suppress this warning, call:
09:54:18 hint: 
09:54:18 hint:  git config --global init.defaultBranch <name>
09:54:18 hint: 
09:54:18 hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
09:54:18 hint: 'development'. The just-created branch can be renamed via this command:
09:54:18 hint: 
09:54:18 hint:  git branch -m <name>
09:54:18 Switched to a new branch 'main'
09:54:18 Fetching /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/HookedFunctions
09:54:18 Fetched /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/HookedFunctions from cache (0.02s)
09:54:18 Fetching /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/swift-nio-http2
09:54:18 Fetched /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/swift-nio-http2 from cache (0.02s)
09:54:18 Fetching /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/AtomicCounter
09:54:18 Fetched /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/AtomicCounter from cache (0.02s)
09:54:18 Fetching https://github.com/apple/swift-nio.git from cache
09:54:18 Fetched https://github.com/apple/swift-nio.git from cache (1.81s)
09:54:18 Computing version for https://github.com/apple/swift-nio.git
09:54:18 Computed https://github.com/apple/swift-nio.git at 2.62.0 (1.13s)
09:54:18 Fetching https://github.com/apple/swift-collections.git from cache
09:54:18 Fetching https://github.com/apple/swift-atomics.git from cache
09:54:18 Fetched https://github.com/apple/swift-atomics.git from cache (0.49s)
09:54:18 Fetched https://github.com/apple/swift-collections.git from cache (0.51s)
09:54:18 Computing version for https://github.com/apple/swift-atomics.git
09:54:18 Computed https://github.com/apple/swift-atomics.git at 1.2.0 (1.05s)
09:54:18 Computing version for https://github.com/apple/swift-collections.git
09:54:18 Computed https://github.com/apple/swift-collections.git at 1.0.5 (1.00s)
09:54:19 Creating working copy for https://github.com/apple/swift-nio.git
09:54:19 Working copy of https://github.com/apple/swift-nio.git resolved at 2.62.0
09:54:19 Creating working copy for /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/HookedFunctions
09:54:19 Working copy of /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/HookedFunctions resolved at main (c2ae86d)
09:54:19 Creating working copy for https://github.com/apple/swift-atomics.git
09:54:19 Working copy of https://github.com/apple/swift-atomics.git resolved at 1.2.0
09:54:19 Creating working copy for /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/swift-nio-http2
09:54:19 Working copy of /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/swift-nio-http2 resolved at main (d87fc38)
09:54:19 Creating working copy for https://github.com/apple/swift-collections.git
09:54:19 Working copy of https://github.com/apple/swift-collections.git resolved at 1.0.5
09:54:19 Creating working copy for /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/AtomicCounter
09:54:19 Working copy of /tmp/.swift-nio-http1-server-sh-tests_RXkdk2/test.tmp_Dy7waw/.nio_alloc_counter_tests_q2sHLc/AtomicCounter resolved at main (11b505b)
09:54:19 --- OUTPUT  END  ---
09:54:19 FAILURE (oks: 0, failures: 1)

I think the output is different if the limits are incorrect though and it's not immediately obvious what the issue here is. Can you try opening an empty PR as well?

glbrntt commented 9 months ago

@simonjbeaumont I'll merge this given https://github.com/apple/swift-nio-http2/pull/431 has the same issue.