From 8790bda37d7f95bda4e4dd31fe50318335981e79 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 27 Nov 2023 14:23:43 -0800 Subject: [PATCH 1/4] feat: include SLOGFILE in start_agd --- upgrade-test-scripts/start_agd.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/upgrade-test-scripts/start_agd.sh b/upgrade-test-scripts/start_agd.sh index 5003c233..8d541526 100644 --- a/upgrade-test-scripts/start_agd.sh +++ b/upgrade-test-scripts/start_agd.sh @@ -6,5 +6,8 @@ grep -qF 'printKeys' /root/.bashrc || echo "printKeys" >>/root/.bashrc source ./env_setup.sh +# start_agd never builds an image so it's safe to include this multigigabyte logfile +export SLOGFILE=slog.slog + # don't use startAgd() because that backgrounds agd start --log_level warn "$@" From 870b8c91fc811ecf686e30dc745f14f36832c0d6 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 27 Nov 2023 10:40:39 -0800 Subject: [PATCH 2/4] feat: include start_agd.sh in test image --- makeDockerfile.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/makeDockerfile.ts b/makeDockerfile.ts index 5073f52c..6a6a9b06 100755 --- a/makeDockerfile.ts +++ b/makeDockerfile.ts @@ -99,7 +99,7 @@ WORKDIR /usr/src/upgrade-test-scripts COPY --link ./upgrade-test-scripts/install_deps.sh /usr/src/upgrade-test-scripts/ RUN --mount=type=cache,target=/root/.yarn ./install_deps.sh ${proposalIdentifier}:${proposalName} -COPY --link --chmod=755 ./upgrade-test-scripts/run_eval.sh /usr/src/upgrade-test-scripts/run_eval.sh +COPY --link --chmod=755 ./upgrade-test-scripts/run_eval.sh /usr/src/upgrade-test-scripts/ SHELL ["/bin/bash", "-c"] RUN ./run_eval.sh ${proposalIdentifier}:${proposalName} `; @@ -127,7 +127,7 @@ COPY --link ./upgrade-test-scripts/lib /usr/src/upgrade-test-scripts/lib COPY --link ./upgrade-test-scripts/install_deps.sh /usr/src/upgrade-test-scripts/ RUN --mount=type=cache,target=/root/.yarn ./install_deps.sh ${proposalIdentifier}:${proposalName} -COPY --link --chmod=755 ./upgrade-test-scripts/run_use.sh /usr/src/upgrade-test-scripts/run_use.sh +COPY --link --chmod=755 ./upgrade-test-scripts/run_use.sh /usr/src/upgrade-test-scripts/ SHELL ["/bin/bash", "-c"] RUN ./run_use.sh ${proposalIdentifier}:${proposalName} `; @@ -151,7 +151,8 @@ WORKDIR /usr/src/upgrade-test-scripts COPY --link ./upgrade-test-scripts/install_deps.sh /usr/src/upgrade-test-scripts/ RUN --mount=type=cache,target=/root/.yarn ./install_deps.sh ${proposalIdentifier}:${proposalName} -COPY --link --chmod=755 ./upgrade-test-scripts/run_test.sh /usr/src/upgrade-test-scripts/run_test.sh +# copy run_test for this entrypoint and start_agd for optional debugging +COPY --link --chmod=755 ./upgrade-test-scripts/run_test.sh ./upgrade-test-scripts/start_agd.sh /usr/src/upgrade-test-scripts/ SHELL ["/bin/bash", "-c"] ENTRYPOINT ./run_test.sh ${proposalIdentifier}:${proposalName} `; @@ -164,7 +165,7 @@ ENTRYPOINT ./run_test.sh ${proposalIdentifier}:${proposalName} # DEFAULT FROM use-${lastProposal.proposalName} -COPY --link --chmod=755 ./upgrade-test-scripts/start_agd.sh /usr/src/upgrade-test-scripts/start_agd.sh +COPY --link --chmod=755 ./upgrade-test-scripts/start_agd.sh /usr/src/upgrade-test-scripts/ WORKDIR /usr/src/upgrade-test-scripts SHELL ["/bin/bash", "-c"] From 85b7bcdb2739304ca06e0bc3a659c604a5895e06 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 27 Nov 2023 14:26:23 -0800 Subject: [PATCH 3/4] refactor: imageNameForProposal --- buildTestImages.ts | 4 ++-- common.ts | 7 +++++-- runTestImages.ts | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/buildTestImages.ts b/buildTestImages.ts index 7f89b68b..05dfff77 100755 --- a/buildTestImages.ts +++ b/buildTestImages.ts @@ -2,7 +2,7 @@ import { parseArgs } from 'node:util'; import { execSync } from 'node:child_process'; -import { imageNameForProposalTest, readProposals } from './common'; +import { imageNameForProposal, readProposals } from './common'; import { refreshDockerfile } from './makeDockerfile'; refreshDockerfile(); @@ -25,7 +25,7 @@ for (const proposal of proposals) { if (!dry) { console.log(`\nBuilding test image for proposal ${proposal.proposalName}`); } - const { name, target } = imageNameForProposalTest(proposal); + const { name, target } = imageNameForProposal(proposal, 'test'); // 'load' to ensure the images are output to the Docker client. Seems to be necessary // for the CI docker/build-push-action to re-use the cached stages. const cmd = `docker buildx build --load --tag ${name} --target ${target} .`; diff --git a/common.ts b/common.ts index 3dd2f5f8..deccc2d5 100644 --- a/common.ts +++ b/common.ts @@ -52,8 +52,11 @@ export function lastPassedProposal(proposals: ProposalInfo[]): ProposalInfo { return last; } -export function imageNameForProposalTest(proposal) { - const target = `test-${proposal.proposalName}`; +export function imageNameForProposal( + proposal: ProposalCommon, + stage: 'test' | 'eval', +) { + const target = `${stage}-${proposal.proposalName}`; return { name: `${repository}:${target}`, target, diff --git a/runTestImages.ts b/runTestImages.ts index b9dd11ba..786a7416 100755 --- a/runTestImages.ts +++ b/runTestImages.ts @@ -2,7 +2,7 @@ import { parseArgs } from 'node:util'; import { execSync } from 'node:child_process'; -import { imageNameForProposalTest, readProposals } from './common'; +import { imageNameForProposal, readProposals } from './common'; const options = { match: { short: 'm', type: 'string' }, @@ -19,7 +19,7 @@ const proposals = match for (const proposal of proposals) { console.log(`Running test image for proposal ${proposal.proposalName}`); - const { name } = imageNameForProposalTest(proposal); + const { name } = imageNameForProposal(proposal, 'test'); // 'rm' to remove the container when it exits const cmd = `docker run --rm ${name}`; execSync(cmd, { stdio: 'inherit' }); From b2e319f620dee6e82b075e611f990dffdc6f8328 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 27 Nov 2023 14:23:28 -0800 Subject: [PATCH 4/4] feat: debug test image --- README.md | 11 +++++++-- common.ts | 10 +++++++++ debugTestImage.ts | 35 +++++++++++++++++++++++++++++ upgrade-test-scripts/run_eval.sh | 0 upgrade-test-scripts/run_test.sh | 0 upgrade-test-scripts/run_use.sh | 0 upgrade-test-scripts/start_ag0.sh | 0 upgrade-test-scripts/start_agd.sh | 0 upgrade-test-scripts/start_to_to.sh | 0 9 files changed, 54 insertions(+), 2 deletions(-) create mode 100755 debugTestImage.ts mode change 100644 => 100755 upgrade-test-scripts/run_eval.sh mode change 100644 => 100755 upgrade-test-scripts/run_test.sh mode change 100644 => 100755 upgrade-test-scripts/run_use.sh mode change 100644 => 100755 upgrade-test-scripts/start_ag0.sh mode change 100644 => 100755 upgrade-test-scripts/start_agd.sh mode change 100644 => 100755 upgrade-test-scripts/start_to_to.sh diff --git a/README.md b/README.md index 06a68743..3d562071 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,15 @@ To run the tests for particular proposals, ./runTestImages.ts --match upgrade ``` -## Contributing +## Debugging + +To get the local files into the container, use a [bind mount](https://docs.docker.com/storage/bind-mounts/). E.g. + +``` +docker run -it --entrypoint bash --mount type=bind,src=.,dst=/usr/src/a3p ghcr.io/agoric/agoric-3-proposals:use-upgrade-8 +``` + +# Contributing To add a proposal, see [CONTRIBUTING.md](./CONTRIBUTING.md). @@ -102,7 +110,6 @@ docker run ghrc.io/agoric/agoric-3-proposals:dev ## Future work - [ ] 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 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 diff --git a/common.ts b/common.ts index deccc2d5..b50d454e 100644 --- a/common.ts +++ b/common.ts @@ -45,6 +45,16 @@ export function readProposals(): ProposalInfo[] { return proposalPaths.map(readInfo); } +export const readOneProposal = (match: string) => { + const allProposals = readProposals(); + + const proposals = allProposals.filter(p => p.proposalName.includes(match)); + + assert(proposals.length > 0, 'no proposals match'); + assert(proposals.length === 1, 'too many proposals match'); + return proposals[0]; +}; + export function lastPassedProposal(proposals: ProposalInfo[]): ProposalInfo { // @ts-expect-error use es2023; findLast is available in Node 18 const last = proposals.findLast(p => p.proposalIdentifier.match(/^\d/)); diff --git a/debugTestImage.ts b/debugTestImage.ts new file mode 100755 index 00000000..69ef8f1b --- /dev/null +++ b/debugTestImage.ts @@ -0,0 +1,35 @@ +#!/usr/bin/env tsx +/** + * @file like runTestImages.ts, but for a single proposal, + * and leaves the chain running + */ +import { execSync } from 'node:child_process'; +import { parseArgs } from 'node:util'; +import { imageNameForProposal, readOneProposal } from './common'; + +const options = { + match: { short: 'm', type: 'string' }, +} as const; +const { values } = parseArgs({ options }); + +const proposal = readOneProposal(values.match!); +const { name } = imageNameForProposal(proposal, 'test'); + +console.log( + ` +Starting chain of test image for proposal ${proposal.proposalName} + +To get an interactive shell in the container, use an IDE feature like "Attach Shell" or this command:' + + docker exec -ti $(docker ps -q -f ancestor=${name}) bash + +And within that shell: + cd /usr/src/proposals/ && ./test.sh + +The 'proposals' path is mounted in the container so your edits will appear there. +`, +); + +// start the chain, with the repo mounted at /usr/src +const cmd = `docker run --mount type=bind,src=./proposals,dst=/usr/src/proposals -it --entrypoint /usr/src/upgrade-test-scripts/start_agd.sh ${name}`; +execSync(cmd, { stdio: 'inherit' }); diff --git a/upgrade-test-scripts/run_eval.sh b/upgrade-test-scripts/run_eval.sh old mode 100644 new mode 100755 diff --git a/upgrade-test-scripts/run_test.sh b/upgrade-test-scripts/run_test.sh old mode 100644 new mode 100755 diff --git a/upgrade-test-scripts/run_use.sh b/upgrade-test-scripts/run_use.sh old mode 100644 new mode 100755 diff --git a/upgrade-test-scripts/start_ag0.sh b/upgrade-test-scripts/start_ag0.sh old mode 100644 new mode 100755 diff --git a/upgrade-test-scripts/start_agd.sh b/upgrade-test-scripts/start_agd.sh old mode 100644 new mode 100755 diff --git a/upgrade-test-scripts/start_to_to.sh b/upgrade-test-scripts/start_to_to.sh old mode 100644 new mode 100755