Revert the changes needed to support runtests.py

This commit is contained in:
Pedro Algarvio 2020-08-20 20:50:58 +01:00 committed by Daniel Wozniak
parent 4ade178052
commit 88a24c3dd0
10 changed files with 467 additions and 834 deletions

View file

@ -1,6 +1,7 @@
"""
Set up the Salt integration test suite
"""
import atexit
import copy
import errno
@ -182,15 +183,6 @@ class TestDaemon:
self.colors = salt.utils.color.get_colors(
self.parser.options.no_colors is False
)
self.clear_line = "\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
self.virt_minion_enabled = False
if salt.utils.path.which("docker"):
for test in self.parser.options.name:
if test.endswith("integration.modules.test_virt"):
self.virt_minion_enabled = True
break
if salt.utils.platform.is_windows():
# There's no shell color support on windows...
for key in self.colors:
@ -207,9 +199,6 @@ class TestDaemon:
self._enter_mockbin()
self.minion_targets = {"minion", "sub_minion"}
if self.virt_minion_enabled:
self.minion_targets.add("virt_minion_0")
self.minion_targets.add("virt_minion_1")
if self.parser.options.transport == "zeromq":
self.start_zeromq_daemons()
@ -266,84 +255,6 @@ class TestDaemon:
finally:
self.post_setup_minions()
def start_virt_minion(
self,
name,
config_dir,
libvirt_tcp_port,
libvirt_tls_port,
ssh_port,
sshd_port,
host_uuid,
):
"""
Start virt minion daemon
"""
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting {name} ... {ENDC}".format(
**self.colors, name=name,
)
)
sys.stdout.flush()
process = start_virt_daemon(
container_img="quay.io/rst0git/virt-minion",
container_name=name,
libvirt_tcp_port=libvirt_tcp_port,
libvirt_tls_port=libvirt_tls_port,
ssh_port=ssh_port,
sshd_port=sshd_port,
host_uuid=host_uuid,
daemon_config_dir=config_dir,
)
sys.stdout.write(self.clear_line)
sys.stdout.write(
" * {LIGHT_GREEN}Starting {name} ... STARTED!\n{ENDC}".format(
**self.colors, name=name,
)
)
sys.stdout.flush()
return process
except (RuntimeWarning, RuntimeError) as err:
sys.stdout.write(self.clear_line)
sys.stdout.write(
" * {LIGHT_RED}Starting {name} ... FAILED!\n{ENDC}".format(
**self.colors, name=name,
)
)
sys.stdout.flush()
raise TestDaemonStartFailed(str(err))
def start_salt_daemon(self, **kwargs):
"""
Start salt daemon
"""
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting {name} ... {ENDC}".format(
**self.colors, name=kwargs["daemon_name"],
)
)
sys.stdout.flush()
process = start_daemon(**kwargs)
sys.stdout.write(self.clear_line)
sys.stdout.write(
" * {LIGHT_GREEN}Starting {name} ... STARTED!\n{ENDC}".format(
**self.colors, name=kwargs["daemon_name"],
)
)
sys.stdout.flush()
return process
except (RuntimeWarning, RuntimeError) as err:
sys.stdout.write(self.clear_line)
sys.stdout.write(
" * {LIGHT_RED}Starting {name} ... FAILED!\n{ENDC}".format(
**self.colors, name=kwargs["daemon_name"],
)
)
sys.stdout.flush()
raise TestDaemonStartFailed(str(err))
def start_zeromq_daemons(self):
"""
Fire up the daemons used for zeromq tests
@ -353,112 +264,275 @@ class TestDaemon:
)
self.log_server_process = threading.Thread(target=self.log_server.serve_forever)
self.log_server_process.start()
self.master_process = self.start_salt_daemon(
daemon_name="salt-master",
daemon_id=self.master_opts["id"],
daemon_log_prefix="salt-master/{}".format(self.master_opts["id"]),
daemon_cli_script_name="master",
daemon_config=self.master_opts,
daemon_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
daemon_class=SaltMaster,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
event_listener_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
start_timeout=120,
)
self.minion_process = self.start_salt_daemon(
daemon_name="salt-minion",
daemon_id=self.master_opts["id"],
daemon_log_prefix="salt-minion/{}".format(self.minion_opts["id"]),
daemon_cli_script_name="minion",
daemon_config=self.minion_opts,
daemon_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
daemon_class=SaltMinion,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
event_listener_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
start_timeout=120,
)
if self.virt_minion_enabled:
self.virt_minion_0_process = self.start_virt_minion(
name="virt_minion_0",
libvirt_tcp_port=2203,
libvirt_tls_port=2204,
ssh_port=2202,
sshd_port=2201,
host_uuid="e1b1e6bb-20ef-4c99-8208-3067725e0e46",
config_dir=RUNTIME_VARS.TMP_VIRT_MINION_0_CONF_DIR,
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting salt-master ... {ENDC}".format(**self.colors)
)
self.virt_minion_1_process = self.start_virt_minion(
name="virt_minion_1",
libvirt_tcp_port=2205,
libvirt_tls_port=2206,
ssh_port=2201,
sshd_port=2202,
host_uuid="2b1de640-a3fd-81e3-3d89-40167e11160e",
config_dir=RUNTIME_VARS.TMP_VIRT_MINION_1_CONF_DIR,
sys.stdout.flush()
self.master_process = start_daemon(
daemon_name="salt-master",
daemon_id=self.master_opts["id"],
daemon_log_prefix="salt-master/{}".format(self.master_opts["id"]),
daemon_cli_script_name="master",
daemon_config=self.master_opts,
daemon_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
daemon_class=SaltMaster,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
event_listener_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
start_timeout=120,
)
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_GREEN}Starting salt-master ... STARTED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
except (RuntimeWarning, RuntimeError):
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_RED}Starting salt-master ... FAILED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
raise TestDaemonStartFailed()
self.sub_minion_process = self.start_salt_daemon(
daemon_name="sub salt-minion",
daemon_id=self.master_opts["id"],
daemon_log_prefix="sub-salt-minion/{}".format(self.sub_minion_opts["id"]),
daemon_cli_script_name="minion",
daemon_config=self.sub_minion_opts,
daemon_config_dir=RUNTIME_VARS.TMP_SUB_MINION_CONF_DIR,
daemon_class=SaltMinion,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
event_listener_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
start_timeout=120,
)
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting salt-minion ... {ENDC}".format(**self.colors)
)
sys.stdout.flush()
self.minion_process = start_daemon(
daemon_name="salt-minion",
daemon_id=self.master_opts["id"],
daemon_log_prefix="salt-minion/{}".format(self.minion_opts["id"]),
daemon_cli_script_name="minion",
daemon_config=self.minion_opts,
daemon_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
daemon_class=SaltMinion,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
event_listener_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
start_timeout=120,
)
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_GREEN}Starting salt-minion ... STARTED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
except (RuntimeWarning, RuntimeError):
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_RED}Starting salt-minion ... FAILED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
raise TestDaemonStartFailed()
self.prep_syndic()
self.smaster_process = self.start_salt_daemon(
daemon_name="salt-smaster",
daemon_id=self.syndic_master_opts["id"],
daemon_log_prefix="salt-smaster/{}".format(self.syndic_master_opts["id"]),
daemon_cli_script_name="master",
daemon_config=self.syndic_master_opts,
daemon_config_dir=RUNTIME_VARS.TMP_SYNDIC_MASTER_CONF_DIR,
daemon_class=SaltMaster,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
event_listener_config_dir=RUNTIME_VARS.TMP_SYNDIC_MASTER_CONF_DIR,
start_timeout=120,
)
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting sub salt-minion ... {ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
self.sub_minion_process = start_daemon(
daemon_name="sub salt-minion",
daemon_id=self.master_opts["id"],
daemon_log_prefix="sub-salt-minion/{}".format(
self.sub_minion_opts["id"]
),
daemon_cli_script_name="minion",
daemon_config=self.sub_minion_opts,
daemon_config_dir=RUNTIME_VARS.TMP_SUB_MINION_CONF_DIR,
daemon_class=SaltMinion,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
event_listener_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
start_timeout=120,
)
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_GREEN}Starting sub salt-minion ... STARTED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
except (RuntimeWarning, RuntimeError):
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_RED}Starting sub salt-minion ... FAILED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
raise TestDaemonStartFailed()
self.syndic_process = self.start_salt_daemon(
daemon_name="salt-syndic",
daemon_id=self.syndic_opts["id"],
daemon_log_prefix="salt-syndic/{}".format(self.syndic_opts["id"]),
daemon_cli_script_name="syndic",
daemon_config=self.syndic_opts,
daemon_config_dir=RUNTIME_VARS.TMP_SYNDIC_MINION_CONF_DIR,
daemon_class=SaltSyndic,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
event_listener_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
start_timeout=120,
)
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting syndic salt-master ... {ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
self.prep_syndic()
self.smaster_process = start_daemon(
daemon_name="salt-smaster",
daemon_id=self.syndic_master_opts["id"],
daemon_log_prefix="salt-smaster/{}".format(
self.syndic_master_opts["id"]
),
daemon_cli_script_name="master",
daemon_config=self.syndic_master_opts,
daemon_config_dir=RUNTIME_VARS.TMP_SYNDIC_MASTER_CONF_DIR,
daemon_class=SaltMaster,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
event_listener_config_dir=RUNTIME_VARS.TMP_SYNDIC_MASTER_CONF_DIR,
start_timeout=120,
)
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_GREEN}Starting syndic salt-master ... STARTED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
except (RuntimeWarning, RuntimeError):
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_RED}Starting syndic salt-master ... FAILED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
raise TestDaemonStartFailed()
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting salt-syndic ... {ENDC}".format(**self.colors)
)
sys.stdout.flush()
self.syndic_process = start_daemon(
daemon_name="salt-syndic",
daemon_id=self.syndic_opts["id"],
daemon_log_prefix="salt-syndic/{}".format(self.syndic_opts["id"]),
daemon_cli_script_name="syndic",
daemon_config=self.syndic_opts,
daemon_config_dir=RUNTIME_VARS.TMP_SYNDIC_MINION_CONF_DIR,
daemon_class=SaltSyndic,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
event_listener_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
start_timeout=120,
)
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_GREEN}Starting salt-syndic ... STARTED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
except (RuntimeWarning, RuntimeError):
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_RED}Starting salt-syndic ... FAILED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
raise TestDaemonStartFailed()
if self.parser.options.proxy:
self.minion_targets.add(self.proxy_opts["id"])
self.proxy_process = self.start_salt_daemon(
daemon_name="salt-proxy",
daemon_id=self.proxy_opts["id"],
daemon_log_prefix="salt-proxy/{}".format(self.proxy_opts["id"]),
daemon_cli_script_name="proxy",
daemon_config=self.proxy_opts,
daemon_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
daemon_class=SaltProxy,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
start_timeout=120,
)
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting salt-proxy ... {ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
self.proxy_process = start_daemon(
daemon_name="salt-proxy",
daemon_id=self.proxy_opts["id"],
daemon_log_prefix="salt-proxy/{}".format(self.proxy_opts["id"]),
daemon_cli_script_name="proxy",
daemon_config=self.proxy_opts,
daemon_config_dir=RUNTIME_VARS.TMP_CONF_DIR,
daemon_class=SaltProxy,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
start_timeout=120,
)
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_GREEN}Starting salt-proxy ... STARTED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
except (RuntimeWarning, RuntimeError):
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_RED}Starting salt-proxy ... FAILED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
raise TestDaemonStartFailed()
start_tcp_daemons = start_zeromq_daemons
@ -475,7 +549,9 @@ class TestDaemon:
Generate keys and start an ssh daemon on an alternate port
"""
sys.stdout.write(
" * {LIGHT_GREEN}Starting {} ... {ENDC}".format("SSH server", **self.colors)
" * {LIGHT_GREEN}Starting {0} ... {ENDC}".format(
"SSH server", **self.colors
)
)
keygen = salt.utils.path.which("ssh-keygen")
sshd = salt.utils.path.which("sshd")
@ -716,8 +792,6 @@ class TestDaemon:
os.makedirs(RUNTIME_VARS.TMP)
os.makedirs(RUNTIME_VARS.TMP_ROOT_DIR)
os.makedirs(RUNTIME_VARS.TMP_CONF_DIR)
os.makedirs(RUNTIME_VARS.TMP_VIRT_MINION_0_CONF_DIR)
os.makedirs(RUNTIME_VARS.TMP_VIRT_MINION_1_CONF_DIR)
os.makedirs(RUNTIME_VARS.TMP_SUB_MINION_CONF_DIR)
os.makedirs(RUNTIME_VARS.TMP_SYNDIC_MASTER_CONF_DIR)
os.makedirs(RUNTIME_VARS.TMP_SYNDIC_MINION_CONF_DIR)
@ -810,27 +884,6 @@ class TestDaemon:
if virtualenv_binary:
minion_opts["venv_bin"] = virtualenv_binary
# This libvirt + minion connects to master
virt_minion_0_opts = salt.config._read_conf_file(
os.path.join(RUNTIME_VARS.CONF_DIR, "virt_minion_0")
)
virt_minion_0_opts["user"] = "root"
virt_minion_0_opts["cachedir"] = "cache"
virt_minion_0_opts["root_dir"] = "/etc/salt"
virt_minion_0_opts["pki_dir"] = "pki"
virt_minion_0_opts["hosts.file"] = "hosts"
virt_minion_0_opts["aliases.file"] = "aliases"
virt_minion_1_opts = salt.config._read_conf_file(
os.path.join(RUNTIME_VARS.CONF_DIR, "virt_minion_1")
)
virt_minion_1_opts["user"] = "root"
virt_minion_1_opts["cachedir"] = "cache"
virt_minion_1_opts["root_dir"] = "/etc/salt"
virt_minion_1_opts["pki_dir"] = "pki"
virt_minion_1_opts["hosts.file"] = "hosts"
virt_minion_1_opts["aliases.file"] = "aliases"
# This sub_minion also connects to master
sub_minion_opts = salt.config._read_conf_file(
os.path.join(RUNTIME_VARS.CONF_DIR, "sub_minion")
@ -894,8 +947,6 @@ class TestDaemon:
if transport == "tcp":
master_opts["transport"] = "tcp"
minion_opts["transport"] = "tcp"
virt_minion_0_opts["transport"] = "tcp"
virt_minion_1_opts["transport"] = "tcp"
sub_minion_opts["transport"] = "tcp"
syndic_master_opts["transport"] = "tcp"
proxy_opts["transport"] = "tcp"
@ -1009,8 +1060,6 @@ class TestDaemon:
master_opts["runtests_conn_check_port"] = get_unused_localhost_port()
minion_opts["runtests_conn_check_port"] = get_unused_localhost_port()
virt_minion_0_opts["runtests_conn_check_port"] = get_unused_localhost_port()
virt_minion_1_opts["runtests_conn_check_port"] = get_unused_localhost_port()
sub_minion_opts["runtests_conn_check_port"] = get_unused_localhost_port()
syndic_opts["runtests_conn_check_port"] = get_unused_localhost_port()
syndic_master_opts["runtests_conn_check_port"] = get_unused_localhost_port()
@ -1046,8 +1095,6 @@ class TestDaemon:
if entry in (
"master",
"minion",
"virt_minion_0",
"virt_minion_1",
"sub_minion",
"syndic",
"syndic_master",
@ -1079,31 +1126,6 @@ class TestDaemon:
salt.utils.yaml.safe_dump(
computed_config, fp_, default_flow_style=False
)
virt_minion_0_computed_config = copy.deepcopy(virt_minion_0_opts)
with salt.utils.files.fopen(
os.path.join(RUNTIME_VARS.TMP_VIRT_MINION_0_CONF_DIR, "minion"), "w"
) as wfh:
salt.utils.yaml.safe_dump(
virt_minion_0_computed_config, wfh, default_flow_style=False
)
shutil.copyfile(
os.path.join(RUNTIME_VARS.TMP_CONF_DIR, "master"),
os.path.join(RUNTIME_VARS.TMP_VIRT_MINION_0_CONF_DIR, "master"),
)
virt_minion_1_computed_config = copy.deepcopy(virt_minion_1_opts)
with salt.utils.files.fopen(
os.path.join(RUNTIME_VARS.TMP_VIRT_MINION_1_CONF_DIR, "minion"), "w"
) as wfh:
salt.utils.yaml.safe_dump(
virt_minion_1_computed_config, wfh, default_flow_style=False
)
shutil.copyfile(
os.path.join(RUNTIME_VARS.TMP_CONF_DIR, "master"),
os.path.join(RUNTIME_VARS.TMP_VIRT_MINION_1_CONF_DIR, "master"),
)
sub_minion_computed_config = copy.deepcopy(sub_minion_opts)
with salt.utils.files.fopen(
os.path.join(RUNTIME_VARS.TMP_SUB_MINION_CONF_DIR, "minion"), "w"
@ -1143,12 +1165,6 @@ class TestDaemon:
minion_opts = salt.config.minion_config(
os.path.join(RUNTIME_VARS.TMP_CONF_DIR, "minion")
)
virt_minion_0_opts = salt.config.minion_config(
os.path.join(RUNTIME_VARS.TMP_VIRT_MINION_0_CONF_DIR, "minion")
)
virt_minion_1_opts = salt.config.minion_config(
os.path.join(RUNTIME_VARS.TMP_VIRT_MINION_1_CONF_DIR, "minion")
)
syndic_opts = salt.config.syndic_config(
os.path.join(RUNTIME_VARS.TMP_SYNDIC_MINION_CONF_DIR, "master"),
os.path.join(RUNTIME_VARS.TMP_SYNDIC_MINION_CONF_DIR, "minion"),
@ -1166,8 +1182,6 @@ class TestDaemon:
RUNTIME_VARS.RUNTIME_CONFIGS["master"] = freeze(master_opts)
RUNTIME_VARS.RUNTIME_CONFIGS["minion"] = freeze(minion_opts)
RUNTIME_VARS.RUNTIME_CONFIGS["syndic"] = freeze(syndic_opts)
RUNTIME_VARS.RUNTIME_CONFIGS["virt_minion_0"] = freeze(virt_minion_0_opts)
RUNTIME_VARS.RUNTIME_CONFIGS["virt_minion_1"] = freeze(virt_minion_1_opts)
RUNTIME_VARS.RUNTIME_CONFIGS["sub_minion"] = freeze(sub_minion_opts)
RUNTIME_VARS.RUNTIME_CONFIGS["syndic_master"] = freeze(syndic_master_opts)
RUNTIME_VARS.RUNTIME_CONFIGS["proxy"] = freeze(proxy_opts)
@ -1194,28 +1208,16 @@ class TestDaemon:
os.path.join(minion_opts["pki_dir"], "accepted"),
os.path.join(minion_opts["pki_dir"], "rejected"),
os.path.join(minion_opts["pki_dir"], "pending"),
os.path.join(virt_minion_0_opts["pki_dir"], "accepted"),
os.path.join(virt_minion_0_opts["pki_dir"], "rejected"),
os.path.join(virt_minion_0_opts["pki_dir"], "pending"),
os.path.join(virt_minion_1_opts["pki_dir"], "accepted"),
os.path.join(virt_minion_1_opts["pki_dir"], "rejected"),
os.path.join(virt_minion_1_opts["pki_dir"], "pending"),
os.path.join(sub_minion_opts["pki_dir"], "accepted"),
os.path.join(sub_minion_opts["pki_dir"], "rejected"),
os.path.join(sub_minion_opts["pki_dir"], "pending"),
os.path.dirname(master_opts["log_file"]),
minion_opts["extension_modules"],
virt_minion_0_opts["extension_modules"],
virt_minion_0_opts["pki_dir"],
virt_minion_1_opts["extension_modules"],
virt_minion_1_opts["pki_dir"],
sub_minion_opts["extension_modules"],
sub_minion_opts["pki_dir"],
proxy_opts["pki_dir"],
master_opts["sock_dir"],
syndic_master_opts["sock_dir"],
virt_minion_0_opts["sock_dir"],
virt_minion_1_opts["sock_dir"],
sub_minion_opts["sock_dir"],
minion_opts["sock_dir"],
RUNTIME_VARS.TMP_STATE_TREE,
@ -1230,8 +1232,6 @@ class TestDaemon:
cls.master_opts = master_opts
cls.minion_opts = minion_opts
# cls.proxy_opts = proxy_opts
cls.virt_minion_0_opts = virt_minion_0_opts
cls.virt_minion_1_opts = virt_minion_1_opts
cls.sub_minion_opts = sub_minion_opts
cls.syndic_opts = syndic_opts
cls.syndic_master_opts = syndic_master_opts
@ -1242,27 +1242,11 @@ class TestDaemon:
"""
Kill the minion and master processes
"""
try:
if hasattr(self.virt_minion_0_process, "terminate"):
self.virt_minion_0_process.terminate()
else:
log.error("self.virt_minion_0_process can't be terminated.")
except AttributeError:
pass
try:
if hasattr(self.virt_minion_1_process, "terminate"):
self.virt_minion_1_process.terminate()
else:
log.error("self.virt_minion_1_process can't be terminated.")
except AttributeError:
pass
try:
if hasattr(self.sub_minion_process, "terminate"):
self.sub_minion_process.terminate()
else:
log.error("self.sub_minion_process can't be terminated.")
log.error("self.sub_minion_process can't be terminate.")
except AttributeError:
pass
@ -1270,7 +1254,7 @@ class TestDaemon:
if hasattr(self.minion_process, "terminate"):
self.minion_process.terminate()
else:
log.error("self.minion_process can't be terminated.")
log.error("self.minion_process can't be terminate.")
except AttributeError:
pass
@ -1379,7 +1363,11 @@ class TestDaemon:
job_finished = False
while now <= expire:
running = self.__client_job_running(targets, jid)
sys.stdout.write(self.clear_line)
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
if not running and job_finished is False:
# Let's not have false positives and wait one more seconds
job_finished = True
@ -1390,10 +1378,10 @@ class TestDaemon:
if job_finished is False:
sys.stdout.write(
" * {LIGHT_YELLOW}[Quit in {}]{ENDC} Waiting for {}".format(
" * {LIGHT_YELLOW}[Quit in {0}]{ENDC} Waiting for {1}".format(
"{}".format(expire - now).rsplit(".", 1)[0],
", ".join(running),
**self.colors,
**self.colors
)
)
sys.stdout.flush()
@ -1416,8 +1404,10 @@ class TestDaemon:
timeout = 120
# Let's sync all connected minions
print(
" {LIGHT_BLUE}*{ENDC} Syncing minion's {} "
"(saltutil.sync_{})".format(", ".join(targets), modules_kind, **self.colors)
" {LIGHT_BLUE}*{ENDC} Syncing minion's {1} "
"(saltutil.sync_{1})".format(
", ".join(targets), modules_kind, **self.colors
)
)
syncing = set(targets)
jid_info = self.client.run_job(
@ -1429,8 +1419,10 @@ class TestDaemon:
if self.wait_for_jid(targets, jid_info["jid"], timeout) is False:
print(
" {LIGHT_RED}*{ENDC} WARNING: Minions failed to sync {}. "
"Tests requiring these {} WILL fail".format(modules_kind, **self.colors)
" {LIGHT_RED}*{ENDC} WARNING: Minions failed to sync {0}. "
"Tests requiring these {0} WILL fail".format(
modules_kind, **self.colors
)
)
raise SystemExit()
@ -1446,16 +1438,16 @@ class TestDaemon:
if isinstance(output["ret"], str):
# An errors has occurred
print(
" {LIGHT_RED}*{ENDC} {} Failed to sync {2}: "
"{}".format(
" {LIGHT_RED}*{ENDC} {0} Failed to sync {2}: "
"{1}".format(
name, output["ret"], modules_kind, **self.colors
)
)
return False
print(
" {LIGHT_GREEN}*{ENDC} Synced {} {2}: "
"{}".format(
" {LIGHT_GREEN}*{ENDC} Synced {0} {2}: "
"{1}".format(
name, ", ".join(output["ret"]), modules_kind, **self.colors
)
)
@ -1464,8 +1456,8 @@ class TestDaemon:
syncing.remove(name)
except KeyError:
print(
" {LIGHT_RED}*{ENDC} {} already synced??? "
"{}".format(name, output, **self.colors)
" {LIGHT_RED}*{ENDC} {0} already synced??? "
"{1}".format(name, output, **self.colors)
)
return True

View file

@ -1,116 +0,0 @@
# basic config
# Connects to master
master: localhost
interface: 127.0.0.1
master_port: 64506
tcp_pub_port: 64530
tcp_pull_port: 64531
sock_dir: virt_minion_0_sock
id: virt_minion_0
open_mode: True
log_file: virt_minion_0.log
log_level_logfile: debug
pidfile: virt_minion_0.pid
# Give the minion extra attempts to find the master
# This is especially needed for the TCP tests as we
# wait for the master to come up in 2016.3. See #35489.
master_tries: 5
# module extension
test.foo: baz
integration.test: True
# Grains addons
grains:
test_grain: cheese
script: grail
alot: many
planets:
- mercury
- venus
- earth
- mars
level1:
level2: foo
companions:
one:
- susan
- ian
- barbara
tokenv2:
keystone.endpoint: http://localhost:35357/v2.0
keystone.token: administrator
tokenv3:
keystone.endpoint: http://localhost:35357/v3
keystone.token: administrator
adminv2:
keystone.user: admin
keystone.password: adminpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
demov2:
keystone.user: demo
keystone.password: demopass
keystone.tenant: demo
keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
adminv3:
keystone.user: admin
keystone.password: adminpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v3/'
demov3:
keystone.user: demo
keystone.password: demopass
keystone.tenant: demo
keystone.auth_url: 'http://127.0.0.1:5000/v3/'
zookeeper:
prod:
hosts: 'localhost:2181'
default_acl:
- username: daniel
password: test
read: true
write: true
create: true
delete: true
admin: true
username: daniel
password: test
hosts: 'localhost:2181'
default_acl:
- username: daniel
password: test
read: true
write: true
create: true
delete: true
admin: true
username: daniel
password: test
config_test:
spam: eggs
mine_functions:
test.ping: []
test.arg:
- isn't
- allow_tgt: 'sub_minion'
# sdb env module
osenv:
driver: env
# cmd blacklist
cmd_blacklist_glob:
- 'bad_command *'
- 'second_bad_command *'
autosign_grains:
- test_grain
# disable discovery for test suite saltstack/salt-jenkins#683
discovery: false
sdbvault:
driver: vault

View file

@ -1,116 +0,0 @@
# basic config
# Connects to master
master: localhost
interface: 127.0.0.1
master_port: 64506
tcp_pub_port: 64540
tcp_pull_port: 64541
sock_dir: virt_minion_1_sock
id: virt_minion_1
open_mode: True
log_file: virt_minion_1.log
log_level_logfile: debug
pidfile: virt_minion_1.pid
# Give the minion extra attempts to find the master
# This is especially needed for the TCP tests as we
# wait for the master to come up in 2016.3. See #35489.
master_tries: 5
# module extension
test.foo: baz
integration.test: True
# Grains addons
grains:
test_grain: cheese
script: grail
alot: many
planets:
- mercury
- venus
- earth
- mars
level1:
level2: foo
companions:
one:
- susan
- ian
- barbara
tokenv2:
keystone.endpoint: http://localhost:35357/v2.0
keystone.token: administrator
tokenv3:
keystone.endpoint: http://localhost:35357/v3
keystone.token: administrator
adminv2:
keystone.user: admin
keystone.password: adminpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
demov2:
keystone.user: demo
keystone.password: demopass
keystone.tenant: demo
keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
adminv3:
keystone.user: admin
keystone.password: adminpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v3/'
demov3:
keystone.user: demo
keystone.password: demopass
keystone.tenant: demo
keystone.auth_url: 'http://127.0.0.1:5000/v3/'
zookeeper:
prod:
hosts: 'localhost:2181'
default_acl:
- username: daniel
password: test
read: true
write: true
create: true
delete: true
admin: true
username: daniel
password: test
hosts: 'localhost:2181'
default_acl:
- username: daniel
password: test
read: true
write: true
create: true
delete: true
admin: true
username: daniel
password: test
config_test:
spam: eggs
mine_functions:
test.ping: []
test.arg:
- isn't
- allow_tgt: 'sub_minion'
# sdb env module
osenv:
driver: env
# cmd blacklist
cmd_blacklist_glob:
- 'bad_command *'
- 'second_bad_command *'
autosign_grains:
- test_grain
# disable discovery for test suite saltstack/salt-jenkins#683
discovery: false
sdbvault:
driver: vault

View file

@ -3,6 +3,7 @@ Set up the Salt multimaster test suite
"""
# Import Python libs
import copy
import logging
import os
@ -184,19 +185,47 @@ class MultimasterTestDaemon(TestDaemon):
)
self.log_server_process = threading.Thread(target=self.log_server.serve_forever)
self.log_server_process.start()
self.master_process = self.start_salt_daemon(
daemon_name="salt-master",
daemon_id=self.mm_master_opts["id"],
daemon_log_prefix="salt-master/{}".format(self.mm_master_opts["id"]),
daemon_cli_script_name="master",
daemon_config=self.mm_master_opts,
daemon_config_dir=RUNTIME_VARS.TMP_MM_CONF_DIR,
daemon_class=SaltMaster,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
start_timeout=120,
)
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting salt-master ... {ENDC}".format(**self.colors)
)
sys.stdout.flush()
self.master_process = start_daemon(
daemon_name="salt-master",
daemon_id=self.mm_master_opts["id"],
daemon_log_prefix="salt-master/{}".format(self.mm_master_opts["id"]),
daemon_cli_script_name="master",
daemon_config=self.mm_master_opts,
daemon_config_dir=RUNTIME_VARS.TMP_MM_CONF_DIR,
daemon_class=SaltMaster,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
start_timeout=120,
)
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_GREEN}Starting salt-master ... STARTED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
except (RuntimeWarning, RuntimeError):
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_RED}Starting salt-master ... FAILED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
raise TestDaemonStartFailed()
# Clone the master key to sub-master's pki dir
for keyfile in ("master.pem", "master.pub"):
@ -205,48 +234,139 @@ class MultimasterTestDaemon(TestDaemon):
os.path.join(self.mm_sub_master_opts["pki_dir"], keyfile),
)
self.sub_master_process = self.start_salt_daemon(
daemon_name="sub salt-master",
daemon_id=self.mm_master_opts["id"],
daemon_log_prefix="sub-salt-master/{}".format(
self.mm_sub_master_opts["id"]
),
daemon_cli_script_name="master",
daemon_config=self.mm_sub_master_opts,
daemon_config_dir=RUNTIME_VARS.TMP_MM_SUB_CONF_DIR,
daemon_class=SaltMaster,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
start_timeout=120,
)
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting second salt-master ... {ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
self.sub_master_process = start_daemon(
daemon_name="sub salt-master",
daemon_id=self.mm_master_opts["id"],
daemon_log_prefix="sub-salt-master/{}".format(
self.mm_sub_master_opts["id"]
),
daemon_cli_script_name="master",
daemon_config=self.mm_sub_master_opts,
daemon_config_dir=RUNTIME_VARS.TMP_MM_SUB_CONF_DIR,
daemon_class=SaltMaster,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
start_timeout=120,
)
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_GREEN}Starting second salt-master ... STARTED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
except (RuntimeWarning, RuntimeError):
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_RED}Starting second salt-master ... FAILED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
raise TestDaemonStartFailed()
self.minion_process = self.start_salt_daemon(
daemon_name="salt-minion",
daemon_id=self.mm_master_opts["id"],
daemon_log_prefix="salt-minion/{}".format(self.mm_minion_opts["id"]),
daemon_cli_script_name="minion",
daemon_config=self.mm_minion_opts,
daemon_config_dir=RUNTIME_VARS.TMP_MM_CONF_DIR,
daemon_class=SaltMinion,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
start_timeout=120,
)
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting salt-minion ... {ENDC}".format(**self.colors)
)
sys.stdout.flush()
self.minion_process = start_daemon(
daemon_name="salt-minion",
daemon_id=self.mm_master_opts["id"],
daemon_log_prefix="salt-minion/{}".format(self.mm_minion_opts["id"]),
daemon_cli_script_name="minion",
daemon_config=self.mm_minion_opts,
daemon_config_dir=RUNTIME_VARS.TMP_MM_CONF_DIR,
daemon_class=SaltMinion,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
start_timeout=120,
)
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_GREEN}Starting salt-minion ... STARTED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
except (RuntimeWarning, RuntimeError):
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_RED}Starting salt-minion ... FAILED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
raise TestDaemonStartFailed()
self.sub_minion_process = self.start_salt_daemon(
daemon_name="sub salt-minion",
daemon_id=self.mm_master_opts["id"],
daemon_log_prefix="sub-salt-minion/{}".format(
self.mm_sub_minion_opts["id"]
),
daemon_cli_script_name="minion",
daemon_config=self.mm_sub_minion_opts,
daemon_config_dir=RUNTIME_VARS.TMP_MM_SUB_CONF_DIR,
daemon_class=SaltMinion,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
start_timeout=120,
)
try:
sys.stdout.write(
" * {LIGHT_YELLOW}Starting sub salt-minion ... {ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
self.sub_minion_process = start_daemon(
daemon_name="sub salt-minion",
daemon_id=self.mm_master_opts["id"],
daemon_log_prefix="sub-salt-minion/{}".format(
self.mm_sub_minion_opts["id"]
),
daemon_cli_script_name="minion",
daemon_config=self.mm_sub_minion_opts,
daemon_config_dir=RUNTIME_VARS.TMP_MM_SUB_CONF_DIR,
daemon_class=SaltMinion,
bin_dir_path=SCRIPT_DIR,
fail_hard=True,
start_timeout=120,
)
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_GREEN}Starting sub salt-minion ... STARTED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
except (RuntimeWarning, RuntimeError):
sys.stdout.write(
"\r{}\r".format(
" " * getattr(self.parser.options, "output_columns", PNUM)
)
)
sys.stdout.write(
" * {LIGHT_RED}Starting sub salt-minion ... FAILED!\n{ENDC}".format(
**self.colors
)
)
sys.stdout.flush()
raise TestDaemonStartFailed()
start_tcp_daemons = start_zeromq_daemons

View file

@ -4,7 +4,6 @@ Discover all instances of unittest.TestCase in this directory.
"""
# pylint: disable=file-perms
# Import python libs
import collections
import os
import sys
@ -65,7 +64,6 @@ import salt.utils.platform # isort:skip
if not salt.utils.platform.is_windows():
import resource
# Import Salt Testing libs
from tests.support.parser import PNUM, print_header # isort:skip
from tests.support.parser.cover import SaltCoverageTestingParser # isort:skip
@ -910,8 +908,8 @@ class SaltTestsuiteParser(SaltCoverageTestingParser):
):
status.append(self.run_integration_suite(**TEST_SUITES[suite]))
return status
except TestDaemonStartFailed as err:
self.exit(status=2, msg=str(err))
except TestDaemonStartFailed:
self.exit(status=2)
def run_multimaster_tests(self):
"""

View file

@ -7,6 +7,7 @@
Some reusable class Mixins
"""
import atexit
import copy
import functools
@ -207,10 +208,6 @@ class AdaptedConfigurationTestCaseMixin:
return os.path.join(RUNTIME_VARS.TMP_SYNDIC_MASTER_CONF_DIR, "master")
if filename == "syndic":
return os.path.join(RUNTIME_VARS.TMP_SYNDIC_MINION_CONF_DIR, "minion")
if filename == "virt_minion_0":
return os.path.join(RUNTIME_VARS.TMP_VIRT_MINION_0_CONF_DIR, "minion")
if filename == "virt_minion_1":
return os.path.join(RUNTIME_VARS.TMP_VIRT_MINION_1_CONF_DIR, "minion")
if filename == "sub_minion":
return os.path.join(RUNTIME_VARS.TMP_SUB_MINION_CONF_DIR, "minion")
if filename == "mm_master":

View file

@ -9,6 +9,8 @@
Tests related paths
"""
import logging
import os
import re
@ -67,8 +69,6 @@ TMP_PILLAR_TREE = os.path.join(SYS_TMP_DIR, "salt-temp-pillar-tree")
TMP_PRODENV_STATE_TREE = os.path.join(SYS_TMP_DIR, "salt-temp-prodenv-state-tree")
TMP_PRODENV_PILLAR_TREE = os.path.join(SYS_TMP_DIR, "salt-temp-prodenv-pillar-tree")
TMP_CONF_DIR = TMP_MINION_CONF_DIR = os.path.join(TMP, "config")
TMP_VIRT_MINION_0_CONF_DIR = os.path.join(TMP_CONF_DIR, "virt_minion_0")
TMP_VIRT_MINION_1_CONF_DIR = os.path.join(TMP_CONF_DIR, "virt_minion_1")
TMP_SUB_MINION_CONF_DIR = os.path.join(TMP_CONF_DIR, "sub-minion")
TMP_SYNDIC_MINION_CONF_DIR = os.path.join(TMP_CONF_DIR, "syndic-minion")
TMP_SYNDIC_MASTER_CONF_DIR = os.path.join(TMP_CONF_DIR, "syndic-master")

View file

@ -9,10 +9,8 @@
Process handling utilities
"""
import logging
import os
import subprocess
import time
from saltfactories.utils.processes.helpers import ( # pylint: disable=unused-import
collect_child_processes,
@ -115,156 +113,6 @@ class SaltSyndic(GetSaltRunFixtureMixin, PytestSaltSyndic):
"""
class SaltVirtContainer:
"""
Class which represents virt-minion container
"""
def __init__(
self,
container_name,
container_img,
ssh_port,
sshd_port,
libvirt_tcp_port,
libvirt_tls_port,
host_uuid,
daemon_config_dir,
):
self.container_name = container_name
self.container_img = container_img
self.ssh_port = ssh_port
self.sshd_port = sshd_port
self.libvirt_tcp_port = libvirt_tcp_port
self.libvirt_tls_port = libvirt_tls_port
self.host_uuid = host_uuid
self.daemon_config_dir = daemon_config_dir
self.pid_file = os.path.join(daemon_config_dir, container_name + ".pid")
def _run_cmd(self, cmd):
log.debug("Running command:\n%s", " ".join(cmd))
return subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True,
)
def update_image(self):
"""
`docker run` doesn't pull down the latest image if the image
already exists locally. This method invokes `docker pull`
explicitly.
"""
process = self._run_cmd(["docker", "pull", self.container_img])
output = process.communicate()[0]
if process.returncode != 0:
raise RuntimeError(
"Failed to pull image '{}':\n{}".format(self.container_img, output)
)
def start(self):
log.info(
"Minion log file: {}/{}.log".format(
self.daemon_config_dir, self.container_name
)
)
salt_root_path = os.path.abspath(os.path.join(__file__, "..", "..", ".."))
# Start container
process = self._run_cmd(
[
"docker",
"run",
"-d",
"--rm",
"--privileged",
"--cap-add=ALL",
"--network=host",
"--add-host=virt_minion_0:127.0.0.1",
"--add-host=virt_minion_1:127.0.0.1",
"--name=" + self.container_name,
"--hostname=" + self.container_name,
"-e",
"LIBVIRT_TCP_PORT={}".format(self.libvirt_tcp_port),
"-e",
"LIBVIRT_TLS_PORT={}".format(self.libvirt_tls_port),
"-e",
"SSH_PORT={}".format(self.ssh_port),
"-e",
"SSHD_PORT={}".format(self.sshd_port),
"-e",
"HOST_UUID=" + self.host_uuid,
"-v",
salt_root_path + ":/salt",
"-v",
self.daemon_config_dir + ":/etc/salt",
self.container_img,
]
)
output = process.communicate()[0]
if process.returncode != 0:
raise RuntimeError(
"Failed to start '{}':\n{}".format(self.container_name, output)
)
def wait_until_minion_is_running(self, timeout=60):
"""
Wait until a pid file exists and check the container state every 10 sec
"""
log.info("Wating for pidfile ({}s timeout): {}".format(timeout, self.pid_file))
cmd = ["docker", "inspect", "-f", "{{.State.Running}}", self.container_name]
while not os.path.isfile(self.pid_file):
time.sleep(1)
if timeout > 0:
if timeout % 10 == 0:
process = self._run_cmd(cmd)
output = process.communicate()[0].decode("utf-8")
if process.returncode != 0 or output.strip().lower() != "true":
raise RuntimeError(
"Container '{}' isn't running:\n{}".format(
self.container_name, output
)
)
timeout -= 1
else:
self.terminate()
raise RuntimeError("Timeout: minion daemon isn't running.")
def terminate(self):
"""
Send a KILL signal to container.
"""
self._run_cmd(["docker", "kill", self.container_name])
os.remove(self.pid_file)
def start_virt_daemon(
container_name,
container_img,
ssh_port,
sshd_port,
libvirt_tcp_port,
libvirt_tls_port,
host_uuid,
daemon_config_dir,
):
"""
Start a salt minion daemon inside a container.
"""
container = SaltVirtContainer(
container_name=container_name,
container_img=container_img,
ssh_port=ssh_port,
sshd_port=sshd_port,
libvirt_tcp_port=libvirt_tcp_port,
libvirt_tls_port=libvirt_tls_port,
host_uuid=host_uuid,
daemon_config_dir=daemon_config_dir,
)
container.update_image()
container.start()
container.wait_until_minion_is_running()
return container
def start_daemon(
daemon_name=None,
daemon_id=None,

View file

@ -378,84 +378,6 @@ def salt_minion_config(request, salt_factories, salt_master_config):
)
@pytest.fixture(scope="session")
def salt_virt_minion_0_config(request, salt_factories, salt_master_config):
with salt.utils.files.fopen(
os.path.join(RUNTIME_VARS.CONF_DIR, "virt_minion_0")
) as rfh:
config_defaults = yaml.deserialize(rfh.read())
config_defaults["hosts.file"] = "hosts"
config_defaults["aliases.file"] = "aliases"
config_defaults["transport"] = request.config.getoption("--transport")
config_overrides = {
"file_roots": {
"base": [
RUNTIME_VARS.TMP_STATE_TREE,
os.path.join(RUNTIME_VARS.FILES, "file", "base"),
],
# Alternate root to test __env__ choices
"prod": [
RUNTIME_VARS.TMP_PRODENV_STATE_TREE,
os.path.join(RUNTIME_VARS.FILES, "file", "prod"),
],
},
"pillar_roots": {
"base": [
RUNTIME_VARS.TMP_PILLAR_TREE,
os.path.join(RUNTIME_VARS.FILES, "pillar", "base"),
],
"prod": [RUNTIME_VARS.TMP_PRODENV_PILLAR_TREE],
},
}
return salt_factories.configure_minion(
request,
"virt_minion_0",
master_id="master",
config_defaults=config_defaults,
config_overrides=config_overrides,
)
@pytest.fixture(scope="session")
def salt_virt_minion_1_config(request, salt_factories, salt_master_config):
with salt.utils.files.fopen(
os.path.join(RUNTIME_VARS.CONF_DIR, "virt_minion_1")
) as rfh:
config_defaults = yaml.deserialize(rfh.read())
config_defaults["hosts.file"] = "hosts"
config_defaults["aliases.file"] = "aliases"
config_defaults["transport"] = request.config.getoption("--transport")
config_overrides = {
"file_roots": {
"base": [
RUNTIME_VARS.TMP_STATE_TREE,
os.path.join(RUNTIME_VARS.FILES, "file", "base"),
],
# Alternate root to test __env__ choices
"prod": [
RUNTIME_VARS.TMP_PRODENV_STATE_TREE,
os.path.join(RUNTIME_VARS.FILES, "file", "prod"),
],
},
"pillar_roots": {
"base": [
RUNTIME_VARS.TMP_PILLAR_TREE,
os.path.join(RUNTIME_VARS.FILES, "pillar", "base"),
],
"prod": [RUNTIME_VARS.TMP_PRODENV_PILLAR_TREE],
},
}
return salt_factories.configure_minion(
request,
"virt_minion_1",
master_id="master",
config_defaults=config_defaults,
config_overrides=config_overrides,
)
@pytest.fixture(scope="session")
def salt_sub_minion_config(request, salt_factories, salt_master_config):
with salt.utils.files.fopen(
@ -558,15 +480,11 @@ def bridge_pytest_and_runtests(
salt_syndic_config,
salt_master_config,
salt_minion_config,
salt_virt_minion_0_config,
salt_virt_minion_1_config,
salt_sub_minion_config,
):
# Make sure unittest2 uses the pytest generated configuration
RUNTIME_VARS.RUNTIME_CONFIGS["master"] = freeze(salt_master_config)
RUNTIME_VARS.RUNTIME_CONFIGS["minion"] = freeze(salt_minion_config)
RUNTIME_VARS.RUNTIME_CONFIGS["virt_minion_0"] = freeze(salt_virt_minion_0_config)
RUNTIME_VARS.RUNTIME_CONFIGS["virt_minion_1"] = freeze(salt_virt_minion_1_config)
RUNTIME_VARS.RUNTIME_CONFIGS["sub_minion"] = freeze(salt_sub_minion_config)
RUNTIME_VARS.RUNTIME_CONFIGS["syndic_master"] = freeze(salt_syndic_master_config)
RUNTIME_VARS.RUNTIME_CONFIGS["syndic"] = freeze(salt_syndic_config)
@ -578,12 +496,6 @@ def bridge_pytest_and_runtests(
RUNTIME_VARS.TMP_ROOT_DIR = salt_factories.root_dir.realpath().strpath
RUNTIME_VARS.TMP_CONF_DIR = os.path.dirname(salt_master_config["conf_file"])
RUNTIME_VARS.TMP_MINION_CONF_DIR = os.path.dirname(salt_minion_config["conf_file"])
RUNTIME_VARS.TMP_VIRT_MINION_0_CONF_DIR = os.path.dirname(
salt_virt_minion_0_config["conf_file"]
)
RUNTIME_VARS.TMP_VIRT_MINION_1_CONF_DIR = os.path.dirname(
salt_virt_minion_1_config["conf_file"]
)
RUNTIME_VARS.TMP_SUB_MINION_CONF_DIR = os.path.dirname(
salt_sub_minion_config["conf_file"]
)

View file

@ -181,8 +181,6 @@ RUNTIME_VARS = RuntimeVars(
TMP_CONF_CLOUD_PROVIDER_INCLUDES=os.path.join(
paths.TMP_CONF_DIR, "cloud.providers.d"
),
TMP_VIRT_MINION_0_CONF_DIR=paths.TMP_VIRT_MINION_0_CONF_DIR,
TMP_VIRT_MINION_1_CONF_DIR=paths.TMP_VIRT_MINION_1_CONF_DIR,
TMP_SUB_MINION_CONF_DIR=paths.TMP_SUB_MINION_CONF_DIR,
TMP_SYNDIC_MASTER_CONF_DIR=paths.TMP_SYNDIC_MASTER_CONF_DIR,
TMP_SYNDIC_MINION_CONF_DIR=paths.TMP_SYNDIC_MINION_CONF_DIR,