Documentation ¶
Index ¶
- Constants
- type ImageConfig
- type Manager
- func (m *Manager) ClearResources() error
- func (m *Manager) ExecCmd(t *testing.T, containerName string, command []string, success string) (bytes.Buffer, bytes.Buffer, error)
- func (m *Manager) ExecCmdWithResponseString(t *testing.T, chainId string, containerName string, command []string, ...) (bytes.Buffer, bytes.Buffer, error)
- func (m *Manager) ExecHermesCmd(t *testing.T, command []string, success string) (bytes.Buffer, bytes.Buffer, error)
- func (m *Manager) ExecTxCmd(t *testing.T, chainId string, containerName string, command []string) (outBuff bytes.Buffer, errBuff bytes.Buffer, err error)
- func (m *Manager) GetHostPort(containerName string, portId string) (string, error)
- func (m *Manager) GetNodeResource(containerName string) (*dockertest.Resource, error)
- func (m *Manager) PurgeResource(resource *dockertest.Resource) error
- func (m *Manager) RemoveNodeResource(containerName string) error
- func (m *Manager) RunChainInitResource(chainId string, chainVotingPeriod, chainExpeditedVotingPeriod int, ...) (*dockertest.Resource, error)
- func (m *Manager) RunHermesResource(...) (*dockertest.Resource, error)
- func (m *Manager) RunNodeResource(containerName, valCondifDir string) (*dockertest.Resource, error)
Constants ¶
const ( // Current Git branch c4e-chain repo/version. It is meant to be built locally. // It is used when skipping upgrade by setting startUpgrade in test suite to true). // This image should be pre-built with `make docker-build-debug` either in CI or locally. CurrentBranchC4eRepository = "chain4energy" CurrentBranchC4eTag = "debug" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ImageConfig ¶
type ImageConfig struct { InitRepository string InitTag string C4eRepository string C4eTag string RelayerRepository string RelayerTag string }
ImageConfig contains all images and their respective tags needed for running e2e tests.
func NewImageConfig ¶
func NewImageConfig(startUpgrade bool, migrationChaining bool) ImageConfig
NewImageConfig returns ImageConfig needed for running e2e test. If startUpgrade is true, returns images for running the upgrade
type Manager ¶
type Manager struct { ImageConfig // contains filtered or unexported fields }
Manager is a wrapper around all Docker instances, and the Docker API. It provides utilities to run and interact with all Docker containers used within e2e testing.
func NewManager ¶
func NewManager(startUpgrade, migrationChainging bool, isDebugLogEnabled bool, signMode string) (docker *Manager, err error)
NewManager creates a new Manager instance and initializes all Docker specific utilies. Returns an error if initialiation fails.
func (*Manager) ClearResources ¶
ClearResources removes all outstanding Docker resources created by the Manager.
func (*Manager) ExecCmd ¶
func (m *Manager) ExecCmd(t *testing.T, containerName string, command []string, success string) (bytes.Buffer, bytes.Buffer, error)
ExecCmd executes command by running it on the node container (specified by containerName) success is the output of the command that needs to be observed for the command to be deemed successful. It is found by checking if stdout or stderr contains the success string anywhere within it. returns container std out, container std err, and error if any. An error is returned if the command fails to execute or if the success string is not found in the output.
func (*Manager) ExecCmdWithResponseString ¶
func (m *Manager) ExecCmdWithResponseString(t *testing.T, chainId string, containerName string, command []string, successStr string) (bytes.Buffer, bytes.Buffer, error)
ExecCmdWithResponseString Runs ExecCmd, with flags for txs added. namely adding flags `--chain-id={chain-id} -b=block --yes --keyring-backend=test "--log_format=json"`, and searching for `successStr`
func (*Manager) ExecHermesCmd ¶
func (m *Manager) ExecHermesCmd(t *testing.T, command []string, success string) (bytes.Buffer, bytes.Buffer, error)
ExecHermesCmd executes command on the hermes relaer container.
func (*Manager) ExecTxCmd ¶
func (m *Manager) ExecTxCmd(t *testing.T, chainId string, containerName string, command []string) (outBuff bytes.Buffer, errBuff bytes.Buffer, err error)
ExecTxCmd Runs ExecCmdWithResponseString searching for `code: 0`
func (*Manager) GetHostPort ¶
GetHostPort returns the port-forwarding address of the running host necessary to connect to the portId exposed inside the container. The container is determined by containerName. Returns the host-port or error if any.
func (*Manager) GetNodeResource ¶
GetNodeResource returns the node resource for containerName.
func (*Manager) PurgeResource ¶
PurgeResource purges the container resource and returns an error if any.
func (*Manager) RemoveNodeResource ¶
RemoveNodeResource removes a node container specified by containerName. Returns error if any.
func (*Manager) RunChainInitResource ¶
func (m *Manager) RunChainInitResource(chainId string, chainVotingPeriod, chainExpeditedVotingPeriod int, validatorConfigBytes []byte, mountDir string, appStateBytes []byte) (*dockertest.Resource, error)
RunChainInitResource runs a chain init container to initialize genesis and configs for a chain with chainId. The chain is to be configured with chainVotingPeriod and validators deserialized from validatorConfigBytes. The genesis and configs are to be mounted on the init container as volume on mountDir path. Returns the container resource and error if any. This method does not Purge the container. The caller must deal with removing the resource.
func (*Manager) RunHermesResource ¶
func (m *Manager) RunHermesResource(chainAID, c4eARelayerNodeName, c4eAValMnemonic, chainBID, c4eBRelayerNodeName, c4eBValMnemonic string, hermesCfgPath string) (*dockertest.Resource, error)
RunHermesResource runs a Hermes container. Returns the container resource and error if any. the name of the hermes container is "<chain A id>-<chain B id>-relayer"
func (*Manager) RunNodeResource ¶
RunNodeResource runs a node container. Assings containerName to the container. Mounts the container on valConfigDir volume on the running host. Returns the container resource and error if any.