Skip to content

feat(e2e): add support running behind proxy - #5348

Merged
jsjoeio merged 14 commits into
mainfrom
jsjoeio/proxy-e2e
Aug 9, 2022
Merged

jsjoeio merged 14 commits into
mainfrom
jsjoeio/proxy-e2e

Conversation

@jsjoeio

@jsjoeio jsjoeio commented Jul 15, 2022 •

Copy link
Copy Markdown
Contributor

Description

This PR adds a new job to run our end-to-end tests behind a reverse-proxy (with Caddy) to simulate how code-server runs in coder/coder and in many community-member deployments.

Changes

  • add new job to ci along with Caddyfile
  • refactor auth in e2e tests
  • refactor address() method in e2e model to work with reverse-proxy
  • add USE_PROXY env var used in e2e tests and scripts

Fixes #5337

@jsjoeio
jsjoeio requested a review from a team July 15, 2022 20:58
@jsjoeio jsjoeio self-assigned this Jul 15, 2022
@jsjoeio
jsjoeio marked this pull request as draft July 15, 2022 20:58
@github-actions

github-actions Bot commented Jul 15, 2022 •

Copy link
Copy Markdown

✨ code-server docs for PR #5348 is ready! It will be updated on every commit.

Comment thread test/e2e/models/CodeServer.ts Resolved
@codecov

codecov Bot commented Jul 15, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #5348 (b991350) into main (efb5bae) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5348   +/-   ##
=======================================
  Coverage   72.42%   72.42%           
=======================================
  Files          30       30           
  Lines        1672     1672           
  Branches      366      366           
=======================================
  Hits         1211     1211           
  Misses        398      398           
  Partials       63       63           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efb5bae...b991350. Read the comment docs.

@jsjoeio
jsjoeio temporarily deployed to npm July 15, 2022 21:03 Inactive
@github-actions

github-actions Bot commented Jul 15, 2022 •

Copy link
Copy Markdown

✨ code-server dev build published to npm for PR #5348!

  • Last publish status: success
  • Commit: b991350

To install in a local project, run:

npm install @coder/code-server-pr@5348

To install globally, run:

npm install -g @coder/code-server-pr@5348

code-asher
code-asher previously approved these changes Jul 15, 2022
Comment thread test/e2e/models/CodeServer.ts Resolved
@jsjoeio
jsjoeio temporarily deployed to npm July 15, 2022 22:10 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm July 20, 2022 19:18 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm July 21, 2022 20:42 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm July 21, 2022 21:00 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm July 21, 2022 21:54 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm July 21, 2022 22:10 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm July 21, 2022 22:28 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm July 22, 2022 17:29 Inactive
Comment thread .github/workflows/ci.yaml Resolved
Comment thread ci/Caddyfile Resolved
Comment thread docs/MAINTAINING.md Resolved
@jsjoeio
jsjoeio temporarily deployed to npm July 22, 2022 21:48 Inactive
@jsjoeio

jsjoeio commented Jul 22, 2022 •

Copy link
Copy Markdown
Contributor Author

Need to figure out Caddyfile issues.

Opened forum post here: https://caddy.community/t/automatically-forward-subpath-to-port-on-localhost/16629

Oddly enough:

{
	admin    localhost:4444
}
:8000/*/ide/* {
        handle {
                respond "hello world" 200
        }

}

Doesn't work with http://localhost:8000/8080/ide/hi so something is up

@jsjoeio
jsjoeio temporarily deployed to npm July 22, 2022 23:35 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm August 1, 2022 21:06 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm August 1, 2022 21:29 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm August 1, 2022 22:06 Inactive
Comment thread test/e2e/models/CodeServer.ts Resolved
Comment thread test/e2e/models/CodeServer.ts Resolved
Comment thread test/e2e/models/CodeServer.ts Resolved
@jsjoeio
jsjoeio temporarily deployed to npm August 3, 2022 22:34 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm August 5, 2022 21:48 Inactive
@jsjoeio
jsjoeio temporarily deployed to npm August 5, 2022 22:17 Inactive
jsjoeio added 5 commits August 8, 2022 10:16
We don't need the submodules for the e2e job. This will speed up the
checkout step.
This adds a new job to CI to run our tests behind Caddy and simulate
code-server running against a reverse-proxy.
This refactors the e2e test in a couple ways:
- remove setting cookie in localStorage (instead we pass --auth none)
- refactor address() method to account for reverse proxy logic
@jsjoeio
jsjoeio force-pushed the jsjoeio/proxy-e2e branch from a223de2 to 070a328 Compare August 8, 2022 17:25
Comment thread test/e2e/models/CodeServer.ts Resolved
Comment thread test/playwright.config.ts Resolved
@jsjoeio
jsjoeio marked this pull request as ready for review August 8, 2022 17:30
@jsjoeio
jsjoeio requested a review from code-asher August 8, 2022 17:30
@jsjoeio
jsjoeio temporarily deployed to npm August 8, 2022 17:32 Inactive

@code-asher code-asher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

May reverse proxies never break again! 🥂

Comment thread .github/workflows/ci.yaml Resolved
Comment thread test/utils/constants.ts Resolved
Comment thread test/utils/helpers.ts Outdated
*/
export async function getMaybeProxiedCodeServer(codeServer: CodeServerPage | CodeServer): Promise<string> {
let address = await codeServer.address()
if (process.env.USE_PROXY && process.env.USE_PROXY === "1") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: we could do with just the latter check

Suggested change
if (process.env.USE_PROXY && process.env.USE_PROXY === "1") {
if (process.env.USE_PROXY === "1") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ooops sorry my suggestion removed the indent, I keep forgetting copy does not copy the indent and I have to add it back in manually.

@jsjoeio jsjoeio Aug 9, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

😂 i'll fix locally, no worries. i didn't realize that either

@jsjoeio
jsjoeio enabled auto-merge (squash) August 9, 2022 17:22
@jsjoeio
jsjoeio temporarily deployed to npm August 9, 2022 17:37 Inactive
Comment thread test/utils/helpers.ts Resolved
@jsjoeio
jsjoeio temporarily deployed to npm August 9, 2022 18:07 Inactive
@jsjoeio
jsjoeio merged commit f178f04 into main Aug 9, 2022
@jsjoeio
jsjoeio deleted the jsjoeio/proxy-e2e branch August 9, 2022 18:24

This branch was previously deployed

1 inactive deployment
npm — b9913509 Deployed Aug 9, 2022 by jsjoeio
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.

[Feat]: add test suite for running e2e tests behind proxy/not root

2 participants