Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SwingSet): Support SLOG* environment variables when running tests #10061

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"lint:eslint": "eslint ."
},
"devDependencies": {
"@agoric/telemetry": "^0.6.2",
"@types/better-sqlite3": "^7.6.9",
"@types/microtime": "^2.1.0",
"@types/tmp": "^0.2.0",
Expand Down
18 changes: 9 additions & 9 deletions packages/SwingSet/test/vat-admin/terminate/terminate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { kser, kunser } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';

import {
buildVatController,
loadSwingsetConfigFile,
buildKernelBundles,
} from '../../../src/index.js';
import { enumeratePrefixedKeys } from '../../../src/kernel/state/storageHelper.js';
import { buildTestVatController } from '../../../tools/test-vat-controller.js';
import { restartVatAdminVat } from '../../util.js';

test.before(async t => {
Expand Down Expand Up @@ -44,7 +44,7 @@ async function doTerminateNonCritical(
const config = await loadSwingsetConfigFile(configPath);
config.defaultReapInterval = 'never';
const kernelStorage = initSwingStore().kernelStorage;
const controller = await buildVatController(config, [], {
const controller = await buildTestVatController(config, [], {
...t.context.data,
kernelStorage,
});
Expand Down Expand Up @@ -108,7 +108,7 @@ async function doTerminateCritical(
const config = await loadSwingsetConfigFile(configPath);
config.defaultReapInterval = 'never';
const kernelStorage = initSwingStore().kernelStorage;
const controller = await buildVatController(config, [], {
const controller = await buildTestVatController(config, [], {
...t.context.data,
kernelStorage,
});
Expand Down Expand Up @@ -382,7 +382,7 @@ test.serial('exit with presence', async t => {
.pathname;
const config = await loadSwingsetConfigFile(configPath);
config.defaultReapInterval = 'never';
const controller = await buildVatController(config, [], t.context.data);
const controller = await buildTestVatController(config, [], t.context.data);
t.teardown(controller.shutdown);
await controller.run();
t.deepEqual(controller.dump().log, [
Expand All @@ -401,7 +401,7 @@ test.serial('dispatches to the dead do not harm kernel', async t => {

const ss1 = initSwingStore();
{
const c1 = await buildVatController(config, [], {
const c1 = await buildTestVatController(config, [], {
kernelStorage: ss1.kernelStorage,
kernelBundles: t.context.data.kernelBundles,
});
Expand All @@ -420,7 +420,7 @@ test.serial('dispatches to the dead do not harm kernel', async t => {
const serialized = ss1.debug.serialize();
const ss2 = initSwingStore(null, { serialized });
{
const c2 = await buildVatController(config, [], {
const c2 = await buildTestVatController(config, [], {
kernelStorage: ss2.kernelStorage,
kernelBundles: t.context.data.kernelBundles,
});
Expand All @@ -442,7 +442,7 @@ test.serial('invalid criticalVatKey causes vat creation to fail', async t => {
.pathname;
const config = await loadSwingsetConfigFile(configPath);
config.defaultReapInterval = 'never';
const controller = await buildVatController(config, [], t.context.data);
const controller = await buildTestVatController(config, [], t.context.data);
t.teardown(controller.shutdown);
await t.throwsAsync(() => controller.run(), {
message: /invalid criticalVatKey/,
Expand All @@ -456,7 +456,7 @@ test.serial('dead vat state removed', async t => {
config.defaultReapInterval = 'never';
const { kernelStorage, debug } = initSwingStore();

const controller = await buildVatController(config, [], {
const controller = await buildTestVatController(config, [], {
kernelStorage,
kernelBundles: t.context.data.kernelBundles,
});
Expand Down Expand Up @@ -492,7 +492,7 @@ test.serial('terminate with presence', async t => {
).pathname;
const config = await loadSwingsetConfigFile(configPath);
config.defaultReapInterval = 'never';
const controller = await buildVatController(config, [], t.context.data);
const controller = await buildTestVatController(config, [], t.context.data);
t.teardown(controller.shutdown);
await controller.run();
t.deepEqual(controller.dump().log, [
Expand Down
23 changes: 23 additions & 0 deletions packages/SwingSet/tools/test-vat-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import process from 'node:process';
// eslint-disable-next-line import/no-extraneous-dependencies
import { makeSlogSender } from '@agoric/telemetry';
import { buildVatController } from '../src/index.js';

export const buildTestVatController = async (
config,
argv,
runtimeOptions,
deviceEndowments,
) => {
const { env = process.env, slogSender: explicitSlogSender } = runtimeOptions;
await null;
if (
!explicitSlogSender &&
(env.SLOGFILE || env.SLOGSENDER || env.SLOGSENDER_AGENT)
) {
const slogSender = await makeSlogSender({ env });
runtimeOptions = { ...runtimeOptions, slogSender };
}
return buildVatController(config, argv, runtimeOptions, deviceEndowments);
};
harden(buildTestVatController);
Loading