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

[DBM-2797] fix rate limited activity collection test case #15715

Merged

Conversation

lu-zhengda
Copy link
Contributor

@lu-zhengda lu-zhengda commented Aug 29, 2023

What does this PR do?

This PR fixes the flakey test test_activity_collection_rate_limit.
The test relies on time.sleep(sleep_time) to run the activity collection for certain period of time and then uses the sleep_time to calculate the maximum possible metrics to be collected during this time period.

The reason why the test sometimes fails is because check.cancel() cancels a list of checks one by one. By the time it successfully cancels _query_activity, the collection of the metrics might run slightly over the sleep_time, causing the number of metrics collected exceed the maximum number we are expecting.

The change is to calculate the expected max_collections based on time_elapsed. This way it provides a more accurate view of how much time the check has been running.

Motivation

More robust logic in calculating the expected max_collections to prevent tests fails intermittently.

Additional Notes

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Changelog entries must be created for modifications to shipped code
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.

@lu-zhengda lu-zhengda self-assigned this Aug 29, 2023
@lu-zhengda lu-zhengda marked this pull request as ready for review August 29, 2023 18:57
@lu-zhengda lu-zhengda requested review from a team as code owners August 29, 2023 18:57
@codecov
Copy link

codecov bot commented Aug 29, 2023

Codecov Report

Merging #15715 (694b09a) into master (574bcdf) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Flag Coverage Δ
mysql 87.37% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@github-actions
Copy link

Test Results

     16 files       16 suites   41m 44s ⏱️
   138 tests    138 ✔️ 0 💤 0
1 104 runs  1 095 ✔️ 9 💤 0

Results for commit 694b09a.

@lu-zhengda lu-zhengda merged commit a822589 into master Aug 30, 2023
@lu-zhengda lu-zhengda deleted the zhengda.lu/fix-test_activity_collection_rate_limit branch August 30, 2023 14:58
boluwaji-deriv pushed a commit to boluwaji-deriv/integrations-core that referenced this pull request Aug 30, 2023
FlorentClarret added a commit that referenced this pull request Aug 31, 2023
#15629)

* Revise postgresql.replication_delay to Function with Archive WAL-driven PostgreSQL Replica

* modify query and also add changelog message

* update master with branch

* update master with branch

