-
Notifications
You must be signed in to change notification settings - Fork 54
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
test(gossipsub): Part 1 Test cases covering subscribe and unsubscribe Events #1201
base: master
Are you sure you want to change the base?
Conversation
how about |
# Addition of Designed Test cases for 6. Topic Membership Tests: https://www.notion.so/Gossipsub-651e02d4d7894bb2ac1e4edb55f3192d | ||
|
||
# Simulate the `SUBSCRIBE` event and check proper handling in the mesh and gossipsub structures | ||
asyncTest "handle SUBSCRIBE event": |
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.
This test is very similar to
asyncTest "subscribe/unsubscribeAll": |
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.
Agree on this but little difference is there
Subscription Handler:
Newly added test (handle SUBSCRIBE event):
Uses an anonymous function when subscribing to the topic, and it does not test for the dynamic dispatch mechanism used to handle topic messages.
Existing test (subscribe/unsubscribeAll):
It defines a handler function for handling messages sent to the subscribed topic. This makes the test more practical for simulating message reception and processing. It also uses dynamic dispatch for testing the subscription and unsubscription.
You can keep the newly added test if you want a lightweight, focused check for basic subscription functionality. If not required then will remove it as it was added keeping in mind for light sanity @AlejandroCabeza
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.
Uses an anonymous function when subscribing to the topic, and it does not test for the dynamic dispatch mechanism used to handle topic messages.
This doesn't need to be tested in this test.
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.
But we could replace the existing test with the first two you created. There's a lot of code repetition in testgossipinternal
as pointed out here #1207.
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.
Agree on it. I Will follow this as another task and can move all common lines of code to func to ensure testgossipinternal is clean with no redundant line of code in relevant file as well
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.
Please remove asyncTest "subscribe/unsubscribeAll"
in testgossipinternal.
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.
Please remove
asyncTest "subscribe/unsubscribeAll"
in testgossipinternal.
Removed
We follow conventional commits for the PR title. In this case, it will start with |
I am adding other tests in the same file related to Topic Membership Tests for Join topic, leave topic, and mesh updated on peer subscribing and leaving topic. Earlier suggestion looks fine but else will modify as per your suggestion |
Thanks. Will follow same in upcoming PRs |
added test wrt subscribe and unsubscribe added tests/pubsub/testgossipinternal2 file linters feat: rendezvous refactor (#1183) Hello! This PR aim to refactor rendezvous code so that it is easier to impl. Waku rdv strategy. The hardcoded min and max TTL were out of range with what we needed and specifying which peers to interact with is also needed since Waku deals with peers on multiple separate shards. I tried to keep the changes to a minimum, specifically I did not change the name of any public procs which result in less than descriptive names in some cases. I also wanted to return results instead of raising exceptions but didn't. Would it be acceptable to do so? Please advise on best practices, thank you. --------- Co-authored-by: Ludovic Chenut <ludovic@status.im> refactor and suite name refactor chore(ci): Enable S3 caching for interop (#1193) - Adds our S3 bucket for caching docker images as Protocol Labs shut down their shared one. - Remove the free disk space workaround that prevented the jobs from failing for using too much space for the images. --------- Co-authored-by: diegomrsantos <diego@status.im> PR review comment changes
9230ecd
to
eb2f6bf
Compare
I'm not sure if gossip membership makes sense. |
check gossipSub.topics.contains(topic) | ||
|
||
# Check if the topic is added to gossipsub and the peers list is not empty | ||
check gossipSub.gossipsub[topic].len() > 0 |
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.
If we move this line before subscribeToTopics(gossipSub, @[topic])
it's already true, so we aren't testing anything here.
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.
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.
what was exactly 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.
Its after subscription and I am testing subscribed value
check gossipSub.gossipsub[topic].len() == 5
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1201 +/- ##
==========================================
+ Coverage 84.54% 84.55% +0.01%
==========================================
Files 93 93
Lines 16650 16681 +31
==========================================
+ Hits 14076 14104 +28
- Misses 2574 2577 +3 |
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.
LGTM
check gossipSub.topics.contains(topic) | ||
|
||
# Check if the topic is added to gossipsub and the peers list is not empty | ||
check gossipSub.gossipsub[topic].len() > 0 |
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.
since the numbers of peers is set to 5 so to ensure the length is set correctly we could change to
check gossipSub.gossipsub[topic].len() == 5
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.
done
gossipSub.topicParams[topic] = TopicParams.init() | ||
gossipSub.gossipsub[topic] = initHashSet[PubSubPeer]() | ||
|
||
if gossipSub.topics.len < gossipSub.topicsHigh: |
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.
since we want to test the reaction of the logic if we subscribed to more than the limit then we need to try to add more subscribtions than the limit and check the reaction
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.
let topicCount = 15 # Total number of topics to be tested
let gossipSubParams = 10 # Subscription limit for the topics
let topicNames = toSeq(mapIt(0..topicCount - 1, "topic" & $it))
checking subscription beyond the limit and asserting it.
gossipSub.PubSub.unsubscribeAll(topic) | ||
|
||
# Simulate the `SUBSCRIBE` to the topic and check proper handling in the mesh and gossipsub structures | ||
asyncTest "handle SUBSCRIBE to the topic": |
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.
This test is still not checking changes to the mesh.
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.
Mesh test is written separately in PR Part 2 as per designed Test case
- "handle JOIN topic and mesh is updated"
- "handle LEAVE topic and mesh is updated"
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.
Im not sure this separation is necessary tbh.
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.
merged Part 2 PR in this PR only
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.
There are things to be addressed
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.
Thanks for review.
Have addressed all review as per requirements
check gossipSub.topics.contains(topic) | ||
|
||
# Check if the topic is added to gossipsub and the peers list is not empty | ||
check gossipSub.gossipsub[topic].len() > 0 |
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.
done
gossipSub.topicParams[topic] = TopicParams.init() | ||
gossipSub.gossipsub[topic] = initHashSet[PubSubPeer]() | ||
|
||
if gossipSub.topics.len < gossipSub.topicsHigh: |
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.
let topicCount = 15 # Total number of topics to be tested
let gossipSubParams = 10 # Subscription limit for the topics
let topicNames = toSeq(mapIt(0..topicCount - 1, "topic" & $it))
checking subscription beyond the limit and asserting it.
check gossipSub.topics.contains(topic) | ||
|
||
# Check if the topic is added to gossipsub and the peers list is not empty | ||
check gossipSub.gossipsub[topic].len() > 0 |
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.
Its after subscription and I am testing subscribed value
check gossipSub.gossipsub[topic].len() == 5
gossipSub.PubSub.unsubscribeAll(topic) | ||
|
||
# Simulate the `SUBSCRIBE` to the topic and check proper handling in the mesh and gossipsub structures | ||
asyncTest "handle SUBSCRIBE to the topic": |
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.
Mesh test is written separately in PR Part 2 as per designed Test case
- "handle JOIN topic and mesh is updated"
- "handle LEAVE topic and mesh is updated"
|
||
for topic in topicNames: | ||
if gossipSub.topics.len < gossipSub.topicsHigh: |
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.
Now that I think about this, this doesn't make a lot of sense. The limit shouldn't be handled by the test, not manually by us. This is what the test should be asserting, actually: That regardless of the amount of subscriptions done, it shouldn't exceed the limit.
P.S.: Please, remove all the PubSub
usages you added as these are GossipSub
cases.
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.
PubSub removed
Test Plan: https://www.notion.so/Gossipsub-651e02d4d7894bb2ac1e4edb55f3192d
Topic Membership Tests:
Test added: (TC6.6: Verify the handling of subscription changes when the underlying pubsub framework sends SUBSCRIBE and UNSUBSCRIBE events.)
SUBSCRIBE
event and check proper handling in the mesh and gossipsub structuresPart 2:
TC6.1: Verify that peers can correctly join a topic using JOIN(topic).
TC6.2: Ensure that peers can correctly leave a topic using LEAVE(topic).
TC6.5: Multiple peers join and leave topic simultaneously