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

tests: fix flaky TestAgent #4203

Merged
merged 6 commits into from Jun 21, 2023
Merged

tests: fix flaky TestAgent #4203

merged 6 commits into from Jun 21, 2023

Conversation

pmalek
Copy link
Member

@pmalek pmalek commented Jun 21, 2023

What this PR does / why we need it:

This PR introduces a Ticker interface within the license agent and uses that to mock time 🕐 .

This should help us fix #4200.

Which issue this PR fixes:

Fixes #4200.

@pmalek pmalek self-assigned this Jun 21, 2023
@pmalek pmalek marked this pull request as ready for review June 21, 2023 10:21
@pmalek pmalek requested a review from a team as a code owner June 21, 2023 10:21
@programmer04 programmer04 self-requested a review June 21, 2023 10:47
@codecov
Copy link

codecov bot commented Jun 21, 2023

Codecov Report

Patch coverage: 92.5% and no project coverage change.

Comparison is base (68b9e6f) 62.5% compared to head (ba7399a) 62.5%.

❗ Current head ba7399a differs from pull request most recent head b2d137c. Consider uploading reports for the commit b2d137c to get more accurate results

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #4203   +/-   ##
=====================================
  Coverage   62.5%   62.5%           
=====================================
  Files        151     153    +2     
  Lines      16987   17008   +21     
=====================================
+ Hits       10622   10640   +18     
- Misses      5697    5698    +1     
- Partials     668     670    +2     
Impacted Files Coverage Δ
internal/adminapi/backoff_strategy_konnect.go 100.0% <ø> (+1.0%) ⬆️
internal/util/clock/ticker.go 80.0% <80.0%> (ø)
internal/adminapi/client.go 44.6% <100.0%> (ø)
internal/license/agent.go 90.8% <100.0%> (+1.0%) ⬆️
internal/util/clock/clock.go 100.0% <100.0%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pmalek pmalek enabled auto-merge (squash) June 21, 2023 11:42
internal/license/agent.go Outdated Show resolved Hide resolved
test/mocks/ticker.go Outdated Show resolved Hide resolved
internal/license/agent_test.go Show resolved Hide resolved
test/mocks/ticker.go Outdated Show resolved Hide resolved
internal/util/clock/ticker.go Outdated Show resolved Hide resolved
pmalek and others added 2 commits June 21, 2023 13:55
Co-authored-by: Jakub Warczarek <jakub.warczarek@konghq.com>
@pmalek pmalek requested a review from programmer04 June 21, 2023 12:30
Copy link
Member

@programmer04 programmer04 left a comment

Choose a reason for hiding this comment

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

Just one small thing that I spotted

internal/license/agent_test.go Outdated Show resolved Hide resolved
@pmalek pmalek requested a review from programmer04 June 21, 2023 12:52
Copy link
Member

@programmer04 programmer04 left a comment

Choose a reason for hiding this comment

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

🍏

@pmalek pmalek added this to the KIC v2.11.0 milestone Jun 21, 2023
@pmalek pmalek merged commit 11d1c90 into main Jun 21, 2023
26 checks passed
@pmalek pmalek deleted the fix-flaky-TestAgent branch June 21, 2023 13:24
czeslavo pushed a commit that referenced this pull request Jul 13, 2023
* tests: fix flaky TestAgent

* Apply suggestions from code review

Co-authored-by: Jakub Warczarek <jakub.warczarek@konghq.com>

* tests: address review comments, cleanup

* tests: don't use assertions in goroutines in TestAgent

* tests: don't use assertions in goroutines in TestAgent

---------

Co-authored-by: Jakub Warczarek <jakub.warczarek@konghq.com>
czeslavo added a commit that referenced this pull request Jul 13, 2023
Co-authored-by: Patryk Małek <patryk.malek@konghq.com>
Co-authored-by: Jakub Warczarek <jakub.warczarek@konghq.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.

Flaky unit test TestAgent
2 participants