Skip to content

Commit

Permalink
Merge branch 'main' into 225-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero authored Aug 10, 2022
2 parents c4fcea5 + 4275a4e commit 00bbd75
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 89 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.17.2" # The Go version to use.
go-version: 1.18
- run: go test -v -timeout 10m -race ./...
e2e_test:
name: e2e tests
Expand All @@ -51,10 +51,10 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18
- name: Run e2e tests
shell: bash
run: scripts/tests.e2e.sh 1.7.12 1.7.13
run: scripts/tests.e2e.sh 1.7.15 1.7.16 0.2.4
release:
needs: [lint_test, unit_test, e2e_test]
runs-on: ubuntu-latest
Expand All @@ -66,7 +66,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ run:
- api/mocks
- local/mocks
- rpcpb
go: "1.17"
go: "1.18"

linters:
disable:
Expand Down
98 changes: 41 additions & 57 deletions cmd/control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"os"
"os/signal"
Expand Down Expand Up @@ -147,14 +146,17 @@ func newStartCommand() *cobra.Command {
&whitelistedSubnets,
"whitelisted-subnets",
"",
"whitelisted subnets (comma-separated)",
"[optional] whitelisted subnets (comma-separated)",
)
cmd.PersistentFlags().StringVar(
&chainConfigs,
"chain-configs",
"",
"[optional] JSON string of map that maps from chain id to its config file contents",
"[optional] JSON string of map from chain id to its config file contents",
)
if err := cmd.MarkPersistentFlagRequired("avalanchego-path"); err != nil {
panic(err)
}
return cmd
}

Expand Down Expand Up @@ -224,19 +226,10 @@ func startFunc(cmd *cobra.Command, args []string) error {

func newCreateBlockchainsCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "create-blockchains [options]",
Use: "create-blockchains blockchain-specs [options]",
Short: "Create blockchains.",
RunE: createBlockchainsFunc,
Args: cobra.ExactArgs(0),
}
cmd.PersistentFlags().StringVar(
&blockchainSpecsStr,
"blockchain-specs",
"",
"JSON string of list of [(VM name, its genesis file path, optional subnet id to use)]",
)
if err := cmd.MarkPersistentFlagRequired("blockchain-specs"); err != nil {
panic(err)
Args: cobra.ExactArgs(1),
}
return cmd
}
Expand All @@ -248,9 +241,7 @@ func createBlockchainsFunc(cmd *cobra.Command, args []string) error {
}
defer cli.Close()

if blockchainSpecsStr == "" {
return errors.New("empty blockchain-specs argument")
}
blockchainSpecsStr := args[0]

blockchainSpecs := []*rpcpb.BlockchainSpec{}
if err := json.Unmarshal([]byte(blockchainSpecsStr), &blockchainSpecs); err != nil {
Expand Down Expand Up @@ -449,20 +440,19 @@ func streamStatusFunc(cmd *cobra.Command, args []string) error {
return nil
}

var nodeName string

func newRemoveNodeCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "remove-node [options]",
Use: "remove-node node-name [options]",
Short: "Removes a node.",
RunE: removeNodeFunc,
Args: cobra.ExactArgs(0),
Args: cobra.ExactArgs(1),
}
cmd.PersistentFlags().StringVar(&nodeName, "node-name", "", "node name to remove")
return cmd
}

