Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: fix more tests that are failing when running on different VMs #637

Draft
wants to merge 4 commits into
base: openSUSE/release/3006.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/pytests/functional/cache/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

docker = pytest.importorskip("docker")

pytest.importorskip("MySQLdb")

log = logging.getLogger(__name__)

INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"
Expand Down
1 change: 1 addition & 0 deletions tests/pytests/functional/modules/test_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)
@pytest.mark.requires_network
@pytest.mark.slow_test
@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_list_available_packages(modules, pip_version, tmp_path):
with VirtualEnv(venv_dir=tmp_path, pip_requirement=pip_version) as virtualenv:
virtualenv.install("-U", pip_version)
Expand Down
4 changes: 3 additions & 1 deletion tests/pytests/functional/modules/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ def setup_teardown_vars(file, service, system):
_machine_info = False

try:
_systemd_timesyncd_available_ = service.available("systemd-timesyncd")
_systemd_timesyncd_available_ = service.available(
"systemd-timesyncd"
) and not service.masked("systemd-timesyncd")
if _systemd_timesyncd_available_:
res = service.stop("systemd-timesyncd")
assert res
Expand Down
11 changes: 11 additions & 0 deletions tests/pytests/functional/states/test_pip_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def test_pip_installed_removed(modules, states):


@pytest.mark.slow_test
@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_pip_installed_removed_venv(tmp_path, create_virtualenv, states):
venv_dir = tmp_path / "pip_installed_removed"
create_virtualenv(str(venv_dir))
Expand All @@ -105,6 +106,7 @@ def test_pip_installed_removed_venv(tmp_path, create_virtualenv, states):


@pytest.mark.slow_test
@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_pip_installed_errors(tmp_path, modules, state_tree):
venv_dir = tmp_path / "pip-installed-errors"
# Since we don't have the virtualenv created, pip.installed will
Expand Down Expand Up @@ -141,6 +143,7 @@ def test_pip_installed_errors(tmp_path, modules, state_tree):
assert state_return.result is True


@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_pip_installed_name_test_mode(tmp_path, create_virtualenv, states):
"""
Test pip.installed state while test=true
Expand All @@ -154,6 +157,7 @@ def test_pip_installed_name_test_mode(tmp_path, create_virtualenv, states):
assert name in ret.comment


@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_pip_installed_pkgs_test_mode(tmp_path, create_virtualenv, states):
"""
Test pip.installed state while test=true
Expand All @@ -168,6 +172,7 @@ def test_pip_installed_pkgs_test_mode(tmp_path, create_virtualenv, states):


@pytest.mark.slow_test
@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_issue_2028_pip_installed_state(
tmp_path, modules, state_tree, get_python_executable
):
Expand Down Expand Up @@ -226,6 +231,7 @@ def test_issue_2028_pip_installed_state(


@pytest.mark.slow_test
@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_issue_2087_missing_pip(tmp_path, create_virtualenv, modules):
venv_dir = tmp_path / "issue-2087-missing-pip"

Expand Down Expand Up @@ -271,6 +277,7 @@ def test_issue_2087_missing_pip(tmp_path, create_virtualenv, modules):
@pytest.mark.destructive_test
@pytest.mark.slow_test
@pytest.mark.skip_if_not_root
@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_issue_6912_wrong_owner(tmp_path, create_virtualenv, modules, states):
# Setup virtual environment directory to be used throughout the test
venv_dir = tmp_path / "6912-wrong-owner"
Expand Down Expand Up @@ -338,6 +345,7 @@ def test_issue_6912_wrong_owner(tmp_path, create_virtualenv, modules, states):
@pytest.mark.skip_on_darwin(reason="Test is flaky on macosx")
@pytest.mark.slow_test
@pytest.mark.skip_if_not_root
@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_issue_6912_wrong_owner_requirements_file(
tmp_path, create_virtualenv, state_tree, modules, states
):
Expand Down Expand Up @@ -409,6 +417,7 @@ def test_issue_6912_wrong_owner_requirements_file(

@pytest.mark.destructive_test
@pytest.mark.slow_test
@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_issue_6833_pip_upgrade_pip(tmp_path, create_virtualenv, modules, states):
# Create the testing virtualenv
if sys.platform == "win32":
Expand Down Expand Up @@ -465,6 +474,7 @@ def test_issue_6833_pip_upgrade_pip(tmp_path, create_virtualenv, modules, states


@pytest.mark.slow_test
@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_pip_installed_specific_env(
tmp_path, state_tree_prod, states, create_virtualenv
):
Expand Down Expand Up @@ -514,6 +524,7 @@ def test_pip_installed_specific_env(


@pytest.mark.slow_test
@pytest.mark.skip_if_binaries_missing("virtualenv", reason="Needs virtualenv binary")
def test_22359_pip_installed_unless_does_not_trigger_warnings(
create_virtualenv, tmp_path, states
):
Expand Down
2 changes: 1 addition & 1 deletion tests/pytests/functional/states/test_x509_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
pkcs12,
)

import salt.utils.x509 as x509util
x509util = pytest.importorskip("salt.utils.x509")

HAS_LIBS = True
except ImportError:
Expand Down
6 changes: 6 additions & 0 deletions tests/pytests/integration/cli/test_syndic_eauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@

import pytest

from salt.utils.versions import Version

docker = pytest.importorskip("docker")

INSIDE_CONTAINER = os.getenv("HOSTNAME", "") == "salt-test-container"

pytestmark = [
pytest.mark.core_test,
pytest.mark.skipif(INSIDE_CONTAINER, reason="Cannot run in a container"),
pytest.mark.skipif(
Version(docker.__version__) < Version("4.0.0"),
reason="Test does not work in this version of docker-py",
),
]


Expand Down