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

feat: use nwaku docker instead of building binaries #1259

Merged
merged 5 commits into from
Apr 17, 2023

Conversation

danisharora099
Copy link
Collaborator

@danisharora099 danisharora099 commented Mar 23, 2023

Problem

When testing nwaku interop/running tests locally, the nwaku repo needs to be cloned (the first time) & built (along with building the Nim compiler) which takes a lot of time

Solution

Using tagged nwaku images directly within the js-waku context using dockerode that would allow for:

  • easily switching between nwaku versions without rebuilding binary
  • no need to clone nwaku within the repo
  • significantly reduce time it takes for CI to run (=$)
  • spawn/run multiple tests async (can leverage in future)

TODO:

  • fix CI for go-waku (use statusteam/go-waku:latest)

Notes

@danisharora099 danisharora099 changed the title Feat/nwaku docker feat: dockerize nwaku for tests Mar 23, 2023
@danisharora099 danisharora099 changed the title feat: dockerize nwaku for tests feat: use nwaku docker instead of building binaries Mar 23, 2023
@github-actions
Copy link

github-actions bot commented Mar 23, 2023

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku core 116.85 KB (0%) 2.4 s (0%) 3.3 s (+26.53% 🔺) 5.6 s
Waku default setup 387.98 KB (0%) 7.8 s (0%) 6.4 s (-2.12% 🔽) 14.1 s
ECIES encryption 28.02 KB (0%) 561 ms (0%) 1.3 s (-11.07% 🔽) 1.9 s
Symmetric encryption 28.03 KB (0%) 561 ms (0%) 1.8 s (+38.58% 🔺) 2.4 s
DNS discovery 108.07 KB (0%) 2.2 s (0%) 3.2 s (+9.98% 🔺) 5.4 s
Privacy preserving protocols 116.38 KB (0%) 2.4 s (0%) 1.7 s (-31.91% 🔽) 4 s
Light protocols 118.2 KB (0%) 2.4 s (0%) 2.8 s (-6.97% 🔽) 5.1 s
History retrieval protocols 118.21 KB (0%) 2.4 s (0%) 2.4 s (+25.88% 🔺) 4.7 s

@danisharora099 danisharora099 force-pushed the feat/nwaku-docker branch 3 times, most recently from 30fca72 to cc466ac Compare March 23, 2023 14:14
@danisharora099 danisharora099 marked this pull request as ready for review March 23, 2023 14:21
@danisharora099 danisharora099 requested a review from weboko March 23, 2023 14:21
@danisharora099 danisharora099 force-pushed the feat/nwaku-docker branch 3 times, most recently from ff7ac51 to 56dad13 Compare March 24, 2023 10:48
Copy link
Collaborator

@fryorcraken fryorcraken left a comment

Choose a reason for hiding this comment

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

Being able to run the js-waku CI against a local binary is important when working on any interop matter.

I don't think running a node in docker should totally replace running a binary.

Happy for it to be the default method though.

OR if we want docker method to replace binary method, then how does it look like when I want to run the test with go-waku or nwaku compiled locally? Currently, only docker images supported are the one published.

