Skip to content

Commit

Permalink
Merge pull request #2124 from reubenmiller/refactor-uninstall-script
Browse files Browse the repository at this point in the history
refactor(uninstall): explicitly remove all packages to avoid problems when dependencies are changed
  • Loading branch information
reubenmiller authored Aug 4, 2023
2 parents 88f620f + de1402e commit 61a4bc2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
31 changes: 24 additions & 7 deletions tests/RobotFramework/tests/installation/install_tedge.robot
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ Install latest via script (from current branch)
Execute Command chmod a+x /setup/get-thin-edge_io.sh && sudo /setup/get-thin-edge_io.sh
Tedge Version Should Match Regex ^\\d+\\.\\d+\\.\\d+$

# Uninstall
Uninstall tedge using local Script
Tedge Should Not Be Installed

Install specific version via script (from current branch)
Transfer To Device ${CURDIR}/../../../../get-thin-edge_io.sh /setup/
Execute Command chmod a+x /setup/get-thin-edge_io.sh && sudo /setup/get-thin-edge_io.sh 0.8.1
Tedge Version Should Be Equal 0.8.1

# Uninstall
Uninstall tedge using local Script
Tedge Should Not Be Installed

Install latest tedge via script (from main branch)
Execute Command curl -fsSL https://raw.githubusercontent.com/thin-edge/thin-edge.io/main/get-thin-edge_io.sh | sudo sh -s
Tedge Version Should Match Regex ^\\d+\\.\\d+\\.\\d+$
Expand All @@ -25,6 +33,7 @@ Install then uninstall latest tedge via script (from main branch)
# Install (just install everything, don't set anything up)
Execute Command ./bootstrap.sh --install --no-bootstrap --no-connect
Execute Command dpkg -s tedge
Execute Command dpkg -s tedge-watchdog
Execute Command dpkg -s tedge-mapper
Execute Command dpkg -s tedge-agent
Execute Command dpkg -s c8y-log-plugin
Expand All @@ -34,13 +43,7 @@ Install then uninstall latest tedge via script (from main branch)

# Uninstall
Execute Command curl -sSL https://raw.githubusercontent.com/thin-edge/thin-edge.io/main/uninstall-thin-edge_io.sh | sudo sh -s purge
Execute Command dpkg -s tedge exp_exit_code=!0
Execute Command dpkg -s tedge-mapper exp_exit_code=!0
Execute Command dpkg -s tedge-agent exp_exit_code=!0
Execute Command dpkg -s c8y-log-plugin exp_exit_code=!0
Execute Command dpkg -s c8y-configuration-plugin exp_exit_code=!0
Execute Command dpkg -s c8y-firmware-plugin exp_exit_code=!0
Execute Command dpkg -s c8y-remote-access-plugin exp_exit_code=!0
Tedge Should Not Be Installed

*** Keywords ***

Expand All @@ -56,3 +59,17 @@ Tedge Version Should Be Equal
[Arguments] ${expected}
${VERSION}= Execute Command tedge --version | cut -d' ' -f 2 strip=True
Should Be Equal ${VERSION} ${expected}

Uninstall tedge using local Script
Transfer To Device ${CURDIR}/../../../../uninstall-thin-edge_io.sh /setup/
Execute Command chmod a+x /setup/uninstall-thin-edge_io.sh && sudo /setup/uninstall-thin-edge_io.sh purge

Tedge Should Not Be Installed
Execute Command dpkg -s tedge exp_exit_code=!0
Execute Command dpkg -s tedge-watchdog exp_exit_code=!0
Execute Command dpkg -s tedge-mapper exp_exit_code=!0
Execute Command dpkg -s tedge-agent exp_exit_code=!0
Execute Command dpkg -s c8y-log-plugin exp_exit_code=!0
Execute Command dpkg -s c8y-configuration-plugin exp_exit_code=!0
Execute Command dpkg -s c8y-firmware-plugin exp_exit_code=!0
Execute Command dpkg -s c8y-remote-access-plugin exp_exit_code=!0
6 changes: 2 additions & 4 deletions uninstall-thin-edge_io.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

set -e

# Here don't need to remove/purge the tedge_mapper, tedge_agent, and tedge_watchdog packages explicitly,
# as they will be removed by removing the tedge package.
# Package names for version <= 0.8.1
packages="tedge tedge_apt_plugin tedge_apama_plugin c8y_log_plugin c8y_configuration_plugin"
packages="tedge tedge_apt_plugin tedge_apama_plugin c8y_log_plugin c8y_configuration_plugin tedge_mapper tedge_agent tedge_watchdog"

# Package names for version > 0.8.1
packages="$packages tedge-apt-plugin tedge-apama-plugin c8y-log-plugin c8y-configuration-plugin c8y-remote-access-plugin c8y-firmware-plugin"
packages="$packages tedge-apt-plugin tedge-apama-plugin c8y-log-plugin c8y-configuration-plugin c8y-remote-access-plugin c8y-firmware-plugin tedge-watchdog tedge-agent tedge-mapper"

extension_services="tedge-watchdog.service tedge-mapper-collectd.service c8y-log-plugin.service c8y-configuration-plugin.service c8y-firmware-plugin.service"

Expand Down

0 comments on commit 61a4bc2

Please sign in to comment.