Skip to content

Comments

refactor: enable parallel ci bats tests by enabling dfx start and bootstrap to pick random webserver ports#920

Merged
mergify[bot] merged 22 commits intomasterfrom
pshahi/parallel-tests-changes
Sep 30, 2020
Merged

refactor: enable parallel ci bats tests by enabling dfx start and bootstrap to pick random webserver ports#920
mergify[bot] merged 22 commits intomasterfrom
pshahi/parallel-tests-changes

Conversation

@p-shahi
Copy link
Contributor

@p-shahi p-shahi commented Aug 12, 2020

I'm going to merge these commits into #877

So far this PR does a couple things

  • fixes the fact that ipv6 addresses could not be provided to dfx start
  • fixes that both dfx bootstrap and dfx start could not handle the user providing port 0 i.e. telling dfx to pick a random port for the webserver
  • writes the port used by the webserver to .dfx/webserver-port (similar to .dfx/pid) so that it can be queried by dfx (or by the bats test)

the second and third bullet will enable the bats tests to run in parallel in darwin (w/o network sandbox) since we'll tell dfx start or dfx bootstrap to use port 0, the kernel will dynamically allocate a port, and the bats test can read .dfx/webserver-port

@p-shahi p-shahi requested a review from hansl August 12, 2020 23:35
@p-shahi p-shahi changed the title Pshahi/parallel tests changes refactor: enable parallel ci bats tests by enabling dfx start and bootstrap to pick random webserver ports Aug 12, 2020
@p-shahi p-shahi requested a review from basvandijk August 13, 2020 00:02
@p-shahi
Copy link
Contributor Author

p-shahi commented Aug 13, 2020

@basvandijk If I rebase this branch, it will get evaluation errors like so: https://hydra.dfinity.systems/jobset/dfinity-ci-build/sdk.pr-918#tabs-errors

if args.is_present("background") {
send_background()?;
return ping_and_wait(&frontend_url);
return Ok(());
Copy link
Contributor

Choose a reason for hiding this comment

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

We should still leave the process when the frontend is available, so ping_and_wait should stay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the 0 port case, doing ping_and_wait will fail: If the user does dfx start --host 127.0.0.1:0 the foreground process will attempt to ping_and_wait("http://127.0.0.1:0") when the port it should actually use is only allocated to the background process.
Since we still call ping_and_wait in the bg process here https://github.com/dfinity-lab/sdk/blob/54e3b812e0351f5f3e55f8a9aeedcfabc7e7f3cb/src/dfx/src/commands/start.rs#L196 I though it was ok to delete it.

Copy link

Choose a reason for hiding this comment

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

I agree that we should wait until ping succeeds. Can we do that by waiting for the background process to write its port into webserver-port, and then using that to ping?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Np, done. PTAL @ericswanson-dfinity

basvandijk and others added 7 commits August 24, 2020 12:44
Running the e2e bats test sequentially took 15m on my laptop. We
should run them all in parallel such that we don't have to wait so
long on CI.
@p-shahi p-shahi force-pushed the pshahi/parallel-tests-changes branch from 54e3b81 to f303e36 Compare August 24, 2020 19:48
@p-shahi p-shahi marked this pull request as ready for review September 29, 2020 01:34
@p-shahi p-shahi requested review from a user and hansl September 29, 2020 01:38
if args.is_present("background") {
send_background()?;
return ping_and_wait(&frontend_url);
return Ok(());
Copy link

Choose a reason for hiding this comment

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

I agree that we should wait until ping succeeds. Can we do that by waiting for the background process to write its port into webserver-port, and then using that to ping?

thiserror = "1.0.20"
toml = "0.5.5"
tokio = "0.2.10"
tokio = { version = "0.2.10", features = [ "fs" ] }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@p-shahi p-shahi requested a review from a user September 29, 2020 19:17
@ghost
Copy link

ghost commented Sep 29, 2020

How can we run e2e tests locally after this change? These are what I usually run:

$ nix-shell -A e2e-tests --option extra-binary-caches https://nix.dfinity.systems default.nix
error: nix-shell requires a single derivation
Try 'nix-shell --help' for more information.
$ nix-shell -A e2e-tests-ic-ref default.nix
error: nix-shell requires a single derivation
Try 'nix-shell --help' for more information.

These are both documented in the contributing document. Could you please update it?

@p-shahi
Copy link
Contributor Author

p-shahi commented Sep 29, 2020

How can we run e2e tests locally after this change? These are what I usually run:

$ nix-shell -A e2e-tests --option extra-binary-caches https://nix.dfinity.systems default.nix
error: nix-shell requires a single derivation
Try 'nix-shell --help' for more information.
$ nix-shell -A e2e-tests-ic-ref default.nix
error: nix-shell requires a single derivation
Try 'nix-shell --help' for more information.

These are both documented in the contributing document. Could you please update it?

Yep, will update docs. Both will work by doing nix-build instead of nix-shell

Related question, do you ever do this workflow:

nix-build nix -A sources.bats-support --no-link
> /nix/store/96aq8dqy2nwwvz5cvyyrcrlirf54i0mj-source
nix-shell -A e2e-tests .
export BATSLIB=/nix/store/96aq8dqy2nwwvz5cvyyrcrlirf54i0mj-source
cd e2e/bats
bats *.bash

@ghost
Copy link

ghost commented Sep 29, 2020

No, I have never seen that workflow! Here is what happened when I tried it:

± nix-build nix -A sources.bats-support --no-link
/nix/store/8xc343cx9bap7i8qa2ryian6j02kmc1v-bats-support-src
± nix-shell -A e2e-tests .
error: nix-shell requires a single derivation
Try 'nix-shell --help' for more information.

@mergify mergify bot merged commit 3c3356d into master Sep 30, 2020
@mergify mergify bot deleted the pshahi/parallel-tests-changes branch September 30, 2020 00:05
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.

3 participants