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

Conversation

mauromalara
Copy link
Contributor

@mauromalara mauromalara commented Feb 3, 2022

Related issue
#2236

Description

This PR closes #2236. This PR adds reduce the time execution of the tests marked with tier and skipped.

The changes made are:

Deleted

  • The old pytest_runtest_setup hook implementation has been deleted

Added

  • The pytest_collection_modifyitems hook has been implemented, which deselects all the tests that do not match the tier passed as a parameter when launching pytest.

DoD

  • Python codebase satisfies PEP-8 style style guide. pycodestyle --max-line-length=120 --show-source --show-pep8 file.py.

Tests

  • Analysisd tests with tier 0 passed and the skipped ones take less than ~12 minutes.

Outputs

Analysisd tests with tier 0

============================= test session starts ==============================
platform linux -- Python 3.6.8, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 -- /bin/python3
cachedir: .pytest_cache
metadata: {'Python': '3.6.8', 'Platform': 'Linux-3.10.0-693.11.6.el7.x86_64-x86_64-with-centos-7.4.1708-Core', 'Packages': {'pytest': '6.2.2', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins': {'metadata': '1.8.0', 'testinfra': '5.0.0', 'html': '3.1.1'}}
rootdir: /tmp/Test_integration_B19987_20220203205634/tests/integration, configfile: pytest.ini
plugins: metadata-1.8.0, testinfra-5.0.0, html-3.1.1
collecting ... collected 57159 items / 57132 deselected / 27 selected

test_analysisd/test_error_messages/test_error_messages.py::test_error_messages[Event message errors] PASSED [  3%]
test_analysisd/test_error_messages/test_error_messages.py::test_error_messages[dbsync errors] PASSED [  7%]
test_analysisd/test_event_messages/test_event_messages.py::test_event_messages[Add] PASSED [ 11%]
test_analysisd/test_event_messages/test_event_messages.py::test_event_messages[Modify] PASSED [ 14%]
test_analysisd/test_event_messages/test_event_messages.py::test_event_messages[Delete] PASSED [ 18%]
test_analysisd/test_event_messages/test_event_messages.py::test_event_messages[Modify - Large inodes] PASSED [ 22%]
test_analysisd/test_integrity_messages/test_integrity_messages.py::test_integrity_messages[Integrity_check_global] PASSED [ 25%]
test_analysisd/test_integrity_messages/test_integrity_messages.py::test_integrity_messages[Integrity_check_left] PASSED [ 29%]
test_analysisd/test_integrity_messages/test_integrity_messages.py::test_integrity_messages[Integrity_check_right] PASSED [ 33%]
test_analysisd/test_integrity_messages/test_integrity_messages.py::test_integrity_messages[Integrity_clear] PASSED [ 37%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test1.xml] PASSED [ 40%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test2.xml] PASSED [ 44%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test3.xml] PASSED [ 48%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test4.xml] PASSED [ 51%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test5.xml] PASSED [ 55%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test6.xml] PASSED [ 59%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test7.xml] PASSED [ 62%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test8.xml] PASSED [ 66%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test9.xml] PASSED [ 70%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test10.xml] PASSED [ 74%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test11.xml] PASSED [ 77%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test12.xml] PASSED [ 81%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test13.xml] PASSED [ 85%]
test_analysisd/test_mitre/test_mitre_check_alert.py::test_mitre_check_alert[/tmp/Test_integration_B19987_20220203205634/tests/integration/test_analysisd/test_mitre/data/test14.xml] PASSED [ 88%]
test_analysisd/test_scan_messages/test_scan_messages.py::test_scan_messages[Scan start] PASSED [ 92%]
test_analysisd/test_scan_messages/test_scan_messages.py::test_scan_messages[Scan end] PASSED [ 96%]
test_analysisd/test_syscollector/test_syscollector_events.py::test_syscollector_events[Test syscollector events-Test syscollector events] SKIPPED [100%]

- generated html file: file:///tmp/Test_integration_B19987_20220203205634/report.html -
========= 26 passed, 1 skipped, 57132 deselected in 606.91s (0:10:06) ==========

@mauromalara mauromalara changed the title fix: Fix tier skipping tests implementation #2236 Analysisd Tier 0: Reduce execution time for skipped tests Feb 3, 2022
@mauromalara mauromalara changed the title Analysisd Tier 0: Reduce execution time for skipped tests Analysisd Tier 0: Reduce execution time Feb 3, 2022
@mauromalara mauromalara changed the title Analysisd Tier 0: Reduce execution time Analysisd: Reduce execution time of tests with tier 0 Feb 3, 2022
@mauromalara
Copy link
Contributor Author

mauromalara commented Feb 3, 2022

03/02/2022

Package

Version Revision Link
4.4.0 0.40400.20220202 package

Testing

Analysisd (TIER 0)

OS Local Jenkins Notes
R1 🟢 🟢 - Build
R2 🟢 🟢 - Build
R3 🟢 🟢 - Build

@Rebits Rebits force-pushed the 2236-reduce-skipping-time-analysisd-tier0 branch from 469ca02 to 29224bb Compare March 21, 2022 14:58
Copy link
Member

@Rebits Rebits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mauromalara
Copy link
Contributor Author

mauromalara commented Mar 21, 2022

Package

Version Revision Link
4.3.0 0.40302.20211123 https://packages-dev.wazuh.com/staging/yum/wazuh-manager-4.3.0-0.40302.20211123.x86_64.rpm

Testing

Analysisd - Before changes

OS Jenkins Notes
R1 🟢 - Build ~ 35m
R2 🟢 - Build ~ 36m
R3 🟢 - Build ~ 37m

Analysisd - After changes

OS Jenkins Notes
R1 🟢 - Build ~ 10m
R2 🟢 - Build ~ 10m
R3 🟢 - Build ~ 10 m

  • 🟢: All pass
  • 🟡: Some warnings
  • 🔴: Some errors/fails
  • 🔵: In progress

Copy link
Member

@Rebits Rebits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Rebits Rebits merged commit 9f92730 into master Mar 22, 2022
@Rebits Rebits deleted the 2236-reduce-skipping-time-analysisd-tier0 branch March 22, 2022 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Analysisd Tier 0 IT execution spend most time skipping tests than running them
2 participants