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

Cleanup tests after app home internal url #982

Conversation

fflorent
Copy link
Collaborator

@fflorent fflorent commented May 14, 2024

Context and proposed solution

This PR is a follow-up of PR #864, which introduced many tests to ensure that the DocApi can work behind a proxy, and especially ensures that the requests initiated internally do not pass through the proxy when APP_HOME_INTERNAL_URL and APP_DOC_INTERNAL_URL are set.

We especially set APP_DOC_INTERNAL_URL to the doc worker so until-now-skipped tests can be executed (namely document is protected during upload-and-import sequence and /workspaces/{wid}/import handles empty filenames). TestServer and TestProxiedServer have been reworked to achieve that, especially to separate the instanciation (during which a port is found for them) and their start.

There are also other inconsistencies fixed, various cleanups, etc.

Tests?

  • 👍 We work on tests, so yes!

@fflorent
Copy link
Collaborator Author

Opening this PR to know whether all the tests pass.

@fflorent fflorent force-pushed the cleanup-tests-after-app-home-internal-url branch 2 times, most recently from 106b041 to 03a8c4d Compare May 14, 2024 17:11
@fflorent fflorent marked this pull request as ready for review May 14, 2024 17:11
@fflorent fflorent added the anct label Jul 3, 2024
@fflorent fflorent self-assigned this Jul 31, 2024
@fflorent fflorent force-pushed the cleanup-tests-after-app-home-internal-url branch from 03a8c4d to 579ed39 Compare August 14, 2024 15:49
@fflorent fflorent force-pushed the cleanup-tests-after-app-home-internal-url branch from 579ed39 to 354e177 Compare October 8, 2024 15:45
@fflorent fflorent marked this pull request as draft October 10, 2024 08:41
@fflorent fflorent force-pushed the cleanup-tests-after-app-home-internal-url branch 2 times, most recently from 1be171e to cb593da Compare November 5, 2024 10:52
@@ -257,25 +249,16 @@ export class TestServerReverseProxy {
this._requireFromOutsideHeader = true;
}

public async start(homeServer: TestServer, docServer: TestServer) {
this._app.all(['/dw/dw1', '/dw/dw1/*'], (oreq, ores) => this._getRequestHandlerFor(docServer));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These endpoints seem to not have been called until I enabled the tests above. That's the reason why this error in the code had no impact until now (if I restore the old version I get tests that fail).

await docs.start(home.serverUrl, {
...additionalEnvConfiguration,
APP_DOC_URL: `${proxy.serverUrl}/dw/dw1`,
APP_DOC_INTERNAL_URL: docs.serverUrl,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I mentioned in the PR description that I had to rework the TestServer class. That's the reason why.

You can see that the serverUrl is now known before the server is started, which lets us provide the APP_DOC_INTERNAL_URL to the doc worker.

@fflorent fflorent requested a review from hexaltation November 5, 2024 16:49
@fflorent fflorent marked this pull request as ready for review November 5, 2024 16:49
test/server/lib/DocApi.ts Show resolved Hide resolved
test/server/lib/DocApi.ts Show resolved Hide resolved
@@ -28,31 +27,36 @@ export class TestServer {
_homeUrl?: string,
options: {output?: Writable} = {}, // Pipe server output to the given stream
): Promise<TestServer> {

const server = new this(serverTypes, tempDirectory, suitename);
const port = await getAvailablePort(parseInt(process.env.GET_AVAILABLE_PORT_START || '8080', 10));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is GET_AVAILABLE_PORT_START used? getAvailablePort has a default value for its first argument (8000)

@fflorent fflorent requested a review from hexaltation November 20, 2024 13:34
@fflorent fflorent force-pushed the cleanup-tests-after-app-home-internal-url branch from 7de1e98 to d9598b7 Compare November 20, 2024 13:34
Copy link
Collaborator

@hexaltation hexaltation left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@paulfitz paulfitz left a comment

Choose a reason for hiding this comment

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

Thanks for the follow up @fflorent !

@paulfitz paulfitz merged commit c280a7d into gristlabs:main Nov 21, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants