-
Notifications
You must be signed in to change notification settings - Fork 73
Add integration test coverage where meshsync handles ReSync request a… #493
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
base: master
Are you sure you want to change the base?
Conversation
|
Yay, your first pull request! 👍 A contributor will be by to give feedback soon. In the meantime, please review the Meshery Contributors' Welcome Guide and sure to join the community Slack. |
Summary of ChangesHello @CodexRaunak, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the integration test suite by introducing a new test case that specifically validates the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds an integration test to verify that meshsync correctly handles a ReSync request and republishes cluster data. The changes look good and the test case is a valuable addition. I've provided a few suggestions to improve maintainability and fix a minor bug in the new test case. Specifically, I've recommended refactoring the use of a global variable for the broker instance in favor of explicit dependency passing, fixing an issue where the test was logging incorrect data, and replacing magic numbers with named constants for better readability.
integration-tests/meshsync_as_binary_with_k8s_cluster_integration_test.go
Outdated
Show resolved
Hide resolved
integration-tests/meshsync_as_binary_with_k8s_cluster_test_cases_mode_a_broker_test.go
Outdated
Show resolved
Hide resolved
integration-tests/meshsync_as_binary_with_k8s_cluster_test_cases_mode_a_broker_test.go
Outdated
Show resolved
Hide resolved
5e5da85 to
a500f92
Compare
|
@n2h9 can we have a review on this. Added a integration test where |
n2h9
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution @CodexRaunak 🙇♀️ .
-
It could be that the implemented test is not testing the resync functionality, but the initial data produced by meshsync. The code reads from
outchannel, this channel is being populated even before call to resync. It is how meshsync works, it starts, discovers k8s cluster, and pushes data to the broker. We need to first read up all the messages from the channel, only when there is no more active publishing from meshsync, we send resync-requests and then check that we receive something again. Preferably do some intelligent checks that we received the same or almost the same data. -
I think
brokerMessageHandleris not the best place for triggering resync, this is a part which handles messages from the broker. We still can use it for both initial messages processing, and after resync is being triggered. -
The current tests, neither
TestMeshsyncBinaryWithK8sClusterIntegrationnorTestMeshsyncLibraryWithK8sClusterCustomBrokerIntegrationdo not provide an option to publish to meshsync topics right now. We will need
or enhance one (or both) of them (and hence the test case structure as well);
or write a new top level test;
integration-tests/meshsync_as_binary_with_k8s_cluster_test_cases_mode_a_broker_test.go
Outdated
Show resolved
Hide resolved
…nd publishes cluster data back Signed-off-by: Raunak Madan <[email protected]>
a500f92 to
49df6cf
Compare
…ts initial discovery Signed-off-by: Raunak Madan <[email protected]>
…rely on events instead of timers Signed-off-by: Raunak Madan <[email protected]>
|
Thanks for this feedback Nikita Before triggering resync, as we want to wait for the initial discovery done by the meshsync, there are 2 ways (as of my research) we could check that:
For the intelligent checks we are comparing the data before resync and the data we got after the resync. Could u please give me review on this approach, I am open for any suggestions. |
Hey @CodexRaunak hello 👋 ! Thank you for you contribution 👍 There are could be couple potential issues with this approach:
There are dynamic informers, which emit events on any updates to tracked resources. The point in this pr where you added DISCOVERY_COMPLETE message emission, as far as I understand, is a point where dynamic informers are set up. It does not necessarily mean that all "initial events" are already published. A possible approach could be to perform this determination only on the integration test side. |
…overy Signed-off-by: Raunak Madan <[email protected]>
Can u re-review it, |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #493 +/- ##
=========================================
- Coverage 7.32% 7.31% -0.01%
=========================================
Files 35 35
Lines 1762 1764 +2
=========================================
Hits 129 129
- Misses 1623 1625 +2
Partials 10 10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Raunak Madan <[email protected]>
n2h9
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a good progress here 👍
left a couple comments
thank you 🙇♀️
|
|
||
| if msg.Object != nil { | ||
| kr, err := unmarshalObject(msg.Object) | ||
| if err == nil && kr.Kind != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should handle unmarshaling error, how we do it in other test cases (for both discovery and after resync cases).
|
|
||
| // Stop once threshold reached | ||
| if len(afterResync) >= resyncSuccessThreshold { | ||
| goto DONE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the purpose of this goto is to break from the loop, in that case it is more common to put a label on the loop and then inside the loop use break <label>, check: Effective Go#switch (scroll down a bit to "break out of a surrounding loop").
Also, I think, we have a single loop, no nested loops, so simple break should do the thing as well.
|
|
||
| resyncRequested := false | ||
|
|
||
| for msg := range out { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the current approach mixes in together "discovery", "after discovery" stages, which looks to me as independent and sequential.
The triggering of resync messages does not depend on the messages, probably should be outside of the loop.
I suggest to break this loop into 3 sequential pieces:
- discovery stage: reading from
out, handling debounce logic, when debounce condition is met, stops reading fromout; - trigger resync message;
- after the discovery stage: reading from
out.
This PR fixes #481
Description
meshsynchandlesReSyncrequest and publishes cluster data backReSyncrequest using the samebrbroker.ListenToRequests()goroutine receives the message → sees Entity ==resync-discovery→ sends a struct into theReSyncchanneldebouncedRestartDiscoveryunmarshalObject()to check for Kubernetes resourceSigned commits