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

fixup test runner #8

Merged
merged 9 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ jobs:
df -h
- uses: actions/checkout@v3
- run: yarn global add tsx
- name: generate Dockerfile
run: ./makeDockerfile.ts
- name: build test images
run: ./buildTestImages.ts
- name: run test images
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ To add a proposal, see [./CONTRIBUTING.md]

- [ ] include a way to test soft patches that weren't proposals (e.g. PismoB)
- [ ] documentation and tooling for debugging
- [ ] separate console output for agd and the scripts (had been with tmux before but trouble, try Docker compose)
- [ ] remove use of `agoric-sdk:dev`; that's a concern of SDK
- [ ] separate agd and actions/test services with docker-compose (https://github.com/Agoric/agoric-sdk/discussions/8480#discussioncomment-7438329)
- [ ] separate console output for agd and the scripts (had been with tmux before but trouble, try Docker compose https://github.com/Agoric/agoric-sdk/discussions/8480#discussioncomment-7438329)
- [ ] way to query capdata in one shot (not resorting to follow jsonlines hackery)
- [ ] within each proposal, separate dirs for supporting files so images don't invalidate
16 changes: 12 additions & 4 deletions buildTestImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
import { parseArgs } from 'node:util';
import { execSync } from 'node:child_process';
import { imageNameForProposalTest, readProposals } from './common';
import { refreshDockerfile } from './makeDockerfile';

refreshDockerfile();

const options = {
match: { short: 'm', type: 'string' },
dry: { type: 'boolean' },
};
const { values } = parseArgs({ options });

const { match } = values;
const { match, dry } = values;

const allProposals = readProposals();

Expand All @@ -19,10 +23,14 @@ const proposals = match
: allProposals;

for (const proposal of proposals) {
console.log(`\nBuilding test image for proposal ${proposal.proposalName}`);
if (!dry) {
console.log(`\nBuilding test image for proposal ${proposal.proposalName}`);
}
const { name, target } = imageNameForProposalTest(proposal);
const cmd = `docker build --tag ${name} --target ${target} .`;
console.log(cmd);
// TODO stream the output
execSync(cmd);
if (!dry) {
// TODO stream the output
execSync(cmd);
}
}
2 changes: 1 addition & 1 deletion common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ProposalCommon = {
};

export type SoftwareUpgradeProposal = ProposalCommon & {
sdkVersion: string;
sdkImageTag: string;
planName: string;
releaseNodes: string;
type: 'Software Upgrade Proposal';
Expand Down
30 changes: 18 additions & 12 deletions makeDockerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ENV UPGRADE_TO=${to} THIS_NAME=${agZeroUpgrade}
# put env functions into shell environment
RUN echo '. /usr/src/upgrade-test-scripts/env_setup.sh' >> ~/.bashrc

COPY --chmod=755 ./upgrade-test-scripts /usr/src/upgrade-test-scripts
COPY --link --chmod=755 ./upgrade-test-scripts /usr/src/upgrade-test-scripts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHELL ["/bin/bash", "-c"]
# this is the only layer that starts ag0
RUN /usr/src/upgrade-test-scripts/start_ag0.sh
Expand All @@ -51,7 +51,7 @@ RUN /usr/src/upgrade-test-scripts/start_ag0.sh
FROM use-${lastProposal.proposalName} as prepare-${proposalName}
ENV UPGRADE_TO=${planName}
# base is a fresh sdk image so copy these supports
COPY --chmod=755 ./upgrade-test-scripts/*.sh /usr/src/upgrade-test-scripts/
COPY --link --chmod=755 ./upgrade-test-scripts/*.sh /usr/src/upgrade-test-scripts/

WORKDIR /usr/src/upgrade-test-scripts
SHELL ["/bin/bash", "-c"]
Expand All @@ -63,16 +63,16 @@ RUN ./start_to_to.sh
* - Start agd with the SDK that has the upgradeHandler
* - Run any core-evals associated with the proposal (either the ones specified in prepare, or straight from the proposal)
*/
EXECUTE({ proposalName, planName, sdkVersion }: SoftwareUpgradeProposal) {
EXECUTE({ proposalName, planName, sdkImageTag }: SoftwareUpgradeProposal) {
return `
# EXECUTE ${proposalName}
FROM ghcr.io/agoric/agoric-sdk:${sdkVersion} as execute-${proposalName}
FROM ghcr.io/agoric/agoric-sdk:${sdkImageTag} as execute-${proposalName}
ENV THIS_NAME=${planName}

# base is a fresh sdk image so copy these supports
COPY --chmod=755 ./upgrade-test-scripts/*.sh /usr/src/upgrade-test-scripts/
COPY --link --chmod=755 ./upgrade-test-scripts/*.sh /usr/src/upgrade-test-scripts/

COPY --from=prepare-${proposalName} /root/.agoric /root/.agoric
COPY --link --from=prepare-${proposalName} /root/.agoric /root/.agoric

WORKDIR /usr/src/upgrade-test-scripts
SHELL ["/bin/bash", "-c"]
Expand All @@ -91,7 +91,7 @@ RUN ./start_to_to.sh
# EVAL ${proposalName}
FROM use-${lastProposal.proposalName} as eval-${proposalName}

COPY --chmod=755 ./proposals/${proposalIdentifier}:${proposalName} /usr/src/proposals/${proposalIdentifier}:${proposalName}
COPY --link --chmod=755 ./proposals/${proposalIdentifier}:${proposalName} /usr/src/proposals/${proposalIdentifier}:${proposalName}

WORKDIR /usr/src/upgrade-test-scripts
SHELL ["/bin/bash", "-c"]
Expand All @@ -110,10 +110,10 @@ RUN ./run_eval.sh ${proposalIdentifier}:${proposalName}
# USE ${proposalName}
FROM ${previousStage}-${proposalName} as use-${proposalName}

COPY --chmod=755 ./proposals/${proposalIdentifier}:${proposalName} /usr/src/proposals/${proposalIdentifier}:${proposalName}
COPY --link --chmod=755 ./proposals/${proposalIdentifier}:${proposalName} /usr/src/proposals/${proposalIdentifier}:${proposalName}

# XXX for 'lib' dir for JS modules
COPY --chmod=755 ./upgrade-test-scripts /usr/src/upgrade-test-scripts/
COPY --link --chmod=755 ./upgrade-test-scripts /usr/src/upgrade-test-scripts/
# TODO remove network dependencies in stages
RUN cd /usr/src/upgrade-test-scripts/lib/ && yarn install

Expand All @@ -138,7 +138,7 @@ FROM use-${proposalName} as test-${proposalName}
# XXX the test files were already copied in the "use" stage
WORKDIR /usr/src/upgrade-test-scripts
SHELL ["/bin/bash", "-c"]
RUN ./run_tests.sh ${proposalIdentifier}:${proposalName}
ENTRYPOINT ./run_test.sh ${proposalIdentifier}:${proposalName}
`;
},
};
Expand Down Expand Up @@ -171,5 +171,11 @@ for (const proposal of readProposals()) {
previousProposal = proposal;
}

const contents = blocks.join('\n');
fs.writeFileSync('Dockerfile', contents);
export function refreshDockerfile() {
const contents = blocks.join('\n');
fs.writeFileSync('Dockerfile', contents);
}

if (require.main === module) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we used ES modules and node doesn't support this idiom in that context.

Does .ts not get compiled to ES modules?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node only uses ESM if package.json has "type": "module". But there's no package.json here so it defaults to CJS

refreshDockerfile();
}
2 changes: 1 addition & 1 deletion proposals/16:upgrade-8/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdkVersion": "29",
"sdkImageTag": "29",
"planName": "agoric-upgrade-8",
"type": "Software Upgrade Proposal"
}
2 changes: 1 addition & 1 deletion proposals/29:upgrade-9/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"releaseNotes": "https://github.com/Agoric/agoric-sdk/releases/tag/pismoC",
"sdkVersion": "31",
"sdkImageTag": "31",
"planName": "agoric-upgrade-9",
"type": "Software Upgrade Proposal"
}
2 changes: 1 addition & 1 deletion proposals/34:upgrade-10/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"releaseNotes": "https://github.com/Agoric/agoric-sdk/releases/tag/mainnet1B-rc3",
"sdkVersion": "35",
"sdkImageTag": "35",
"planName": "agoric-upgrade-10",
"type": "Software Upgrade Proposal"
}
2 changes: 1 addition & 1 deletion proposals/43:upgrade-11/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"releaseNotes": "https://github.com/Agoric/agoric-sdk/releases/tag/agoric-upgrade-11",
"sdkVersion": "36",
"sdkImageTag": "36",
"planName": "agoric-upgrade-11",
"type": "Software Upgrade Proposal"
}
1 change: 0 additions & 1 deletion proposals/43:upgrade-11/legacy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
source /usr/src/upgrade-test-scripts/env_setup.sh

# Enable debugging
set -x

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the "Enable debugging" comment stays? on purpose?
not a big deal...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, will remove. (CI's not passing anyway)

export_genesis() {
GENESIS_EXPORT_DIR="$1"
Expand Down
7 changes: 1 addition & 6 deletions upgrade-test-scripts/lib/vat-status.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-check
import dbOpenAmbient from 'better-sqlite3';
import { HOME } from './constants.js';
import { NonNullish } from './assert.js';

/**
* @file look up vat incarnation from kernel DB
Expand Down Expand Up @@ -66,12 +67,6 @@ const makeSwingstore = db => {
});
};

/** @type {<T>(val: T | undefined) => T} */
const NonNullish = val => {
if (!val) throw Error('required');
return val;
};

/**
* @param {string} vatName
*/
Expand Down
1 change: 0 additions & 1 deletion upgrade-test-scripts/run_eval.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Note that STDOUT mixes the two. TODO separate them cleanly with log output.

set -e
set -x

source ./env_setup.sh

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Note that STDOUT mixes the two. TODO separate them cleanly with log output.

set -e
set -x

source ./env_setup.sh

Expand Down
1 change: 0 additions & 1 deletion upgrade-test-scripts/run_use.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Note that STDOUT mixes the two. TODO separate them cleanly with log output.

set -e
set -x

source ./env_setup.sh

Expand Down
Loading