Skip to content

Commit d3e9210

Browse files
committed
removing --hard option from clean cmd
1 parent 42e6f1b commit d3e9210

File tree

7 files changed

+25
-81
lines changed

7 files changed

+25
-81
lines changed

cmd/commands.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,6 @@ avalanche network clean [subcommand] [flags]
20672067
**Flags:**
20682068
20692069
```bash
2070-
--hard Also clean downloaded avalanchego and plugin binaries
20712070
-h, --help help for clean
20722071
--config string config file (default is $HOME/.avalanche-cli/config.json)
20732072
--log-level string log level for the application (default "ERROR")

cmd/networkcmd/clean.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package networkcmd
55
import (
66
"errors"
77
"os"
8-
"path/filepath"
98

109
"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
1110
"github.com/ava-labs/avalanche-cli/pkg/constants"
@@ -19,8 +18,6 @@ import (
1918
"github.com/spf13/cobra"
2019
)
2120

22-
var hard bool
23-
2421
func newCleanCmd() *cobra.Command {
2522
cmd := &cobra.Command{
2623
Use: "clean",
@@ -32,13 +29,6 @@ configuration.`,
3229
Args: cobrautils.ExactArgs(0),
3330
}
3431

35-
cmd.Flags().BoolVar(
36-
&hard,
37-
"hard",
38-
false,
39-
"Also clean downloaded avalanchego and plugin binaries",
40-
)
41-
4232
return cmd
4333
}
4434

@@ -59,12 +49,6 @@ func clean(*cobra.Command, []string) error {
5949
return err
6050
}
6151

62-
if hard {
63-
ux.Logger.PrintToUser("hard clean requested via flag, removing all downloaded avalanchego and plugin binaries")
64-
binDir := filepath.Join(app.GetBaseDir(), constants.AvalancheCliBinDir)
65-
cleanBins(binDir)
66-
}
67-
6852
if err := app.ResetPluginsDir(); err != nil {
6953
return err
7054
}

tests/e2e/commands/network.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,6 @@ func CleanNetwork() {
3030
gomega.Expect(err).Should(gomega.BeNil())
3131
}
3232

33-
/* #nosec G204 */
34-
func CleanNetworkHard() {
35-
cmd := exec.Command(
36-
CLIBinary,
37-
NetworkCmd,
38-
"clean",
39-
"--hard",
40-
"--"+constants.SkipUpdateFlag,
41-
)
42-
output, err := cmd.CombinedOutput()
43-
if err != nil {
44-
fmt.Println(cmd.String())
45-
fmt.Println(string(output))
46-
utils.PrintStdErr(err)
47-
}
48-
gomega.Expect(err).Should(gomega.BeNil())
49-
}
50-
5133
/* #nosec G204 */
5234
func StartNetwork() string {
5335
return StartNetworkWithVersion("")

tests/e2e/testcases/network/suite.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -116,31 +116,4 @@ var _ = ginkgo.Describe("[Network]", ginkgo.Ordered, func() {
116116

117117
commands.DeleteSubnetConfig(subnetName)
118118
})
119-
120-
ginkgo.It("clean hard deletes plugin binaries non SOV", func() {
121-
commands.CreateSubnetEvmConfigNonSOV(subnetName, utils.SubnetEvmGenesisPath, false)
122-
deployOutput := commands.DeploySubnetLocallyNonSOV(subnetName)
123-
rpcs, err := utils.ParseRPCsFromOutput(deployOutput)
124-
if err != nil {
125-
fmt.Println(deployOutput)
126-
}
127-
gomega.Expect(err).Should(gomega.BeNil())
128-
gomega.Expect(rpcs).Should(gomega.HaveLen(1))
129-
130-
// check that plugin binaries exist
131-
plugins, err := utils.GetPluginBinaries()
132-
// should have only subnet-evm binary
133-
gomega.Expect(len(plugins)).Should(gomega.Equal(1))
134-
gomega.Expect(err).Should(gomega.BeNil())
135-
136-
commands.CleanNetwork()
137-
138-
// check that plugin binaries exist
139-
plugins, err = utils.GetPluginBinaries()
140-
// should be empty
141-
gomega.Expect(len(plugins)).Should(gomega.Equal(0))
142-
gomega.Expect(err).Should(gomega.BeNil())
143-
144-
commands.DeleteSubnetConfig(subnetName)
145-
})
146119
})

