upgrade

package
v12.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// LocalVersionTag defines the docker image ImageTag when building locally
	LocalVersionTag = "latest"
)

The constants used in the upgrade tests are defined here

Variables

This section is empty.

Functions

func CheckLegacyProposal

func CheckLegacyProposal(version string) bool

CheckLegacyProposal checks if the running node requires a legacy proposal

func RetrieveUpgradesList

func RetrieveUpgradesList(upgradesPath string) ([]string, error)

RetrieveUpgradesList parses the app/upgrades folder and returns a slice of semver upgrade versions in ascending order, e.g ["v1.0.0", "v1.0.1", "v1.1.0", ... , "v10.0.0"]

Types

type EvermintVersion

type EvermintVersion []string

EvermintVersion is a custom comparator for sorting semver version strings.

func (EvermintVersion) Len

func (v EvermintVersion) Len() int

Len is the number of stored versions..

func (EvermintVersion) Less

func (v EvermintVersion) Less(i, j int) bool

Less compares semver versions strings properly

func (EvermintVersion) Swap

func (v EvermintVersion) Swap(i, j int)

Swap swaps the elements with indexes i and j. It is needed to sort the slice.

type Manager

type Manager struct {

	// CurrentNode stores the currently running docker container
	CurrentNode *dockertest.Resource

	// HeightBeforeStop stores the last block height that was reached before the last running node container
	// was stopped
	HeightBeforeStop int

	// UpgradeHeight stores the upgrade height for the latest upgrade proposal that was submitted
	UpgradeHeight uint
	// contains filtered or unexported fields
}

Manager defines a docker pool instance, used to build, run, interact with and stop docker containers running nodes of our chain.

func NewManager

func NewManager(networkName string) (*Manager, error)

NewManager creates new docker pool and network and returns a populated Manager instance

func (*Manager) BuildImage

func (m *Manager) BuildImage(name, version, dockerFile, contextDir string, args map[string]string) error

BuildImage builds a docker image to run in the provided context directory with <name>:<version> as the image target

func (*Manager) Client

func (m *Manager) Client() *docker.Client

The Client method returns the Docker client used by the Manager's pool

func (*Manager) ContainerID

func (m *Manager) ContainerID() string

ContainerID returns the docker container ID of the currently running Node

func (*Manager) CreateDepositProposalExec

func (m *Manager) CreateDepositProposalExec(chainID string, id int) (string, error)

CreateDepositProposalExec creates a gov tx to deposit for the proposal with the given id

func (*Manager) CreateExec

func (m *Manager) CreateExec(cmd []string, containerID string) (string, error)

CreateExec creates docker exec command for specified container

func (*Manager) CreateModuleQueryExec

func (m *Manager) CreateModuleQueryExec(moduleName, subCommand, chainID string) (string, error)

CreateModuleQueryExec creates a module query for out chain

func (*Manager) CreateSubmitProposalExec

func (m *Manager) CreateSubmitProposalExec(targetVersion, chainID string, upgradeHeight uint, legacy bool, flags ...string) (string, error)

CreateSubmitProposalExec creates a gov tx to submit an upgrade proposal to the chain

func (*Manager) CreateVoteProposalExec

func (m *Manager) CreateVoteProposalExec(chainID string, id int, flags ...string) (string, error)

CreateVoteProposalExec creates gov tx to vote 'yes' on the proposal with the given id

func (*Manager) ExportState

func (m *Manager) ExportState(targetDir string) error

ExportState executes the 'docker cp' command to copy home dir of chain home in container to the specified target dir (local)

See https://docs.docker.com/engine/reference/commandline/cp/

func (*Manager) GetLogs

func (m *Manager) GetLogs(containerID string) (stdOut, stdErr string, err error)

GetLogs returns the logs of the container with the provided containerID

func (*Manager) GetNodeHeight

func (m *Manager) GetNodeHeight(ctx context.Context) (int, error)

GetNodeHeight calls the CLI in the current node container to get the current block height

func (*Manager) GetNodeVersion

func (m *Manager) GetNodeVersion(ctx context.Context) (string, error)

GetNodeVersion calls the CLI in the current node container to get the current node version

func (*Manager) KillCurrentNode

func (m *Manager) KillCurrentNode() error

KillCurrentNode stops the execution of the currently used docker container

func (*Manager) RemoveNetwork

func (m *Manager) RemoveNetwork() error

RemoveNetwork removes the Manager's used network from the pool

func (*Manager) RunExec

func (m *Manager) RunExec(ctx context.Context, exec string) (outBuf bytes.Buffer, errBuf bytes.Buffer, err error)

RunExec runs the provided docker exec call

func (*Manager) RunNode

func (m *Manager) RunNode(node *Node) error

RunNode creates a docker container from the provided node instance and runs it. To make sure the node started properly, get requests are sent to the JSON-RPC server repeatedly with a timeout of 60 seconds. In case the node fails to start, the container logs are returned along with the error.

func (*Manager) WaitForHeight

func (m *Manager) WaitForHeight(ctx context.Context, height int) (string, error)

WaitForHeight queries the node every second until the node will reach the specified height. After 5 minutes this function times out and returns an error

type Node

type Node struct {
	RunOptions *dockertest.RunOptions
	// contains filtered or unexported fields
}

Node represents a node of our chain in the context of the upgrade tests. It contains fields to store the used repository, version as well as custom run options for dockertest.

func NewNode

func NewNode(repository, version string) *Node

NewNode creates a new instance of the node with a set of sensible default RunOptions for dockertest.

func (*Node) Mount

func (n *Node) Mount(mountPath string)

Mount sets the container mount point, which is used as the value for 'docker run --volume'.

See https://docs.docker.com/engine/reference/builder/#volume

func (*Node) SetCmd

func (n *Node) SetCmd(cmd []string)

SetCmd sets the container entry command and overrides the image CMD instruction.

See https://docs.docker.com/engine/reference/builder/#cmd

func (*Node) SetEnvVars

func (n *Node) SetEnvVars(vars []string)

SetEnvVars allows to set additional container environment variables by passing a slice of strings that each fit the pattern "VAR_NAME=value".

func (*Node) UseRunOptions

func (n *Node) UseRunOptions()

UseRunOptions sets a flag to allow the node Manager to run the container with additional run options.

type Params

type Params struct {
	// MountPath defines the path where the docker container is mounted
	MountPath string
	// Versions defines the slice of versions that are run during the upgrade tests
	Versions []VersionConfig
	// ChainID defines the chain ID used for the upgrade tests
	ChainID string
	// SkipCleanup defines if the docker containers are removed after the tests
	SkipCleanup bool
	// WorkDirRoot defines the working directory
	WorkDirRoot string
}

Params defines the parameters for the upgrade test suite

func LoadUpgradeParams

func LoadUpgradeParams(upgradesFolder string) (Params, error)

LoadUpgradeParams loads the upgrade parameters from the environment variables

type VersionConfig

type VersionConfig struct {
	// UpgradeName defines the upgrade name to use in the proposal
	UpgradeName string
	// ImageTag defines the version tag to use in the docker image
	ImageTag string
	// ImageName defines the image name for the docker image
	ImageName string
}

VersionConfig defines a struct that contains the version and the source repository for an upgrade

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL