Files
wekan/tests/ferretdbPolling.test.cjs
T
Lauri Ojansivu 794346e396 cpu-exec qemu-user fallback everywhere; tests for all newest fixes.
Fix #6458 completely: the reporter's host runs inside a hypervisor that
masks AVX, and the old per-tool AVX wrappers (amd64-only, PATH-based)
were bypassed by absolute-path mongod invocations.

- New general snap-src/bin/cpu-exec: runs any binary directly when the
  CPU has the features it declares (--features x86_64=avx,aarch64=atomics
  or WEKAN_REQUIRED_CPU_FEATURES) and through same-arch qemu-user when
  not; plain zero-overhead exec with no declared features. Lookup order:
  WEKAN_QEMU_USER, qemu-<arch> next to the script (bundle/Docker),
  $SNAP/qemu-<arch>, the snap's migratemongo/avx one, then system
  qemu-user(-static). Clear error + direct run when no qemu exists, so
  the real SIGILL surfaces instead of hiding.
- Snap: mongodb-control and migration-control run every mongod 7 through
  cpu-exec, so MongoDB works without AVX (slower) and migration can READ
  modern MongoDB data on such CPUs; completed-FerretDB switch and
  migration fallbacks unchanged (switch_to_completed_ferretdb extracted).
- release-all.yml: every Linux bundle .zip ships cpu-exec + this-arch's
  static qemu-user (amd64/arm64/ppc64le/s390x/riscv64; stripped from
  win64/mac bundles), flowing into Docker and Snap automatically;
  Sandstorm .spk gets both via build-deps.sh. Bundle launcher and Docker
  entrypoint route node/ferretdb through cpu-exec.
- Docs: mongodb-avx-qemu.md and mongodb-raspi4-qemu.md document the
  built-in mechanism.

Tests, with negative cases, for the newest features and fixes at
changelog: htmljs array-vs-attributes (#6459), description draft
normalize/reset (#6455), comment draft lifecycle (#5547), attachment
delete guard (#5282), rules move actions + import normalization (#6472),
snap mongod-failure/migration recovery (#6458 #6466), FerretDB polling
defaults (#6467 #6468), UI density guards for every #6465 fix, and a
behavioral cpu-exec test against fake cpuinfo + fake qemu. All wired
into test:unit:node. Go table tests for the FerretDB SQLite filter
pushdown are in the wekan/FerretDB repo.

Updated ChangeLog.

Thanks to xet7.
2026-07-16 17:40:24 +03:00

63 lines
2.7 KiB
JavaScript

'use strict';
// Plain-Node regression guard (no Meteor) for issues #6467/#6468 (WeKan side):
// with FerretDB there is no oplog, so Meteor observes every query by POLLING —
// and Meteor's defaults re-run every observed query 50 ms after ANY write and
// at least every 10 s, which multiplied into hundreds of full queries per
// second and pinned FerretDB's CPU at 250-400% for 1-2 users. The snap and the
// bundle launcher must default to calmer polling when the database is
// FerretDB, while keeping user overrides.
// Run: node tests/ferretdbPolling.test.cjs
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const repoRoot = path.resolve(__dirname, '..');
const read = rel => fs.readFileSync(path.join(repoRoot, rel), 'utf8');
const wekanControl = read('snap-src/bin/wekan-control');
const startWekan = read('releases/ferretdb/start-wekan.sh');
let passed = 0;
function test(name, fn) {
fn();
passed += 1;
console.log(' ok -', name);
}
test('snap: calm polling defaults exist for the ferretdb database', () => {
assert.ok(wekanControl.includes('METEOR_POLLING_THROTTLE_MS=2000'));
assert.ok(wekanControl.includes('METEOR_POLLING_INTERVAL_MS=30000'));
});
test('snap: the defaults are scoped to database=ferretdb', () => {
const block = wekanControl.match(
/if \[ "ferretdb" = "\$\{DATABASE\}" \]; then[\s\S]*?METEOR_POLLING_INTERVAL_MS[\s\S]*?\nfi/,
);
assert.ok(block, 'polling exports live inside a ferretdb-only guard — MongoDB uses the oplog');
});
test('snap: user-provided values are respected (only set when empty)', () => {
assert.ok(/\[ -z "\$\{METEOR_POLLING_THROTTLE_MS\}" \] && export METEOR_POLLING_THROTTLE_MS=2000/.test(wekanControl));
assert.ok(/\[ -z "\$\{METEOR_POLLING_INTERVAL_MS\}" \] && export METEOR_POLLING_INTERVAL_MS=30000/.test(wekanControl));
});
test('bundle launcher: same defaults, same override semantics', () => {
assert.ok(startWekan.includes('METEOR_POLLING_THROTTLE_MS="${METEOR_POLLING_THROTTLE_MS:-2000}"'));
assert.ok(startWekan.includes('METEOR_POLLING_INTERVAL_MS="${METEOR_POLLING_INTERVAL_MS:-30000}"'));
});
test('bundle launcher: defaults only apply when the bundled FerretDB is used', () => {
assert.ok(/if \[ "\$want_ferret" = true \]; then\s*\n\s*export METEOR_POLLING_THROTTLE_MS/.test(startWekan),
'pointing MONGO_URL at an external MongoDB must keep Meteor defaults');
});
test('negative: the snap does not advertise an oplog URL for ferretdb', () => {
// The whole point of the polling defaults: with FerretDB there is no oplog.
assert.ok(/\[ "ferretdb" != "\$\{DATABASE\}" \]/.test(wekanControl),
'MONGO_OPLOG_URL stays MongoDB-only');
});
console.log(`\n${passed} tests passed`);