Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set AdapterOptions with env values in Default impl #324

Merged
merged 3 commits into from
Jan 2, 2024

Conversation

mxfactorial
Copy link
Contributor

@mxfactorial mxfactorial commented Dec 27, 2023

Issue #, if available:

none

Description of changes:

  • set AdapterOptions with env values in Default impl
  • remove borrow for consistent lets
  • add serial_test dev-dep
  • run 3 tests serially to avoid mixing env vars

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@bnusunny
Copy link
Contributor

bnusunny commented Jan 1, 2024

@mxfactorial thanks for this PR. Did you have issues to run the tests? Could you share steps for reproduction?

@mxfactorial
Copy link
Contributor Author

mxfactorial commented Jan 1, 2024

comment #[serial] on the dev branch line 114, then cargo test in a couple loops to reproduce an intermittent test failure:

❯ COUNT=2; while [[ $COUNT -gt 0 ]]; do cargo test; COUNT=$(($COUNT-1)); done
    Finished test [unoptimized + debuginfo] target(s) in 0.19s
warning: the following packages contain code that will be rejected by a future version of Rust: lalrpop v0.19.8
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 2`
     Running unittests src/lib.rs (target/debug/deps/lambda_web_adapter-cbf22d34f04abe8d)

running 3 tests
test tests::test_status_200_is_ok ... ok
test tests::test_status_500_is_bad ... ok
test tests::test_status_403_is_bad_when_configured ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

     Running unittests src/main.rs (target/debug/deps/lambda_adapter-4795adf0408a4ad0)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/e2e_tests/main.rs (target/debug/deps/e2e_tests-00604db3a1d1c8df)

running 4 tests
test test_http_basic_request ... ignored
test test_http_compress ... ignored
test test_http_headers ... ignored
test test_http_query_params ... ignored

test result: ok. 0 passed; 0 failed; 4 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/integ_tests/main.rs (target/debug/deps/integ_tests-a9c099e23d7d148b)

running 15 tests
test test_readiness_check_port_fallback_to_lwa_port ... ok
test test_default_adapter_options ... FAILED
test test_adapter_options_from_namespaced_env ... ok
test test_http_readiness_check ... FAILED
test test_http_query_params ... ok
test test_http_context_headers ... ok
test test_http_path_encoding ... ok
test test_http_basic_request ... ok
test test_http_compress_disallowed_type ... ok
test test_http_content_encoding_suffix ... ok
test test_http_headers ... ok
test test_http_context_multi_headers ... ok
test test_http_compress_already_compressed ... ok
test test_http_compress ... ok
test test_http_post_put_delete ... ok

failures:

---- test_default_adapter_options stdout ----
thread 'test_default_adapter_options' panicked at tests/integ_tests/main.rs:49:5:
assertion `left == right` failed
  left: "8000"
 right: "3000"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- test_http_readiness_check stdout ----
thread 'test_http_readiness_check' panicked at /Users/mx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/httpmock-0.6.8/src/api/mock.rs:523:17:
No request has been received by the mock server.


failures:
    test_default_adapter_options
    test_http_readiness_check

test result: FAILED. 13 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

error: test failed, to rerun pass `--test integ_tests`
    Finished test [unoptimized + debuginfo] target(s) in 0.18s
warning: the following packages contain code that will be rejected by a future version of Rust: lalrpop v0.19.8
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 2`
     Running unittests src/lib.rs (target/debug/deps/lambda_web_adapter-cbf22d34f04abe8d)

running 3 tests
test tests::test_status_500_is_bad ... ok
test tests::test_status_403_is_bad_when_configured ... ok
test tests::test_status_200_is_ok ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

     Running unittests src/main.rs (target/debug/deps/lambda_adapter-4795adf0408a4ad0)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/e2e_tests/main.rs (target/debug/deps/e2e_tests-00604db3a1d1c8df)

running 4 tests
test test_http_basic_request ... ignored
test test_http_compress ... ignored
test test_http_headers ... ignored
test test_http_query_params ... ignored

test result: ok. 0 passed; 0 failed; 4 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/integ_tests/main.rs (target/debug/deps/integ_tests-a9c099e23d7d148b)

running 15 tests
test test_readiness_check_port_fallback_to_lwa_port ... ok
test test_default_adapter_options ... ok
test test_adapter_options_from_namespaced_env ... ok
test test_http_query_params ... ok
test test_http_path_encoding ... ok
test test_http_compress_disallowed_type ... ok
test test_http_readiness_check ... ok
test test_http_context_multi_headers ... ok
test test_http_basic_request ... ok
test test_http_context_headers ... ok
test test_http_headers ... ok
test test_http_content_encoding_suffix ... ok
test test_http_compress_already_compressed ... ok
test test_http_compress ... ok
test test_http_post_put_delete ... ok

test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

   Doc-tests lambda_web_adapter

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

but cargo nextest run --profile ci from pipeline.yaml continues to pass:

