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

startWorker tests #6124

Merged
merged 12 commits into from
Jun 27, 2024
Merged

startWorker tests #6124

merged 12 commits into from
Jun 27, 2024

Conversation

RamIdeas
Copy link
Contributor

What this PR solves / how to test

This PR rewrites the fixtures/dev-env tests as e2e tests. Whereas the former were written when only the ProxyController had been implemented and therefore faked all other events, these new tests assume a full implementation.

The steps in each test are identical but have been rewritten for e2e usage. Notable difference: the script contents is written to disk instead of passing it via config because config.entrypoint.contents has been descoped for now.

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Included
    • Not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required / Maybe required
    • Not required because:
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Included
    • Not necessary because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Not necessary because:

@RamIdeas RamIdeas requested a review from a team as a code owner June 21, 2024 21:03
Copy link

changeset-bot bot commented Jun 21, 2024

🦋 Changeset detected

Latest commit: 883cb9d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@RamIdeas RamIdeas added the e2e Run e2e tests on a PR label Jun 21, 2024
Copy link
Contributor

github-actions bot commented Jun 21, 2024

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9695127283/npm-package-wrangler-6124

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6124/npm-package-wrangler-6124

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9695127283/npm-package-wrangler-6124 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9695127283/npm-package-create-cloudflare-6124 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9695127283/npm-package-cloudflare-kv-asset-handler-6124
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9695127283/npm-package-miniflare-6124
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9695127283/npm-package-cloudflare-pages-shared-6124
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9695127283/npm-package-cloudflare-vitest-pool-workers-6124

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240620.0
workerd 1.20240620.1 1.20240620.1
workerd --version 1.20240620.1 2024-06-20

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@RamIdeas RamIdeas force-pushed the startWorker-tests branch 2 times, most recently from 86f68bb to 3cb2867 Compare June 21, 2024 23:10
this.latest = input;
this.emitConfigUpdateEvent(this.latest);
this.emitConfigUpdateEvent(this.config);
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a bug fix? If so what is it fixing? Is there a relevant test that would fail if this got reverted?
What is the difference between this.latest and this.config?

Copy link
Contributor Author

@RamIdeas RamIdeas Jun 25, 2024

Choose a reason for hiding this comment

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

It was just an unused property of the startWorker programmatic interface only (not wrangler_dev or unstable_dev). this.latest was used instead and internally where it mattered. Now there is a use-case for both latest and config – renamed to latestInput and latestConfig in another PR. There are tests in this PR that use the worker.config (which is a getter for this ConfigController.latestConfig) value and will fail if it is not set

@@ -51,7 60,7 @@ export interface StartDevWorkerOptions {
* This is the `main` property of a wrangler.toml.
* You can specify a file path or provide the contents directly.
*/
entrypoint: FilePath;
entrypoint?: FilePath;
Copy link
Contributor

Choose a reason for hiding this comment

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

What does it mean for a worker to have no entry-point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed offline, it means you will have to have a main field in your config file. There is existing runtime code to check one of the possible ways to provide an entrypoint is actually provided and throws if not. The existing code was a bit too hairy to create a static type union but will be possible in the future as more deadcode paths are removed.

Base automatically changed from improve-e2e-win-etc to main June 26, 2024 14:09
@RamIdeas RamIdeas force-pushed the startWorker-tests branch 2 times, most recently from c1b4e9f to cb5ccb7 Compare June 26, 2024 17:52
petebacondarwin and others added 12 commits June 27, 2024 11:39
- `child_process.kill()` doesn't really work on Windows. Using `kill-tree` library instead
- `killAllWranglerDev()` helper could mess up parallel tests since it kills all wrangler/workerd processes regardless of whether they are part of the current test
- `shellac` library has issues on Windows when running background tasks. Using simple `execSync` and `spawn` functions instead
- tightened up the timeouts a bit to avoid long running false negatives
- reworked the helpers to use a class `WranglerE2ETestHelper` rather than the `e2eTest` extension.
by rewriting dev-env fixture tests as e2e tests without fakes
@RamIdeas RamIdeas merged commit d03b102 into main Jun 27, 2024
21 checks passed
@RamIdeas RamIdeas deleted the startWorker-tests branch June 27, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e tests on a PR
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants