Skip to content

Commit

Permalink
chore(swingset-liveslots): add retry logic to liveslots-real-gc test (#…
Browse files Browse the repository at this point in the history
…11015)

refs: #9392

## Description
Adding retry logic to all liveslots-real-gc tests as a temporary workaround to substantially reduce flakiness due to node GC non-determinism.

### Security Considerations
N/A

### Scaling Considerations
some [infrequently] failing tests will get to run twice.

### Documentation Considerations
N/A

### Testing Considerations
Tested manually.

### Upgrade Considerations
N/A
  • Loading branch information
siarhei-agoric authored Feb 19, 2025
1 parent fe64626 commit 42dbac1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
20 changes: 20 additions & 0 deletions packages/internal/tools/avaRetry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Run the test and retry once if it fails.
*
* @param {any} test - AVA test driver function.
* @param {string} title - The title of the test.
* @param {import('ava').Implementation<unknown[]>} predicate - The test
* implementation.
*/
export const avaRetry = (test, title, predicate) => {
test(title, async t => {
const result = await t.try(predicate);
if (result.passed) {
result.commit();
} else {
result.discard();
const retryResult = await t.try(predicate);
retryResult.commit();
}
});
};
16 changes: 9 additions & 7 deletions packages/swingset-liveslots/test/liveslots-real-gc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import test from 'ava';
import { Far } from '@endo/marshal';
import { makePromiseKit } from '@endo/promise-kit';
import { kslot, kser } from '@agoric/kmarshal';
import { avaRetry } from '@agoric/internal/tools/avaRetry.js';
import engineGC from './engine-gc.js';
import { watchCollected, makeGcAndFinalize } from './gc-and-finalize.js';
import { buildSyscall, makeDispatch } from './liveslots-helpers.js';
Expand All @@ -26,7 +27,7 @@ const gcAndFinalize = makeGcAndFinalize(engineGC);
// inconsistent GC behavior under Node.js and AVA with tests running
// in parallel, so we mark them all with test.serial()

test.serial('liveslots retains pending exported promise', async t => {
avaRetry(test.serial, 'liveslots retains pending exported promise', async t => {
const { log, syscall } = buildSyscall();
let collected;
const success = [];
Expand Down Expand Up @@ -64,7 +65,7 @@ test.serial('liveslots retains pending exported promise', async t => {
t.deepEqual(success, ['yes']);
});

test.serial('liveslots retains device nodes', async t => {
avaRetry(test.serial, 'liveslots retains device nodes', async t => {
const { syscall } = buildSyscall();
let collected;
const recognize = new WeakSet(); // real WeakSet
Expand Down Expand Up @@ -92,7 +93,7 @@ test.serial('liveslots retains device nodes', async t => {
t.deepEqual(success, [true]);
});

test.serial('GC syscall.dropImports', async t => {
avaRetry(test.serial, 'GC syscall.dropImports', async t => {
const { log, syscall } = buildSyscall();
let collected;
function build(_vatPowers) {
Expand Down Expand Up @@ -177,7 +178,7 @@ test.serial('GC syscall.dropImports', async t => {
t.deepEqual(log, []);
});

test.serial('GC dispatch.retireImports', async t => {
avaRetry(test.serial, 'GC dispatch.retireImports', async t => {
const { log, syscall } = buildSyscall();
function build(_vatPowers) {
// eslint-disable-next-line no-unused-vars
Expand Down Expand Up @@ -210,7 +211,7 @@ test.serial('GC dispatch.retireImports', async t => {
// when we implement VOM.vrefIsRecognizable, this test might do more
});

test.serial('GC dispatch.retireExports', async t => {
avaRetry(test.serial, 'GC dispatch.retireExports', async t => {
const { log, syscall } = buildSyscall();
function build(_vatPowers) {
const ex1 = Far('export', {});
Expand Down Expand Up @@ -253,7 +254,7 @@ test.serial('GC dispatch.retireExports', async t => {
t.deepEqual(log, []);
});

test.serial('GC dispatch.dropExports', async t => {
avaRetry(test.serial, 'GC dispatch.dropExports', async t => {
const { log, syscall } = buildSyscall();
let collected;
function build(_vatPowers) {
Expand Down Expand Up @@ -326,7 +327,8 @@ test.serial('GC dispatch.dropExports', async t => {
t.deepEqual(log, []);
});

test.serial(
avaRetry(
test.serial,
'GC dispatch.retireExports inhibits syscall.retireExports',
async t => {
const { log, syscall } = buildSyscall();
Expand Down

0 comments on commit 42dbac1

Please sign in to comment.