Skip to content

Commit

Permalink
test(upgrade): return upgrade version to test against (#1899)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Nov 2, 2023
1 parent 5225242 commit 50afc5e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
test_required=$(./script/upgrades.sh test-required ${{ env.RELEASE_TAG }})
echo "TEST_REQUIRED=$test_required" >> $GITHUB_ENV
- name: run test
if: env.TEST_REQUIRED == 'true'
if: env.TEST_REQUIRED != ''
env:
UPGRADE_BINARY_VERSION: ${{ env.RELEASE_TAG }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ jobs:
- name: Ensure only directories exists in upgrades dir
run: |
dir=./upgrades/software
if [[ $(find "$dir" ! -path "$dir" -maxdepth 1 -type f | wc -c) -ne 0 ]]; then
if [[ $(find "$dir" ! -path "$dir" -maxdepth 1 -type f | wc -c) -ne 0 ]]; then
echo "$dir must contain only directories"
exit 1
fi
Expand All @@ -204,7 +204,7 @@ jobs:
dir=./upgrades/software
while read upgrade; do
./script/semver.sh validate "$upgrade"
done <<< $(find "$dir" ! -path "$dir" -maxdepth 1 -type d -exec basename {} \;)
done <<< $(find "$dir" ! -path "$dir" -maxdepth 1 -type d -exec basename {} \;)
network-upgrade:
runs-on: upgrade-tester
steps:
Expand All @@ -225,7 +225,7 @@ jobs:
echo "TEST_REQUIRED=$test_required" >> $GITHUB_ENV
- name: run test
id: test
if: env.TEST_REQUIRED == 'true'
if: env.TEST_REQUIRED != ''
run: |
cd tests/upgrade
make test
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ GIT_HEAD_COMMIT_LONG := $(shell git log -1 --format='%H')
GIT_HEAD_COMMIT_SHORT := $(shell git rev-parse --short HEAD)
GIT_HEAD_ABBREV := $(shell git rev-parse --abbrev-ref HEAD)

RELEASE_TAG ?= $(shell git describe --tags --abbrev=0)
IS_PREREL := $(shell $(ROOT_DIR)/script/is_prerelease.sh "$(RELEASE_TAG)" && echo "true" || echo "false")
IS_MAINNET := $(shell $(ROOT_DIR)/script/mainnet-from-tag.sh "$(RELEASE_TAG)" && echo "true" || echo "false")
IS_STABLE ?= false
Expand Down
2 changes: 2 additions & 0 deletions make/init.mk
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ GOLANGCI_LINT := $(AKASH_DEVCACHE_BIN)/golangci-lint
STATIK := $(AKASH_DEVCACHE_BIN)/statik
COSMOVISOR := $(AKASH_DEVCACHE_BIN)/cosmovisor

RELEASE_TAG ?= $(shell git describe --tags --abbrev=0)

include $(AKASH_ROOT)/make/setup-cache.mk
5 changes: 3 additions & 2 deletions make/test-upgrade.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export AKASH_LOG_COLOR = true

KEY_OPTS := --keyring-backend=$(AKASH_KEYRING_BACKEND)
KEY_NAME ?= validator
UPGRADE_TO ?= v0.26.0
UPGRADE_TO ?= $(shell $(ROOT_DIR)/script/upgrades.sh test-required $(RELEASE_TAG))
# v0.28.0
UPGRADE_FROM := $(shell cat $(ROOT_DIR)/meta.json | jq -r --arg name $(UPGRADE_TO) '.upgrades[$$name].from_version' | tr -d '\n')
GENESIS_BINARY_VERSION := $(shell cat $(ROOT_DIR)/meta.json | jq -r --arg name $(UPGRADE_TO) '.upgrades[$$name].from_binary' | tr -d '\n')
UPGRADE_BINARY_VERSION ?= local
Expand Down Expand Up @@ -42,7 +43,7 @@ test: $(COSMOVISOR) init

.PHONY: test-reset
test-reset:
$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --uname=$(UPGRADE_TO) --config="$(PWD)/config.json" clean
$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --config="$(PWD)/config.json" clean

.PHONY: clean
clean:
Expand Down
8 changes: 2 additions & 6 deletions script/upgrades.sh
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ test-required)
# current git reference is matching upgrade name. looks like release has been cut
# so lets run the last test
if [[ "$curr_ref" == "$upgrade_name" ]]; then
echo -e "true"
echo -e "$upgrade_name"
exit 0
fi

Expand Down Expand Up @@ -371,11 +371,7 @@ test-required)
fi
done

if [[ "$upgrade_name" == "" ]]; then
echo -n "false"
else
echo -n "true"
fi
echo -n "$upgrade_name"

exit 0
;;
Expand Down
13 changes: 9 additions & 4 deletions tests/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ loop:
l.t.Log("no post upgrade handlers found. submitting shutdown")
_ = bus.Publish(postUpgradeTestDone{})

break loop
break
}

l.t.Log("running post upgrade test handler")
Expand All @@ -587,6 +587,7 @@ loop:
})
}
case postUpgradeTestDone:
l.t.Log("shutting down validator(s)")
for _, val := range l.validators {
_ = val.pubsub.Publish(eventShutdown{})
}
Expand Down Expand Up @@ -1055,7 +1056,8 @@ loop:
}

for name, module := range migrations {
if module.status == testModuleStatusChecked {
switch module.status {
case testModuleStatusChecked:
if !module.expected.compare(module.actual) {
merr := fmt.Sprintf("migration for module (%s) finished with mismatched versions:\n"+
"\texpected:\n"+
Expand All @@ -1070,8 +1072,11 @@ loop:

errs = append(errs, merr)
}
} else {
merr := fmt.Sprintf("detected unexpected pmigration in module (%s)", name)
case testModuleStatusNotChecked:
merr := fmt.Sprintf("required migration for module module (%s) was not detected", name)
errs = append(errs, merr)
case testModuleStatusUnexpected:
merr := fmt.Sprintf("detected unexpected migration in module (%s)", name)
errs = append(errs, merr)
}
}
Expand Down

0 comments on commit 50afc5e

Please sign in to comment.