func removeNodeFunc(cmd *cobra.Command, args []string) error {
// no validation for empty string required, as covered by `cobra.ExactArgs`
nodeName := args[0]
cli, err := newClient()
if err != nil {
return err
Expand All @@ -482,17 +472,11 @@ func removeNodeFunc(cmd *cobra.Command, args []string) error {

func newAddNodeCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "add-node [options]",
Use: "add-node node-name [options]",
Short: "Add a new node to the network",
RunE: addNodeFunc,
Args: cobra.ExactArgs(0),
Args: cobra.ExactArgs(1),
}
cmd.PersistentFlags().StringVar(
&nodeName,
"node-name",
"",
"node name to add",
)
cmd.PersistentFlags().StringVar(
&avalancheGoBinPath,
"avalanchego-path",
Expand All @@ -515,6 +499,8 @@ func newAddNodeCommand() *cobra.Command {
}

func addNodeFunc(cmd *cobra.Command, args []string) error {
// no validation for empty string required, as covered by `cobra.ExactArgs`
nodeName := args[0]
cli, err := newClient()
if err != nil {
return err
Expand Down Expand Up @@ -559,17 +545,11 @@ func addNodeFunc(cmd *cobra.Command, args []string) error {

func newRestartNodeCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "restart-node [options]",
Short: "Restarts the server.",
Use: "restart-node node-name [options]",
Short: "Restarts a node.",
RunE: restartNodeFunc,
Args: cobra.ExactArgs(0),
Args: cobra.ExactArgs(1),
}
cmd.PersistentFlags().StringVar(
&nodeName,
"node-name",
"",
"node name to restart",
)
cmd.PersistentFlags().StringVar(
&avalancheGoBinPath,
"avalanchego-path",
Expand All @@ -586,6 +566,8 @@ func newRestartNodeCommand() *cobra.Command {
}

func restartNodeFunc(cmd *cobra.Command, args []string) error {
// no validation for empty string required, as covered by `cobra.ExactArgs`
nodeName := args[0]
cli, err := newClient()
if err != nil {
return err
Expand All @@ -610,21 +592,17 @@ func restartNodeFunc(cmd *cobra.Command, args []string) error {

func newAttachPeerCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "attach-peer [options]",
Use: "attach-peer node-name [options]",
Short: "Attaches a peer to the node.",
RunE: attachPeerFunc,
Args: cobra.ExactArgs(0),
Args: cobra.ExactArgs(1),
}
cmd.PersistentFlags().StringVar(
&nodeName,
"node-name",
"",
"node name to attach a peer to",
)
return cmd
}

func attachPeerFunc(cmd *cobra.Command, args []string) error {
// no validation for empty string required, as covered by `cobra.ExactArgs`
nodeName := args[0]
cli, err := newClient()
if err != nil {
return err
Expand All @@ -650,17 +628,12 @@ var (

func newSendOutboundMessageCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "send-outbound-message [options]",
Short: "Sends an outbound message to an attached peer.",
RunE: sendOutboundMessageFunc,
Args: cobra.ExactArgs(0),
Use: "send-outbound-message node-name [options]",
Short: "Sends an outbound message to an attached peer.",
RunE: sendOutboundMessageFunc,
Args: cobra.ExactArgs(1),
ValidArgs: []string{"node-name"},
}
cmd.PersistentFlags().StringVar(
&nodeName,
"node-name",
"",
"node name that has an attached peer",
)
cmd.PersistentFlags().StringVar(
&peerID,
"peer-id",
Expand All @@ -679,10 +652,21 @@ func newSendOutboundMessageCommand() *cobra.Command {
"",
"Message bytes in base64 encoding",
)
if err := cmd.MarkPersistentFlagRequired("peer-id"); err != nil {
panic(err)
}
if err := cmd.MarkPersistentFlagRequired("message-op"); err != nil {
panic(err)
}
if err := cmd.MarkPersistentFlagRequired("message-bytes-b64"); err != nil {
panic(err)
}
return cmd
}

func sendOutboundMessageFunc(cmd *cobra.Command, args []string) error {
// no validation for empty string required, as covered by `cobra.ExactArgs`
nodeName := args[0]
cli, err := newClient()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ava-labs/avalanche-network-runner

go 1.17
go 1.18

require (
github.com/ava-labs/avalanchego v1.7.16
Expand Down
45 changes: 40 additions & 5 deletions scripts/tests.e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,39 @@ if ! [[ "$0" =~ scripts/tests.e2e.sh ]]; then
exit 255
fi

DEFAULT_VERSION_1=1.7.12
DEFAULT_VERSION_2=1.7.13
DEFAULT_VERSION_1=1.7.15
DEFAULT_VERSION_2=1.7.16
DEFAULT_SUBNET_EVM_VERSION=0.2.4

if [ $# == 0 ]; then
VERSION_1=$DEFAULT_VERSION_1
VERSION_2=$DEFAULT_VERSION_2
SUBNET_EVM_VERSION=$DEFAULT_SUBNET_EVM_VERSION
else
VERSION_1=$1
if [[ -z "${VERSION_1}" ]]; then
echo "Missing version argument!"
echo "Usage: ${0} [VERSION_1] [VERSION_2]" >> /dev/stderr
echo "Usage: ${0} [VERSION_1] [VERSION_2] [SUBNET_EVM_VERSION]" >> /dev/stderr
exit 255
fi
VERSION_2=$2
if [[ -z "${VERSION_2}" ]]; then
echo "Missing version argument!"
echo "Usage: ${0} [VERSION_1] [VERSION_2]" >> /dev/stderr
echo "Usage: ${0} [VERSION_1] [VERSION_2] [SUBNET_EVM_VERSION]" >> /dev/stderr
exit 255
fi
SUBNET_EVM_VERSION=$3
if [[ -z "${SUBNET_EVM_VERSION}" ]]; then
echo "Missing version argument!"
echo "Usage: ${0} [VERSION_1] [VERSION_2] [SUBNET_EVM_VERSION]" >> /dev/stderr
exit 255
fi
fi

echo "Running e2e tests with:"
echo VERSION_1: ${VERSION_1}
echo VERSION_2: ${VERSION_2}
echo SUBNET_EVM_VERSION: ${SUBNET_EVM_VERSION}

if [ ! -f /tmp/avalanchego-v${VERSION_1}/avalanchego ]
then
Expand Down Expand Up @@ -93,6 +102,31 @@ then
find /tmp/avalanchego-v${VERSION_2}
fi

if [ ! -f /tmp/subnet-evm-v${SUBNET_EVM_VERSION}/subnet-evm ]
then
############################
# download subnet-evm
# https://github.com/ava-labs/subnet-evm/releases
GOARCH=$(go env GOARCH)
DOWNLOAD_URL=https://github.com/ava-labs/subnet-evm/releases/download/v${SUBNET_EVM_VERSION}/subnet-evm_${SUBNET_EVM_VERSION}_linux_${GOARCH}.tar.gz
DOWNLOAD_PATH=/tmp/subnet-evm.tar.gz
if [[ ${GOOS} == "darwin" ]]; then
DOWNLOAD_URL=https://github.com/ava-labs/subnet-evm/releases/download/v${SUBNET_EVM_VERSION}/subnet-evm_${SUBNET_EVM_VERSION}_darwin_${GOARCH}.tar.gz
fi

rm -rf /tmp/subnet-evm-v${SUBNET_EVM_VERSION}
rm -f ${DOWNLOAD_PATH}

echo "downloading subnet-evm ${SUBNET_EVM_VERSION} at ${DOWNLOAD_URL}"
curl -L ${DOWNLOAD_URL} -o ${DOWNLOAD_PATH}

echo "extracting downloaded subnet-evm"
mkdir /tmp/subnet-evm-v${SUBNET_EVM_VERSION}
tar xzvf ${DOWNLOAD_PATH} -C /tmp/subnet-evm-v${SUBNET_EVM_VERSION}
# NOTE: We are copying the subnet-evm binary here to a plugin hardcoded as srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy which corresponds to the VM name `subnetevm` used as such in the test
cp /tmp/subnet-evm-v${SUBNET_EVM_VERSION}/subnet-evm /tmp/avalanchego-v${VERSION_2}/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy
find /tmp/subnet-evm-v${SUBNET_EVM_VERSION}/subnet-evm
fi
############################
echo "building runner"
./scripts/build.sh
Expand Down Expand Up @@ -125,7 +159,8 @@ echo "running e2e tests"
--grpc-endpoint="0.0.0.0:8080" \
--grpc-gateway-endpoint="0.0.0.0:8081" \
--avalanchego-path-1=/tmp/avalanchego-v${VERSION_1}/avalanchego \
--avalanchego-path-2=/tmp/avalanchego-v${VERSION_2}/avalanchego
--avalanchego-path-2=/tmp/avalanchego-v${VERSION_2}/avalanchego \
--subnet-evm-path=/tmp/subnet-evm-v${SUBNET_EVM_VERSION}/subnet-evm

kill -9 ${PID}
echo "ALL SUCCESS!"
Loading

0 comments on commit 00bbd75

Please sign in to comment.