tests/e2e/testcases/packageman/suite.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var _ = ginkgo.Describe("[Package Management]", ginkgo.Ordered, func() {
3030
gomega.Expect(err).Should(gomega.BeNil())
3131
})
3232
ginkgo.BeforeEach(func() {
33-
commands.CleanNetworkHard()
33+
commands.CleanNetwork()
3434
})
3535

3636
ginkgo.AfterEach(func() {
@@ -42,9 +42,11 @@ var _ = ginkgo.Describe("[Package Management]", ginkgo.Ordered, func() {
4242
})
4343

4444
ginkgo.It("can deploy a subnet with subnet-evm version non SOV", func() {
45-
// check subnet-evm install precondition
46-
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey1])).Should(gomega.BeFalse())
47-
gomega.Expect(utils.CheckAvalancheGoExists(binaryToVersion[utils.SoloAvagoKey])).Should(gomega.BeFalse())
45+
// remove installed subnet-evm if detected
46+
if utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey1]) ||
47+
utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloAvagoKey]) {
48+
_ = utils.DeleteBins()
49+
}
4850

4951
commands.CreateSubnetEvmConfigWithVersionNonSOV(subnetName, utils.SubnetEvmGenesisPath, binaryToVersion[utils.SoloSubnetEVMKey1], false)
5052
deployOutput := commands.DeploySubnetLocallyWithVersionNonSOV(subnetName, binaryToVersion[utils.SoloAvagoKey])
@@ -73,9 +75,10 @@ var _ = ginkgo.Describe("[Package Management]", ginkgo.Ordered, func() {
7375
evmVersion := binaryToVersion[utils.SoloSubnetEVMKey1]
7476
avagoVersion := binaryToVersion[utils.SoloAvagoKey]
7577

76-
// check subnet-evm install precondition
77-
gomega.Expect(utils.CheckSubnetEVMExists(evmVersion)).Should(gomega.BeFalse())
78-
gomega.Expect(utils.CheckAvalancheGoExists(avagoVersion)).Should(gomega.BeFalse())
78+
// remove subnet-evm if installed version detected
79+
if utils.CheckSubnetEVMExists(evmVersion) || utils.CheckAvalancheGoExists(avagoVersion) {
80+
_ = utils.DeleteBins()
81+
}
7982

8083
commands.CreateSubnetEvmConfigWithVersionSOV(subnetName, utils.SubnetEvmGenesisPoaPath, evmVersion)
8184
deployOutput := commands.DeploySubnetLocallyWithVersionSOV(subnetName, avagoVersion)
@@ -101,9 +104,11 @@ var _ = ginkgo.Describe("[Package Management]", ginkgo.Ordered, func() {
101104
})
102105

103106
ginkgo.It("can deploy multiple subnet-evm versions non SOV", func() {
104-
// check subnet-evm install precondition
105-
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey1])).Should(gomega.BeFalse())
106-
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey2])).Should(gomega.BeFalse())
107+
// remove installed subnet-evm if detected
108+
if utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey1]) ||
109+
utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey2]) {
110+
_ = utils.DeleteBins()
111+
}
107112

108113
commands.CreateSubnetEvmConfigWithVersionNonSOV(subnetName, utils.SubnetEvmGenesisPath, binaryToVersion[utils.SoloSubnetEVMKey1], false)
109114
commands.CreateSubnetEvmConfigWithVersionNonSOV(secondSubnetName, utils.SubnetEvmGenesis2Path, binaryToVersion[utils.SoloSubnetEVMKey2], false)
@@ -145,9 +150,10 @@ var _ = ginkgo.Describe("[Package Management]", ginkgo.Ordered, func() {
145150
})
146151

