Skip to content

Commit

Permalink
Merge pull request #4256 from Agoric/mhofman/loadgen-integration
Browse files Browse the repository at this point in the history
Add loadgen to deployment integration test
  • Loading branch information
mergify[bot] authored Feb 9, 2022
2 parents 93ef5ae + c1f3c19 commit 9d7286e
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 6 deletions.
42 changes: 39 additions & 3 deletions .github/workflows/deployment-test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Chain deployment test

on:
# Use the following to explicitly start thit workflow.
# Use the following to explicitly start this workflow.
# packages/deployment/scripts/start-deployment-test.sh <BRANCH-OR-TAG>
workflow_dispatch:
# Otherwise, run on default branch.
Expand All @@ -21,12 +21,48 @@ jobs:
- uses: ./.github/actions/restore-node
with:
node-version: 14.x
- name: Build cosmic-swingset dependencies

# Select a branch on loadgen to test against by adding text to the body of the
# pull request. For example: #loadgen-branch: user-123-update-foo
# The default is 'main'
- name: Get the appropriate loadgen branch
id: get-loadgen-branch
uses: actions/[email protected]
with:
result-encoding: string
script: |
let branch = 'main';
if (context.payload.pull_request) {
const { body } = context.payload.pull_request;
const regex = /.*\#loadgen-branch:\s+(\S+)/;
const result = regex.exec(body);
if (result) {
branch = result[1];
}
}
console.log(branch);
return branch;
- name: Check out loadgen
uses: actions/checkout@v2
with:
repository: Agoric/testnet-load-generator
path: testnet-load-generator
ref: ${{steps.get-loadgen-branch.outputs.result}}

- name: Move repos under /usr/src where scripts expect them
run: |
# Some of our build relies on /usr/src/agoric-sdk
set -e
sudo mv "$GITHUB_WORKSPACE/testnet-load-generator" /usr/src/testnet-load-generator
sudo mv "$GITHUB_WORKSPACE" /usr/src/agoric-sdk
ln -s /usr/src/agoric-sdk/packages/deployment/bin/ag-setup-cosmos /usr/local/bin/ag-setup-cosmos
ln -s /usr/src/agoric-sdk "$GITHUB_WORKSPACE"
working-directory: /

- name: Build cosmic-swingset dependencies
run: |
# Some of our build relies on /usr/src/agoric-sdk
set -e
cd /usr/src/agoric-sdk/packages/cosmic-swingset
make install
working-directory: /
Expand Down
26 changes: 26 additions & 0 deletions packages/deployment/scripts/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ thisdir=$(cd "$(dirname -- "$real0")" > /dev/null && pwd -P)

export NETWORK_NAME=${NETWORK_NAME-localtest}

RESULTSDIR=${RESULTSDIR-"$NETWORK_NAME/results"}
mkdir -p "$RESULTSDIR"
pushd "$RESULTSDIR"
RESULTSDIR="$PWD"
popd

mkdir -p "$NETWORK_NAME/setup"
cd "$NETWORK_NAME/setup"

Expand All @@ -21,3 +27,23 @@ DOCKER_VOLUMES="$(cd "$thisdir/../../.." > /dev/null && pwd -P):/usr/src/agoric-
# Go ahead and bootstrap with detailed debug logging.
AG_COSMOS_START_ARGS="--log_level=info --trace-store=.ag-chain-cosmos/data/kvstore.trace" \
"$thisdir/setup.sh" bootstrap ${1+"$@"}

if [ -d /usr/src/testnet-load-generator ]
then
/usr/src/agoric-sdk/packages/deployment/scripts/setup.sh show-config > "$RESULTSDIR/network-config"
cp ag-chain-cosmos/data/genesis.json "$RESULTSDIR/genesis.json"
cp "$AG_SETUP_COSMOS_HOME/ag-chain-cosmos/data/genesis.json" "$RESULTSDIR/genesis.json"
cd /usr/src/testnet-load-generator
$thisdir/../../solo/bin/ag-solo init \
_agstate/agoric-servers/testnet-8000 \
--webport=8000 \
--netconfig="$RESULTSDIR/network-config"
$AG_SETUP_COSMOS_HOME/faucet-helper.sh add-egress \
loadgen $(cat _agstate/agoric-servers/testnet-8000/ag-cosmos-helper-address)
SDK_BUILD=0 SDK_SRC=/usr/src/agoric-sdk OUTPUT_DIR="$RESULTSDIR" ./start.sh \
--no-stage.save-storage --stages=3 --stage.duration=4 \
--stage.loadgen.vault.interval=12 --stage.loadgen.vault.limit=2 \
--stage.loadgen.amm.interval=12 --stage.loadgen.amm.wait=6 --stage.loadgen.amm.limit=2 \
--profile=testnet "--testnet-origin=file://$RESULTSDIR" \
--no-reset
fi
17 changes: 14 additions & 3 deletions packages/deployment/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,20 @@ const makeProviders = ({ env, inquirer, wr, setup, fetch, needBacktick }) => ({
askDetails: async (_provider, _myDetails) => {
let vspec = '';

const dockerInfo = await needBacktick(`docker info`);
const cgroupMatch = dockerInfo.match(/^\s*Cgroup\sVersion:\s*(\d+)/im);
if (!cgroupMatch || Number(cgroupMatch[1]) < 2) {
let cgroupVersion = 0;
try {
const dockerInfo = JSON.parse(
await needBacktick(
`curl -s --unix-socket /var/run/docker.sock http://localhost/v1.41/info`,
),
);
cgroupVersion = parseInt(dockerInfo.CgroupVersion, 10);
} catch (e) {
// Ignore
}

// Tolerate NaN returned by any parseInt errors.
if (!(cgroupVersion >= 2)) {
// Older cgroup version, we need to mount `/sys/fs/cgroup` explicitly
// for our Agoric deployment Docker containers' systemd.
vspec += ',/sys/fs/cgroup:/sys/fs/cgroup';
Expand Down

0 comments on commit 9d7286e

Please sign in to comment.