awslabs / aws-crt-nodejs

NodeJS bindings for the AWS Common Runtime.
Apache License 2.0
38 stars 24 forks source link

Refactor flaky MQTT311 tests #419

Closed bretambrose closed 1 year ago

bretambrose commented 1 year ago

The shared MQTT311 tests are consistently flaky. This PR is an attempt to uncover/resolve this flakiness. After completing the refactor, I have not observed any test failures across a decent number of full CI re-runs.

This PR refactors the tests in several ways:

  1. Try-blocks for all promise executor functions leading to rejections. This keeps exceptions from disrupting anything outside the promise.
  2. Drops all truthy resolution checks. Awaiting the promise is sufficient.
  3. Rewrites the tests to use a top-down procedural style for clarity of ordering. Step-by-step awaits are not how you'd write a real application, but for tests, they make following the control flow and expectations much easier.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.