Skip to content

MQTT test refactor PR (#818) crashes WebSocket tests in environments without IoT credentials #844

@kaukabrizvi

Description

@kaukabrizvi

Describe the bug

s2n-tls is the TLS/SSL implementation used by aws-crt-cpp. As part of s2n-tls CI, the s2nUnitCRT job in the s2nGeneralBatch job builds aws-crt-cpp from latest main, substitutes in the current s2n-tls source, and runs the full aws-crt-cpp test suite. This validates that s2n-tls changes don't break the CRT integration. The job runs without IoT credentials or AWS config files since it's purely a build/unit-test environment.

After the merge of #818 ("Mqtt test refactor"), 5 MQTT5 WebSocket tests in s2n-tls crash with a fatal assertion (Signal received: 0) instead of gracefully skipping in CI environments that lack IoT credentials:

This breaks downstream CI for any project that builds and tests aws-crt-cpp without IoT credentials (e.g., s2n-tls's s2nUnitCRT job). For immediate resolution, we can pin to the commit prior to the breaking PR. Once this issue is resolved, we can return to testing from latest.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

The WebSocket MQTT5 tests (Mqtt5WSConnectionWithMutualTLS, Mqtt5WSConnectionWithHttpProxy, Mqtt5WSConnectionFull, Mqtt5to3AdapterWSConnectionMinimalThroughMqtt3, Mqtt5to3AdapterWSConnectionMinimalThroughMqtt5) should gracefully skip when run in CI environments without IoT credentials, as they did prior to PR #818.

Current Behavior

After PR #818 ("Mqtt test refactor"), these 5 tests crash with Signal received: 0, errno: 0 and a stack trace instead of skipping. The refactored createTestContext function's MQTT5CONNECT_WS_IOT_CORE case unconditionally calls CredentialsProvider::CreateCredentialsProviderChainDefault() and passes the result into Aws::Iot::WebsocketConfig without validation. In environments without AWS credentials, the default chain falls through to the ECS provider and the resulting state triggers a fatal assertion during client construction. The old per-test code either required certs (causing an early skip) or had explicit ASSERT_TRUE(provider) checks that are now missing from the shared path.

Reproduction Steps

Build and run the aws-crt-cpp tests on a machine without IoT credentials or AWS config files. All 5 tests should crash with Signal received: 0 as observed in https://us-west-2.codebuild.aws.amazon.com/project/eyJlbmNyeXB0ZWREYXRhIjoidUpNb2QzNjZzQ3lrWm1UQ2xzdFZMN1ZGYWE5dVlSQ1ZKd1BnZzZ6aXN1dlZXTmFuZWdvNnR0SitPaFlIcUdjaDZ6RU9KemY2Mi9ybXVBajF0RXo4NmZ1Rnl4dkZrT241UUY4MTVQMkRuNTQ9IiwiaXZQYXJhbWV0ZXJTcGVjIjoiemFRUDgvZUMreVhER0RKaiIsIm1hdGVyaWFsU2V0U2VyaWFsIjoxfQ%3D%3D/build/58f37502-7178-47d6-bb62-64b2261f1e4d. On commit 7cb4eaa (one before the refactor), the same tests skip cleanly as observed in https://us-west-2.codebuild.aws.amazon.com/project/eyJlbmNyeXB0ZWREYXRhIjoidUpNb2QzNjZzQ3lrWm1UQ2xzdFZMN1ZGYWE5dVlSQ1ZKd1BnZzZ6aXN1dlZXTmFuZWdvNnR0SitPaFlIcUdjaDZ6RU9KemY2Mi9ybXVBajF0RXo4NmZ1Rnl4dkZrT241UUY4MTVQMkRuNTQ9IiwiaXZQYXJhbWV0ZXJTcGVjIjoiemFRUDgvZUMreVhER0RKaiIsIm1hdGVyaWFsU2V0U2VyaWFsIjoxfQ%3D%3D/build/b4cbe105-20b7-4164-b49a-c2380eb729d8

Possible Solution

Either validate the credentials provider in the MQTT5CONNECT_WS_IOT_CORE case of createTestContext and skip if it's null/invalid, or gate the MQTT5CONNECT_WS_IOT_CORE env var check on an additional credential-availability check so the test skips properly.

Additional Information/Context

No response

aws-crt-cpp version used

main at commit fbb9615 (includes PR #818, "Mqtt test refactor"). Last working commit: 7cb4eaa.

Compiler and version used

GCC 13

Operating System and version

Ubuntu 24 (x86_64 Linux)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.potential-regressionMarking this issue as a potential regression to be checked by team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions