use fresher node and debian version (#1255)

This moves to node 22 and debian bookworm, since the versions we've been building and testing with are getting old.

There is some old material kept around for (speaks very quietly) Python 2 (looks around hoping no-one heard) which we continue to support for some long-time users but really really should drop soon.

The changes for the node upgrade were all test related. I did them in a way that shouldn't impair running on older versions of node, and did spot checks for this. This is to give some breathing room for upgrading Grist Lab's grist-saas as follow up work.
This commit is contained in:
Paul Fitzpatrick
2024-10-10 16:59:03 -04:00
committed by GitHub
parent 1a527d74a0
commit aa69652a33
11 changed files with 127 additions and 61 deletions

View File

@@ -76,6 +76,8 @@ function makeConfig(username: string): AxiosRequestConfig {
}
describe('DocApi', function () {
const webhooksTestPort = Number(process.env.WEBHOOK_TEST_PORT || 34365);
this.timeout(30000);
testUtils.setTmpLogLevel('error');
let oldEnv: testUtils.EnvironmentSnapshot;
@@ -121,7 +123,7 @@ describe('DocApi', function () {
homeUrl = serverUrl = home.serverUrl;
hasHomeApi = true;
});
testDocApi();
testDocApi({webhooksTestPort});
});
describe('With GRIST_ANON_PLAYGROUND disabled', async () => {
@@ -157,7 +159,7 @@ describe('DocApi', function () {
homeUrl = serverUrl = home.serverUrl;
hasHomeApi = true;
});
testDocApi();
testDocApi({webhooksTestPort});
});
describe('behind a reverse-proxy', function () {
@@ -206,7 +208,7 @@ describe('DocApi', function () {
after(() => tearDown(proxy, [home, docs]));
testDocApi();
testDocApi({webhooksTestPort});
});
async function testCompareDocs(proxy: TestServerReverseProxy, home: TestServer) {
@@ -261,7 +263,7 @@ describe('DocApi', function () {
serverUrl = docs.serverUrl;
hasHomeApi = false;
});
testDocApi();
testDocApi({webhooksTestPort});
});
}
@@ -323,7 +325,10 @@ describe('DocApi', function () {
});
// Contains the tests. This is where you want to add more test.
function testDocApi() {
function testDocApi(settings: {
webhooksTestPort: number,
}) {
const { webhooksTestPort } = settings;
let chimpy: AxiosRequestConfig, kiwi: AxiosRequestConfig,
charon: AxiosRequestConfig, nobody: AxiosRequestConfig, support: AxiosRequestConfig;
@@ -3478,13 +3483,20 @@ function testDocApi() {
});
describe('webhooks related endpoints', async function () {
const serving: Serving = await serveSomething(app => {
app.use(express.json());
app.post('/200', ({body}, res) => {
res.sendStatus(200);
res.end();
});
}, webhooksTestPort);
let serving: Serving;
before(async function () {
serving = await serveSomething(app => {
app.use(express.json());
app.post('/200', ({body}, res) => {
res.sendStatus(200);
res.end();
});
}, webhooksTestPort);
});
after(async function () {
await serving.shutdown();
});
/*
Regression test for old _subscribe endpoint. /docs/{did}/webhooks should be used instead to subscribe
@@ -3577,7 +3589,8 @@ function testDocApi() {
}
}]
},
403, /Column not found notExisting/);
// this check was previously just wrong, was the test not running somehow??
404, /Column not found "notExisting"/);
});
@@ -5385,8 +5398,6 @@ async function getWorkspaceId(api: UserAPIImpl, name: string) {
return workspaces.find((w) => w.name === name)!.id;
}
const webhooksTestPort = Number(process.env.WEBHOOK_TEST_PORT || 34365);
async function setupDataDir(dir: string) {
// we'll be serving Hello.grist content for various document ids, so let's make copies of it in
// tmpDir

View File

@@ -84,15 +84,17 @@ describe("ProxyAgent", function () {
it("should report error when proxy fails", async function() {
// if the proxy isn't listening, fetches produces error messages.
await testProxyServer.dispose();
// Error message depends a little on node version.
const logMessages2 = await captureLog('warn', async () => {
await assert.isRejected(testFetch('/200'), /ECONNREFUSED/);
await assert.isRejected(testFetch('/404'), /ECONNREFUSED/);
await assert.isRejected(testFetch('/200'), /(request.*failed)|(ECONNREFUSED)/);
await assert.isRejected(testFetch('/404'), /(request.*failed)|(ECONNREFUSED)/);
});
// We rely on "ProxyAgent error" message to detect issues with the proxy server.
// Error message depends a little on node version.
assertMatchArray(logMessages2, [
/warn: ProxyAgent error.*ECONNREFUSED/,
/warn: ProxyAgent error.*ECONNREFUSED/,
/warn: ProxyAgent error.*((request.*failed)|(ECONNREFUSED)|(AggregateError))/,
/warn: ProxyAgent error.*((request.*failed)|(ECONNREFUSED)|(AggregateError))/,
]);
});
});

View File

@@ -51,7 +51,8 @@ describe('UnhandledErrors', function() {
}, 1000, 100);
// We expect the server to be dead now.
await assert.isRejected(fetch(`${server.serverUrl}/status`), /failed.*ECONNREFUSED/);
// Error message depends a little on node version.
await assert.isRejected(fetch(`${server.serverUrl}/status`), /(request.*failed)|(ECONNREFUSED)/);
} finally {
await server.stop();