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

test(sharding): Implement sharding tests #2603

Merged
merged 12 commits into from
May 13, 2024
Merged

Conversation

AlejandroCabeza
Copy link
Contributor

@AlejandroCabeza AlejandroCabeza commented Apr 18, 2024

Description

Implement sharding tests

Changes

  • Implement Sharding tests
  • Add minor utilities
  • Move utilities to their own module

@AlejandroCabeza AlejandroCabeza changed the title tests(sharding): Implement sharding tests test(sharding): Implement sharding tests Apr 18, 2024
Copy link

github-actions bot commented Apr 18, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2603-rln-v2-true

Built from 1c9e81b

Copy link

github-actions bot commented Apr 22, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2603-rln-v2

Built from 62d1c80

Copy link

github-actions bot commented Apr 22, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2603-rln-v1

Built from 62d1c80

Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

LGTM! Gorgeous PR, thanks! 🥳
Just added some nitpick comments :)

serverHandler = server.subscribeCompletionHandler(topic)
clientHandler = client.subscribeCompletionHandler(topic)

# await sleepAsync(FUTURE_TIMEOUT)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's better remove that comment :)

Comment on lines +87 to +89
discard await server.publish(
some(topic),
WakuMessage(payload: "message2".toBytes(), contentTopic: "contentTopic"),
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are we testing in the second publish?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In one, the client is the publisher, in the other, the server is.

serverHandler = server.subscribeCompletionHandler(topic1)
clientHandler = client.subscribeCompletionHandler(topic2)

await sleepAsync(FUTURE_TIMEOUT)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have the impression that this isn't needed, comparing to the previous test :)

WakuMessage(payload: "message1".toBytes(), contentTopic: contentTopicShort),
)
let
serverResult1 = await serverHandler.waitForResult(FUTURE_TIMEOUT_LONG)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why we need a longer wait in this case?


# When the server publishes a message in the server's subscribed topic
discard await server.publish(
some(pubsubTopic1),
Copy link
Collaborator

Choose a reason for hiding this comment

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

You did a great job of calculating the value and then hard-coding it above but I wonder if we could use a value obtained from codebase logic instead of using a hard-coded value. That would also help to understand how the pubsub topic is inferred from the content topic

Copy link
Contributor

@gabrielmer gabrielmer left a comment

Choose a reason for hiding this comment

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

Looks amazing! Thanks so much 🤩

tests/waku_enr/test_sharding.nim Show resolved Hide resolved
Copy link
Contributor

@NagyZoltanPeter NagyZoltanPeter left a comment

Choose a reason for hiding this comment

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

Amazing!!!
Maybe there is some room to shorten runtime of the tests.

)
let
serverResult1 = await serverHandler.waitForResult(FUTURE_TIMEOUT)
clientResult1 = await clientHandler.waitForResult(FUTURE_TIMEOUT)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it is ok to shrink timeout in such error case as it won't complete before! WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The FUTURE_TIMEOUT is a 1s const. Do you think it's too much?

clientResult2 = await clientHandler.waitForResult(FUTURE_TIMEOUT)

# Then the client receives the message but the server does not
check serverResult2.isErr()
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiousity: Is it possible - a valid scenario - to publish message on topic I'm not subscribed to? Seems to me controversial due I cannot relay message on topic Im not subscribed to. Am I missing sthg?

WakuMessage(payload: "message2".toBytes(), contentTopic: contentTopic2),
)
let
serverResult2 = await serverHandler.waitForResult(FUTURE_TIMEOUT_LONG)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should not wait that long (10sec) for something will not occur...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might've been copy-paste mistake. I've updated it.

assertResultOk(await serverHandler1.waitForResult(FUTURE_TIMEOUT))
assertResultOk(await clientHandler1.waitForResult(FUTURE_TIMEOUT))
check:
(await serverHandler2.waitForResult(FUTURE_TIMEOUT)).isErr()
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm not mistaken it is 6 sec wait added here. Can it be shorter or wait parallel somehow and than check ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good question. I'm not sure how I'd do this in Nim, perhaps the waitFor allFutures(@[])? But I'm not sure if that behaves like that.

assertResultOk(await serverHandler2.waitForResult(FUTURE_TIMEOUT))
assertResultOk(await clientHandler2.waitForResult(FUTURE_TIMEOUT))
check:
(await serverHandler1.waitForResult(FUTURE_TIMEOUT)).isErr()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

@AlejandroCabeza AlejandroCabeza merged commit 6c3ad50 into master May 13, 2024
14 of 15 checks passed
@AlejandroCabeza AlejandroCabeza deleted the tests/sharding branch May 13, 2024 15:43
Ivansete-status pushed a commit that referenced this pull request May 14, 2024
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

4 participants