Skip to content

Commit

Permalink
Some more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MKLeb committed Jul 31, 2023
1 parent e519ae4 commit ba4b645
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 39 deletions.
2 changes: 0 additions & 2 deletions pkg/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ def salt_master(salt_factories, install_salt, state_tree, pillar_tree):
if platform.is_windows():
if install_salt.classic:
master_script = True
# this check will need to be changed to install_salt.relenv
# once the package version returns 3006 and not 3005 on master
if install_salt.relenv:
master_script = True
elif not install_salt.upgrade:
Expand Down
41 changes: 6 additions & 35 deletions pkg/tests/support/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
import pprint
import re
import shutil
import tarfile
import textwrap
import time
from typing import TYPE_CHECKING, Any, Dict, List
from zipfile import ZipFile
from typing import TYPE_CHECKING, Dict, List

import attr
import distro
Expand All @@ -30,26 +28,13 @@
from saltfactories.daemons import api, master, minion
from saltfactories.utils import cli_scripts

try:
import crypt

HAS_CRYPT = True
except ImportError:
HAS_CRYPT = False
try:
import pwd

HAS_PWD = True
except ImportError:
HAS_PWD = False

try:
import winreg

HAS_WINREG = True
except ImportError:
HAS_WINREG = False

TESTS_DIR = pathlib.Path(__file__).resolve().parent.parent
CODE_DIR = TESTS_DIR.parent
ARTIFACTS_DIR = CODE_DIR / "artifacts"
Expand Down Expand Up @@ -182,23 +167,6 @@ def update_process_path(self):
# make it to this python session, so we need to update that
os.environ["PATH"] = ";".join([str(self.install_dir), os.getenv("path")])

# When the MSI installer is run from self.proc.run, it doesn't update
# the registry. When run from a normal command prompt it does. Until we
# figure that out, we will update the process path as above. This
# doesn't really check that the path is being set though... but I see
# no other way around this
# if HAS_WINREG:
# log.debug("Refreshing the path")
# # Get the updated system path from the registry
# path_key = winreg.OpenKeyEx(
# winreg.HKEY_LOCAL_MACHINE,
# r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment",
# )
# current_path = winreg.QueryValueEx(path_key, "path")[0]
# path_key.Close()
# # Update the path for the current running process
# os.environ["PATH"] = current_path

def get_version(self, version_only=False):
"""
Return the version information needed to install a previous version of Salt.
Expand All @@ -219,6 +187,8 @@ def get_version(self, version_only=False):
else:
# This is an upgrade, start on the previous version
major, minor = self.prev_version.split(".", 1)
if version_only:
return version
return major, minor

def __attrs_post_init__(self):
Expand Down Expand Up @@ -387,10 +357,10 @@ def _install_pkgs(self, upgrade=False):

def package_python_version(self):
return self.proc.run(
self.binary_paths["python"],
str(self.binary_paths["python"][0]),
"-c",
"import sys; print('{}.{}'.format(*sys.version_info))",
).stdout
).stdout.strip()

def install(self, upgrade=False):
self._install_pkgs(upgrade=upgrade)
Expand Down Expand Up @@ -429,6 +399,7 @@ def install_previous(self):
root_url = "py3/"

if self.distro_name in ["redhat", "centos", "amazon", "fedora", "vmware"]:
# Removing EPEL repo files
for fp in pathlib.Path("/etc", "yum.repos.d").glob("epel*"):
fp.unlink()
gpg_key = "SALTSTACK-GPG-KEY.pub"
Expand Down
4 changes: 2 additions & 2 deletions pkg/tests/upgrade/test_salt_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def test_salt_upgrade(salt_call_cli, install_salt):
assert "Authentication information could" in use_lib.stderr

# Upgrade Salt from previous version and test
new_py_version = install_salt.package_python_version()
install_salt.install(upgrade=True)
new_py_version = install_salt.package_python_version()
ret = salt_call_cli.run("test.ping")
assert ret.returncode == 0
assert ret.data

# Install dep following upgrade
# TODO: This should be removed when we stop testing against versions < 3006.0
if not install_salt.relenv and original_py_version == new_py_version:
if not install_salt.relenv or original_py_version != new_py_version:
install = salt_call_cli.run("--local", "pip.install", dep)
assert install.returncode == 0

Expand Down

0 comments on commit ba4b645

Please sign in to comment.