github.com/MetalBlockchain/metalgo@v1.11.9/tests/upgrade/upgrade_test.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package upgrade
     5  
     6  import (
     7  	"flag"
     8  	"fmt"
     9  	"testing"
    10  
    11  	"github.com/onsi/ginkgo/v2"
    12  	"github.com/stretchr/testify/require"
    13  
    14  	"github.com/MetalBlockchain/metalgo/tests/fixture/e2e"
    15  	"github.com/MetalBlockchain/metalgo/tests/fixture/tmpnet"
    16  )
    17  
    18  func TestUpgrade(t *testing.T) {
    19  	ginkgo.RunSpecs(t, "upgrade test suites")
    20  }
    21  
    22  var (
    23  	avalancheGoExecPath            string
    24  	avalancheGoExecPathToUpgradeTo string
    25  )
    26  
    27  func init() {
    28  	flag.StringVar(
    29  		&avalancheGoExecPath,
    30  		"metalgo-path",
    31  		"",
    32  		"metalgo executable path",
    33  	)
    34  	flag.StringVar(
    35  		&avalancheGoExecPathToUpgradeTo,
    36  		"metalgo-path-to-upgrade-to",
    37  		"",
    38  		"metalgo executable path to upgrade to",
    39  	)
    40  }
    41  
    42  var _ = ginkgo.Describe("[Upgrade]", func() {
    43  	require := require.New(ginkgo.GinkgoT())
    44  
    45  	ginkgo.It("can upgrade versions", func() {
    46  		network := tmpnet.NewDefaultNetwork("avalanchego-upgrade")
    47  		e2e.StartNetwork(network, avalancheGoExecPath, "" /* pluginDir */, 0 /* shutdownDelay */, false /* reuseNetwork */)
    48  
    49  		ginkgo.By(fmt.Sprintf("restarting all nodes with %q binary", avalancheGoExecPathToUpgradeTo))
    50  		for _, node := range network.Nodes {
    51  			ginkgo.By(fmt.Sprintf("restarting node %q with %q binary", node.NodeID, avalancheGoExecPathToUpgradeTo))
    52  			require.NoError(node.Stop(e2e.DefaultContext()))
    53  
    54  			node.RuntimeConfig.AvalancheGoPath = avalancheGoExecPathToUpgradeTo
    55  
    56  			require.NoError(network.StartNode(e2e.DefaultContext(), ginkgo.GinkgoWriter, node))
    57  
    58  			ginkgo.By(fmt.Sprintf("waiting for node %q to report healthy after restart", node.NodeID))
    59  			e2e.WaitForHealthy(node)
    60  		}
    61  
    62  		e2e.CheckBootstrapIsPossible(network)
    63  	})
    64  })