// compare.mjs's arguments. const usage = 'usage: node harness/compare.mjs [--steps N] [--seed N] [--check-every N] [--crash-every N] [--firehose] [--commands] [--s3] [--limits | --invites | --lifecycle | --moves | --store | --scale | --pages | --upgrade | --upgrade-write | --migrate] [--only name,...] [--impl name] [--area name --result file.json] [--tally file.json] -- ' const dash = process.argv.indexOf('--') const opts = process.argv.slice(2, dash === -1 ? undefined : dash) /// The command that starts the server. export const command = dash === -1 ? [] : process.argv.slice(dash + 1) const opt = (name, fallback) => { const i = opts.indexOf(name) return i === -1 ? fallback : Number(opts[i + 1]) } const str = (name, fallback) => { const i = opts.indexOf(name) return i === -1 ? fallback : opts[i + 1] } export const STEPS = opt('--steps', 400) /// `--steps` when it is given, for runs whose own default differs. export const STEPS_GIVEN = opt('--steps', undefined) export const SEED = opt('--seed', 1) export const CHECK_EVERY = opt('--check-every', 10) /// The implementation the server is, by its adapter's name in /// lib/adapters/: Monolith, started with the command after `--`, unless /// another is named, which its adapter starts itself. export const IMPL = str('--impl', 'monolith') /// A compatibility run (compat.mjs): only the core checks of this area, /// going on past a difference, its tally written to `RESULT` as JSON. export const AREA = str('--area', null) export const RESULT = str('--result', null) /// Where to write, at the end, how many of each kind of request the run /// made: two runs of one seed make the same, so a change that must leave /// the run as it was is shown to (compat/README.md, "Adding an /// implementation"). export const TALLY = str('--tally', null) if ((IMPL === 'monolith' && !command.length) || (AREA && !RESULT)) { console.error(usage) process.exit(2) } export const CRASH_EVERY = opt('--crash-every', 0) /// A run of its own of the store (spec/STORE.md): churn on a few accounts, /// with the backfill window short on both sides, held to the store's bounds. export const STORE = opts.includes('--store') /// The backfill window both sides are started with, in milliseconds: the /// store run's, or by default the reference's day. export const BACKFILL_MS = STORE ? 5000 : undefined export const FIREHOSE = opts.includes('--firehose') || STORE || AREA === 'firehose' export const COMMANDS = opts.includes('--commands') /// A run of its own with the rate limits on, and the checks of what the /// server holds (spec/LIMITS.md); or with invite codes required. export const LIMITS = opts.includes('--limits') export const INVITES = opts.includes('--invites') /// A run of its own: accounts deactivated, taken down and deleted, and what /// each state does to every method (spec/LIFECYCLE.md). Its steps are /// changes of state, each followed by many requests: 80 unless `--steps`. export const LIFECYCLE = opts.includes('--lifecycle') export const LIFECYCLE_STEPS = opt('--steps', 80) /// A run of its own: accounts moving to the server and away from it, /// through a third PDS, and the five methods of a move by account state /// (spec/MIGRATION.md). Its steps are a move in, a move out, the states /// and a did:web account, in turn: 6 unless `--steps`. export const MOVES = opts.includes('--moves') export const MOVES_STEPS = opt('--steps', 6) /// A run of its own of the server's memory and starts with many accounts /// and much data (spec/STORE.md, "Scale"), with a small cache. export const SCALE = opts.includes('--scale') /// The server's `PDS_CACHE_BYTES`: the scale run's, or by default its own. export const CACHE_BYTES = SCALE ? 16 * 1048576 : undefined /// A run of its own: the authorization pages driven in a browser on both /// sides (spec/OAUTH-PAGES.md). Its steps are flows, each from a PAR to the /// client's redirect URI: 30 unless `--steps`. export const PAGES = opts.includes('--pages') export const PAGES_STEPS = opt('--steps', 30) /// A run of its own, of the server alone: started on the data directories /// the previous version wrote, in harness/upgrade/, every read as that /// version answered (spec/STORE.md, "Upgrades"); or, with --upgrade-write, /// those directories and answers made, with the server given as the /// previous version. export const UPGRADE = opts.includes('--upgrade') export const UPGRADE_WRITE = opts.includes('--upgrade-write') /// A run of its own: the server's blobs moved from its data directory into /// a bucket of the S3 store the harness runs and back, by `pds /// migrate-blobs` killed as it goes (spec/BLOBS.md, "Moving them"). export const MIGRATE = opts.includes('--migrate') if (LIMITS + INVITES + LIFECYCLE + MOVES + STORE + SCALE + PAGES + UPGRADE + UPGRADE_WRITE + MIGRATE > 1 || (MIGRATE && IMPL !== 'monolith')) { console.error(usage) process.exit(2) } /// Blobs kept in buckets of an S3 store the harness runs (lib/s3.mjs), one /// for each side, held to spec/BLOBS.md, "Where blobs are kept": with the /// random steps (and --crash-every, --firehose), or --lifecycle. export const S3 = opts.includes('--s3') if (S3 && (LIMITS || INVITES || MOVES || STORE || SCALE || PAGES || UPGRADE || UPGRADE_WRITE || MIGRATE || AREA || IMPL !== 'monolith')) { console.error(usage) process.exit(2) } /// Only these steps, by name: of the random steps, or of a --limits or /// --invites run's checks. For seeing one check fail on its own. const only = opts.indexOf('--only') export const ONLY = only === -1 ? null : new Set(opts[only + 1].split(','))