Skip to content

Commit

Permalink
Remove 4.0 support from launcher/updater
Browse files Browse the repository at this point in the history
  • Loading branch information
eaon committed Jun 23, 2022
1 parent e2c673c commit 266cbe4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
14 changes: 8 additions & 6 deletions launcher/sdw_updater_gui/Updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
# logic to leverage the Qubes Python API.
MIGRATION_DIR = "/tmp/sdw-migrations" # nosec

DEBIAN_VERSION = "bullseye"

sdlog = Util.get_logger(module=__name__)
detail_log = Util.get_logger(prefix=DETAIL_LOGGER_PREFIX, module=__name__)

Expand All @@ -39,13 +41,13 @@
# In the future, we could use qvm-prefs to extract this information.
current_vms = {
"fedora": "fedora-35",
"sd-viewer": "sd-large-buster-template",
"sd-app": "sd-small-buster-template",
"sd-log": "sd-small-buster-template",
"sd-devices": "sd-large-buster-template",
"sd-proxy": "sd-small-buster-template",
"sd-viewer": "sd-large-{}-template".format(DEBIAN_VERSION),
"sd-app": "sd-small-{}-template".format(DEBIAN_VERSION),
"sd-log": "sd-small-{}-template".format(DEBIAN_VERSION),
"sd-devices": "sd-large-{}-template".format(DEBIAN_VERSION),
"sd-proxy": "sd-small-{}-template".format(DEBIAN_VERSION),
"sd-whonix": "whonix-gw-16",
"sd-gpg": "sd-small-buster-template",
"sd-gpg": "sd-small-{}-template".format(DEBIAN_VERSION),
}

current_templates = set([val for key, val in current_vms.items() if key != "dom0"])
Expand Down
7 changes: 0 additions & 7 deletions launcher/tests/fixtures/os-release-qubes-4.0

This file was deleted.

10 changes: 6 additions & 4 deletions launcher/tests/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"sd-devices",
]

DEBIAN_VERSION = "bullseye"

TEST_RESULTS_OK = {
"dom0": UpdateStatus.UPDATES_OK,
"fedora": UpdateStatus.UPDATES_OK,
Expand Down Expand Up @@ -491,8 +493,8 @@ def test_shutdown_and_start_vms(
]
template_vm_calls = [
call("fedora-35"),
call("sd-large-buster-template"),
call("sd-small-buster-template"),
call("sd-large-{}-template".format(DEBIAN_VERSION)),
call("sd-small-{}-template".format(DEBIAN_VERSION)),
call("whonix-gw-16"),
]
app_vm_calls = [
Expand Down Expand Up @@ -537,8 +539,8 @@ def test_shutdown_and_start_vms_sysvm_fail(
]
template_vm_calls = [
call("fedora-35"),
call("sd-large-buster-template"),
call("sd-small-buster-template"),
call("sd-large-{}-template".format(DEBIAN_VERSION)),
call("sd-small-{}-template".format(DEBIAN_VERSION)),
call("whonix-gw-16"),
]
error_calls = [
Expand Down
23 changes: 10 additions & 13 deletions launcher/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
path_to_util = os.path.join(os.path.dirname(os.path.abspath(__file__)), relpath_util)
util = SourceFileLoader("Util", path_to_util).load_module()

DEBIAN_VERSION = "bullseye"


@mock.patch("Util.sdlog.error")
@mock.patch("Util.sdlog.warning")
Expand Down Expand Up @@ -200,7 +202,6 @@ def test_for_conflicting_process(
@pytest.mark.parametrize(
"os_release_fixture,version_contains",
[
("os-release-qubes-4.0", "4.0"),
("os-release-qubes-4.1", "4.1"),
("os-release-ubuntu", None),
("no-such-file", None),
Expand All @@ -209,7 +210,7 @@ def test_for_conflicting_process(
@mock.patch("Util.sdlog.error")
@mock.patch("Util.sdlog.warning")
@mock.patch("Util.sdlog.info")
@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0"))
@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1"))
def test_detect_qubes(
mocked_info, mocked_warning, mocked_error, os_release_fixture, version_contains
):
Expand All @@ -232,7 +233,6 @@ def test_detect_qubes(
@pytest.mark.parametrize(
"os_release_fixture,expected_qt_version",
[
("os-release-qubes-4.0", 4),
("os-release-qubes-4.1", 5),
("os-release-ubuntu", 4),
("no-such-file", 4),
Expand All @@ -242,7 +242,7 @@ def test_detect_qubes(
@mock.patch("Util.sdlog.error")
@mock.patch("Util.sdlog.warning")
@mock.patch("Util.sdlog.info")
@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0"))
@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1"))
def test_pick_qt(
mocked_info,
mocked_warning,
Expand Down Expand Up @@ -282,7 +282,7 @@ def test_pick_bad_qt(mocked_info, mocked_warning, mocked_error, env_override):
"""
mocked_env = {"SDW_UPDATER_QT": env_override}
with mock.patch.dict("os.environ", mocked_env), mock.patch(
"Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0")
"Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1")
), pytest.raises(ValueError):
util.get_qt_version()

Expand All @@ -303,21 +303,20 @@ def test_get_logger():
@pytest.mark.parametrize(
"os_release_fixture,version_contains",
[
("os-release-qubes-4.0", "4.0"),
("os-release-qubes-4.1", "4.1"),
("os-release-ubuntu", None),
("no-such-file", None),
],
)
@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0"))
@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1"))
def test_is_sdapp_halted_yes(os_release_fixture, version_contains):
"""
When sd-app state is 'Halted'
Then `Util.is_sdapp_halted()` should return True
"""
output = bytes(
"NAME STATE CLASS LABEL TEMPLATE\nsd-app"
" Halted AppVM yellow sd-small-buster-template\n",
" Halted AppVM yellow sd-small-{}-template\n".format(DEBIAN_VERSION),
"utf-8",
)

Expand All @@ -329,21 +328,20 @@ def test_is_sdapp_halted_yes(os_release_fixture, version_contains):
@pytest.mark.parametrize(
"os_release_fixture,version_contains",
[
("os-release-qubes-4.0", "4.0"),
("os-release-qubes-4.1", "4.1"),
("os-release-ubuntu", None),
("no-such-file", None),
],
)
@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0"))
@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1"))
def test_is_sdapp_halted_no(os_release_fixture, version_contains):
"""
When sd-app is not Halted (i.e. Running, Pasued)
Then Util.is_sd_app_halted() should return False
"""
output = bytes(
"NAME STATE CLASS LABEL TEMPLATE\nsd-app"
" Paused AppVM yellow sd-small-buster-template\n",
" Paused AppVM yellow sd-small-{}-template\n".format(DEBIAN_VERSION),
"utf-8",
)

Expand All @@ -355,13 +353,12 @@ def test_is_sdapp_halted_no(os_release_fixture, version_contains):
@pytest.mark.parametrize(
"os_release_fixture,version_contains",
[
("os-release-qubes-4.0", "4.0"),
("os-release-qubes-4.1", "4.1"),
("os-release-ubuntu", None),
("no-such-file", None),
],
)
@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0"))
@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1"))
@mock.patch("subprocess.check_output", side_effect=subprocess.CalledProcessError(1, "check_output"))
def test_is_sdapp_halted_error(patched_subprocess, os_release_fixture, version_contains):
"""
Expand Down

0 comments on commit 266cbe4

Please sign in to comment.