@@ -427,7 +428,8 @@ describe("Waku Relay [node only]", () => {
let nwaku: Nwaku;

afterEach(async function () {
!!nwaku && nwaku.stop();
!!nwaku &&
nwaku.stop().catch((e) => console.log("Nwaku failed to stop", e));
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can use everywhere ?. operator.

Copy link
Collaborator Author

@danisharora099 danisharora099 Apr 11, 2023

Choose a reason for hiding this comment

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

@weboko
Since this change addresses a larger change in the general codebase, and also is outside the scope of this PR, I opened an issue for it: #1301

@fryorcraken
Copy link
Collaborator

OR if we want docker method to replace binary method, then how does it look like when I want to run the test with go-waku or nwaku compiled locally? Currently, only docker images supported are the one published.

As discussed in a call, an acceptable outcome would be to add a doc that explains how to run a local instance of nwaku or go-waku with the js-waku CI. I imagine something like:

  1. cd nwaku; make wakunode2
  2. docker build .
  3. set some env to point to locally built docker and use it to run js-waku tests.

@danisharora099
Copy link
Collaborator Author

OR if we want docker method to replace binary method, then how does it look like when I want to run the test with go-waku or nwaku compiled locally? Currently, only docker images supported are the one published.

As discussed in a call, an acceptable outcome would be to add a doc that explains how to run a local instance of nwaku or go-waku with the js-waku CI. I imagine something like:

  1. cd nwaku; make wakunode2
  2. docker build .
  3. set some env to point to locally built docker and use it to run js-waku tests.

Addressed with 85c1968

Copy link
Collaborator

@fryorcraken fryorcraken left a comment

Choose a reason for hiding this comment

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

Would be good to add somewhere, probably the main readme or test readme that docker needs to be installed.

Copy link
Collaborator

@fryorcraken fryorcraken left a comment

Choose a reason for hiding this comment

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

Getting

     Error: (HTTP code 404) no such container - No such image: statusteam/nim-waku:v0.16.0 
      at /home/fryorcraken/src/waku-org/js-waku/node_modules/docker-modem/lib/modem.js:343:17
      at getCause (/home/fryorcraken/src/waku-org/js-waku/node_modules/docker-modem/lib/modem.js:373:7)
      at Modem.buildPayload (/home/fryorcraken/src/waku-org/js-waku/node_modules/docker-modem/lib/modem.js:342:5)
      at IncomingMessage.<anonymous> (/home/fryorcraken/src/waku-org/js-waku/node_modules/docker-modem/lib/modem.js:310:16)

Because I did not pull the image name. Any chance you could a try catch around this error and ask the dev have you run docker pull <imagename`"?

@@ -59,10 +59,6 @@
"fix:prettier": "prettier . --write",
"fix:lint": "eslint src *.js --fix",
"pretest": "run-s pretest:*",
"pretest:1-init-git-submodules": "[ -f '../../nwaku/build/wakunode2' ] || git submodule update --init --recursive",
"pretest:2-build-nwaku": "[ -f '../../nwaku/build/wakunode2' ] || run-s nwaku:build",
"nwaku:build": "(PROC=$(nproc --all 2>/dev/null || echo 2); cd ../../nwaku; make -j$PROC update; NIMFLAGS=\"-d:chronicles_colors=off -d:chronicles_sinks=textlines -d:chronicles_log_level=TRACE\" make -j$PROC wakunode2)",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The docker image are not build with these options so logs contain some color or other random chars:

�      �TRC 2023-03-29 04:42:56.808+00:00 registering protocols                      topics="libp2p multistream" tid=1 file=multistream.nim:224 protos="@[\"/libp2p/autonat/1.0.0\"]"

@jm-clius do we have an option to pass to wakunode2 to get clean ASCII logs?

Choose a reason for hiding this comment

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

Unfortunately compiled binary can only set logLevel and logFormat (as TEXT or JSON).

Copy link
Collaborator

@fryorcraken fryorcraken left a comment

Choose a reason for hiding this comment

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

works for me but first try was not pleasant. Would be good to improve the docs as suggested above.

@danisharora099 danisharora099 force-pushed the feat/nwaku-docker branch 3 times, most recently from 376ee75 to d82aea5 Compare March 29, 2023 10:23
@danisharora099
Copy link
Collaborator Author

danisharora099 commented Mar 29, 2023

This PR is currently blocked as described in #1280

Copy link
Collaborator

@fryorcraken fryorcraken left a comment

Choose a reason for hiding this comment

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

bit of tidying up needed

- uses: ./.github/actions/npm
- run: npm run build:esm
- run: npm run pretest
Copy link
Collaborator

Choose a reason for hiding this comment

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

ah yeah that's annoying

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed it from ci.yml by adding npm run precheck inside of test:node before running mocha within /tests specifically

@danisharora099 danisharora099 force-pushed the feat/nwaku-docker branch 4 times, most recently from b76b2fc to 258ddec Compare April 3, 2023 12:06
### ⚠ BREAKING CHANGES

* add and implement IReceiver ([#1219](https://github.com/waku-org/js-waku/issues/1219))
- add and implement IReceiver ([#1219](https://github.com/waku-org/js-waku/issues/1219))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Changelogs should be reverted.
Did it happen after you got my fix for prettier?

Copy link
Collaborator Author

@danisharora099 danisharora099 Apr 6, 2023

Choose a reason for hiding this comment

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

Thanks for flagging!
Fixed! Won't be a problem anymore.


import debug from "debug";

const log = debug("waku:test:run");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now it should be safe to use console.log since this is merged #1291

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed here: cdde79d

Copy link
Collaborator

@weboko weboko left a comment

Choose a reason for hiding this comment

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

From my side no additional comments.
Good work 👍

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.

switch to nwaku docker images instead of locally building
4 participants