Skip to content

Commit

Permalink
Merge pull request #2546 from wazuh/2236-reduce-skipping-time-analysi…
Browse files Browse the repository at this point in the history
…sd-tier0
  • Loading branch information
Rebits committed Mar 22, 2022
2 parents 13db0b8 + 051c137 commit 9f92730
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
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://github.com/wazuh/wazuh-qa/pull/2409))
- Migrate test_remoted documentation to schema 2.0 ([#2426](https://github.com/wazuh/wazuh-qa/pull/2426))
- Fix FIM test: Replace callback_generator function to generate_monitoring_callback ([#2535](https://github.com/wazuh/wazuh-qa/pull/2535))
- Analysisd: Reduce execution time of tests with tier 0 ([#2546](https://github.com/wazuh/wazuh-qa/pull/2546))

### Deleted
- Delete FIM tests deprecated ([#2200](https://github.com/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

0 comments on commit 9f92730

Please sign in to comment.