Skip to content

Commit 7f03570

Browse files
committed
fix: network upgrade test
Signed-off-by: Artur Troian <[email protected]>
1 parent 2e7d706 commit 7f03570

File tree

6 files changed

+73
-9
lines changed

6 files changed

+73
-9
lines changed

.github/workflows/tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ jobs:
176176
- name: configure variables
177177
run: |
178178
test_required=$(./script/upgrades.sh test-required ${{ github.ref }})
179+
snapshot_source=$(./script/upgrades.sh snapshot-source ${{ github.ref }})
179180
echo "TEST_REQUIRED=$test_required" >> $GITHUB_ENV
181+
echo "SNAPSHOT_SOURCE=$snapshot_source" >> $GITHUB_ENV
180182
- name: run test
181183
id: test
182184
if: env.TEST_REQUIRED != ''

make/test-upgrade.mk

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ UPGRADE_FROM := $(shell cat $(ROOT_DIR)/meta.json | jq -r --arg name
2121
GENESIS_BINARY_VERSION := $(shell cat $(ROOT_DIR)/meta.json | jq -r --arg name $(UPGRADE_TO) '.upgrades[$$name].from_binary' | tr -d '\n')
2222
UPGRADE_BINARY_VERSION ?= local
2323

24+
SNAPSHOT_SOURCE ?= mainnet
25+
26+
ifneq ($(SNAPSHOT_SOURCE),mainnet)
27+
ifeq ($(SNAPSHOT_SOURCE),sandbox)
28+
SNAPSHOT_NETWORK := sandbox-01
29+
else
30+
$(error "invalid snapshot source $(SNAPSHOT_SOURCE)")
31+
endif
32+
else
33+
SNAPSHOT_NETWORK := akashnet-2
34+
endif
35+
36+
SNAPSHOT_URL ?= https://snapshots.akash.network/$(SNAPSHOT_NETWORK)/latest
2437
REMOTE_TEST_WORKDIR ?= ~/go/src/github.com/akash-network/node
2538
REMOTE_TEST_HOST ?=
2639

@@ -49,7 +62,7 @@ test-reset:
4962
$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --config="$(PWD)/config.json" --uto=$(UPGRADE_TO) clean
5063
$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --config="$(PWD)/config.json" --uto=$(UPGRADE_TO) --gbv=$(GENESIS_BINARY_VERSION) bins
5164
$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --config="$(PWD)/config.json" --uto=$(UPGRADE_TO) keys
52-
$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --config="$(PWD)/config.json" --state-config=$(STATE_CONFIG) prepare-state
65+
$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --config="$(PWD)/config.json" --state-config=$(STATE_CONFIG) --snapshot-url=$(SNAPSHOT_URL) prepare-state
5366

5467
.PHONY: prepare-state
5568
prepare-state:

script/upgrades.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,46 @@ case "$1" in
595595
exit 1
596596
fi
597597

598+
;;
599+
snapshot-source)
600+
shift
601+
602+
curr_ref=$1
603+
snapshot_source="sandbox"
604+
605+
is_valid=$($semver validate "$curr_ref")
606+
607+
if [[ $is_valid == "valid" ]]; then
608+
build=$($semver get build "$curr_ref")
609+
if [[ -n $build ]]; then
610+
# Split the input by dots, as only dot is allowed in semver build token
611+
IFS='.' read -ra PARTS <<< "$build"
612+
# Process pairs (key at even index, value at odd index)
613+
for ((i=0; i<${#PARTS[@]}; i+=2)); do
614+
key="${PARTS[i]}"
615+
value="${PARTS[i+1]}"
616+
617+
# Skip if value is missing
618+
if [ -z "$value" ]; then
619+
continue
620+
fi
621+
622+
case "$key" in
623+
network)
624+
snapshot_source=$value
625+
;;
626+
*)
627+
;;
628+
esac
629+
done
630+
fi
631+
elif [[ $curr_ref == "mainnet/main" || $curr_ref == "main" ]]; then
632+
snapshot_source="mainnet"
633+
fi
634+
635+
echo -n "$snapshot_source"
636+
637+
exit 0
598638
;;
599639
test-required)
600640
shift

