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

Fix intermittent issue with metrics tests #662

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

arsh
Copy link
Contributor

@arsh arsh commented Dec 4, 2023

Description of change

Fixes intermittent issues when testing metrics emission by using rusty_fork_test to make sure there isn't any global state interfering with this test.

Relevant issues: N/A

Does this change impact existing behavior?

No


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the Developer Certificate of Origin (DCO).

@arsh arsh had a problem deploying to PR integration tests December 4, 2023 09:47 — with GitHub Actions Failure
@arsh arsh had a problem deploying to PR integration tests December 4, 2023 09:47 — with GitHub Actions Failure
@arsh arsh had a problem deploying to PR integration tests December 4, 2023 09:47 — with GitHub Actions Failure
@arsh arsh had a problem deploying to PR integration tests December 4, 2023 09:47 — with GitHub Actions Failure
@arsh arsh force-pushed the metrics-tests-failures branch from 60782e9 to 5c3ce0e Compare December 4, 2023 09:49
@arsh arsh temporarily deployed to PR integration tests December 4, 2023 09:50 — with GitHub Actions Inactive
@arsh arsh temporarily deployed to PR integration tests December 4, 2023 09:50 — with GitHub Actions Inactive
@arsh arsh temporarily deployed to PR integration tests December 4, 2023 09:50 — with GitHub Actions Inactive
@arsh arsh temporarily deployed to PR integration tests December 4, 2023 09:50 — with GitHub Actions Inactive
@arsh arsh requested review from passaro and dannycjones December 4, 2023 09:53
dannycjones
dannycjones previously approved these changes Dec 4, 2023
Copy link
Contributor

@dannycjones dannycjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looks good! Thanks for adding the better assertion message for when these fail.

LGTM in its current state. If you have time, can you try the fork suggestion to see if it works?

Copy link
Contributor

@passaro passaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good to me and it fixes the issue. My only concern is that if we ever decide to start looking at metrics in other tests, we will have to review it again.
On the other hand, if we move this test to the tests folder and run it in isolation, the filter becomes redundant.

const TEST_GAUGE: &str = "test_gauge";
const TEST_HISTOGRAM: &str = "test_histogram";
const TEST_METRICS: [&str; 3] = [TEST_COUNTER, TEST_GAUGE, TEST_HISTOGRAM];

#[test]
fn basic_metrics() {
let sink = Arc::new(MetricsSink::new());
let recorder = MetricsRecorder { sink: sink.clone() };
metrics::set_boxed_recorder(Box::new(recorder)).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue is actually with set_boxed_recorder: this is global and supposed to be only called once. At the moment, this is indeed the only test that calls it, but as you noticed, other tests run in parallel may interfere with this one.
Should we move this test to the "integration tests", where it can be run in isolation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Daniel suggested using rusty_fork_test which makes this test to run in a separate process preventing any global state from interfering with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that works too. And it's probably better than my suggestion: no need to expose e.g. MetricsSink.

@arsh arsh force-pushed the metrics-tests-failures branch from 5c3ce0e to 572b89b Compare December 4, 2023 10:21
@arsh arsh had a problem deploying to PR integration tests December 4, 2023 10:21 — with GitHub Actions Failure
@arsh arsh had a problem deploying to PR integration tests December 4, 2023 10:21 — with GitHub Actions Failure
@arsh arsh had a problem deploying to PR integration tests December 4, 2023 10:21 — with GitHub Actions Failure
@arsh arsh had a problem deploying to PR integration tests December 4, 2023 10:21 — with GitHub Actions Failure
@arsh arsh force-pushed the metrics-tests-failures branch from 572b89b to 2bfa549 Compare December 4, 2023 10:30
@arsh arsh temporarily deployed to PR integration tests December 4, 2023 10:30 — with GitHub Actions Inactive
@arsh arsh temporarily deployed to PR integration tests December 4, 2023 10:30 — with GitHub Actions Inactive
@arsh arsh temporarily deployed to PR integration tests December 4, 2023 10:30 — with GitHub Actions Inactive
@arsh arsh temporarily deployed to PR integration tests December 4, 2023 10:30 — with GitHub Actions Inactive
Copy link
Contributor

@passaro passaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dannycjones dannycjones changed the title Fix intermittent issue with metrics tests. Fix intermittent issue with metrics tests Dec 4, 2023
Copy link
Contributor

@dannycjones dannycjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@arsh arsh added this pull request to the merge queue Dec 4, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 4, 2023
@arsh arsh added this pull request to the merge queue Dec 4, 2023
Merged via the queue into awslabs:main with commit ecc2162 Dec 4, 2023
@arsh arsh deleted the metrics-tests-failures branch December 4, 2023 14:30
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.

3 participants