github.com/cgcardona/r-subnet-evm@v0.1.5/tests/load/load_test.go (about)

     1  // Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package load
     5  
     6  import (
     7  	"fmt"
     8  	"os"
     9  	"os/exec"
    10  	"strings"
    11  	"testing"
    12  
    13  	"github.com/cgcardona/r-subnet-evm/tests/utils/runner"
    14  	"github.com/ethereum/go-ethereum/log"
    15  	ginkgo "github.com/onsi/ginkgo/v2"
    16  	"github.com/onsi/gomega"
    17  )
    18  
    19  var getSubnet func() *runner.Subnet
    20  
    21  func init() {
    22  	getSubnet = runner.RegisterFiveNodeSubnetRun()
    23  }
    24  
    25  func TestE2E(t *testing.T) {
    26  	gomega.RegisterFailHandler(ginkgo.Fail)
    27  	ginkgo.RunSpecs(t, "subnet-evm small load simulator test suite")
    28  }
    29  
    30  var _ = ginkgo.Describe("[Load Simulator]", ginkgo.Ordered, func() {
    31  	ginkgo.It("basic subnet load test", ginkgo.Label("load"), func() {
    32  		subnetDetails := getSubnet()
    33  		blockchainID := subnetDetails.BlockchainID
    34  
    35  		nodeURIs := subnetDetails.ValidatorURIs
    36  		rpcEndpoints := make([]string, 0, len(nodeURIs))
    37  		for _, uri := range nodeURIs {
    38  			rpcEndpoints = append(rpcEndpoints, fmt.Sprintf("%s/ext/bc/%s/rpc", uri, blockchainID))
    39  		}
    40  		commaSeparatedRPCEndpoints := strings.Join(rpcEndpoints, ",")
    41  		err := os.Setenv("RPC_ENDPOINTS", commaSeparatedRPCEndpoints)
    42  		gomega.Expect(err).Should(gomega.BeNil())
    43  
    44  		log.Info("Sleeping with network running", "rpcEndpoints", commaSeparatedRPCEndpoints)
    45  		cmd := exec.Command("./scripts/run_simulator.sh")
    46  		log.Info("Running load simulator script", "cmd", cmd.String())
    47  
    48  		out, err := cmd.CombinedOutput()
    49  		fmt.Printf("\nCombined output:\n\n%s\n", string(out))
    50  		gomega.Expect(err).Should(gomega.BeNil())
    51  	})
    52  })