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

Refactor non-docker container stats and add unit tests #4200

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

sparrc
Copy link
Contributor

@sparrc sparrc commented Jun 5, 2024

Summary

This is a minor followup to #4196

Change NonDockerContainerStats from a pointer to a reference, and change the restartCount field from a reference to a pointer.

What this does is enables the getNonDockerContainerStats function to always return the object, but only return restartCount when it should be set to a non-nil value. This will make NonDockerContainerStats easier to extend in the future, and allows for checking if restartCount is set or not explicitly. We expect this field to not be set (nil) when the feature is not enabled. This allows for explicit testing and checking of three scenarios:

  1. When restart policy is not enabled or unset, restartCount == nil
  2. When restart policy is enabled but no restarts occurred, restartCount == 0
  3. When restart policy is enabled and restarts occurred, restartCount > 0

Testing

Unit tests were added to verify exact scenarios when we expect restartCount to be nil, zero, and non-zero.

Description for the changelog

NA

Licensing

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

@sparrc sparrc requested a review from a team as a code owner June 5, 2024 19:24
@sparrc sparrc force-pushed the crp-new-metric-v2 branch from af9aa58 to 6a64e11 Compare June 5, 2024 19:30
@sparrc sparrc added the bot/test label Jun 5, 2024
@sparrc sparrc changed the title [wip] Refactor non-docker container stats and add unit tests Refactor non-docker container stats and add unit tests Jun 5, 2024
@sparrc sparrc merged commit 05aebff into aws:feature/crp Jun 6, 2024
40 checks passed
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.

None yet

4 participants