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

Analysisd: Reduce execution time of tests with tier 0 #2546

Merged
merged 4 commits into from
Mar 22, 2022
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Release report: TBD
- Add wpk test documentation ([#2409](https:/wazuh/wazuh-qa/pull/2409))
- Migrate test_remoted documentation to schema 2.0 ([#2426](https:/wazuh/wazuh-qa/pull/2426))
- Fix FIM test: Replace callback_generator function to generate_monitoring_callback ([#2535](https:/wazuh/wazuh-qa/pull/2535))
- Analysisd: Reduce execution time of tests with tier 0 ([#2546](https:/wazuh/wazuh-qa/pull/2546))

### Deleted
- Delete FIM tests deprecated ([#2200](https:/wazuh/wazuh-qa/pull/2200))
Expand Down
34 changes: 16 additions & 18 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,26 @@ def get_report_files():
###############################


def pytest_runtest_setup(item):
# Find if platform applies
supported_platforms = PLATFORMS.intersection(mark.name for mark in item.iter_markers())
plat = sys.platform

if supported_platforms and plat not in supported_platforms:
pytest.skip("Cannot run on platform {}".format(plat))

host_type = 'agent' if 'agent' in get_service() else 'server'
supported_types = HOST_TYPES.intersection(mark.name for mark in item.iter_markers())
if supported_types and host_type not in supported_types:
pytest.skip("Cannot run on wazuh {}".format(host_type))
# Consider only first mark
levels = [mark.kwargs['level'] for mark in item.iter_markers(name="tier")]
if levels and len(levels) > 0:
def pytest_collection_modifyitems(session, config, items):
selected = []
deselected = []
for item in items:
levels = [mark.kwargs['level'] for mark in item.iter_markers(name="tier")]
tiers = item.config.getoption("--tier")
if tiers is not None and levels[0] not in tiers:
pytest.skip(f"test requires tier level {levels[0]}")
deselected.append(item)
continue
elif item.config.getoption("--tier-minimum") > levels[0]:
pytest.skip(f"test requires a minimum tier level {levels[0]}")
deselected.append(item)
continue
elif item.config.getoption("--tier-maximum") < levels[0]:
pytest.skip(f"test requires a maximum tier level {levels[0]}")
deselected.append(item)

else:
selected.append(item)

config.hook.pytest_deselected(items=deselected)
items[:] = selected


@pytest.fixture(scope='module')
Expand Down