Skip to content

Commit

Permalink
Prepare for PocketIC snapshots (#6367)
Browse files Browse the repository at this point in the history
# Motivation

We want to start using PocketIC to create snsdemo snapshots.
When running a PocketIC snapshot, there is no `replica` process running.
We use `pgrep replica` in several places to check if a replica is
running.

For now I'm not checking the scripts output so it still calls it a
"replica" when `dfx start` is running, regardless of whether it's
PocketIC or not.

# Changes

1. Where we check `pgrep replica`, also check `pgrep pocket-ic`.
2. In `scripts/nns-dapp/test-proposal-payload` use `dfx info
webserver-port` instead of `dfx info replica-port`, which is required
when running PocketIC and also works fine without it.

# Tests

1. Manually ran `scripts/nns-dapp/test-proposal-payload` with and
without PocketIC snapshot.
2. Relying on CI for the others.

# Todos

- [ ] Add entry to changelog (if necessary).
not necessary
  • Loading branch information
dskloetd authored Feb 7, 2025
1 parent 8baae1a commit 7c6bc96
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion scripts/deploy-devenv
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ else
exit 1
fi

if ! pgrep -x replica; then
if ! pgrep -x replica && ! pgrep -x pocket-ic; then
echo "A local replica must be running to deploy to." >&2
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/dfx-snapshot-install
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ install_state() {

output_restore_backup_script() {
cat <<-EOF
if pgrep -x replica; then
if pgrep -x replica || pgrep -x pocket-ic; then
echo "A replica is still running. State should be restored automatically when the replica is stopped." >&2
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/dfx-snapshot-start
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ source "$(clap.build)"
# shellcheck disable=SC2009
SCRIPT_COUNT="$(ps -A -o command | grep -c "^bash .*$(basename "$0")")"

if pgrep -x replica || [ "$SCRIPT_COUNT" -gt 2 ]; then
if pgrep -x replica || pgrep -x pocket-ic || [ "$SCRIPT_COUNT" -gt 2 ]; then
echo "ERROR: There is already a replica running. Please stop it first."
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/nns-dapp/release-sop
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ sha256() {
}

get_dfx_identity() {
if pgrep -x replica; then
if pgrep -x replica || pgrep -x pocket-ic; then
(
echo
echo "A replica is running."
Expand Down
4 changes: 2 additions & 2 deletions scripts/nns-dapp/test-proposal-payload
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ clap.define short=i long=identity desc="Identity to use to create proposals" var
source "$(clap.build)"

# Check if a replica is running:
if ! pgrep -x replica; then
if ! pgrep -x replica && ! pgrep -x pocket-ic; then
echo "A replica must be running to submit proposals to." >&2
exit 1
fi
Expand All @@ -33,7 +33,7 @@ fi
PEM="${IDENTITY_PATH}/identity.pem"
NNS_URL="http://localhost:$(
cd ~
dfx info replica-port
dfx info webserver-port
)"
NEURON_ID="$(cat "${IDENTITY_PATH}/neurons/local")"
SUMMARY="Testing proposal payloads"
Expand Down
2 changes: 1 addition & 1 deletion scripts/nns-dapp/upgrade-downgrade-test
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if ! [ -f "$ARGS_FILE" ]; then
fi

# Check if a replica is running:
if pgrep -x replica; then
if pgrep -x replica || pgrep -x pocket-ic; then
echo "A replica is already running. Shut it down first." >&2
exit 1
fi
Expand Down

0 comments on commit 7c6bc96

Please sign in to comment.