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

Addition of tests for dlqMessageHandler in common domain #5969

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

abhishekj720
Copy link
Contributor

@abhishekj720 abhishekj720 commented May 6, 2024

What changed?
Added test for start, stop, merge and emitDLQSize in dlqMessageHandler

Why?
As part of test coverage week

How did you test it?
Unit tests

Potential risks
No risks, as these are unit tests

Release notes

Documentation Changes

Copy link

codecov bot commented May 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.00%. Comparing base (17a7ba7) to head (513e789).
Report is 5 commits behind head on master.

❗ Current head 513e789 differs from pull request most recent head 008c622. Consider uploading reports for the commit 008c622 to get more accurate results

Additional details and impacted files
Files Coverage Δ
common/domain/dlq_message_handler.go 94.23% <ø> (ø)

... and 42 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17a7ba7...008c622. Read the comment docs.

common/domain/dlqMessageHandler_test.go Show resolved Hide resolved
common/domain/dlqMessageHandler_test.go Outdated Show resolved Hide resolved
common/domain/dlqMessageHandler_test.go Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented May 7, 2024

Pull Request Test Coverage Report for Build 018f56af-f81d-4dcb-81d4-fe4ed2c71f51

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 2 files are covered.
  • 43 unchanged lines in 15 files lost coverage.
  • Overall coverage increased (+0.02%) to 68.432%

Files with Coverage Reduction New Missed Lines %
tools/cli/admin_db_decode_thrift.go 1 71.79%
service/history/queue/timer_queue_processor_base.go 1 78.28%
service/matching/taskReader.go 2 84.88%
common/persistence/sql/sqlplugin/postgres/task.go 2 73.4%
service/history/task/transfer_active_task_executor.go 2 72.9%
common/util.go 2 91.78%
service/matching/taskListManager.go 2 81.16%
service/history/execution/mutable_state_util.go 2 78.52%
common/membership/hashring.go 2 84.69%
service/history/task/task.go 3 84.81%
Totals Coverage Status
Change from base Build 018f54e5-7508-40f1-ae99-a0884c40b0fa: 0.02%
Covered Lines: 100515
Relevant Lines: 146882

💛 - Coveralls

common/domain/dlq_message_handler_test.go Show resolved Hide resolved
common/domain/dlq_message_handler_test.go Show resolved Hide resolved
// Wait a bit to ensure the loop exits
time.Sleep(1 * time.Nanosecond)

s.dlqMessageHandler.logger.Warn("Failed to get DLQ size.", tag.Error(errors.New("DomainReplicationQueueSizeLimit")))
Copy link
Contributor

Choose a reason for hiding this comment

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

did you mean to add an expected warning call here instead of actually calling warn function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, so should use mockLogger? this is a testlogger: testlogger.New(s.Suite.T())

Copy link
Contributor

Choose a reason for hiding this comment

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

yes. you are just adding another log. no validation here.
as mentioned in other comment let's ignore this edge case. not much value in validating warning log is there

Comment on lines +539 to +546
// Allow some time for the goroutine to run and tick at least once
time.Sleep(1 * time.Nanosecond)

// Close the done channel to signal the loop to stop
close(s.dlqMessageHandler.done)

// Wait a bit to ensure the loop exits
time.Sleep(1 * time.Nanosecond)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this setup ensures the desired err handling branch to be hit. It's a tricky one and I think we can ignore that

Copy link
Contributor

Choose a reason for hiding this comment

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

yea. if we wanted to test that we'd probably need to:

  • start the goroutine
  • advance the clock
  • wait for the mock call to occur (use a .DoAndReturn to monitor this, e.g. close a channel in there)
  • then close the done chan

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, maybe will add some time later

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 suggestion would be to skip the test for now then, time.Sleep tends to cause test flakiness in CD pipelines and make everyone sad

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

9 participants