Skip to content

Commit e98c98a

Browse files
test: parallelised integration tests (#1220)
* test: add one more worker * chore: add parallelism to docker-compose tests * chore: move some polling tests to worker
1 parent 9219959 commit e98c98a

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

.github/workflows/ci-main.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ jobs:
159159
runs-on: ubuntu-latest
160160
if: "contains(needs.integration-tests-check.outputs.commit_message, '[run-int-tests]') || github.ref_name == 'develop'"
161161
timeout-minutes: 120
162+
strategy:
163+
matrix:
164+
index: [1, 2, 3, 4, 5, 6]
162165
steps:
163166
- name: Checkout Project
164167
uses: actions/checkout@v4
@@ -176,7 +179,7 @@ jobs:
176179
- name: run tests
177180
working-directory: integration_tests
178181
run: |
179-
poetry run pytest --splunk_host="localhost" --splunk_password="changeme2" --trap_external_ip="$(hostname -I | cut -d " " -f1)" --sc4snmp_deployment="microk8s"
182+
poetry run pytest --splunk_host="localhost" --splunk_password="changeme2" --trap_external_ip="$(hostname -I | cut -d " " -f1)" --sc4snmp_deployment="microk8s" -m part${{ matrix.index }}
180183
181184
test-integration-compose:
182185
name: Run integration tests in docker compose deployment
@@ -185,6 +188,9 @@ jobs:
185188
runs-on: ubuntu-latest
186189
if: "contains(needs.integration-tests-check.outputs.commit_message, '[run-int-tests]') || github.ref_name == 'develop'"
187190
timeout-minutes: 120
191+
strategy:
192+
matrix:
193+
index: [ 1, 2, 3, 4, 5, 6 ]
188194
steps:
189195
- name: Checkout Project
190196
uses: actions/checkout@v4
@@ -213,4 +219,4 @@ jobs:
213219
- name: run tests
214220
working-directory: integration_tests
215221
run: |
216-
poetry run pytest --splunk_host="localhost" --splunk_password="changeme2" --trap_external_ip="$(hostname -I | cut -d " " -f1)" --sc4snmp_deployment="docker-compose"
222+
poetry run pytest --splunk_host="localhost" --splunk_password="changeme2" --trap_external_ip="$(hostname -I | cut -d " " -f1)" --sc4snmp_deployment="docker-compose" -m part${{ matrix.index }}

integration_tests/test_poller_integration.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
logger = logging.getLogger(__name__)
3838

3939

40+
@pytest.mark.part1
4041
class TestSanity:
4142
def test_poller_integration_event(self, setup_splunk):
4243
logger.info("Integration test for poller event")
@@ -116,6 +117,7 @@ def setup_profile(request):
116117

117118

118119
@pytest.mark.usefixtures("setup_profile")
120+
@pytest.mark.part1
119121
class TestProfiles:
120122
def test_static_profiles_metrics(self, setup_splunk):
121123
search_string = """| mpreview index=netmetrics| spath profiles | search profiles=generic_switch
@@ -177,6 +179,7 @@ def setup_profiles(request):
177179

178180

179181
@pytest.mark.usefixtures("setup_profiles")
182+
@pytest.mark.part1
180183
class TestProfilesWorkflow:
181184
def test_add_new_profile_and_reload(self, setup_splunk):
182185
search_string = """| mpreview index=netmetrics| spath profiles | search profiles=new_profile """
@@ -283,6 +286,7 @@ def setup_smart_profiles(request):
283286

284287

285288
@pytest.mark.usefixtures("setup_smart_profiles")
289+
@pytest.mark.part1
286290
class TestSmartProfiles:
287291
def test_smart_profiles_field(self, setup_splunk):
288292
search_string = """| mpreview index=netmetrics| spath profiles | search profiles=smart_profile_field | search icmpOutDestUnreachs """
@@ -360,6 +364,7 @@ def setup_modify_profile(request):
360364

361365

362366
@pytest.mark.usefixtures("setup_modify_profile")
367+
@pytest.mark.part2
363368
class TestModifyProfilesFrequency:
364369
def test_sanity_frequency_field(self, setup_splunk):
365370
search_string = """| mpreview index=netmetrics earliest=-30s | search profiles=test_modify frequency=5 """
@@ -416,6 +421,7 @@ def test_modify_frequency_field(self, request, setup_splunk):
416421

417422

418423
@pytest.mark.usefixtures("setup_modify_profile")
424+
@pytest.mark.part2
419425
class TestModifyProfilesVarBinds:
420426
def test_sanity_varBinds_field(self, setup_splunk):
421427
search_string = """| mpreview index=netmetrics earliest=-30s | search profiles=test_modify UDP-MIB"""
@@ -527,6 +533,7 @@ def setup_small_walk(request):
527533

528534

529535
@pytest.mark.usefixtures("setup_small_walk")
536+
@pytest.mark.part2
530537
class TestSmallWalk:
531538
def test_check_if_walk_scope_was_smaller(self, setup_splunk):
532539
time.sleep(20)
@@ -583,6 +590,7 @@ def setup_small_walk_with_full_walk_enabled(request):
583590

584591

585592
@pytest.mark.usefixtures("setup_small_walk_with_full_walk_enabled")
593+
@pytest.mark.part2
586594
class TestSmallWalkWithFullWalkEnabled:
587595
def test_check_if_full_walk_is_done_with_profile_set(self, setup_splunk):
588596
time.sleep(20)
@@ -633,6 +641,7 @@ def setup_partial_walk(request):
633641

634642

635643
@pytest.mark.usefixtures("setup_partial_walk")
644+
@pytest.mark.part2
636645
class TestPartialWalk:
637646
def test_check_if_partial_walk_is_done(self, setup_splunk):
638647
time.sleep(20)
@@ -705,6 +714,7 @@ def setup_v3_connection(request):
705714

706715

707716
@pytest.mark.usefixtures("setup_v3_connection")
717+
@pytest.mark.part2
708718
class TestSNMPv3Connection:
709719
def test_snmpv3_walk(self, setup_splunk):
710720
time.sleep(200)
@@ -794,6 +804,7 @@ def setup_groups(request):
794804

795805

796806
@pytest.mark.usefixtures("setup_groups")
807+
@pytest.mark.part3
797808
class TestGroupsInventory:
798809
def test_ip_address_inventory(self, setup_splunk):
799810
time.sleep(20)
@@ -923,6 +934,7 @@ def setup_single_ang_group(request):
923934

924935

925936
@pytest.mark.usefixtures("setup_single_ang_group")
937+
@pytest.mark.part3
926938
class TestIgnoreSingleIfInGroup:
927939
def test_host_from_group(self, request, setup_splunk):
928940
trap_external_ip = request.config.getoption("trap_external_ip")
@@ -1018,6 +1030,7 @@ def setup_single_gt_and_lt_profiles(request):
10181030

10191031

10201032
@pytest.mark.usefixtures("setup_single_gt_and_lt_profiles")
1033+
@pytest.mark.part3
10211034
class TestSingleGtAndLtCorrectCondition:
10221035
def test_gt_profile(self, request, setup_splunk):
10231036
time.sleep(20)
@@ -1109,6 +1122,7 @@ def setup_single_in_and_equals_profiles(request):
11091122

11101123

11111124
@pytest.mark.usefixtures("setup_single_in_and_equals_profiles")
1125+
@pytest.mark.part4
11121126
class TestSingleInAndEqualsCorrectCondition:
11131127
def test_in_profile(self, request, setup_splunk):
11141128
time.sleep(20)
@@ -1203,6 +1217,7 @@ def setup_single_regex_and_options_profiles(request):
12031217

12041218

12051219
@pytest.mark.usefixtures("setup_single_regex_and_options_profiles")
1220+
@pytest.mark.part4
12061221
class TestSingleRegexCorrectCondition:
12071222
def test_regex_profile(self, request, setup_splunk):
12081223
time.sleep(20)
@@ -1302,6 +1317,7 @@ def setup_single_gt_and_lt_profiles_with_negation(request):
13021317

13031318

13041319
@pytest.mark.usefixtures("setup_single_gt_and_lt_profiles_with_negation")
1320+
@pytest.mark.part4
13051321
class TestSingleGtAndLtWithNegationCorrectCondition:
13061322
def test_not_gt_profile(self, request, setup_splunk):
13071323
time.sleep(20)
@@ -1403,6 +1419,7 @@ def setup_single_in_and_equals_profiles_with_negation(request):
14031419

14041420

14051421
@pytest.mark.usefixtures("setup_single_in_and_equals_profiles_with_negation")
1422+
@pytest.mark.part4
14061423
class TestSingleInAndEqualsWithNegationCorrectCondition:
14071424
def test_not_in_profile(self, request, setup_splunk):
14081425
time.sleep(20)
@@ -1504,6 +1521,7 @@ def setup_single_regex_and_options_profiles_with_negation(request):
15041521

15051522

15061523
@pytest.mark.usefixtures("setup_single_regex_and_options_profiles_with_negation")
1524+
@pytest.mark.part5
15071525
class TestSingleRegexWithNegationCorrectCondition:
15081526
def test_not_regex_profile(self, request, setup_splunk):
15091527
time.sleep(20)
@@ -1609,6 +1627,7 @@ def setup_multiple_conditions_profiles(request):
16091627

16101628

16111629
@pytest.mark.usefixtures("setup_multiple_conditions_profiles")
1630+
@pytest.mark.part5
16121631
class TestMultipleCorrectConditions:
16131632
def test_gt_and_equals_profile(self, request, setup_splunk):
16141633
time.sleep(20)
@@ -1720,6 +1739,7 @@ def setup_wrong_conditions_profiles(request):
17201739

17211740

17221741
@pytest.mark.usefixtures("setup_wrong_conditions_profiles")
1742+
@pytest.mark.part5
17231743
class TestWrongConditions:
17241744
def test_wrong_profiles(self, request, setup_splunk):
17251745
time.sleep(20)
@@ -1819,6 +1839,7 @@ def setup_misconfigured_profiles(request):
18191839

18201840

18211841
@pytest.mark.usefixtures("setup_misconfigured_profiles")
1842+
@pytest.mark.part6
18221843
class TestMisconfiguredProfiles:
18231844
def test_wrong_profiles(self, request, setup_splunk):
18241845
time.sleep(20)
@@ -1902,6 +1923,7 @@ def setup_misconfigured_groups(request):
19021923

19031924

19041925
@pytest.mark.usefixtures("setup_misconfigured_groups")
1926+
@pytest.mark.part6
19051927
class TestMisconfiguredGroups:
19061928
def test_wrong_groups(self, request, setup_splunk):
19071929
time.sleep(20)

integration_tests/test_trap_integration.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import logging
1717
import time
1818

19+
import pytest
1920
from pysnmp.hlapi import *
2021

2122
from integration_tests.splunk_test_utils import (
@@ -75,6 +76,7 @@ def send_v3_trap(host, port, object_identity, *var_binds):
7576
logger.error(f"{error_indication}")
7677

7778

79+
@pytest.mark.part6
7880
def test_trap_v1(request, setup_splunk):
7981
trap_external_ip = request.config.getoption("trap_external_ip")
8082
logger.info(f"I have: {trap_external_ip}")
@@ -105,6 +107,7 @@ def test_trap_v1(request, setup_splunk):
105107
assert result_count == 1
106108

107109

110+
@pytest.mark.part6
108111
def test_trap_v2(request, setup_splunk):
109112
trap_external_ip = request.config.getoption("trap_external_ip")
110113
logger.info(f"I have: {trap_external_ip}")
@@ -135,6 +138,7 @@ def test_trap_v2(request, setup_splunk):
135138
assert result_count == 1
136139

137140

141+
@pytest.mark.part6
138142
def test_added_varbind(request, setup_splunk):
139143
trap_external_ip = request.config.getoption("trap_external_ip")
140144
logger.info(f"I have: {trap_external_ip}")
@@ -158,6 +162,7 @@ def test_added_varbind(request, setup_splunk):
158162
assert result_count == 1
159163

160164

165+
@pytest.mark.part6
161166
def test_many_traps(request, setup_splunk):
162167
trap_external_ip = request.config.getoption("trap_external_ip")
163168
logger.info(f"I have: {trap_external_ip}")
@@ -188,6 +193,7 @@ def test_many_traps(request, setup_splunk):
188193
assert result_count == 5
189194

190195

196+
@pytest.mark.part6
191197
def test_more_than_one_varbind(request, setup_splunk):
192198
trap_external_ip = request.config.getoption("trap_external_ip")
193199
logger.info(f"I have: {trap_external_ip}")
@@ -218,6 +224,7 @@ def test_more_than_one_varbind(request, setup_splunk):
218224
assert result_count == 1
219225

220226

227+
@pytest.mark.part6
221228
def test_loading_mibs(request, setup_splunk):
222229
trap_external_ip = request.config.getoption("trap_external_ip")
223230
logger.info(f"I have: {trap_external_ip}")
@@ -245,6 +252,7 @@ def test_loading_mibs(request, setup_splunk):
245252
assert result_count == 1
246253

247254

255+
@pytest.mark.part6
248256
def test_trap_v3(request, setup_splunk):
249257
trap_external_ip = request.config.getoption("trap_external_ip")
250258
deployment = request.config.getoption("sc4snmp_deployment")

0 commit comments

Comments
 (0)