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

Add fixture/snapshot tests #101

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

isker
Copy link
Contributor

@isker isker commented Feb 3, 2025

Add tests that transform vendored API responses (fixtures) into vendored
/metrics output (snapshots), so that we can see how changes to the
exporter implementation affect the actual output of the exporter, in the
form of changes to the snapshots.

I've sourced the fixtures from debug JSON logging of real API responses
from tasks running in AWS. Each task consisted of an ecs_exporter
container and a prometheus container.

My expectation is that fixtures should not be updated unless we become
informed that API responses have materially changed, e.g. because new
features we are using were added, or breaking changes have been made.

I've got two sets of fixtures and snapshots, one for EC2 and one for
Fargate. The API responses differ between EC2 and Fargate
enough (because, among other things, they use two completely different
implementations of the task metadata API, and two different container
runtimes entirely!) that I think it's worth covering them both
independently.

Closes #99.

isker added 2 commits February 9, 2025 18:50
Add tests that transform vendored API responses (fixtures) into vendored
/metrics output (snapshots), so that we can see how changes to the
exporter implementation affect the actual output of the exporter, in the
form of changes to the snapshots.

I've sourced the fixtures from debug JSON logging of real API responses
from tasks running in AWS. Each task consisted of an ecs_exporter
container and a prometheus container.

My expectation is that fixtures should not be updated unless we become
informed that API responses have materially changed, e.g. because new
features we are using were added, or breaking changes have been made.

I've got two sets of fixtures and snapshots, one for EC2 and one for
Fargate. The API responses differ between EC2 and Fargate
enough (because, among other things, they use two completely different
implementations of the task metadata API, and two different container
runtimes entirely!) that I think it's worth covering them both
independently.

Closes prometheus-community#99.

Signed-off-by: Ian Kerins <[email protected]>
Compare to the sibling metric whose name is spelled correctly:
ecs_network_receive_packets_dropped_total.

This commit shows the snapshot tests in action.

Signed-off-by: Ian Kerins <[email protected]>
As the updated task stats fixture for EC2 shows, stopped containers in
EC2 have the empty JSON object for their stats, instead of the `null`
that Fargate has, which triggered a nil pointer dereference that is now
fixed.

Signed-off-by: Ian Kerins <[email protected]>
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.

Automated tests
1 participant