Skip to content

Commit

Permalink
Merge pull request #5710 from Agoric/mhofman/5447-fix-controller-shut…
Browse files Browse the repository at this point in the history
…down-leak

fix: shutdown controller after tests
  • Loading branch information
mergify[bot] authored Jul 2, 2022
2 parents 9ed4278 + 26766f6 commit f784f83
Show file tree
Hide file tree
Showing 56 changed files with 217 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ async function main(basedir, argv) {
config.defaultManagerType = 'xs-worker';
const controller = await buildVatController(config, argv);
await controller.run();
return controller.dump();
const res = controller.dump();
await controller.shutdown();
return res;
}

const expected = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ async function main(basedir, argv) {
config.defaultManagerType = 'xs-worker';
const controller = await buildVatController(config, argv);
await controller.run();
return controller.dump();
const res = controller.dump();
await controller.shutdown();
return res;
}

const expectedTapFaucetLog = [
Expand Down
4 changes: 4 additions & 0 deletions packages/SwingSet/test/bundling/test-bundles-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test('install bundle', async t => {
const config = {};
const controller = await buildVatController(config);
await controller.run();
t.teardown(controller.shutdown);

const bundleFile = new URL('./bootstrap-bundles.js', import.meta.url)
.pathname;
Expand All @@ -26,6 +27,7 @@ test('install bundle', async t => {
test('install bundle without ID', async t => {
const config = {};
const controller = await buildVatController(config);
t.teardown(controller.shutdown);
await controller.run();

const bundleFile = new URL('./bootstrap-bundles.js', import.meta.url)
Expand All @@ -40,6 +42,7 @@ test('install bundle without ID', async t => {
test('install invalid bundle fails', async t => {
const config = {};
const controller = await buildVatController(config);
t.teardown(controller.shutdown);
await controller.run();

const bundleFile = new URL('./bootstrap-bundles.js', import.meta.url)
Expand All @@ -59,6 +62,7 @@ test('install invalid bundle fails', async t => {
test('install corrupt bundle fails', async t => {
const config = {};
const controller = await buildVatController(config);
t.teardown(controller.shutdown);
await controller.run();

const bundleFile = new URL('./bootstrap-bundles.js', import.meta.url)
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/test/bundling/test-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ test('bundles', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage);
const c = await makeSwingsetController(hostStorage);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
await c.run();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async function testChangeParameters(t) {
const { kvStore } = hostStorage;
await initializeSwingset(config, [], hostStorage);
const c = await makeSwingsetController(hostStorage, null);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
await c.run();
t.is(kvStore.get('kernel.defaultReapInterval'), '1');
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/test/definition/test-vat-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ test('create with setup and buildRootObject', async t => {
},
};
const c = await buildVatController(config, []);
t.teardown(c.shutdown);
c.pinVatRoot('setup');
c.pinVatRoot('liveslots');
let r = c.queueToVatRoot('setup', 'increment', [], 'panic');
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/test/device-hooks/test-device-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ test('add hook', async t => {
const runtimeOpts = { kernelBundle };
await initializeSwingset(config, [], hostStorage, initOpts);
const c = await makeSwingsetController(hostStorage, {}, runtimeOpts);
t.teardown(c.shutdown);

let hookreturn;
function setHookReturn(args, slots = []) {
Expand Down
3 changes: 3 additions & 0 deletions packages/SwingSet/test/device-mailbox/test-device-mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ test('mailbox outbound', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, ['mailbox1'], hostStorage, initOpts);
const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts);
t.teardown(c.shutdown);
await c.run();
// exportToData() provides plain Numbers to the host that needs to convey the messages
t.deepEqual(s.exportToData(), {
Expand Down Expand Up @@ -95,6 +96,7 @@ test('mailbox inbound', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, ['mailbox2'], hostStorage, initOpts);
const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts);
t.teardown(c.shutdown);
await c.run();
const m1 = [1, 'msg1'];
const m2 = [2, 'msg2'];
Expand Down Expand Up @@ -165,6 +167,7 @@ async function makeMailboxKernel(t, hostStorage) {
};
const { runtimeOpts } = bundleOpts(t.context.data);
const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
await c.run();
return [c, mb];
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/test/device-plugin/test-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ async function setupVatController(t) {
t.context.hostStorage,
deviceEndowments,
);
t.teardown(c.shutdown);
const cycle = async () => {
await c.run();
while (inputQueue.length) {
Expand Down
10 changes: 10 additions & 0 deletions packages/SwingSet/test/devices/test-devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ test.serial('d0', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage, initOpts);
const c = await makeSwingsetController(hostStorage, {}, runtimeOpts);
t.teardown(c.shutdown);
await c.run();

// console.log(util.inspect(c.dump(), { depth: null }));
Expand Down Expand Up @@ -120,6 +121,7 @@ test.serial('d1', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage, initOpts);
const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
await c.run();

Expand Down Expand Up @@ -156,6 +158,7 @@ async function test2(t, mode) {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage, initOpts);
const c = await makeSwingsetController(hostStorage, {}, runtimeOpts);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
await c.run(); // startup

Expand Down Expand Up @@ -247,6 +250,7 @@ test.serial('device state', async t => {
// from bootstrap, and read it back.
await initializeSwingset(config, ['write+read'], hostStorage, initOpts);
const c1 = await makeSwingsetController(hostStorage, {}, runtimeOpts);
t.teardown(c1.shutdown);
const d3 = c1.deviceNameToID('d3');
await c1.run();
t.deepEqual(c1.dump().log, ['undefined', 'w+r', 'called', 'got {"s":"new"}']);
Expand Down Expand Up @@ -279,6 +283,7 @@ test.serial('command broadcast', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage, initOpts);
const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
c.queueToVatRoot('bootstrap', 'doCommand1', [], 'panic');
await c.run();
Expand Down Expand Up @@ -308,6 +313,7 @@ test.serial('command deliver', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage, initOpts);
const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
c.queueToVatRoot('bootstrap', 'doCommand2', [], 'panic');
await c.run();
Expand Down Expand Up @@ -350,6 +356,7 @@ test.serial('liveslots throws when D() gets promise', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage, initOpts);
const c = await makeSwingsetController(hostStorage, {}, runtimeOpts);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');

// When liveslots catches an attempt to send a promise into D(), it throws
Expand Down Expand Up @@ -389,6 +396,7 @@ test.serial('syscall.callNow(promise) is vat-fatal', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage, initOpts);
const c = await makeSwingsetController(hostStorage, {}, runtimeOpts);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
await c.run();

Expand Down Expand Up @@ -430,6 +438,7 @@ test.serial('device errors cause vat-catchable D error', async t => {
initOpts,
);
const c = await makeSwingsetController(hostStorage, {}, runtimeOpts);
t.teardown(c.shutdown);
await c.run();

t.is(c.kpStatus(bootstrapResult), 'fulfilled'); // not 'rejected'
Expand Down Expand Up @@ -469,6 +478,7 @@ test.serial('foreign device nodes cause a catchable error', async t => {
initOpts,
);
const c = await makeSwingsetController(hostStorage, {}, runtimeOpts);
t.teardown(c.shutdown);
await c.run();

t.is(c.kpStatus(bootstrapResult), 'fulfilled'); // not 'rejected'
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/test/devices/test-raw-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ test('d1', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage, initOpts);
const c = await makeSwingsetController(hostStorage, devEndows, runtimeOpts);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
await c.run();

Expand Down
2 changes: 2 additions & 0 deletions packages/SwingSet/test/gc/test-gc-vat.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async function dropPresence(t, dropExport) {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage);
const c = await makeSwingsetController(hostStorage);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
t.teardown(c.shutdown);
await c.run();
Expand Down Expand Up @@ -116,6 +117,7 @@ test('forward to fake zoe', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage);
const c = await makeSwingsetController(hostStorage);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
const targetID = c.vatNameToID('target');
c.pinVatRoot('target');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test('unmetered dynamic vat', async t => {
},
};
const c = await buildVatController(config, []);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');

// let the vatAdminService get wired up before we create any new vats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async function testPromiseWatcher(t) {
// ? const { kvStore } = hostStorage;
await initializeSwingset(config, [], hostStorage);
const c = await makeSwingsetController(hostStorage);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
await c.run();

Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/run-policy/test-run-policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ async function testCranks(t, mode) {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage);
const c = await makeSwingsetController(hostStorage);
t.teardown(c.shutdown);
c.pinVatRoot('left');
const rightKref = c.pinVatRoot('right');
const rightID = c.vatNameToID('right');
t.teardown(c.shutdown);
await c.run();

if (mode === 'messages' || mode === 'wallclock') {
Expand Down
6 changes: 6 additions & 0 deletions packages/SwingSet/test/test-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function removeTriple(arr, a, b, c) {
test('load empty', async t => {
const config = {};
const controller = await buildVatController(config);
t.teardown(controller.shutdown);
await controller.run();
t.truthy(true);
});
Expand All @@ -42,6 +43,7 @@ async function simpleCall(t) {
};
const hostStorage = provideHostStorage();
const controller = await buildVatController(config, [], { hostStorage });
t.teardown(controller.shutdown);
const data = controller.dump();
// note: data.vatTables is sorted by vatID, but we have no particular
// reason to believe that vat1 will get a lower ID than vatAdmin, because
Expand Down Expand Up @@ -113,6 +115,7 @@ test('bootstrap', async t => {
new URL('basedir-controller-2', import.meta.url).pathname,
);
const c = await buildVatController(config);
t.teardown(c.shutdown);
await c.run();
t.deepEqual(c.dump().log, ['buildRootObject called', 'bootstrap called']);
});
Expand All @@ -124,6 +127,7 @@ test('XS bootstrap', async t => {
config.defaultManagerType = 'xs-worker';
const hostStorage = provideHostStorage();
const c = await buildVatController(config, [], { hostStorage });
t.teardown(c.shutdown);
await c.run();
t.deepEqual(c.dump().log, ['buildRootObject called', 'bootstrap called']);
t.is(
Expand Down Expand Up @@ -158,6 +162,7 @@ test('static vats are unmetered on XS', async t => {
},
},
);
t.teardown(c.shutdown);
await c.run();
t.deepEqual(c.dump().log, ['buildRootObject called', 'bootstrap called']);
t.deepEqual(limited, [false, false, false, false]);
Expand All @@ -179,6 +184,7 @@ test.serial('bootstrap export', async t => {
);
config.defaultManagerType = 'xs-worker';
const c = await buildVatController(config);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');
const vatAdminVatID = c.vatNameToID('vatAdmin');
const vatAdminDevID = c.deviceNameToID('vatAdmin');
Expand Down
4 changes: 3 additions & 1 deletion packages/SwingSet/test/test-demos-comms.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ async function main(basedir, argv) {
);

await controller.run();
return controller.dump();
const res = controller.dump();
await controller.shutdown();
return res;
}

const encouragementBotCommsGolden = [
Expand Down
4 changes: 3 additions & 1 deletion packages/SwingSet/test/test-demos.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ async function main(basedir, argv) {
deviceEndowments,
);
await controller.run();
return controller.dump();
const res = controller.dump();
await controller.shutdown();
return res;
}

const encouragementBotGolden = [
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/test/test-device-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ test('bridge device', async t => {
};

const c2 = await makeSwingsetController(hostStorage, endowments2);
t.teardown(c2.shutdown);
await c2.run();
// The bootstrap is reloaded from transcript, which means it doesn't run
// any syscalls (they are switched off during replay), so it won't re-run
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/test/test-exomessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ async function beginning(t, mode) {
},
};
const controller = await buildVatController(config, [mode]);
t.teardown(controller.shutdown);
t.is(controller.kpStatus(controller.bootstrapResult), 'unresolved');
return controller;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/SwingSet/test/test-gc-kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,7 @@ test('terminated vat', async t => {
},
};
const c = await buildVatController(config, []);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');

function getRefCountsAndOwners() {
Expand Down Expand Up @@ -1217,6 +1218,7 @@ test.serial('device transfer', async t => {
const hostStorage = provideHostStorage();
await initializeSwingset(config, [], hostStorage);
const c = await makeSwingsetController(hostStorage);
t.teardown(c.shutdown);
c.pinVatRoot('bootstrap');

// The bootstrap() message is already queued. When we call c.step(), it
Expand Down
Loading

0 comments on commit f784f83

Please sign in to comment.