Skip to content

Commit e751d31

Browse files
committed
WIP - fix deb tests
1 parent 7403ff5 commit e751d31

File tree

4 files changed

+43
-28
lines changed

4 files changed

+43
-28
lines changed

noxfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,7 @@ def ci_test_onedir_pkgs(session):
19481948
+ cmd_args[:]
19491949
+ [
19501950
"--no-install",
1951+
"--no-uninstall",
19511952
"--junitxml=artifacts/xml-unittests-output/test-results-install.xml",
19521953
"--log-file=artifacts/logs/runtests-install.log",
19531954
]

tests/pytests/pkg/integration/test_version.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ def test_compare_versions(binary, install_salt):
104104
"""
105105
Test compare versions
106106
"""
107-
version = install_salt.artifact_version
107+
if install_salt.use_prev_version:
108+
version = install_salt.prev_version
109+
else:
110+
version = install_salt.artifact_version
108111
if binary in install_salt.binary_paths:
109112
if install_salt.upgrade:
110113
install_salt.install()

tests/pytests/pkg/upgrade/test_salt_upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def salt_test_upgrade(
9595
new_minion_pids = _get_running_named_salt_pid(process_minion_name)
9696
new_master_pids = _get_running_named_salt_pid(process_master_name)
9797

98-
if sys.platform == "linux":
98+
if sys.platform == "linux" and install_salt.distro_id not in ("ubuntu", "debian"):
9999
assert new_minion_pids
100100
assert new_master_pids
101101
assert new_minion_pids != old_minion_pids

tests/support/pkg.py

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def install_previous(self, downgrade=False):
712712
arch = "amd64"
713713

714714
pathlib.Path("/etc/apt/keyrings").mkdir(parents=True, exist_ok=True)
715-
gpg_full_path = "/etc/apt/keyrings/salt-archive-keyring.gpg"
715+
gpg_full_path = "/etc/apt/keyrings/salt-archive-keyring.pgp"
716716

717717
# download the gpg pub key
718718
download_file(
@@ -724,28 +724,37 @@ def install_previous(self, downgrade=False):
724724
) as fp:
725725
fp.write(
726726
f"deb [signed-by={gpg_full_path} arch={arch}] "
727-
f"{root_url}/saltproject-deb/ {self.distro_codename} main"
727+
f"{root_url}/saltproject-deb/ stable main"
728728
)
729729
self._check_retcode(ret)
730+
pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt-pin-1001")
731+
pref_file.parent.mkdir(exist_ok=True)
732+
pin = f"{self.prev_version.rsplit('.', 1)[0]}.*"
733+
if downgrade:
734+
pin = self.prev_version
735+
with salt.utils.files.fopen(pref_file, "w") as fp:
736+
fp.write(
737+
f"Package: salt-*\n" f"Pin: version {pin}\n" f"Pin-Priority: 1001"
738+
)
730739

731740
cmd = [self.pkg_mngr, "install", *self.salt_pkgs, "-y"]
732741

733-
if downgrade:
734-
pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt.pref")
735-
pref_file.parent.mkdir(exist_ok=True)
736-
# TODO: There's probably something I should put in here to say what version
737-
# TODO: But maybe that's done elsewhere, hopefully in self.salt_pkgs
738-
pref_file.write_text(
739-
textwrap.dedent(
740-
f"""\
741-
Package: salt*
742-
Pin: origin "{root_url}/saltproject-deb"
743-
Pin-Priority: 1001
744-
"""
745-
),
746-
encoding="utf-8",
747-
)
748-
cmd.append("--allow-downgrades")
742+
# if downgrade:
743+
# pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt-pin-1001")
744+
# pref_file.parent.mkdir(exist_ok=True)
745+
# # TODO: There's probably something I should put in here to say what version
746+
# # TODO: But maybe that's done elsewhere, hopefully in self.salt_pkgs
747+
# pref_file.write_text(
748+
# textwrap.dedent(
749+
# f"""\
750+
# Package: salt*
751+
# Pin: origin "{root_url}/saltproject-deb"
752+
# Pin-Priority: 1001
753+
# """
754+
# ),
755+
# encoding="utf-8",
756+
# )
757+
cmd.append("--allow-downgrades")
749758
env = os.environ.copy()
750759
env["DEBIAN_FRONTEND"] = "noninteractive"
751760
extra_args = [
@@ -757,18 +766,20 @@ def install_previous(self, downgrade=False):
757766
self.proc.run(self.pkg_mngr, "update", *extra_args, env=env)
758767

759768
cmd.extend(extra_args)
760-
769+
log.error("Run cmd %s", cmd)
761770
ret = self.proc.run(*cmd, env=env)
771+
log.error("cmd return %r", ret)
762772
# Pre-relenv packages down get downgraded to cleanly programmatically
763773
# They work manually, and the install tests after downgrades will catch problems with the install
774+
self._check_retcode(ret)
764775
# Let's not check the returncode if this is the case
765-
if not (
766-
downgrade
767-
and packaging.version.parse(self.prev_version)
768-
< packaging.version.parse("3006.0")
769-
):
770-
self._check_retcode(ret)
771-
if downgrade:
776+
# if not (
777+
# downgrade
778+
# and packaging.version.parse(self.prev_version)
779+
# < packaging.version.parse("3006.0")
780+
# ):
781+
# self._check_retcode(ret)
782+
if downgrade and not self.no_uninstall:
772783
pref_file.unlink()
773784
self.stop_services()
774785
elif platform.is_windows():

0 commit comments

Comments
 (0)