Skip to content

Commit

Permalink
Use correct broker settings path in functional tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpapaioa authored and JacobCallahan committed Apr 16, 2024
1 parent f91b4eb commit 5fa99d9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
27 changes: 13 additions & 14 deletions tests/functional/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from broker.commands import cli
from broker.providers.container import Container
from broker.settings import inventory_path
from broker.settings import settings_path as SETTINGS_PATH

SCENARIO_DIR = Path("tests/data/cli_scenarios/containers")

Expand Down Expand Up @@ -70,21 +71,20 @@ def test_container_e2e():
assert c_host._cont_inst.top()["Processes"]
res = c_host.execute("hostname")
assert res.stdout.strip() == c_host.hostname
loc_settings_path = Path("broker_settings.yaml")
remote_dir = "/tmp/fake"
c_host.session.sftp_write(loc_settings_path.name, f"{remote_dir}/")
c_host.session.sftp_write(str(SETTINGS_PATH), f"{remote_dir}/")
res = c_host.execute(f"ls {remote_dir}")
assert str(loc_settings_path) in res.stdout
assert SETTINGS_PATH.name in res.stdout
with NamedTemporaryFile() as tmp:
c_host.session.sftp_read(f"{remote_dir}/{loc_settings_path.name}", tmp.file.name)
c_host.session.sftp_read(f"{remote_dir}/{SETTINGS_PATH.name}", tmp.file.name)
data = c_host.session.sftp_read(
f"{remote_dir}/{loc_settings_path.name}", return_data=True
f"{remote_dir}/{SETTINGS_PATH.name}", return_data=True
)
assert (
loc_settings_path.read_bytes() == Path(tmp.file.name).read_bytes()
SETTINGS_PATH.read_bytes() == Path(tmp.file.name).read_bytes()
), "Local file is different from the received one"
assert (
loc_settings_path.read_bytes() == data
SETTINGS_PATH.read_bytes() == data
), "Local file is different from the received one (return_data=True)"
assert data == Path(tmp.file.name).read_bytes(), "Received files do not match"
# test the tail_file context manager
Expand All @@ -102,21 +102,20 @@ def test_container_e2e_mp():
assert c_host._cont_inst.top()["Processes"]
res = c_host.execute("hostname")
assert res.stdout.strip() == c_host.hostname
loc_settings_path = Path("broker_settings.yaml")
remote_dir = "/tmp/fake"
c_host.session.sftp_write(loc_settings_path.name, f"{remote_dir}/")
c_host.session.sftp_write(str(SETTINGS_PATH), f"{remote_dir}/")
res = c_host.execute(f"ls {remote_dir}")
assert str(loc_settings_path) in res.stdout
assert SETTINGS_PATH.name in res.stdout
with NamedTemporaryFile() as tmp:
c_host.session.sftp_read(f"{remote_dir}/{loc_settings_path.name}", tmp.file.name)
c_host.session.sftp_read(f"{remote_dir}/{SETTINGS_PATH.name}", tmp.file.name)
data = c_host.session.sftp_read(
f"{remote_dir}/{loc_settings_path.name}", return_data=True
f"{remote_dir}/{SETTINGS_PATH.name}", return_data=True
)
assert (
loc_settings_path.read_bytes() == Path(tmp.file.name).read_bytes()
SETTINGS_PATH.read_bytes() == Path(tmp.file.name).read_bytes()
), "Local file is different from the received one"
assert (
loc_settings_path.read_bytes() == data
SETTINGS_PATH.read_bytes() == data
), "Local file is different from the received one (return_data=True)"
assert data == Path(tmp.file.name).read_bytes(), "Received files do not match"

Expand Down
33 changes: 16 additions & 17 deletions tests/functional/test_satlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from broker.hosts import Host
from broker.providers.ansible_tower import AnsibleTower
from broker.settings import inventory_path
from broker.settings import settings_path as SETTINGS_PATH

SCENARIO_DIR = Path("tests/data/cli_scenarios/satlab")

Expand Down Expand Up @@ -69,21 +70,20 @@ def test_tower_host():
with Broker(workflow="deploy-rhel") as r_host:
res = r_host.execute("hostname")
assert res.stdout.strip() == r_host.hostname
loc_settings_path = Path("broker_settings.yaml")
remote_dir = "/tmp/fake"
r_host.session.sftp_write(loc_settings_path.name, f"{remote_dir}/", ensure_dir=True)
r_host.session.sftp_write(str(SETTINGS_PATH), f"{remote_dir}/", ensure_dir=True)
res = r_host.execute(f"ls {remote_dir}")
assert str(loc_settings_path) in res.stdout
assert SETTINGS_PATH.name in res.stdout
with NamedTemporaryFile() as tmp:
r_host.session.sftp_read(f"{remote_dir}/{loc_settings_path.name}", tmp.file.name)
r_host.session.sftp_read(f"{remote_dir}/{SETTINGS_PATH.name}", tmp.file.name)
data = r_host.session.sftp_read(
f"{remote_dir}/{loc_settings_path.name}", return_data=True
f"{remote_dir}/{SETTINGS_PATH.name}", return_data=True
)
assert (
loc_settings_path.read_bytes() == Path(tmp.file.name).read_bytes()
SETTINGS_PATH.read_bytes() == Path(tmp.file.name).read_bytes()
), "Local file is different from the received one"
assert (
loc_settings_path.read_bytes() == data
SETTINGS_PATH.read_bytes() == data
), "Local file is different from the received one (return_data=True)"
assert data == Path(tmp.file.name).read_bytes(), "Received files do not match"
# test the tail_file context manager
Expand All @@ -100,28 +100,27 @@ def test_tower_host_mp():
for r_host in r_hosts:
res = r_host.execute("hostname")
assert res.stdout.strip() == r_host.hostname
loc_settings_path = Path("broker_settings.yaml")
remote_dir = "/tmp/fake"
r_host.session.sftp_write(loc_settings_path.name, f"{remote_dir}/", ensure_dir=True)
r_host.session.sftp_write(str(SETTINGS_PATH), f"{remote_dir}/", ensure_dir=True)
res = r_host.execute(f"ls {remote_dir}")
assert str(loc_settings_path) in res.stdout
assert SETTINGS_PATH.name in res.stdout
with NamedTemporaryFile() as tmp:
r_host.session.sftp_read(f"{remote_dir}/{loc_settings_path.name}", tmp.file.name)
r_host.session.sftp_read(f"{remote_dir}/{SETTINGS_PATH.name}", tmp.file.name)
data = r_host.session.sftp_read(
f"{remote_dir}/{loc_settings_path.name}", return_data=True
f"{remote_dir}/{SETTINGS_PATH.name}", return_data=True
)
assert (
loc_settings_path.read_bytes() == Path(tmp.file.name).read_bytes()
SETTINGS_PATH.read_bytes() == Path(tmp.file.name).read_bytes()
), "Local file is different from the received one"
assert (
loc_settings_path.read_bytes() == data
SETTINGS_PATH.read_bytes() == data
), "Local file is different from the received one (return_data=True)"
assert data == Path(tmp.file.name).read_bytes(), "Received files do not match"
# test remote copy from one host to another
r_hosts[0].session.remote_copy(
source=f"{remote_dir}/{loc_settings_path.name}",
source=f"{remote_dir}/{SETTINGS_PATH.name}",
dest_host=r_hosts[1],
dest_path=f"/root/{loc_settings_path.name}",
dest_path=f"/root/{SETTINGS_PATH.name}",
)
res = r_hosts[1].execute(f"ls /root")
assert loc_settings_path.name in res.stdout
assert SETTINGS_PATH.name in res.stdout

0 comments on commit 5fa99d9

Please sign in to comment.