mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 21:07:46 +00:00
[tests] split python e2e tests into chunks (#9771)
Split python tests into two chunks. They take <10m each.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
"build": "node build",
|
||||
"test": "jest --env node --verbose --runInBand --bail",
|
||||
"test-unit": "pnpm test test/unit.test.ts",
|
||||
"test-e2e": "pnpm test test/integration.test.ts"
|
||||
"test-e2e": "pnpm test test/integration-*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/execa": "^0.9.0",
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
require('./integration-setup')(1);
|
||||
|
||||
// NOTE: The fixture `00-request-path` has special case handling for local dev support below
|
||||
|
||||
const assert = require('assert');
|
||||
const fetch = require('node-fetch');
|
||||
const execa = require('execa');
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
const {
|
||||
testDeployment,
|
||||
} = require('../../../test/lib/deployment/test-deployment.js');
|
||||
|
||||
jest.setTimeout(4 * 60 * 1000);
|
||||
const path = require('path');
|
||||
|
||||
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
||||
|
||||
@@ -70,35 +67,3 @@ it('should match the probes against Python dev servers', async () => {
|
||||
process.kill(asgiServer.pid);
|
||||
}
|
||||
});
|
||||
|
||||
const testsThatFailToBuild = new Map([
|
||||
['30-fail-build-invalid-pipfile', 'Unable to parse Pipfile.lock'],
|
||||
[
|
||||
'31-fail-build-invalid-python36',
|
||||
'Python version "3.6" detected in Pipfile.lock is discontinued and must be upgraded.',
|
||||
],
|
||||
]);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const fixture of fs.readdirSync(fixturesPath)) {
|
||||
const errMsg = testsThatFailToBuild.get(fixture);
|
||||
if (errMsg) {
|
||||
// eslint-disable-next-line no-loop-func
|
||||
it(`should fail to build ${fixture}`, async () => {
|
||||
try {
|
||||
await testDeployment(path.join(fixturesPath, fixture));
|
||||
} catch (err) {
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.deployment).toBeTruthy();
|
||||
expect(err.deployment.errorMessage).toBe(errMsg);
|
||||
}
|
||||
});
|
||||
continue; //eslint-disable-line
|
||||
}
|
||||
// eslint-disable-next-line no-loop-func
|
||||
it(`should build ${fixture}`, async () => {
|
||||
await expect(
|
||||
testDeployment(path.join(fixturesPath, fixture))
|
||||
).resolves.toBeDefined();
|
||||
});
|
||||
}
|
||||
1
packages/python/test/integration-2.test.ts
vendored
Normal file
1
packages/python/test/integration-2.test.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
require('./integration-setup')(2);
|
||||
52
packages/python/test/integration-setup.js
vendored
Normal file
52
packages/python/test/integration-setup.js
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { intoChunks } = require('../../../utils/chunk-tests');
|
||||
|
||||
const {
|
||||
testDeployment,
|
||||
} = require('../../../test/lib/deployment/test-deployment.js');
|
||||
|
||||
jest.setTimeout(4 * 60 * 1000);
|
||||
|
||||
module.exports = function setupTests(groupIndex) {
|
||||
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
||||
const testsThatFailToBuild = new Map([
|
||||
['30-fail-build-invalid-pipfile', 'Unable to parse Pipfile.lock'],
|
||||
[
|
||||
'31-fail-build-invalid-python36',
|
||||
'Python version "3.6" detected in Pipfile.lock is discontinued and must be upgraded.',
|
||||
],
|
||||
]);
|
||||
const allFixtures = fs.readdirSync(fixturesPath);
|
||||
|
||||
let chunkedFixtures = allFixtures;
|
||||
if (typeof groupIndex !== 'undefined') {
|
||||
chunkedFixtures = intoChunks(1, 2, allFixtures)[groupIndex - 1];
|
||||
|
||||
console.log('testing group', groupIndex, chunkedFixtures);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const fixture of chunkedFixtures) {
|
||||
const errMsg = testsThatFailToBuild.get(fixture);
|
||||
if (errMsg) {
|
||||
// eslint-disable-next-line no-loop-func
|
||||
it(`should fail to build ${fixture}`, async () => {
|
||||
try {
|
||||
await testDeployment(path.join(fixturesPath, fixture));
|
||||
} catch (err) {
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.deployment).toBeTruthy();
|
||||
expect(err.deployment.errorMessage).toBe(errMsg);
|
||||
}
|
||||
});
|
||||
continue; //eslint-disable-line
|
||||
}
|
||||
// eslint-disable-next-line no-loop-func
|
||||
it(`should build ${fixture}`, async () => {
|
||||
await expect(
|
||||
testDeployment(path.join(fixturesPath, fixture))
|
||||
).resolves.toBeDefined();
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user