ci: Workaround for ip netns bug in container.

Due to `ip netns` issue in https://github.com/containers/podman/issues/11887 ,
`ip netns exec` will fail in podman container.

To workaround it, mount another sysfs to random folder workaround this
problem.

Signed-off-by: Gris Ge <fge@redhat.com>
This commit is contained in:
Gris Ge 2022-08-15 22:08:39 +08:00 committed by Fernando Fernández Mancera
parent a14bdcca61
commit a2303e2ce4

View File

@ -20,6 +20,7 @@
import logging
import os
import subprocess
import tempfile
import warnings
import pytest
@ -70,6 +71,20 @@ def _mark_tier2_tests(items):
item.add_marker(pytest.mark.tier2)
@pytest.fixture(scope="session", autouse=True)
def fix_ip_netns_issue(scope="session", autouse=True):
if os.getenv("CI"):
with tempfile.TemporaryDirectory() as tmpdirname:
subprocess.run(
f"mount -t sysfs --make-private {tmpdirname}".split(),
check=True,
)
yield
subprocess.run(f"umount {tmpdirname}".split())
else:
yield
@pytest.fixture(scope="session", autouse=True)
def test_env_setup():
_logging_setup()