-
Notifications
You must be signed in to change notification settings - Fork 53
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
chore: adding NetConfig test suite #2091
Conversation
This PR may contain changes to configuration options of one of the apps. If you are introducing a breaking change (i.e. the set of options in latest release would no longer be applicable) make sure the original option is preserved with a deprecation note for 2 following releases before it is actually removed. Please also make sure the label |
You can find the image built from this PR at
Built from a4ab1a8 |
../../apps/wakunode2/internal_config, | ||
../wakunode2/test_app, |
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.
When importing defaultTestWakuNodeConf
from test_app
into other test suites, the test_app
suite was being re-run as part of the suites importing it. For easier defaultTestWakuNodeConf
's reusability, moved the function to external_config
, mimicking newTestWakuNode
, which is reused by many test suites and is defined in wakunode.nim
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.
Ah, made a comment about this elsewhere before seeing this. wakunode.nim
is a testlib
- in other words, it's designed to be a utility module for functions useful in tests. newTestWakuNode
defaultTestWakuNodeConf
etc. shouldn't be defined in any "production" modules (test code should remain completely separate. The way to prevent test_app
from being run multiple times for each import is to move defaultTestWakuNodeConf
to a test helper module. I'd suggest just adding it to testlib/wakunode.nim
and importing in both test_app
and test_waku_netconfig
tests/test_waku_netconfig.nim
Outdated
check: | ||
netConfig.announcedAddresses.len == 2 # External address + wsHostAddress | ||
netConfig.announcedAddresses[1] == (ip4TcpEndPoint(extIp, | ||
conf.websocketPort) & wsFlag(wssEnabled)) |
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.
Note that in order to configure WS using an extIp
, the published port isn't extPort
but conf.websocketPort
. For websockets we bind to and announce the same port number.
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.
Looks good and covers quite a lot! Thanks for this. Much better than what we have (which was noting 😅 ). Feel free to mark as ready for review once you think it can be merged.
tests/test_waku_netconfig.nim
Outdated
check: | ||
netConfigRes.isOk() | ||
|
||
asyncTest "AnnouncedAddresses contains only bind address when no external addresses are provided": |
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.
Indentation seem a bit weird.
tests/test_waku_netconfig.nim
Outdated
netConfig.announcedAddresses[0] == formatListenAddress(ip4TcpEndPoint(conf.listenAddress, conf.tcpPort)) | ||
|
||
|
||
asyncTest "AnnouncedAddresses contains external address if extIp/Port are provided": |
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.
Ditto in terms of indentation and for other tests (I think they should be single indented to be considered part of "Waku Netconfig" suite
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.
Good catch! For some reason the tests were still being run as part of the test suite with that indentation, which is pretty interesting. Just pushed a fix for it - thank you!
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. defaultTestWakuNodeConf
should not be defined in a "production" module llike external_config.nim
, but once this has been moved I'll be happy for the suite to be merged. No need to re-request review from my side. Great job!
apps/wakunode2/external_config.nim
Outdated
proc defaultTestWakuNodeConf*(): WakuNodeConf = | ||
WakuNodeConf( | ||
tcpPort: Port(60000), | ||
websocketPort: Port(8000), | ||
listenAddress: ValidIpAddress.init("0.0.0.0"), | ||
rpcAddress: ValidIpAddress.init("127.0.0.1"), | ||
restAddress: ValidIpAddress.init("127.0.0.1"), | ||
metricsServerAddress: ValidIpAddress.init("127.0.0.1"), | ||
dnsAddrsNameServers: @[ValidIpAddress.init("1.1.1.1"), ValidIpAddress.init("1.0.0.1")], | ||
nat: "any", | ||
maxConnections: 50, | ||
topics: @["/waku/2/default-waku/proto"], | ||
relay: true | ||
) |
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.
Why has this been moved from test_app.nim
? I wouldn't move any test code into "production" code.
../../apps/wakunode2/internal_config, | ||
../wakunode2/test_app, |
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.
Ah, made a comment about this elsewhere before seeing this. wakunode.nim
is a testlib
- in other words, it's designed to be a utility module for functions useful in tests. newTestWakuNode
defaultTestWakuNodeConf
etc. shouldn't be defined in any "production" modules (test code should remain completely separate. The way to prevent test_app
from being run multiple times for each import is to move defaultTestWakuNodeConf
to a test helper module. I'd suggest just adding it to testlib/wakunode.nim
and importing in both test_app
and test_waku_netconfig
Ooh now everything makes much more sense! I didn't notice that Thanks so much! |
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 that! You created many more test cases than I could imagine 🥇
Nevertheless, there are a few things that need to be revisited :)
It is especially important the comment about apps/wakunode2/external_config.nim
. I'd prevent changing it.
Cheers!
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.
No further comments than what was already said.
I just feel like we could use the type system in cases like this to enforce some "rules".
My 0.02$
I'm not sure I fully understand the idea. Is it about setting explicitly the type when declaring variables instead of having the types being automatically inferred so we enforce the return types of procs? Or what kind of rules are you thinking of? |
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! Thanks for it! 💯
Probably not practical to do this here but the type system can help enforcing requirement like For example you could use some type to represent the state.
Maybe the Nim type system is not made to do this though IDK. I only done this in Rust. |
* chore: add retention policy with GB or MB limitation #1885 * chore: add retention policy with GB or MB limitation * chore: updated code post review- retention policy * ci: extract discordNotify to separate file Signed-off-by: Jakub Sokołowski <jakub@status.im> * ci: push images to new wakuorg/nwaku repo Signed-off-by: Jakub Sokołowski <jakub@status.im> * ci: enforce default Docker image tags strictly Signed-off-by: Jakub Sokołowski <jakub@status.im> * ci: push GIT_REF if it looks like a version Signed-off-by: Jakub Sokołowski <jakub@status.im> * fix: update wakuv2 fleet DNS discovery enrtree https://github.com/status-im/infra-misc/issues/171 * chore: resolving DNS IP and publishing it when no extIp is provided (#2030) * feat(coverage): Add simple coverage (#2067) * Add test aggregator to all directories. * Implement coverage script. * fix(ci): fix name of discord notify method Also use absolute path to load Groovy script. Signed-off-by: Jakub Sokołowski <jakub@status.im> * chore(networkmonitor): refactor setConnectedPeersMetrics, make it partially concurrent, add version (#2080) * chore(networkmonitor): refactor setConnectedPeersMetrics, make it partially concurrent, add version * add more metrics, refactor how most metrics are calculated * rework metrics table fillup * reset connErr to make sure we honour successful reconnection * chore(cbindings): Adding cpp example that integrates the 'libwaku' (#2079) * Adding cpp example that integrates the `libwaku` --------- Co-authored-by: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com> * fix(ci): update the dependency list in pre-release WF (#2088) * chore: adding NetConfig test suite (#2091) --------- Signed-off-by: Jakub Sokołowski <jakub@status.im> Co-authored-by: Jakub Sokołowski <jakub@status.im> Co-authored-by: Anton Iakimov <yakimant@gmail.com> Co-authored-by: gabrielmer <101006718+gabrielmer@users.noreply.github.com> Co-authored-by: Álex Cabeza Romero <alex93cabeza@gmail.com> Co-authored-by: Vaclav Pavlin <vaclav@status.im> Co-authored-by: Ivan Folgueira Bande <128452529+Ivansete-status@users.noreply.github.com> Co-authored-by: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com>
Description
Added test suite to cover common NetConfig settings
Changes
./tests/test_waku_netconfig.nim
with a NetConfig test suitedefaultTestWakuNodeConf
fromtest_app.nim
toexternal_config.nim
defaultTestWakuNodeConf
to use our current defaultlistenAddress
0.0.0.0
and added more default parametersIssue
closes #1540