Skip to content

Commit

Permalink
test: Update smoke test coverage and improve nightly test workflow (#452
Browse files Browse the repository at this point in the history
)

* update smoke test coverage and workflow

* make format lint

* Replace webhook with slack oauth token

* Add fancy slack payload

* Clean up slack payload syntax

* Clean up slack payload syntax

* fix invalid slack payload syntax

* fix invalid slack payload syntax

* setting payload variable in separate step

* fix slack payload syntax

* fix slack payload syntax

* fix slack payload syntax

* fix slack payload syntax

* add repository name in slack payload

* add slack notifications and conditions
  • Loading branch information
ykim-1 authored Sep 26, 2024
1 parent 77dde13 commit e2b8c46
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,69 @@ jobs:
env:
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}

notify-slack:
runs-on: ubuntu-latest
needs: [integration-tests]
if: always() && github.repository == 'linode/linode_api4-python' # Run even if integration tests fail and only on main repository

steps:
- name: Notify Slack
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:"
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Build Result:*\n${{ steps.integration-tests.outcome == 'success' && ':large_green_circle: Build Passed' || ':red_circle: Build Failed' }}"
},
{
"type": "mrkdwn",
"text": "*Branch:*\n`${{ github.ref_name }}`"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Commit Hash:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>"
},
{
"type": "mrkdwn",
"text": "*Run URL:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run Details>"
}
]
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Triggered by: :bust_in_silhouette: `${{ github.actor }}`"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
71 changes: 71 additions & 0 deletions .github/workflows/nightly-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
inputs:
sha:
description: 'Commit SHA to test'
required: false
default: ''
type: string


jobs:
smoke_tests:
if: github.repository == 'linode/linode_api4-python' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

steps:
Expand All @@ -29,7 +37,70 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run smoke tests
id: smoke_tests
run: |
make smoketest
env:
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}

- name: Notify Slack
if: always() && github.repository == 'linode/linode_api4-python'
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:"
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Build Result:*\n${{ steps.smoke_tests.outcome == 'success' && ':large_green_circle: Build Passed' || ':red_circle: Build Failed' }}"
},
{
"type": "mrkdwn",
"text": "*Branch:*\n`${{ github.ref_name }}`"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Commit Hash:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>"
},
{
"type": "mrkdwn",
"text": "*Run URL:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run Details>"
}
]
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Triggered by: :bust_in_silhouette: `${{ github.actor }}`"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

1 change: 1 addition & 0 deletions test/integration/login_client/test_login_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def test_oauth_client_two(test_linode_client):
oauth_client.delete()


@pytest.mark.smoke
def test_get_oathclient(test_linode_client, test_oauth_client):
client = test_linode_client

Expand Down
1 change: 1 addition & 0 deletions test/integration/models/lke/test_lke.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def test_get_lke_clusters(test_linode_client, lke_cluster):
assert cluster._raw_json == lke_cluster._raw_json


@pytest.mark.smoke
def test_get_lke_pool(test_linode_client, lke_cluster):
cluster = lke_cluster

Expand Down
1 change: 1 addition & 0 deletions test/integration/models/nodebalancer/test_nodebalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def test_create_nb_node(
assert "node_test" == node.label


@pytest.mark.smoke
def test_get_nb_node(test_linode_client, create_nb_config):
node = test_linode_client.load(
NodeBalancerNode,
Expand Down
1 change: 1 addition & 0 deletions test/integration/models/object_storage/test_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def test_bucket(
assert any(b.label == bucket.label for b in buckets)


@pytest.mark.smoke
def test_list_obj_storage_bucket(
test_linode_client: LinodeClient,
bucket: ObjectStorageBucket,
Expand Down
4 changes: 4 additions & 0 deletions test/integration/models/placement/test_placement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest

from linode_api4 import PlacementGroup


@pytest.mark.smoke
def test_get_pg(test_linode_client, create_placement_group):
"""
Tests that a Placement Group can be loaded.
Expand All @@ -9,6 +12,7 @@ def test_get_pg(test_linode_client, create_placement_group):
assert pg.id == create_placement_group.id


@pytest.mark.smoke
def test_update_pg(test_linode_client, create_placement_group):
"""
Tests that a Placement Group can be updated successfully.
Expand Down
2 changes: 2 additions & 0 deletions test/integration/models/profile/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from linode_api4.objects import PersonalAccessToken, Profile, SSHKey


@pytest.mark.smoke
def test_user_profile(test_linode_client):
client = test_linode_client

Expand All @@ -20,6 +21,7 @@ def test_get_personal_access_token_objects(test_linode_client):
assert isinstance(personal_access_tokens[0], PersonalAccessToken)


@pytest.mark.smoke
@pytest.mark.flaky(reruns=3, reruns_delay=2)
def test_get_sshkeys(test_linode_client, test_sshkey):
client = test_linode_client
Expand Down
3 changes: 3 additions & 0 deletions test/integration/models/vpc/test_vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
from linode_api4 import VPC, ApiError, VPCSubnet


@pytest.mark.smoke
def test_get_vpc(test_linode_client, create_vpc):
vpc = test_linode_client.load(VPC, create_vpc.id)
test_linode_client.vpcs()
assert vpc.id == create_vpc.id


@pytest.mark.smoke
def test_update_vpc(test_linode_client, create_vpc):
vpc = create_vpc
new_label = create_vpc.label + "-updated"
Expand All @@ -33,6 +35,7 @@ def test_get_subnet(test_linode_client, create_vpc_with_subnet):
assert loaded_subnet.id == subnet.id


@pytest.mark.smoke
def test_update_subnet(test_linode_client, create_vpc_with_subnet):
vpc, subnet = create_vpc_with_subnet
new_label = subnet.label + "-updated"
Expand Down

0 comments on commit e2b8c46

Please sign in to comment.