❯ COUNT=2; while [[ $COUNT -gt 0 ]]; do cargo nextest run --profile ci; COUNT=$(($COUNT-1)); done
warning: ignoring unknown configuration keys in config file /Users/mx/code/branches/aws-lambda-web-adapter/.config/nextest.toml: profile.ci.inherits
    Finished test [unoptimized + debuginfo] target(s) in 0.23s
warning: the following packages contain code that will be rejected by a future version of Rust: lalrpop v0.19.8
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 2`
    Starting 18 tests across 4 binaries (4 skipped)
        PASS [   0.178s] lambda_web_adapter tests::test_status_403_is_bad_when_configured
        PASS [   0.179s] lambda_web_adapter tests::test_status_200_is_ok
        PASS [   0.172s] lambda_web_adapter::integ_tests test_http_compress_disallowed_type
        PASS [   0.173s] lambda_web_adapter::integ_tests test_http_compress_already_compressed
        PASS [   0.176s] lambda_web_adapter::integ_tests test_default_adapter_options
        PASS [   0.177s] lambda_web_adapter tests::test_status_500_is_bad
        PASS [   0.170s] lambda_web_adapter::integ_tests test_http_context_headers
        PASS [   0.171s] lambda_web_adapter::integ_tests test_http_content_encoding_suffix
        PASS [   0.175s] lambda_web_adapter::integ_tests test_http_basic_request
        PASS [   0.177s] lambda_web_adapter::integ_tests test_adapter_options_from_namespaced_env
        PASS [   0.174s] lambda_web_adapter::integ_tests test_http_compress
        PASS [   0.171s] lambda_web_adapter::integ_tests test_http_context_multi_headers
        PASS [   0.076s] lambda_web_adapter::integ_tests test_http_headers
        PASS [   0.065s] lambda_web_adapter::integ_tests test_http_path_encoding
        PASS [   0.066s] lambda_web_adapter::integ_tests test_http_post_put_delete
        PASS [   0.065s] lambda_web_adapter::integ_tests test_http_query_params
        PASS [   0.043s] lambda_web_adapter::integ_tests test_readiness_check_port_fallback_to_lwa_port
        PASS [   0.061s] lambda_web_adapter::integ_tests test_http_readiness_check
------------
     Summary [   0.240s] 18 tests run: 18 passed, 4 skipped
warning: ignoring unknown configuration keys in config file /Users/mx/code/branches/aws-lambda-web-adapter/.config/nextest.toml: profile.ci.inherits
    Finished test [unoptimized + debuginfo] target(s) in 0.19s
warning: the following packages contain code that will be rejected by a future version of Rust: lalrpop v0.19.8
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 2`
    Starting 18 tests across 4 binaries (4 skipped)
        PASS [   0.172s] lambda_web_adapter tests::test_status_200_is_ok
        PASS [   0.171s] lambda_web_adapter tests::test_status_403_is_bad_when_configured
        PASS [   0.170s] lambda_web_adapter tests::test_status_500_is_bad
        PASS [   0.168s] lambda_web_adapter::integ_tests test_http_basic_request
        PASS [   0.170s] lambda_web_adapter::integ_tests test_adapter_options_from_namespaced_env
        PASS [   0.165s] lambda_web_adapter::integ_tests test_http_compress_disallowed_type
        PASS [   0.167s] lambda_web_adapter::integ_tests test_http_compress
        PASS [   0.169s] lambda_web_adapter::integ_tests test_default_adapter_options
        PASS [   0.164s] lambda_web_adapter::integ_tests test_http_content_encoding_suffix
        PASS [   0.167s] lambda_web_adapter::integ_tests test_http_compress_already_compressed
        PASS [   0.155s] lambda_web_adapter::integ_tests test_http_context_headers
        PASS [   0.087s] lambda_web_adapter::integ_tests test_http_context_multi_headers
        PASS [   0.074s] lambda_web_adapter::integ_tests test_http_headers
        PASS [   0.064s] lambda_web_adapter::integ_tests test_http_path_encoding
        PASS [   0.068s] lambda_web_adapter::integ_tests test_http_post_put_delete
        PASS [   0.067s] lambda_web_adapter::integ_tests test_http_query_params
        PASS [   0.045s] lambda_web_adapter::integ_tests test_readiness_check_port_fallback_to_lwa_port
        PASS [   0.064s] lambda_web_adapter::integ_tests test_http_readiness_check
------------
     Summary [   0.236s] 18 tests run: 18 passed, 4 skipped

is a pass from cargo test a requirement?

@bnusunny
Copy link
Contributor

bnusunny commented Jan 2, 2024

No, we use cargo-nextest to run all tests. cargo-nextest executes each individual test in a separate process, in parallel. Here is the information on how it works.

@mxfactorial
Copy link
Contributor Author

added as required

ready for review when convenient

@bnusunny bnusunny merged commit 5f1f946 into awslabs:main Jan 2, 2024
22 checks passed
@mxfactorial mxfactorial deleted the adapter-opts-defaul branch January 2, 2024 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants