Skip to content

Commit

Permalink
test: retry failing tests and enable slack notification (#164)
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy MacDonald <[email protected]>
  • Loading branch information
tmac1973 authored Feb 21, 2024
1 parent 5a6800f commit a70775e
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 14 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ jobs:
LW_API_KEY: ${{ secrets.LW_API_KEY }}
LW_API_SECRET: ${{ secrets.LW_API_SECRET }}
LW_BASE_DOMAIN: ${{ secrets.LW_BASE_DOMAIN }}
# - name: Report Status
# if: always()
# uses: ravsamhq/notify-slack-action@v2
# with:
# status: ${{ job.status }}
# notify_when: "failure"
# notification_title: "{workflow} has {status_message}"
# message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
# footer: "Linked Repo <{repo_url}|{repo}> | <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow>"
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Report Status
if: always()
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
notify_when: "failure"
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}> | <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow>"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
1 change: 1 addition & 0 deletions tests/api/v2/test_agent_access_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_api_create(self):
Agent Access Tokens shouldn't be created with tests
"""

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_id(self, api_object):
self._get_object_classifier_test(api_object, "id", self.OBJECT_ID_NAME)
Expand Down
1 change: 1 addition & 0 deletions tests/api/v2/test_alert_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def test_api_search(self):
"""
pass

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_id(self, api_object):
self._get_object_classifier_test(api_object, "id", self.OBJECT_ID_NAME)
3 changes: 2 additions & 1 deletion tests/api/v2/test_alert_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class TestAlertRules(CrudEndpoint):
OBJECT_ID_NAME = "mcGuid"
OBJECT_TYPE = AlertRulesAPI

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_guid(self, api_object):
self._get_object_classifier_test(api_object, "guid", self.OBJECT_ID_NAME)
Expand All @@ -69,4 +70,4 @@ def test_api_search(self, api_object, request):
"returns": [
"filters"
]
})
})
2 changes: 2 additions & 0 deletions tests/api/v2/test_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ def test_comment(self, api_object):
response = api_object.comment(guid, "Test Comment")
assert "data" in response.keys()

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

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to close an alert that isn't allowed
def test_close_other(self, api_object, open_alerts_filter):
guid = self._search_random_object(api_object, self.OBJECT_ID_NAME, open_alerts_filter)
if guid:
Expand Down
1 change: 1 addition & 0 deletions tests/api/v2/test_container_registries.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class TestContainerRegistries(CrudEndpoint):
OBJECT_ID_NAME = "intgGuid"
OBJECT_TYPE = ContainerRegistriesAPI

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_guid(self, api_object):
self._get_object_classifier_test(api_object, "guid", self.OBJECT_ID_NAME)
Expand Down
3 changes: 2 additions & 1 deletion tests/api/v2/test_data_export_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class TestDataExportRules(CrudEndpoint):
OBJECT_ID_NAME = "mcGuid"
OBJECT_TYPE = DataExportRulesAPI

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_guid(self, api_object):
self._get_object_classifier_test(api_object, "guid", self.OBJECT_ID_NAME)
self._get_object_classifier_test(api_object, "guid", self.OBJECT_ID_NAME)
1 change: 1 addition & 0 deletions tests/api/v2/test_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class TestPolicies(CrudEndpoint):
OBJECT_ID_NAME = "policyId"
OBJECT_TYPE = PoliciesAPI

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

Expand Down
1 change: 1 addition & 0 deletions tests/api/v2/test_policy_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def test_api_create(self, api_object, policy_id, api_object_create_body, request

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

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_guid(self, api_object, policy_id, policy_exception_id):
response = api_object.get(policy_exception_id, policy_id)
Expand Down
1 change: 1 addition & 0 deletions tests/api/v2/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class TestQueries(CrudEndpoint):
OBJECT_ID_NAME = "queryId"
OBJECT_TYPE = QueriesAPI

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_id(self, api_object):
self._get_object_classifier_test(api_object, "id", self.OBJECT_ID_NAME)
Expand Down
1 change: 1 addition & 0 deletions tests/api/v2/test_report_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def test_api_search(self):
"""
pass

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_id(self, api_object):
self._get_object_classifier_test(api_object, "id", self.OBJECT_ID_NAME)
2 changes: 1 addition & 1 deletion tests/api/v2/test_report_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TestReportRules(CrudEndpoint):
OBJECT_ID_NAME = "mcGuid"
OBJECT_TYPE = ReportRulesAPI

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

1 change: 1 addition & 0 deletions tests/api/v2/test_resource_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class TestResourceGroups(CrudEndpoint):
OBJECT_TYPE = ResourceGroupsAPI
OBJECT_PARAM_EXCEPTIONS = ["props"]

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_guid(self, api_object):
response = api_object.get()
Expand Down
1 change: 1 addition & 0 deletions tests/api/v2/test_team_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class TestTeamMembers(CrudEndpoint):
OBJECT_ID_NAME = "userGuid"
OBJECT_TYPE = TeamMembersAPI

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_guid(self, api_object):
self._get_object_classifier_test(api_object, "guid", self.OBJECT_ID_NAME)
1 change: 1 addition & 0 deletions tests/api/v2/test_team_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_api_search(self, api_object, request):
"Not implemented"
pass

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_guid(self, api_object):
self._get_object_classifier_test(api_object, "guid", self.OBJECT_ID_NAME)
1 change: 1 addition & 0 deletions tests/api/v2/test_vulnerability_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class TestVulnerabilityExceptions(CrudEndpoint):
OBJECT_ID_NAME = "exceptionGuid"
OBJECT_TYPE = VulnerabilityExceptionsAPI

@pytest.mark.flaky(reruns=10) # Because sometimes this attempts to get an object that has just been deleted
@pytest.mark.order("first")
def test_api_get_by_guid(self, api_object):
self._get_object_classifier_test(api_object, "guid", self.OBJECT_ID_NAME)
1 change: 1 addition & 0 deletions tests/api/v2/test_vulnerability_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class TestVulnerabilityExceptions(CrudEndpoint):
OBJECT_ID_NAME = "policyGuid"
OBJECT_TYPE = VulnerabilityPoliciesAPI

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

0 comments on commit a70775e

Please sign in to comment.