Skip to content

Commit

Permalink
Fix: Repair "uninstall_all"
Browse files Browse the repository at this point in the history
Refs: #2209
- The "uninstall_all" was broken during development of #2120,
to fix the issue a failure when there is no CNF to uninstall
has been relegated to a warning and exit 1 was removed.
- Two spec tests have been added to avoid this scenario
in the future.
- Additionally some renaming was left-over from #2184 that
was resolved.

Signed-off-by: svteb <[email protected]>
  • Loading branch information
svteb committed Jan 17, 2025
1 parent 0140acb commit d7d704a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
3 changes: 2 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ Run the following to uninstall the CNF (this is assuming you installed the cnf-t
```
cnf-testsuite cnf_uninstall
```
You can also run `cleanup` and cnf-testsuite will attempt to cleanup everything.

To also uninstall helper tools deployed by testsuite run `uninstall_all`.

_NOTE: CNF uninstallation does not handle manually deployed CNFs_
2 changes: 1 addition & 1 deletion SOURCE_INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Run the following to uninstall the CNF:
./cnf-testsuite cnf_uninstall
```

You can also run `cleanup` and cnf-testsuite will attempt to cleanup everything.
To also uninstall helper tools deployed by testsuite run `uninstall_all`.

_NOTE: CNF uninstallation does not handle manually deployed CNFs_

Expand Down
2 changes: 1 addition & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ cnf-config=<path_to_your_config_file>/cnf-testsuite.yml
#### Clean up the CNTI Test Catalog, the K8s cluster, and upstream projects:

```
./cnf-testsuite cleanup
./cnf-testsuite uninstall_all
```

---
Expand Down
26 changes: 22 additions & 4 deletions spec/setup_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ describe "Installation" do
(/Dependency installation complete/ =~ result[:output]).should_not be_nil
end

it "'uninstall_all' should uninstall CNF and testsuite dependencies", tags: ["cnf_installation"] do
begin
result = ShellCmd.cnf_install("cnf-config=./sample-cnfs/sample-minimal-cnf/")
(/CNF installation complete/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.run_testsuite("uninstall_all")
(/All CNF deployments were uninstalled/ =~ result[:output]).should_not be_nil
(/Testsuite helper tools uninstalled./ =~ result[:output]).should_not be_nil
end
end

it "'cnf_install' should pass with a minimal cnf-testsuite.yml", tags:["cnf_installation"] do
result = ShellCmd.cnf_install("cnf-path=./sample-cnfs/sample-minimal-cnf/")
(/CNF installation complete/ =~ result[:output]).should_not be_nil
Expand Down Expand Up @@ -48,7 +59,7 @@ describe "Installation" do
result = ShellCmd.cnf_install("cnf-path=spec/fixtures/sample-bad-config.yml", expect_failure: true)
(/Error during parsing CNF config/ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.cnf_uninstall(expect_failure: true)
result = ShellCmd.cnf_uninstall()
end
end

Expand Down Expand Up @@ -98,7 +109,7 @@ describe "Installation" do
result = ShellCmd.cnf_install("cnf-path=sample-cnfs/sample_coredns/cnf-testsuite.yml")
(/CNF installation complete/ =~ result[:output]).should_not be_nil
result = ShellCmd.cnf_install("cnf-path=sample-cnfs/sample-minimal-cnf/cnf-testsuite.yml")
(/A CNF is already set up. Setting up multiple CNFs is not allowed./ =~ result[:output]).should_not be_nil
(/A CNF is already installed. Installation of multiple CNFs is not allowed./ =~ result[:output]).should_not be_nil
ensure
result = ShellCmd.cnf_uninstall()
(/All CNF deployments were uninstalled/ =~ result[:output]).should_not be_nil
Expand Down Expand Up @@ -151,7 +162,7 @@ describe "Installation" do
result = ShellCmd.cnf_install("cnf-path=spec/fixtures/sample-conflicting-deployments.yml", expect_failure: true)
(/Deployment names should be unique/ =~ result[:output]).should_not be_nil
ensure
ShellCmd.cnf_uninstall(expect_failure: true)
ShellCmd.cnf_uninstall()
end
end

Expand Down Expand Up @@ -206,5 +217,12 @@ describe "Installation" do
pair[1].should be > pair[0]
end
end
end
end

it "'cnf_uninstall' should warn user if no CNF is found", tags: ["cnf_installation"] do
begin
result = ShellCmd.cnf_uninstall()
(/CNF uninstallation skipped/ =~ result[:output]).should_not be_nil
end
end
end
11 changes: 9 additions & 2 deletions src/tasks/cleanup.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ desc "Alias for cnf_uninstall"
task "uninstall", ["cnf_uninstall"] do |_, args|
end

# Private task
task "_tools_uninstall_start" do
stdout_success "Uninstalling testsuite helper tools."
end

desc "Cleans up the CNF Test Suite helper tools and containers"
task "tools_uninstall", [
"_tools_uninstall_start",
"uninstall_sonobuoy",
"uninstall_chaosmesh",
"uninstall_litmus",
Expand All @@ -20,11 +26,12 @@ task "tools_uninstall", [
# Helm needs to be uninstalled last to allow other uninstalls to use helm if necessary.
# Check this issue for details - https://github.com/cncf/cnf-testsuite/issues/1586
"uninstall_local_helm"
] do |_, args|
] do |_, args|
stdout_success "Testsuite helper tools uninstalled."
end

desc "Cleans up the CNF Test Suite sample projects, helper tools, and containers"
task "uninstall_all", ["cnf_uninstall", "tools_uninstall"] do |_, args|
task "uninstall_all", ["cnf_uninstall", "tools_uninstall"] do |_, args|
end

task "delete_results" do |_, args|
Expand Down
4 changes: 2 additions & 2 deletions src/tasks/utils/cnf_installation/install_common.cr
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ module CNFInstall
def self.uninstall_cnf()
cnf_config_path = File.join(CNF_DIR, CONFIG_FILE)
if !File.exists?(cnf_config_path)
stdout_failure "No CNF config found in #{CNF_DIR} directory. Nothing to uninstall"
exit 1
stdout_warning "CNF uninstallation skipped. No CNF config found in #{CNF_DIR} directory. "
return
end
config = Config.parse_cnf_config_from_file(cnf_config_path)

Expand Down

0 comments on commit d7d704a

Please sign in to comment.