Skip to content

Commit

Permalink
Test: Add smoke test suite and workflow (#481)
Browse files Browse the repository at this point in the history
## πŸ“ Description

https://jira.linode.com/browse/TPT-2054
https://jira.linode.com/browse/TPT-2135

## βœ”οΈ How to Test

make smoketest


## πŸ“· Preview

**If applicable, include a screenshot or code snippet of this change.
Otherwise, please remove this section.**
  • Loading branch information
ykim-akamai authored Jun 29, 2023
1 parent 4ab7b79 commit 33c928e
Show file tree
Hide file tree
Showing 22 changed files with 72 additions and 2 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/nightly-smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Nightly Smoke Tests

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
smoke_tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: dev

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install Python deps
run: pip install -r requirements.txt -r requirements-dev.txt wheel boto3

- name: Install Linode CLI
run: make install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run smoke tests
run: |
make smoketest
env:
LINODE_CLI_TOKEN: ${{ secrets.LINODE_TOKEN_2 }}
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ build: clean

.PHONY: requirements
requirements:
pip3 install -r requirements.txt
pip3 install -r requirements.txt -r requirements-dev.txt

.PHONY: lint
lint: build
Expand Down Expand Up @@ -79,3 +79,7 @@ autoflake:

.PHONY: format
format: black isort autoflake

@PHONEY: smoketest
smoketest:
pytest -m smoke tests/integration --disable-warnings
4 changes: 4 additions & 0 deletions tests/integration/cli/test_help.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest

from tests.integration.helpers import exec_test_command


@pytest.mark.smoke
def test_help_page_for_non_aliased_actions():
process = exec_test_command(["linode-cli", "linodes", "list", "--help"])
output = process.stdout.decode()
Expand All @@ -14,6 +17,7 @@ def test_help_page_for_non_aliased_actions():
assert "--tags" in output


@pytest.mark.smoke
def test_help_page_for_aliased_actions():
process = exec_test_command(["linode-cli", "linodes", "ls", "--help"])
output = process.stdout.decode()
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/domains/test_domain_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def domain_records_setup():
delete_target_id(target="domains", id=domain_id)


@pytest.mark.smoke
def test_create_a_domain(create_master_domain):
# Current domain list
process = exec_test_command(
Expand All @@ -86,6 +87,7 @@ def test_create_a_domain(create_master_domain):
)


@pytest.mark.smoke
def test_create_domain_srv_record(domain_records_setup):
domain_id = domain_records_setup[0]

Expand Down Expand Up @@ -135,6 +137,7 @@ def test_list_srv_record(domain_records_setup):
)


@pytest.mark.smoke
def test_view_domain_record(domain_records_setup):
domain_id = domain_records_setup[0]
record_id = domain_records_setup[1]
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/domains/test_domains_tags.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import re
import time

import pytest

from tests.integration.helpers import (
delete_tag,
delete_target_id,
Expand Down Expand Up @@ -57,7 +59,7 @@ def test_fail_to_create_slave_domain_with_invalid_tags():
)


# @pytest.mark.skip(reason="BUG 943")
@pytest.mark.smoke
def test_create_master_domain_with_tags():
timestamp = str(int(time.time()))
tag = "foo"
Expand Down
1 change: 1 addition & 0 deletions tests/integration/domains/test_master_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def test_create_master_domain_fails_without_soa_email():
assert "soa_email soa_email required when type=master" in result


@pytest.mark.smoke
def test_create_master_domain(create_master_domain):
domain_id = create_master_domain
assert re.search("[0-9]+", domain_id)
Expand Down
1 change: 1 addition & 0 deletions tests/integration/domains/test_slave_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def test_create_slave_domain_fails_without_master_dns_server():
)


@pytest.mark.smoke
def test_create_slave_domain(create_slave_domain):
domain_id = create_slave_domain
assert re.search("[0-9]+", domain_id)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/events/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_print_events_usage_information():
assert re.search("view.*Event View", output)