147152
ginkgo.It("can deploy multiple subnet-evm versions SOV", func() {
148-
// check subnet-evm install precondition
149-
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey1])).Should(gomega.BeFalse())
150-
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey2])).Should(gomega.BeFalse())
153+
if utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey1]) ||
154+
utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey2]) {
155+
_ = utils.DeleteBins()
156+
}
151157

152158
commands.CreateSubnetEvmConfigWithVersionSOV(subnetName, utils.SubnetEvmGenesisPoaPath, binaryToVersion[utils.SoloSubnetEVMKey1])
153159
commands.CreateSubnetEvmConfigWithVersionSOV(secondSubnetName, utils.SubnetEvmGenesisPoaPath, binaryToVersion[utils.SoloSubnetEVMKey2])

tests/e2e/testcases/upgrade/non-sov/suite.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var (
5151
// need to have this outside the normal suite because of the BeforeEach
5252
var _ = ginkgo.Describe("[Upgrade expect network failure non SOV]", ginkgo.Ordered, func() {
5353
ginkgo.AfterEach(func() {
54-
commands.CleanNetworkHard()
54+
commands.CleanNetwork()
5555
err := utils.DeleteConfigs(subnetName)
5656
gomega.Expect(err).Should(gomega.BeNil())
5757
})
@@ -91,7 +91,7 @@ var _ = ginkgo.Describe("[Upgrade expect network failure non SOV]", ginkgo.Order
9191
// and then check the file is there and has the correct content.
9292
var _ = ginkgo.Describe("[Upgrade public network non SOV]", ginkgo.Ordered, func() {
9393
ginkgo.AfterEach(func() {
94-
commands.CleanNetworkHard()
94+
commands.CleanNetwork()
9595
err := utils.DeleteConfigs(subnetName)
9696
gomega.Expect(err).Should(gomega.BeNil())
9797
})
@@ -158,7 +158,7 @@ var _ = ginkgo.Describe("[Upgrade local network non SOV]", ginkgo.Ordered, func(
158158
})
159159

160160
ginkgo.AfterEach(func() {
161-
commands.CleanNetworkHard()
161+
commands.CleanNetwork()
162162
err := utils.DeleteConfigs(subnetName)
163163
gomega.Expect(err).Should(gomega.BeNil())
164164
err = utils.DeleteConfigs(secondSubnetName)

tests/e2e/testcases/upgrade/sov/suite.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var (
5151
// need to have this outside the normal suite because of the BeforeEach
5252
var _ = ginkgo.Describe("[Upgrade expect network failure SOV]", ginkgo.Ordered, func() {
5353
ginkgo.AfterEach(func() {
54-
commands.CleanNetworkHard()
54+
commands.CleanNetwork()
5555
err := utils.DeleteConfigs(subnetName)
5656
gomega.Expect(err).Should(gomega.BeNil())
5757
})
@@ -91,7 +91,7 @@ var _ = ginkgo.Describe("[Upgrade expect network failure SOV]", ginkgo.Ordered,
9191
// and then check the file is there and has the correct content.
9292
var _ = ginkgo.Describe("[Upgrade public network SOV]", ginkgo.Ordered, func() {
9393
ginkgo.AfterEach(func() {
94-
commands.CleanNetworkHard()
94+
commands.CleanNetwork()
9595
err := utils.DeleteConfigs(subnetName)
9696
gomega.Expect(err).Should(gomega.BeNil())
9797
})
@@ -158,7 +158,7 @@ var _ = ginkgo.Describe("[Upgrade local network SOV]", ginkgo.Ordered, func() {
158158
})
159159

160160
ginkgo.AfterEach(func() {
161-
commands.CleanNetworkHard()
161+
commands.CleanNetwork()
162162
err := utils.DeleteConfigs(subnetName)
163163
gomega.Expect(err).Should(gomega.BeNil())
164164
err = utils.DeleteConfigs(secondSubnetName)

0 commit comments

Comments
 (0)