tests/upgrade/test-cases.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
"added": [
55
"07-tendermint",
66
"consensus"
7-
],
8-
"removed": [
9-
"crisis",
10-
"agov",
11-
"astaking"
127
]
138
},
149
"migrations": {

tests/upgrade/upgrade_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ loop:
12591259
func (l *validator) scanner(stdout io.Reader, p publisher) error {
12601260
scanner := bufio.NewScanner(stdout)
12611261

1262-
serverStart := "INF starting node with ABCI Tendermint in-process"
1262+
serverStart := "INF starting node with ABCI "
12631263
replayBlocksStart := "INF ABCI Replay Blocks appHeight"
12641264
replayBlocksDone := "INF Replay: Done module=consensus"
12651265
executedBlock := "INF indexed block "
@@ -1268,6 +1268,11 @@ func (l *validator) scanner(stdout io.Reader, p publisher) error {
12681268
addingNewModule := "INF adding a new module: "
12691269
migratingModule := "INF migrating module "
12701270

1271+
rServerStart, err := regexp.Compile(`^` + serverStart + `(Tendermint|CometBFT) in-process`)
1272+
if err != nil {
1273+
return err
1274+
}
1275+
12711276
rNewModule, err := regexp.Compile(`^` + addingNewModule + `(.+) (.+)$`)
12721277
if err != nil {
12731278
return err
@@ -1287,6 +1292,10 @@ scan:
12871292
if strings.Contains(line, upgradeNeeded) {
12881293
evt.id = nodeEventUpgradeDetected
12891294
} else if strings.Contains(line, serverStart) {
1295+
res := rServerStart.FindAllStringSubmatch(line, -1)
1296+
if len(res) != 1 && len(res[0]) != 2 {
1297+
return fmt.Errorf("line \"%s\" does not match regex \"%s\"", line, rServerStart.String())
1298+
}
12901299
evt.id = nodeEventStart
12911300
} else if strings.Contains(line, replayBlocksStart) {
12921301
evt.id = nodeEventReplayBlocksStart

tests/upgrade/workers_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@ import (
66
"context"
77
"testing"
88

9+
"github.com/stretchr/testify/require"
10+
911
sdkmath "cosmossdk.io/math"
1012
sdkclient "github.com/cosmos/cosmos-sdk/client"
1113
sdk "github.com/cosmos/cosmos-sdk/types"
1214
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
1315
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
1416
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
15-
"github.com/stretchr/testify/require"
17+
1618
"pkg.akt.dev/go/cli/flags"
19+
arpcclient "pkg.akt.dev/go/node/client"
1720
aclient "pkg.akt.dev/go/node/client/discovery"
1821
cltypes "pkg.akt.dev/go/node/client/types"
1922
"pkg.akt.dev/go/node/client/v1beta3"
2023
"pkg.akt.dev/go/sdkutil"
2124

25+
"pkg.akt.dev/node/app"
2226
uttypes "pkg.akt.dev/node/tests/upgrade/types"
2327
)
2428

@@ -34,8 +38,9 @@ var _ uttypes.TestWorker = (*postUpgrade)(nil)
3438

3539
func (pu *postUpgrade) Run(ctx context.Context, t *testing.T, params uttypes.TestParams) {
3640
encodingConfig := sdkutil.MakeEncodingConfig()
41+
app.ModuleBasics().RegisterInterfaces(encodingConfig.InterfaceRegistry)
3742

38-
rpcClient, err := sdkclient.NewClientFromNode(params.Node)
43+
rpcClient, err := arpcclient.NewClient(ctx, params.Node)
3944
require.NoError(t, err)
4045

4146
cctx := sdkclient.Context{}.

0 commit comments

Comments
 (0)