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(test-tools): Support lerna in assign-test-ports #23361

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Abe27342
Copy link
Contributor

Description

Adjusts test-tools's assign-test-ports script to support using lerna over pnpm. This allows us to use a modern test-tools version in our LTS branch. See discussion on #23285.

@Copilot Copilot bot review requested due to automatic review settings December 18, 2024 20:48
@github-actions github-actions bot added the base: main PRs targeted against main branch label Dec 18, 2024

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • tools/test-tools/package.json: Language not supported
@@ -1,5 +1,10 @@
#!/usr/bin/env node
const mod = require("../dist/assignTestPorts.js");
const nconf = require("nconf");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was going to keep test-tools dependency-less, but figured it's not much overhead to add nconf and we use it elsewhere in our test infra (e2e test scripts). Open to writing some minimal parsing logic ourselves if reviewer would prefer that though; we don't need a particularly reusable or ergonomic thing here.

Copy link
Contributor

Choose a reason for hiding this comment

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

When do dependencies for assign-test-ports get installed? Is there an existing use case where the dependencies are not installed?
I think using helper is good, but not confident this won't breaking existing workflows. :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of our usage of test-tools should just come via normal dep declaration in package.json, so transitive dependencies should be fine. e.g. see changes in https://github.com/microsoft/FluidFramework/pull/23285/files#diff-483384132d69f74744804315cbd004d361f840a7a007d9cfaca2714c69428493

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, I think this won't be an issue. A bit related, I have another PR open to make test-tools a @fluid-private package in the client release group, so all its uses would be limited to it being a dev dependency during the build.

Copy link
Contributor

Choose a reason for hiding this comment

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

So, if test-tools is becoming private, then I don't think this makes sense to merge to main. Something needs to support the LTS branch. Can either the privatization also happen in LTS OR is there a test-tools release and development branch that this should accumulate to?

@Abe27342
Copy link
Contributor Author

Still working on testing this change in LTS locally.

@Abe27342
Copy link
Contributor Author

Update: my LTS branch doesn't repro the same port assignment error that originally motivated this change, but I have locally verified that:

  1. The script produces a reasonable port map file using both pnpm and lerna (on an lts branch)
  2. Script usage (e.g. help message) remains a reasonable experience
  3. Argument parsing looks correct

So I'm reasonably confident this change should be ok.

@alexvy86
Copy link
Contributor

doesn't repro the same port assignment error that originally motivated this change

Expected, the issue only happens in the build agents where something is listening on port 8084.


// We used to hardcode port 8081 as the initial one
// but as of 2024-11-25 port 8084 is used by something in the build agent image.
// If a package that has jest tests ends up assigned that port,
// jest will fail to start.
// So try to use a port range where nothing will be listening.
const initialPortString = firstArg ?? "9000";
// Note '_' is used for positional arguments in nconf.
const initialPort = nconf.get("_")[0] ?? 9000;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd expect nconf.get() to return a string. I think that gets handled correctly all the way because the first thing we end up doing with it is <value>++, but I think it'd be better to explicitly convert to number here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants