8000 Enable testing with ansible-core devel branch by ssbarnea · Pull Request #1967 · ansible/ansible-navigator · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Enable testing with ansible-core devel branch #1967

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

Draft
wants to merge 2 commits into
base: main
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
1 change: 1 addition & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
other_names: |
lint
docs
devel
platforms: linux,macos
tox:
name: ${{ matrix.name }} / python ${{ matrix.python_version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ansible-navigator:
execution-environment:
environment-variables:
set:
ANSIBLE_COLLECTIONS_PATHS: /tmp/collections
ANSIBLE_COLLECTIONS_PATH: /tmp/collections
exec:
command: echo test_data_from_config
shell: False
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"comment": "ensure env vars get set from config",
"additional_information": {
"present": [
"ANSIBLE_COLLECTIONS_PATHS=/tmp/collections"
"ANSIBLE_COLLECTIONS_PATH=/tmp/collections"
],
"absent": [],
"compared_fixture": false
Expand All @@ -25,7 +25,7 @@
"ANSIBLE_NAVIGATOR_PULL_POLICY=never",
"ANSIBLE_STDOUT_CALLBACK=awx_display",
"ANSIBLE_NAVIGATOR_PLAYBOOK_ARTIFACT_SAVE_AS=./.test_logs/tests/integration/actions/exec/test_stdout_config_file.py/playbook-artifact.log",
"ANSIBLE_COLLECTIONS_PATHS=/tmp/collections",
"ANSIBLE_COLLECTIONS_PATH=/tmp/collections",
"TERM=xterm",
"LAUNCHED_BY_RUNNER=1",
"ANSIBLE_NAVIGATOR_CONFIG=/home/user/github/ansible-navigator/tests/fixtures/integration/actions/exec/ansible-navigator.yaml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"comment": "ensure env vars get set from config",
"additional_information": {
"present": [
"ANSIBLE_COLLECTIONS_PATHS=/tmp/collections"
"ANSIBLE_COLLECTIONS_PATH=/tmp/collections"
],
"absent": [],
"compared_fixture": false
},
"output": [
"ANSIBLE_DEV_TOOLS_CONTAINER=1",
"ANSIBLE_COLLECTIONS_PATHS=/tmp/collections",
"ANSIBLE_COLLECTIONS_PATH=/tmp/collections",
"PWD=/home/user/github/ansible-navigator",
"PIP_BREAK_SYSTEM_PACKAGES=1",
"ANSIBLE_NAVIGATOR_PLAYBOOK_ARTIFACT_SAVE_AS=/home/user/github/ansible-navigator/.test_logs/integration/actions/exec/test_stdout_file.py/test_stdout_file_py/ansible-navigator.log/playbook-artifact.log",
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/actions/exec/test_stdout_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ShellCommand(UiTestStep):
cmdline="/bin/env",
execution_environment=True,
).join(),
present=["ANSIBLE_COLLECTIONS_PATHS=/tmp/collections"],
present=["ANSIBLE_COLLECTIONS_PATH=/tmp/collections"],
),
)

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/actions/run/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
UiTestStep(user_input=":1", comment="play-2 task-2 details"),
UiTestStep(user_input=":back", comment="play-2 details"),
UiTestStep(user_input=":back", comment="all play details"),
UiTestStep(user_input=":st", comment="display stream"),
UiTestStep(user_input=":st", comment="display stream", present=["Successful"]),
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

cmdline = (
f&quo 1E0A t;{PLAYBOOK_COLLECTION} --eev {common_fixture_dir}:{common_fixture_dir}"
f" --senv ANSIBLE_COLLECTIONS_PATHS={common_fixture_dir}"
f" --senv ANSIBLE_COLLECTIONS_PATH={common_fixture_dir}"
)
CLI = Command(subcommand="run", cmdline=cmdline, execution_environment=True).join()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
subcommand="run",
cmdline=cmdline,
execution_environment=False,
precommand=f"ANSIBLE_COLLECTIONS_PATHS={common_fixture_dir}",
precommand=f"ANSIBLE_COLLECTIONS_PATH={common_fixture_dir}",
).join()

initial_steps = (
UiTestStep(
user_input=CLI,
comment="ansible-navigator run playbook",
search_within_response=["Complete", "Successful"],
present=["run integration test play-1", "run integration test play-2"],
),
)

Expand Down
46 changes: 32 additions & 14 deletions tests/integration/actions/stdout/base.py
10000
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from tests.defaults import FIXTURES_DIR
from tests.integration._common import retrieve_fixture_for_step
from tests.integration._common import update_fixtures
from tests.integration._interactions import SearchFor
from tests.integration._interactions import UiTestStep
from tests.integration._tmux_session import TmuxSession
from tests.integration._tmux_session import TmuxSessionKwargs

Expand All @@ -19,6 +21,8 @@
ANSIBLE_PLAYBOOK = TEST_FIXTURE_DIR / "site.yml"
TEST_CONFIG_FILE = TEST_FIXTURE_DIR / "ansible-navigator.yml"

base_steps = UiTestStep(user_input=":0", comment="play-1 details")


class BaseClass:
"""Base class for stdout interactive stdout."""
Expand Down Expand Up @@ -52,37 +56,51 @@ def test(
self,
request: pytest.FixtureRequest,
tmux_session: TmuxSession,
index: int,
user_input: str,
comment: str,
search_within_response: str,
step: UiTestStep,
skip_if_already_failed: None,
) -> None:
# pylint:disable=too-many-arguments
"""Run the tests for stdout, mode and EE set in child class.

Args:
request: A fixture providing details about the test caller
tmux_session: The tmux session to use
index: The test index
user_input: Value to send to the tmux session
comment: Comment to add to the fixture
search_within_response: A list of strings or string to find
step: The commands to issue and content to look for
skip_if_already_failed: Fixture that stops parametrized tests running on first failure.
"""
assert ANSIBLE_PLAYBOOK.exists()
assert TEST_CONFIG_FILE.exists()

received_output = tmux_session.interaction(user_input, search_within_response)
search_within_response: str | list[str]
if step.search_within_response is SearchFor.HELP:
search_within_response = ":help help"
elif step.search_within_response is SearchFor.PROMPT:
search_within_response = tmux_session.cli_prompt
elif step.search_within_response is SearchFor.WARNING:
search_within_response = "Warning"
else:
search_within_response = step.search_within_response
received_output = tmux_session.interaction(step.user_input, search_within_response)

index = step.step_index

fixtures_update_requested = (
self.UPDATE_FIXTURES
or os.environ.get("ANSIBLE_NAVIGATOR_UPDATE_TEST_FIXTURES") == "true"
)
if fixtures_update_requested:
update_fixtures(request, index, received_output, comment)
update_fixtures(request, index, received_output, step.comment)

expected_output = retrieve_fixture_for_step(request, index)
assert expected_output == received_output, "\n" + "\n".join(
difflib.unified_diff(expected_output, received_output, "expected", "received"),
)

page = " ".join(received_output)
if step.present:
assert all(present in page for present in step.present)

if step.absent:
assert not any(absent in page for absent in step.absent)

if not any((step.present, step.absent)):
expected_output = retrieve_fixture_for_step(request, step.step_index)
assert expected_output == received_output, "\n" + "\n".join(
difflib.unified_diff(expected_output, received_output, "expected", "received"),
)
37 changes: 30 additions & 7 deletions tests/integration/actions/stdout/test_direct_interactive_ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,45 @@

import pytest

from tests.integration._interactions import UiTestStep

from .base import ANSIBLE_PLAYBOOK
from .base import BaseClass


CLI = f"ansible-navigator run {ANSIBLE_PLAYBOOK} --execution-environment true --ll debug"

testdata = [
pytest.param(0, CLI, "run top window", "Successful", id="0"),
pytest.param(1, ":st", "Check stdout", ":help help", id="1"),
pytest.param(2, ":back", "Return to play list", ":help help", id="2"),
pytest.param(3, ":stdout", "Check stdout", ":help help", id="3"),
pytest.param(4, ":back", "Return to playlist", ":help help", id="4"),

steps = [
UiTestStep(CLI, comment="run top window", step_index=0, search_within_response="Successful"),
UiTestStep(
user_input=":st",
comment="Check stdout",
step_index=1,
search_within_response=":help help",
),
UiTestStep(
user_input=":back",
comment="Return to play list",
step_index=2,
search_within_response=":help help",
),
UiTestStep(
user_input=":stdout",
comment="Check stdout",
step_index=3,
search_within_response=":help help",
),
UiTestStep(
user_input=":back",
comment="Return to playlist",
step_index=4,
search_within_response=":help help",
),
]


@pytest.mark.parametrize(("index", "user_input", "comment", "search_within_response"), testdata)
@pytest.mark.parametrize("step", steps)
class Test(BaseClass):
"""Run the tests for ``stdout`` from CLI, interactive, with EE."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,47 @@

import pytest

from tests.integration._interactions import UiTestStep

from .base import ANSIBLE_PLAYBOOK
from .base import BaseClass


CLI = f"ansible-navigator run {ANSIBLE_PLAYBOOK} --execution-environment false"

testdata = [
pytest.param(0, CLI, "run top window", "Successful", id="0"),
pytest.param(1, ":st", "Check stdout", ":help help", id="1"),
pytest.param(2, ":back", "Return to play list", ":help help", id="2"),
pytest.param(3, ":stdout", "Check stdout", ":help help", id="3"),
pytest.param(4, ":back", "Return to playlist", ":help help", id="4"),

steps = [
UiTestStep(CLI, comment="run top window", step_index=0, search_within_response="Successful"),
UiTestStep(
user_input=":st",
comment="Check stdout",
step_index=1,
search_within_response=":help help",
present=["PLAY [localhost]", "PLAY RECAP"],
),
UiTestStep(
user_input=":back",
comment="Return to play list",
step_index=2,
search_within_response=":help help",
),
UiTestStep(
user_input=":stdout",
comment="Check stdout",
step_index=3,
search_within_response=":help help",
present=["PLAY RECAP", "TASK [debug]"],
),
UiTestStep(
user_input=":back",
comment="Return to playlist",
step_index=4,
search_within_response=":help help",
),
]


@pytest.mark.parametrize(("index", "user_input", "comment", "search_within_response"), testdata)
@pytest.mark.parametrize("step", steps)
class Test(BaseClass):
"""Run the tests for ``stdout`` from CLI, ``interactive``, without an EE."""

Expand Down
55 changes: 44 additions & 11 deletions tests/integration/actions/stdout/test_welcome_interactive_ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,56 @@

import pytest

from tests.integration._interactions import UiTestStep

from .base import ANSIBLE_PLAYBOOK
from .base import BaseClass


CLI = "ansible-navigator --execution-environment true"

testdata = [
pytest.param(0, CLI, "welcome", ":help help", id="0"),
pytest.param(1, f":run {ANSIBLE_PLAYBOOK}", "Play list", "Successful", id="1"),
pytest.param(2, ":st", "Check stdout", ":help help", id="2"),
pytest.param(3, ":back", "Return to play list", ":help help", id="3"),
pytest.param(4, ":stdout", "Check stdout", ":help help", id="4"),
pytest.param(5, ":back", "Return to playlist", ":help help", id="5"),
]


@pytest.mark.parametrize(("index", "user_input", "comment", "search_within_response"), testdata)
steps = (
UiTestStep(
user_input=CLI, comment="welcome screen", step_index=0, search_within_response=":help help"
),
UiTestStep(
user_input=f":run {ANSIBLE_PLAYBOOK}",
comment="Play list",
step_index=1,
search_within_response="Successful",
),
UiTestStep(
user_input=":st",
comment="Check stdout",
step_index=2,
search_within_response=":help help",
present=["PLAY RECAP"],
),
UiTestStep(
user_input=":back",
comment="Return to play list",
step_index=3,
search_within_response=":help help",
present=["Complete", "Successful"],
),
UiTestStep(
user_input=":stdout",
comment="Check stdout",
step_index=4,
search_within_response=":help help",
present=["PLAY RECAP", "TASK [debug]"],
),
UiTestStep(
user_input=":back",
comment="Return to playlist",
step_index=5,
search_within_response=":help help",
present=["Complete", "Successful"],
),
)


@pytest.mark.parametrize("step", steps)
class Test(BaseClass):
"""Run the tests for stdout from welcome, interactive, with an EE."""

Expand Down
Loading
Loading
0