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

chore(compass-web): refactor sandbox to better handle cert issuing logic #6295

Merged
merged 8 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/webpack-config-compass/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,4 @@ export { sharedExternals, pluginExternals };
export { webpackArgsWithDefaults, isServe } from './args';
export { default as webpack } from 'webpack';
export { merge } from 'webpack-merge';
export { default as WebpackDevServer } from 'webpack-dev-server';
40 changes: 27 additions & 13 deletions packages/compass-e2e-tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ import ResultLogger from './helpers/result-logger';

const debug = Debug('compass-e2e-tests');

const wait = (ms: number) =>
new Promise((resolve) => {
setTimeout(resolve, ms);
});

const allowedArgs = [
'--test-compass-web',
'--no-compile',
Expand Down Expand Up @@ -75,18 +80,27 @@ async function setup() {
},
}
);
// wait for webpack to finish compiling
await new Promise<void>((resolve) => {
let output = '';
const listener = function (chunk: string) {
output += chunk;
if (/^webpack \d+\.\d+\.\d+ compiled/m.test(output)) {
compassWeb.stdout.off('data', listener);
resolve();
}
};
compassWeb.stdout.setEncoding('utf8').on('data', listener);
});

compassWeb.stdout.pipe(process.stdout);
compassWeb.stderr.pipe(process.stderr);

let serverReady = false;
const start = Date.now();
while (!serverReady) {
if (Date.now() - start >= 120_000) {
throw new Error(
'The compass-web sandbox is still not running after 120000ms'
);
}
try {
const res = await fetch('http://localhost:7777');
serverReady = res.ok;
lerouxb marked this conversation as resolved.
Show resolved Hide resolved
debug('Web server ready: %s', serverReady);
} catch (err) {
debug('Failed to connect to dev server: %s', (err as any).message);
}
await wait(1000);
}
} else {
debug('Writing electron-versions.json');
crossSpawn.sync('scripts/write-electron-versions.sh', [], {
Expand Down Expand Up @@ -131,7 +145,7 @@ function cleanup() {
try {
if (compassWeb.pid) {
debug(`killing compass-web [${compassWeb.pid}]`);
kill(compassWeb.pid);
kill(compassWeb.pid, 'SIGINT');
} else {
debug('no pid for compass-web');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"webpack": "webpack-compass",
"postcompile": "npm run typescript",
"typescript": "tsc -p tsconfig-build.json --emitDeclarationOnly",
"start": "npm run webpack serve -- --mode development",
"start": "electron ./scripts/electron-proxy.js",
"analyze": "npm run webpack -- --mode production --analyze",
"watch": "npm run webpack -- --mode development --watch",
"sync": "node scripts/sync-dist-to-mms.js",
Expand Down
7 changes: 7 additions & 0 deletions packages/compass-web/sandbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ const App = () => {
return (
<SandboxConnectionStorageProviver
value={isAtlas ? null : sandboxConnectionStorage}
extraConnectionOptions={
isAtlas
? // In the sandbox we're waiting for cert user to be propagated to
// the clusters, it can take awhile on the first connection
{ connectTimeoutMS: 120_000, serverSelectionTimeoutMS: 120_000 }
: {}
}
>
<Body as="div" className={sandboxContainerStyles}>
<CompassWeb
Expand Down
Loading
Loading