Skip to content

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

Closed

Description

@jsjoeio

What is your suggestion?

To modify our e2e test setup to run the same tests but in an environment that runs code-server not on the root path i.e. behind /ide or something.

Why do you want this feature?

It mimics how many of our users run code-server and also mimics how we run code-server in both Coder and Coder OSS.

It would have prevented a high-impact bug we accidentally introduced in 4.5.0.

See #5321

Are there any workarounds to get this functionality today?

Manually testing code-server behind a reverse proxy with Caddy before each release 😅

Are you interested in submitting a PR for this?

Yes

Notes

Instead of duplicating tests, it would be cool if we added a new script like yarn test:e2e:caddy or something which spun up Caddy in front of code-server and then ran the tests using that environment.

Currently the e2e tests run in parallel (I believe) and use random ports so we'd have to use a wildcard in Caddy (I'm pretty sure it can do that).

We'd also have to make sure code-server's address had the path in it. I'm guessing we could do some environment variable logic or something like PATH_TO_USE="/ide" and then dynamically set address.

_notes from Discord call with @code-asher _

  • install Caddy
  • launch Caddy
  • set env variable to use proxy or special path

we might be able to use named matchers.

simplest way to do this:

  • write Caddyfile
  • run code-server on one port and make sure it works as expected
  • run it on another port and make sure it works
:80 {
        @portLocalhost header_regexp port Host ^([0-9]+)\.localhost$
        handle @portLocalhost {
                reverse_proxy localhost:{re.port.1}
        }
        
        handle {        
                respond "Bad hostname" 400
        }
}

USE_PROXY=1

caddy start

if(USE_PROXY && USE_PROXY=1) {
  return port.localhost
}
const uri = new URL(address)
const port = uri.port
  • add support for USE_PROXY
  • add Caddyfile

Activity

  1. modified the milestones: July 2022, 4.5.1 on Jul 14, 2022
  2. self-assigned this
    on Jul 15, 2022
  3. modified the milestones: July 2022, 4.5.1 on Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementSome improvement that isn't a feature

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions