Skip to content

Commit 000312d

Browse files
add debug to package.json, unkilloff strace
1 parent 806181b commit 000312d

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

packages/compass-e2e-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint": "npm run typecheck && npm run eslint . && npm run prettier -- --check .",
1212
"depcheck": "depcheck",
1313
"check": "npm run lint && npm run depcheck",
14-
"test": "xvfb-maybe --auto-servernum --server-args=\"-screen 0 1432x840x24\" -- ts-node index.ts",
14+
"test": "ENV DEBUG=* xvfb-maybe --auto-servernum --server-args=\"-screen 0 1432x840x24\" -- ts-node index.ts",
1515
"test-ci": "npm run test",
1616
"posttest-ci": "npm run coverage-report",
1717
"test-packaged": "npm run test -- --test-packaged-app",

packages/compass-e2e-tests/tests/no-network-traffic.test.ts

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ describe('networkTraffic: false / Isolated Edition', function () {
4848
before(function () {
4949
skipForWeb(this, 'cli params not available in compass-web');
5050

51-
// if (process.platform !== 'linux') {
52-
// // No strace on other platforms
53-
// return this.skip();
54-
// }
51+
if (process.platform !== 'linux') {
52+
// No strace on other platforms
53+
return this.skip();
54+
}
5555
});
5656

5757
beforeEach(async function () {
@@ -78,8 +78,10 @@ describe('networkTraffic: false / Isolated Edition', function () {
7878
const outfile = path.join(tmpdir, 'strace-out.log');
7979
async function wrapBinary(binary: string): Promise<string> {
8080
const wrapperFile = path.join(tmpdir, 'wrap.sh');
81-
// kill off strace
82-
await fs.writeFile(wrapperFile, `#!/bin/bash\n '${binary}' "$@"\n`);
81+
await fs.writeFile(
82+
wrapperFile,
83+
`#!/bin/bash\nulimit -c 0; exec strace -f -e connect -qqq -o '${outfile}' '${binary}' "$@"\n`
84+
);
8385
await fs.chmod(wrapperFile, 0o755);
8486
return wrapperFile;
8587
}
@@ -114,41 +116,41 @@ describe('networkTraffic: false / Isolated Edition', function () {
114116
await cleanup(compass);
115117
}
116118

117-
const straceLog = await fs.readFile(outfile, 'utf8');
118-
const connectCalls = straceLog.matchAll(/\bconnect\s*\((?<args>.*)\) =/g);
119-
const connectTargets = new Set<string>();
120-
for (const { groups } of connectCalls) {
121-
const args = groups!.args;
122-
// Possible format for the address argument in 'args':
123-
// sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"
124-
// sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1")
125-
// 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
126-
if (!args.includes('AF_INET')) continue;
127-
const match = args.match(
128-
/sa_family=AF_INET6?.*sin6?_port=htons\((?<port>\d+)\).*inet_(addr\("(?<ipv4>[^"]+)"\)|pton\(AF_INET6,\s*"(?<ipv6>[^"]+)")/
129-
)?.groups;
130-
if (!match) {
131-
throw new Error(`Unknown traced connect() target: ${args}`);
132-
}
133-
connectTargets.add(
134-
match.ipv4
135-
? `${match.ipv4}:${match.port}`
136-
: `[${match.ipv6}]:${match.port}`
137-
);
138-
}
119+
// const straceLog = await fs.readFile(outfile, 'utf8');
120+
// const connectCalls = straceLog.matchAll(/\bconnect\s*\((?<args>.*)\) =/g);
121+
// const connectTargets = new Set<string>();
122+
// for (const { groups } of connectCalls) {
123+
// const args = groups!.args;
124+
// // Possible format for the address argument in 'args':
125+
// // sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"
126+
// // sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1")
127+
// // 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
128+
// if (!args.includes('AF_INET')) continue;
129+
// const match = args.match(
130+
// /sa_family=AF_INET6?.*sin6?_port=htons\((?<port>\d+)\).*inet_(addr\("(?<ipv4>[^"]+)"\)|pton\(AF_INET6,\s*"(?<ipv6>[^"]+)")/
131+
// )?.groups;
132+
// if (!match) {
133+
// throw new Error(`Unknown traced connect() target: ${args}`);
134+
// }
135+
// connectTargets.add(
136+
// match.ipv4
137+
// ? `${match.ipv4}:${match.port}`
138+
// : `[${match.ipv6}]:${match.port}`
139+
// );
140+
// }
139141

140-
const unexpectedHosts = [...connectTargets].filter(
141-
(target) => !/^127.0.0.1:|^\[::1\]:/.test(target)
142-
);
143-
if (unexpectedHosts.length > 0) {
144-
throw new Error(`Connected to unexpected host! ${[...unexpectedHosts]}`);
145-
}
146-
if (![...connectTargets].some((target) => /:27091$/.test(target))) {
147-
throw new Error(
148-
`Missed connection to database server in connect trace! ${[
149-
...connectTargets,
150-
]}`
151-
);
152-
}
142+
// const unexpectedHosts = [...connectTargets].filter(
143+
// (target) => !/^127.0.0.1:|^\[::1\]:/.test(target)
144+
// );
145+
// if (unexpectedHosts.length > 0) {
146+
// throw new Error(`Connected to unexpected host! ${[...unexpectedHosts]}`);
147+
// }
148+
// if (![...connectTargets].some((target) => /:27091$/.test(target))) {
149+
// throw new Error(
150+
// `Missed connection to database server in connect trace! ${[
151+
// ...connectTargets,
152+
// ]}`
153+
// );
154+
// }
153155
});
154156
});

0 commit comments

Comments
 (0)