Skip to content

Commit

Permalink
Fix local status (#2353)
Browse files Browse the repository at this point in the history
* fix l1 status for node local

* add e2e for node local cluster status

* add node local status for PoA

* add sleep and fix regex

* missed regex change

* add e2e for status

* simplify regex
  • Loading branch information
arturrez authored Nov 22, 2024
1 parent 162edf1 commit da7e287
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/node/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,8 @@ func LocalStatus(app *application.Avalanche, clusterName string, blockchainName
if err != nil {
return err
}
blockchainID = sc.Networks[clusterConf.Network.Name()].BlockchainID
network := models.ConvertClusterToNetwork(clusterConf.Network)
blockchainID = sc.Networks[network.Name()].BlockchainID
}
if rootDir == currentlyRunningRootDir {
currenlyRunning = fmt.Sprintf(" [%s]", logging.Blue.Wrap("Running"))
Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/commands/etna.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,29 @@ func RemoveEtnaSubnetValidatorFromCluster(
gomega.Expect(err).Should(gomega.BeNil())
return string(output), err
}

func GetLocalClusterStatus(
clusterName string,
blockchainName string,
) (string, error) {
cmd := exec.Command(
CLIBinary,
"node",
"local",
"status",
clusterName,
"--"+constants.SkipUpdateFlag,
)
if blockchainName != "" {
cmd.Args = append(cmd.Args, "--blockchain", blockchainName)
}
fmt.Println(cmd)
output, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(cmd.String())
fmt.Println(string(output))
utils.PrintStdErr(err)
}
gomega.Expect(err).Should(gomega.BeNil())
return string(output), err
}
11 changes: 11 additions & 0 deletions tests/e2e/testcases/subnet/sov/addRemoveValidatorPoA/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ var _ = ginkgo.Describe("[Etna AddRemove Validator SOV PoA]", func() {
gomega.Expect(err).Should(gomega.BeNil())
fmt.Println(output)
})

ginkgo.It("Can get status of the cluster", func() {
output, err := commands.GetLocalClusterStatus(testLocalNodeName, subnetName)
gomega.Expect(err).Should(gomega.BeNil())
fmt.Println(output)
// make sure we can find string with "http://127.0.0.1:9660" and "L1:Validating" string in the output
gomega.Expect(output).To(gomega.MatchRegexp(`http://127\.0\.0\.1:9652.*Validating`), "expect to have L1 validating")
// make sure we can do the same for "http://127.0.0.1:9662"
gomega.Expect(output).To(gomega.MatchRegexp(`http://127\.0\.0\.1:9654.*Validating`), "expect to have L1 validating")
})

ginkgo.It("Can remove bootstrap validator", func() {
output, err := commands.RemoveEtnaSubnetValidatorFromCluster(
testLocalNodeName,
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/testcases/subnet/sov/addRemoveValidatorPoS/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ var _ = ginkgo.Describe("[Etna AddRemove Validator SOV PoS]", func() {
fmt.Println(output)
})

ginkgo.It("Can get status of thecluster", func() {
output, err := commands.GetLocalClusterStatus(testLocalNodeName, subnetName)
gomega.Expect(err).Should(gomega.BeNil())
fmt.Println(output)
// make sure we can find string with "http://127.0.0.1:9660" and "L1:Validating" string in the output
gomega.Expect(output).To(gomega.MatchRegexp(`http://127\.0\.0\.1:9652.*Validating`), "expect to have L1 validating")
// make sure we can do the same for "http://127.0.0.1:9662"
gomega.Expect(output).To(gomega.MatchRegexp(`http://127\.0\.0\.1:9654.*Validating`), "expect to have L1 validating")
})

ginkgo.It("Can wait for min staking period to pass", func() {
time.Sleep(120 * time.Second)
})
Expand Down

0 comments on commit da7e287

Please sign in to comment.