Skip to content

Commit a70775e

Browse files
author
Timothy MacDonald
authored
test: retry failing tests and enable slack notification (#164)
Signed-off-by: Timothy MacDonald <[email protected]>
1 parent 5a6800f commit a70775e

17 files changed

+30
-14
lines changed

.github/workflows/python-test.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ jobs:
5555
LW_API_KEY: ${{ secrets.LW_API_KEY }}
5656
LW_API_SECRET: ${{ secrets.LW_API_SECRET }}
5757
LW_BASE_DOMAIN: ${{ secrets.LW_BASE_DOMAIN }}
58-
# - name: Report Status
59-
# if: always()
60-
# uses: ravsamhq/notify-slack-action@v2
61-
# with:
62-
# status: ${{ job.status }}
63-
# notify_when: "failure"
64-
# notification_title: "{workflow} has {status_message}"
65-
# message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
66-
# footer: "Linked Repo <{repo_url}|{repo}> | <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow>"
67-
# env:
68-
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
58+
- name: Report Status
59+
if: always()
60+
uses: ravsamhq/notify-slack-action@v2
61+
with:
62+
status: ${{ job.status }}
63+
notify_when: "failure"
64+
notification_title: "{workflow} has {status_message}"
65+
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
66+
footer: "Linked Repo <{repo_url}|{repo}> | <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow>"
67+
env:
68+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

tests/api/v2/test_agent_access_tokens.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def test_api_create(self):
3333
Agent Access Tokens shouldn't be created with tests
3434
"""
3535

36+
@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
3637
@pytest.mark.order("first")
3738
def test_api_get_by_id(self, api_object):
3839
self._get_object_classifier_test(api_object, "id", self.OBJECT_ID_NAME)

tests/api/v2/test_alert_profiles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def test_api_search(self):
5858
"""
5959
pass
6060

61+
@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
6162
@pytest.mark.order("first")
6263
def test_api_get_by_id(self, api_object):
6364
self._get_object_classifier_test(api_object, "id", self.OBJECT_ID_NAME)

tests/api/v2/test_alert_rules.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class TestAlertRules(CrudEndpoint):
4545
OBJECT_ID_NAME = "mcGuid"
4646
OBJECT_TYPE = AlertRulesAPI
4747

48+
@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
4849
@pytest.mark.order("first")
4950
def test_api_get_by_guid(self, api_object):
5051
self._get_object_classifier_test(api_object, "guid", self.OBJECT_ID_NAME)
@@ -69,4 +70,4 @@ def test_api_search(self, api_object, request):
6970
"returns": [
7071
"filters"
7172
]
72-
})
73+
})

tests/api/v2/test_alerts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ def test_comment(self, api_object):
7070
response = api_object.comment(guid, "Test Comment")
7171
assert "data" in response.keys()
7272

73+
@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to close an alert that isn't allowed
7374
def test_close_fp(self, api_object, open_alerts_filter):
7475
guid = self._search_random_object(api_object, self.OBJECT_ID_NAME, open_alerts_filter)
7576
if guid:
7677
response = api_object.close(guid, 1)
7778
assert "data" in response.keys()
7879

80+
@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to close an alert that isn't allowed
7981
def test_close_other(self, api_object, open_alerts_filter):
8082
guid = self._search_random_object(api_object, self.OBJECT_ID_NAME, open_alerts_filter)
8183
if guid:

tests/api/v2/test_container_registries.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class TestContainerRegistries(CrudEndpoint):
4141
OBJECT_ID_NAME = "intgGuid"
4242
OBJECT_TYPE = ContainerRegistriesAPI
4343

44+
@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
4445
@pytest.mark.order("first")
4546
def test_api_get_by_guid(self, api_object):
4647
self._get_object_classifier_test(api_object, "guid", self.OBJECT_ID_NAME)

tests/api/v2/test_data_export_rules.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class TestDataExportRules(CrudEndpoint):
4444
OBJECT_ID_NAME = "mcGuid"
4545
OBJECT_TYPE = DataExportRulesAPI
4646

47+
@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
4748
@pytest.mark.order("first")
4849
def test_api_get_by_guid(self, api_object):
49-
self._get_object_classifier_test(api_object, "guid", self.OBJECT_ID_NAME)
50+
self._get_object_classifier_test(api_object, "guid", self.OBJECT_ID_NAME)

tests/api/v2/test_policies.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class TestPolicies(CrudEndpoint):
6868
OBJECT_ID_NAME = "policyId"
6969
OBJECT_TYPE = PoliciesAPI
7070

71+
@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
7172
def test_api_get_by_id(self, api_object):
7273
self._get_object_classifier_test(api_object, "id", self.OBJECT_ID_NAME)
7374

tests/api/v2/test_policy_exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def test_api_create(self, api_object, policy_id, api_object_create_body, request
7575

7676
request.config.cache.set(self.OBJECT_ID_NAME, response["data"][self.OBJECT_ID_NAME])
7777

78+
@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
7879
@pytest.mark.order("first")
7980
def test_api_get_by_guid(self, api_object, policy_id, policy_exception_id):
8081
response = api_object.get(policy_exception_id, policy_id)

tests/api/v2/test_queries.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class TestQueries(CrudEndpoint):
5454
OBJECT_ID_NAME = "queryId"
5555
OBJECT_TYPE = QueriesAPI
5656

57+
@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
5758
@pytest.mark.order("first")
5859
def test_api_get_by_id(self, api_object):
5960
self._get_object_classifier_test(api_object, "id", self.OBJECT_ID_NAME)

0 commit comments

Comments
 (0)