From da7e287b331a02055cb7638838583e7f498638b2 Mon Sep 17 00:00:00 2001 From: arturrez <56270896+arturrez@users.noreply.github.com> Date: Thu, 21 Nov 2024 18:04:15 -0800 Subject: [PATCH] Fix local status (#2353) * 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 --- pkg/node/local.go | 3 ++- tests/e2e/commands/etna.go | 26 +++++++++++++++++++ .../subnet/sov/addRemoveValidatorPoA/suite.go | 11 ++++++++ .../subnet/sov/addRemoveValidatorPoS/suite.go | 10 +++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/pkg/node/local.go b/pkg/node/local.go index e94674d9e..5db31a881 100644 --- a/pkg/node/local.go +++ b/pkg/node/local.go @@ -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")) diff --git a/tests/e2e/commands/etna.go b/tests/e2e/commands/etna.go index 77179b4a1..246f52352 100644 --- a/tests/e2e/commands/etna.go +++ b/tests/e2e/commands/etna.go @@ -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 +} diff --git a/tests/e2e/testcases/subnet/sov/addRemoveValidatorPoA/suite.go b/tests/e2e/testcases/subnet/sov/addRemoveValidatorPoA/suite.go index 82c89929d..2a4821932 100644 --- a/tests/e2e/testcases/subnet/sov/addRemoveValidatorPoA/suite.go +++ b/tests/e2e/testcases/subnet/sov/addRemoveValidatorPoA/suite.go @@ -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, diff --git a/tests/e2e/testcases/subnet/sov/addRemoveValidatorPoS/suite.go b/tests/e2e/testcases/subnet/sov/addRemoveValidatorPoS/suite.go index 2a4967e66..6f39aad4f 100644 --- a/tests/e2e/testcases/subnet/sov/addRemoveValidatorPoS/suite.go +++ b/tests/e2e/testcases/subnet/sov/addRemoveValidatorPoS/suite.go @@ -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) })