@pytest.mark.smoke
def test_list_events():
process = exec_test_command(
BASE_CMD + ["list", "--text", "--no-headers", "--delimiter", ","]
Expand Down Expand Up @@ -115,6 +116,7 @@ def test_mark_event_seen():
assert re.search("[0-9]+,.*,.*,[0-9]+-[0-9][0-9]-.*,.*,[a-z]+.*", result)


@pytest.mark.smoke
def test_mark_event_read():
event_id = (
exec_test_command(
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/firewalls/test_firewalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def firewalls_setup():
delete_target_id(target="firewalls", id=firewall_id)


@pytest.mark.smoke
def test_view_firewall(firewalls_setup):
firewall_id = firewalls_setup

Expand Down Expand Up @@ -78,6 +79,7 @@ def test_list_firewall(firewalls_setup):
assert re.search(firewall_id + "," + FIREWALL_LABEL + ",enabled", result)


@pytest.mark.smoke
def test_create_firewall_with_minimum_required_args():
timestamp = str(int(time.time()))
firewall_label = "label-fw-test" + timestamp
Expand Down
1 change: 1 addition & 0 deletions tests/integration/image/test_plugin_image_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def test_invalid_file(
assert f"No file at {file_path}" in output


@pytest.mark.smoke
@pytest.mark.skipif(platform == "win32", reason="Test N/A on Windows")
def test_file_upload(
fake_image_file,
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/kernels/test_kernels.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import re

import pytest

from tests.integration.helpers import exec_test_command

BASE_CMD = ["linode-cli", "kernels", "list", "--text", "--no-headers"]
Expand Down Expand Up @@ -35,6 +37,7 @@ def test_fields_from_kernels_list():
)


@pytest.mark.smoke
def test_view_kernel():
process = exec_test_command(BASE_CMD + ["--format", "id"])
output = process.stdout.decode()
Expand Down
1 change: 1 addition & 0 deletions tests/integration/linodes/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def test_create_linode_with_backup_disabled(create_linode_setup):
assert re.search(linode_id + ",False", result)


@pytest.mark.smoke
def test_enable_backups(create_linode_setup):
# get linode id
linode_id = create_linode_setup
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/linodes/test_linodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def test_update_linode_with_a_image():
assert "--image" not in result


@pytest.mark.smoke
def test_create_linodes_with_a_label(create_linode_with_label):
result = create_linode_with_label

Expand All @@ -71,6 +72,7 @@ def test_create_linodes_with_a_label(create_linode_with_label):
)


@pytest.mark.smoke
def test_view_linode_configuration(setup_linodes):
linode_id = setup_linodes
result = exec_test_command(
Expand Down
1 change: 1 addition & 0 deletions tests/integration/linodes/test_power_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def create_linode_in_running_state():
delete_target_id("linodes", linode_id)


@pytest.mark.smoke
def test_create_linode_and_boot(setup_power_status):
linode_id = setup_power_status

Expand Down
1 change: 1 addition & 0 deletions tests/integration/lke/test_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def setup_test_clusters():
remove_lke_clusters()


@pytest.mark.smoke
def test_deploy_an_lke_cluster():
timestamp = str(int(time.time()) + randint(10, 1000))
label = "cluster_test" + timestamp
Expand Down
1 change: 1 addition & 0 deletions tests/integration/networking/test_networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def test_display_ips_for_available_linodes(setup_test_networking):
)


@pytest.mark.smoke
def test_view_an_ip_address(setup_test_networking):
linode_id = setup_test_networking
linode_ipv4 = exec_test_command(
Expand Down
1 change: 1 addition & 0 deletions tests/integration/nodebalancers/test_node_balancers.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def test_fail_to_create_nodebalancer_without_region():
assert "region region is required" in result


@pytest.mark.smoke
def test_create_nodebalancer_with_default_conf(
create_nodebalancer_with_default_conf,
):
Expand Down
1 change: 1 addition & 0 deletions tests/integration/ssh/test_plugin_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def test_ssh_instance_provisioning(target_instance: Dict[str, Any]):
assert "is not running" in output


@pytest.mark.smoke
@pytest.mark.skipif(platform == "win32", reason="Test N/A on Windows")
def test_ssh_instance_ready(
ssh_key_pair_generator, target_instance: Dict[str, Any]
Expand Down
1 change: 1 addition & 0 deletions tests/integration/stackscripts/test_stackscripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def test_view_private_stackscript():
)


@pytest.mark.smoke
def test_update_stackscript_compatible_image(create_stackscript):
images = get_linode_image_lists()
private_stackscript = create_stackscript
Expand Down
1 change: 1 addition & 0 deletions tests/integration/tags/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def test_create_tag():
yield unique_tag


@pytest.mark.smoke
def test_view_unique_tag(test_create_tag):
result = exec_test_command(
BASE_CMD + ["list", "--text", "--no-headers"]
Expand Down
1 change: 1 addition & 0 deletions tests/integration/users/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def test_display_users():
exec_test_command(BASE_CMD + ["list"])


@pytest.mark.smoke
@pytest.mark.usefixtures("test_create_user")
def test_view_user():
exec_test_command(BASE_CMD + ["view", unique_user])
1 change: 1 addition & 0 deletions tests/integration/volumes/test_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def test_list_volume(setup_test_volumes):
)


@pytest.mark.smoke
def test_view_single_volume(setup_test_volumes):
volume_id = setup_test_volumes
result = exec_test_command(
Expand Down

0 comments on commit 33c928e

Please sign in to comment.