* Add short hand for force env rebuild in test (#15716)

* add short hand for force-env-rebuild

* add changelog entry

* styling

* [Release] Update metadata (#15717)

* [Release] Bumped postgres version to 14.2.1 (#15713)

* Bump oracledb version (#15595)

* Bump oracledb version

* update reqs

* update changelog

* Mark one metric as optional (#15719)

* Update the test environments (#15644)

* Update the test environments

* Apply suggestions from code review

Co-authored-by: Ofek Lev <ofekmeister@gmail.com>

* update metadata.csv

---------

Co-authored-by: Ofek Lev <ofekmeister@gmail.com>

* [DBM-2685] Fix explaining parameterized queries flood server logs (#15612)

* check if query is parameterized before blindly explain then fail

* update CHANGELOG

* skip explain parameterized query test for pg version < 12

* fix rate limited activity collection test case (#15715)

* [DBM-2734] fix test_snapshot_xmin for pg > 13 (#15718)

* fix test_snapshot_xmin for pg > 13

* reorder the steps to first collect metrics

* remove check.cancel()

---------

Co-authored-by: Steven Yuen <steven.yuen@datadoghq.com>
Co-authored-by: Andrew Zhang <andrew.zhang@datadoghq.com>
Co-authored-by: vivek-datadog <131680079+vivek-datadog@users.noreply.github.com>
Co-authored-by: Florent Clarret <florent.clarret@datadoghq.com>
Co-authored-by: Ofek Lev <ofekmeister@gmail.com>
Co-authored-by: Zhengda Lu <zhengda.lu@datadoghq.com>
lu-zhengda added a commit that referenced this pull request Sep 27, 2023
#15629)

* Revise postgresql.replication_delay to Function with Archive WAL-driven PostgreSQL Replica

* modify query and also add changelog message

* update master with branch

* update master with branch

* Add short hand for force env rebuild in test (#15716)

* add short hand for force-env-rebuild

* add changelog entry

* styling

* [Release] Update metadata (#15717)

* [Release] Bumped postgres version to 14.2.1 (#15713)

* Bump oracledb version (#15595)

* Bump oracledb version

* update reqs

* update changelog

* Mark one metric as optional (#15719)

* Update the test environments (#15644)

* Update the test environments

* Apply suggestions from code review

Co-authored-by: Ofek Lev <ofekmeister@gmail.com>

* update metadata.csv

---------

Co-authored-by: Ofek Lev <ofekmeister@gmail.com>

* [DBM-2685] Fix explaining parameterized queries flood server logs (#15612)

* check if query is parameterized before blindly explain then fail

* update CHANGELOG

* skip explain parameterized query test for pg version < 12

* fix rate limited activity collection test case (#15715)

* [DBM-2734] fix test_snapshot_xmin for pg > 13 (#15718)

* fix test_snapshot_xmin for pg > 13

* reorder the steps to first collect metrics

* remove check.cancel()

---------

Co-authored-by: Steven Yuen <steven.yuen@datadoghq.com>
Co-authored-by: Andrew Zhang <andrew.zhang@datadoghq.com>
Co-authored-by: vivek-datadog <131680079+vivek-datadog@users.noreply.github.com>
Co-authored-by: Florent Clarret <florent.clarret@datadoghq.com>
Co-authored-by: Ofek Lev <ofekmeister@gmail.com>
Co-authored-by: Zhengda Lu <zhengda.lu@datadoghq.com>
lu-zhengda added a commit that referenced this pull request Sep 28, 2023
#15925)

* Revise postgresql.replication_delay to Function with Archive WAL-driv… (#15629)

* Revise postgresql.replication_delay to Function with Archive WAL-driven PostgreSQL Replica

* modify query and also add changelog message

* update master with branch

* update master with branch

* Add short hand for force env rebuild in test (#15716)

* add short hand for force-env-rebuild

* add changelog entry

* styling

* [Release] Update metadata (#15717)

* [Release] Bumped postgres version to 14.2.1 (#15713)

* Bump oracledb version (#15595)

* Bump oracledb version

* update reqs

* update changelog

* Mark one metric as optional (#15719)

* Update the test environments (#15644)

* Update the test environments

* Apply suggestions from code review

Co-authored-by: Ofek Lev <ofekmeister@gmail.com>

* update metadata.csv

---------

Co-authored-by: Ofek Lev <ofekmeister@gmail.com>

* [DBM-2685] Fix explaining parameterized queries flood server logs (#15612)

* check if query is parameterized before blindly explain then fail

* update CHANGELOG

* skip explain parameterized query test for pg version < 12

* fix rate limited activity collection test case (#15715)

* [DBM-2734] fix test_snapshot_xmin for pg > 13 (#15718)

* fix test_snapshot_xmin for pg > 13

* reorder the steps to first collect metrics

* remove check.cancel()

---------

Co-authored-by: Steven Yuen <steven.yuen@datadoghq.com>
Co-authored-by: Andrew Zhang <andrew.zhang@datadoghq.com>
Co-authored-by: vivek-datadog <131680079+vivek-datadog@users.noreply.github.com>
Co-authored-by: Florent Clarret <florent.clarret@datadoghq.com>
Co-authored-by: Ofek Lev <ofekmeister@gmail.com>
Co-authored-by: Zhengda Lu <zhengda.lu@datadoghq.com>

* update changelog

* update changelog

* update changelog

* remove duplicate changelog entry

* update changelog

---------

Co-authored-by: boluwaji-deriv <97861462+boluwaji-deriv@users.noreply.github.com>
Co-authored-by: Steven Yuen <steven.yuen@datadoghq.com>
Co-authored-by: Andrew Zhang <andrew.zhang@datadoghq.com>
Co-authored-by: vivek-datadog <131680079+vivek-datadog@users.noreply.github.com>
Co-authored-by: Florent Clarret <florent.clarret@datadoghq.com>
Co-authored-by: Ofek Lev <ofekmeister@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants