diff --git a/packages/compass-crud/src/stores/crud-store.ts b/packages/compass-crud/src/stores/crud-store.ts index 3475a8392ad..bac9aa2be2c 100644 --- a/packages/compass-crud/src/stores/crud-store.ts +++ b/packages/compass-crud/src/stores/crud-store.ts @@ -123,6 +123,7 @@ export const fetchDocuments: ( options, executionOptions ) => { + console.log('fetching documents inside crud store, pid ', process.pid); const canCalculateDocSize = // $bsonSize is only supported for mongodb >= 4.4.0 semver.gte(serverVersion, '4.4.0') && diff --git a/packages/compass-e2e-tests/helpers/compass.ts b/packages/compass-e2e-tests/helpers/compass.ts index 0395fd8e6fc..53aa3a5a3c5 100644 --- a/packages/compass-e2e-tests/helpers/compass.ts +++ b/packages/compass-e2e-tests/helpers/compass.ts @@ -591,6 +591,7 @@ async function startCompassElectron( name: string, opts: StartCompassOptions = {} ): Promise { + console.log('start compass electron...'); runCounter++; const { testPackagedApp, binary } = await getCompassExecutionParameters(); @@ -617,6 +618,8 @@ async function startCompassElectron( '--log-level=0' ); + chromeArgs.push('--host-rules=MAP * 127.0.0.1'); + if (opts.extraSpawnArgs) { chromeArgs.push(...opts.extraSpawnArgs); } @@ -638,7 +641,8 @@ async function startCompassElectron( // For webdriverio env we are changing appName so that keychain records do not // overlap with anything else. But leave it alone when testing auto-update. if (!process.env.HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE) { - process.env.HADRON_PRODUCT_NAME_OVERRIDE = 'MongoDB Compass WebdriverIO'; + process.env.HADRON_PRODUCT_NAME_OVERRIDE = + 'MongoDB Compassssssss WebdriverIO'; } // Guide cues might affect too many tests in a way where the auto showing of the cue prevents @@ -922,7 +926,11 @@ export async function rebuildNativeModules( export async function compileCompassAssets( compassPath = COMPASS_DESKTOP_PATH ): Promise { - await promisify(execFile)('npm', ['run', 'compile'], { cwd: compassPath }); + console.log('path nonsense: ', compassPath); + await promisify(execFile)('npm', ['run', 'compile'], { + maxBuffer: 256 * 1024 * 1024, + cwd: compassPath, + }); } async function getCompassBuildMetadata(): Promise { @@ -1035,6 +1043,7 @@ export async function init( opts: StartCompassOptions = {} ): Promise { name = pathName(name ?? formattedDate()); + console.log('process pid inside init: ', process.pid); // Unfortunately mocha's type is that this.test inside a test or hook is // optional even though it always exists. So we have a lot of diff --git a/packages/compass-e2e-tests/helpers/test-runner-global-fixtures.ts b/packages/compass-e2e-tests/helpers/test-runner-global-fixtures.ts index a2bd3e751e2..72862303816 100644 --- a/packages/compass-e2e-tests/helpers/test-runner-global-fixtures.ts +++ b/packages/compass-e2e-tests/helpers/test-runner-global-fixtures.ts @@ -58,6 +58,7 @@ export async function mochaGlobalSetup(this: Mocha.Runner) { }; try { + console.log('unzipping fixtures...'); debug('Unzipping fixtures...'); await gunzip( // Not using absolute paths because Windows fails to resolve glob @@ -71,14 +72,19 @@ export async function mochaGlobalSetup(this: Mocha.Runner) { debug('X DISPLAY', process.env.DISPLAY); + console.log('line 75 ish'); + if (!context.disableStartStop) { for (const connectionInfo of DEFAULT_CONNECTIONS) { if (connectionInfo.testServer) { + console.log('cnxn info: ', connectionInfo); debug( 'Starting MongoDB server for connection %s', getConnectionTitle(connectionInfo) ); + console.log('85 ish'); const server = await startTestServer(connectionInfo.testServer); + console.log('stgarted test server'); cleanupFns.push(() => { debug( 'Stopping server for connection %s', @@ -90,6 +96,8 @@ export async function mochaGlobalSetup(this: Mocha.Runner) { throwIfAborted(); } + console.log('line 90 ish'); + if (isTestingWeb(context) && !isTestingAtlasCloudExternal(context)) { debug('Starting Compass Web server ...'); if (isTestingAtlasCloudSandbox(context)) { @@ -123,6 +131,7 @@ export async function mochaGlobalSetup(this: Mocha.Runner) { } } + console.log('mongodb server info'); debug('Getting mongodb server info'); await updateMongoDBServerInfo(); diff --git a/packages/compass-e2e-tests/index.ts b/packages/compass-e2e-tests/index.ts index 86a31aec1a1..b849c87d933 100644 --- a/packages/compass-e2e-tests/index.ts +++ b/packages/compass-e2e-tests/index.ts @@ -54,7 +54,7 @@ async function main() { const e2eTestGroup = context.testGroup; const e2eTestFilter = context.testFilter; - const tests = ( + let tests = ( await glob(`tests/**/${e2eTestFilter}.{test,spec}.ts`, { cwd: __dirname, }) @@ -67,6 +67,7 @@ async function main() { return index >= minGroupIndex && index <= maxGroupIndex; }) .sort((a, b) => { + // this comment is wrong // The only test file that's interested in the first-run experience (at the // time of writing) is time-to-first-query.ts and that happens to be // alphabetically right at the end. Which is fine, but the first test to run @@ -82,18 +83,25 @@ async function main() { } }); + tests = tests.filter((test) => test === 'tests/no-network-traffic.test.ts'); + + console.log('test files: ', tests); debug('Test files:', tests); if (tests.length === 0) { throw new Error('No tests to run'); } + console.log('before mocha 1'); + const mocha = new Mocha({ timeout: context.mochaTimeout, bail: context.mochaBail, reporter: require.resolve('@mongodb-js/mocha-config-compass/reporter'), }); + console.log('after mocha 1'); + // @ts-expect-error mocha types are incorrect, global setup this is bound to // runner, not context mocha.globalSetup(mochaGlobalSetup); @@ -111,9 +119,11 @@ async function main() { mocha.addFile(path.join(__dirname, testPath)); }); + console.log('Running e2e ...'); debug('Running E2E tests'); runnerPromise = new Promise((resolve) => { mocha.run((failures: number) => { + console.log('on finish??'); debug('Finished running e2e tests', { failures }); process.exitCode = failures ? 1 : 0; // Since the webdriverio update something is messing with the terminal's @@ -161,4 +171,6 @@ async function run() { await main(); } +console.log('running???????'); + void run(); diff --git a/packages/compass-e2e-tests/package.json b/packages/compass-e2e-tests/package.json index 34320b6c5f7..107816e6353 100644 --- a/packages/compass-e2e-tests/package.json +++ b/packages/compass-e2e-tests/package.json @@ -11,7 +11,7 @@ "lint": "npm run typecheck && npm run eslint . && npm run prettier -- --check .", "depcheck": "depcheck", "check": "npm run lint && npm run depcheck", - "test": "xvfb-maybe --auto-servernum --server-args=\"-screen 0 1432x840x24\" -- ts-node index.ts", + "test": "ENV DEBUG=*,-electron-rebuild* xvfb-maybe --auto-servernum --server-args=\"-screen 0 1432x840x24\" -- ts-node index.ts", "test-ci": "npm run test", "posttest-ci": "npm run coverage-report", "test-packaged": "npm run test -- --test-packaged-app", diff --git a/packages/compass-e2e-tests/tests/no-network-traffic.test.ts b/packages/compass-e2e-tests/tests/no-network-traffic.test.ts index b913d6fc13c..0e08d72e713 100644 --- a/packages/compass-e2e-tests/tests/no-network-traffic.test.ts +++ b/packages/compass-e2e-tests/tests/no-network-traffic.test.ts @@ -8,6 +8,9 @@ import { promises as fs } from 'fs'; import path from 'path'; import os from 'os'; +import http from 'http'; +import https from 'https'; + /** * @securityTest Enhanced Network Isolation Tests * @@ -22,11 +25,12 @@ describe('networkTraffic: false / Isolated Edition', function () { let i = 0; before(function () { + console.log('an early before in our test of choice'); skipForWeb(this, 'cli params not available in compass-web'); if (process.platform !== 'linux') { // No strace on other platforms - return this.skip(); + // return this.skip(); } }); @@ -56,21 +60,23 @@ describe('networkTraffic: false / Isolated Edition', function () { const wrapperFile = path.join(tmpdir, 'wrap.sh'); await fs.writeFile( wrapperFile, - `#!/bin/bash\nulimit -c 0; exec strace -f -e connect -qqq -o '${outfile}' '${binary}' "$@"\n` + `#!/bin/bash\nulimit -c 0; '${binary}' "$@"\n` ); await fs.chmod(wrapperFile, 0o755); return wrapperFile; } + console.log('process pid inside no network test: ', process.pid); const compass = await init(this.test?.fullTitle(), { extraSpawnArgs: ['--no-network-traffic'], wrapBinary, // TODO(COMPASS-8166): firstRun: true seems to result in network traffic. // Probably the welcome modal. - firstRun: false, + firstRun: true, }); const browser = compass.browser; + console.log('set up default connections...'); await browser.setupDefaultConnections(); { @@ -78,8 +84,9 @@ describe('networkTraffic: false / Isolated Edition', function () { const exitOnDisconnectFile = path.join(tmpdir, 'exitOnDisconnect.js'); await fs.writeFile( exitOnDisconnectFile, - 'process.once("disconnect", () => process.exit())' + 'process.once("disconnect", () => {})' ); + console.log('browser.execute...'); await browser.execute((exitOnDisconnectFile) => { process.env.NODE_OPTIONS ??= ''; process.env.NODE_OPTIONS += ` --require "${exitOnDisconnectFile}"`; @@ -87,47 +94,47 @@ describe('networkTraffic: false / Isolated Edition', function () { } try { + console.log('connect to defaults...'); await browser.connectToDefaults(); } finally { await cleanup(compass); } - const straceLog = await fs.readFile(outfile, 'utf8'); - const connectCalls = straceLog.matchAll(/\bconnect\s*\((?.*)\) =/g); - const connectTargets = new Set(); - for (const { groups } of connectCalls) { - const args = groups!.args; - // Possible format for the address argument in 'args': - // sa_family=AF_UNIX, sun_path="/var/run/nscd/socket" - // sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1") - // sa_family=AF_INET6, sin6_port=htons(80), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "2606:2800:220:1:248:1893:25c8:1946", &sin6_addr), sin6_scope_id=0 - if (!args.includes('AF_INET')) continue; - const match = args.match( - /sa_family=AF_INET6?.*sin6?_port=htons\((?\d+)\).*inet_(addr\("(?[^"]+)"\)|pton\(AF_INET6,\s*"(?[^"]+)")/ - )?.groups; - if (!match) { - throw new Error(`Unknown traced connect() target: ${args}`); - } - connectTargets.add( - match.ipv4 - ? `${match.ipv4}:${match.port}` - : `[${match.ipv6}]:${match.port}` - ); - } + // const straceLog = await fs.readFile(outfile, 'utf8'); + // const connectCalls = straceLog.matchAll(/\bconnect\s*\((?.*)\) =/g); + // const connectTargets = new Set(); + // for (const { groups } of connectCalls) { + // const args = groups!.args; + // // Possible format for the address argument in 'args': + // // sa_family=AF_UNIX, sun_path="/var/run/nscd/socket" + // // sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1") + // // sa_family=AF_INET6, sin6_port=htons(80), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "2606:2800:220:1:248:1893:25c8:1946", &sin6_addr), sin6_scope_id=0 + // if (!args.includes('AF_INET')) continue; + // const match = args.match( + // /sa_family=AF_INET6?.*sin6?_port=htons\((?\d+)\).*inet_(addr\("(?[^"]+)"\)|pton\(AF_INET6,\s*"(?[^"]+)")/ + // )?.groups; + // if (!match) { + // throw new Error(`Unknown traced connect() target: ${args}`); + // } + // connectTargets.add( + // match.ipv4 + // ? `${match.ipv4}:${match.port}` + // : `[${match.ipv6}]:${match.port}` + // ); + // } - if ( - [...connectTargets].some( - (target) => !/^127.0.0.1:|^\[::1\]:/.test(target) - ) - ) { - throw new Error(`Connected to unexpected host! ${[...connectTargets]}`); - } - if (![...connectTargets].some((target) => /:27091$/.test(target))) { - throw new Error( - `Missed connection to database server in connect trace! ${[ - ...connectTargets, - ]}` - ); - } + // const unexpectedHosts = [...connectTargets].filter( + // (target) => !/^127.0.0.1:|^\[::1\]:/.test(target) + // ); + // if (unexpectedHosts.length > 0) { + // throw new Error(`Connected to unexpected host! ${[...unexpectedHosts]}`); + // } + // if (![...connectTargets].some((target) => /:27091$/.test(target))) { + // throw new Error( + // `Missed connection to database server in connect trace! ${[ + // ...connectTargets, + // ]}` + // ); + // } }); }); diff --git a/packages/compass-test-server/src/index.ts b/packages/compass-test-server/src/index.ts index f219932521c..2fe2075cd60 100644 --- a/packages/compass-test-server/src/index.ts +++ b/packages/compass-test-server/src/index.ts @@ -14,6 +14,7 @@ let isClosed = false; const clusters = new Map(); const defaults: MongoClusterOptions = { topology: 'standalone', + binDir: '/opt/homebrew/bin', tmpDir: path.join( os.tmpdir(), `compass-tests-${hash(process.env.EVERGREEN_TASK_ID ?? '')}` @@ -26,8 +27,10 @@ const defaults: MongoClusterOptions = { export async function startTestServer( config: Partial & { alwaysStartNewServer?: boolean } = {} ): Promise { + console.log('29 ish'); const key = JSON.stringify(config); const existing = !config.alwaysStartNewServer && clusters.get(key); + console.log('here 31'); if (existing && !existing.isClosed()) return existing; const cluster = await MongoCluster.start({ ...defaults,