Skip to content

tests(vpc): add regression tests and mute instance tests #1046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 36 additions & 34 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- scaleway-core
- scaleway
- scaleway-async
python-version: ['3.10' ,'3.11', '3.12', '3.13']
defaults:
run:
working-directory: ${{ matrix.lib }}
Expand All @@ -23,7 +24,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
pip install poetry
Expand All @@ -49,7 +50,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
pip install poetry
Expand All @@ -75,7 +76,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
pip install poetry
Expand All @@ -88,34 +89,35 @@ jobs:
- name: Check linting
run: poetry run ruff check . --ignore E721 --ignore F541

# tests:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# lib:
# - scaleway-core
# - scaleway
# - scaleway-async
# defaults:
# run:
# working-directory: ${{ matrix.lib }}
# steps:
# - uses: actions/checkout@v4
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: "3.10"
# - name: Install poetry
# run: |
# pip install poetry
# poetry --version
# - name: Install dependencies and library
# run: poetry install
# - name: Run tests
# run: poetry run python -m unittest discover -s tests -v
# env:
# SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
# SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
# SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
# SCW_DEFAULT_REGION: ${{ secrets.SCW_DEFAULT_REGION }}
# SCW_DEFAULT_ZONE: ${{ secrets.SCW_DEFAULT_ZONE }}
tests:
runs-on: ubuntu-latest
strategy:
matrix:
lib:
- scaleway-core
- scaleway
- scaleway-async
defaults:
run:
working-directory: ${{ matrix.lib }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
pip install poetry
poetry --version
- name: Install dependencies and library
run: poetry install
- name: Run tests
env:
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
SCW_DEFAULT_REGION: ${{ secrets.SCW_DEFAULT_REGION }}
run: poetry run python -m unittest discover -s tests -v

1 change: 1 addition & 0 deletions scaleway-async/tests/test_test_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from scaleway_async.test.v1 import EyeColors, Human, HumanStatus, TestV1API


@unittest.skip("API test is not deployed")
class TestTestV1(unittest.IsolatedAsyncioTestCase):
async def asyncSetUp(self) -> None:
client = Client.from_config_file_and_env()
Expand Down
21 changes: 2 additions & 19 deletions scaleway/tests/test_instance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging
import sys
from typing import List
import unittest
import uuid
Expand All @@ -11,10 +9,6 @@
from scaleway.instance.v1.types import Server, VolumeServerTemplate
from scaleway.block.v1alpha1.types import Volume, CreateVolumeRequestFromEmpty

logger = logging.getLogger()
logger.level = logging.DEBUG
stream_handler = logging.StreamHandler(sys.stdout)
logger.addHandler(stream_handler)

server_name = f"test-sdk-python-{uuid.uuid4().hex[:6]}"
max_retry = 10
Expand All @@ -24,10 +18,11 @@
zone = "fr-par-1"


@unittest.skip("Skipping this test temporarily")
class TestE2EServerCreation(unittest.TestCase):
def setUp(self) -> None:
self.zone = zone
self.client = Client.from_config_file_and_env()
self.client = Client.from_env()
self.instanceAPI = InstanceV1API(self.client, bypass_validation=True)
self.blockAPI = BlockV1Alpha1API(self.client, bypass_validation=True)
self._server = None
Expand All @@ -38,14 +33,11 @@ def tearDown(self) -> None:
self.instanceAPI.detach_server_volume(
server_id=self._server.id, volume_id=volume.id
)
logger.info("✅ Volume {volume.id} has been detach")

self.blockAPI.delete_volume(volume_id=volume.id)
logger.info("✅ Volume {volume.id} has been deleted")

if self._server:
self.instanceAPI.delete_server(zone=self.zone, server_id=self._server.id)
logger.info(f"🗑️ Deleted server: {self._server.id}")

def wait_test_instance_server(self, server_id):
interval = interval
Expand All @@ -55,7 +47,6 @@ def wait_test_instance_server(self, server_id):
s = self.instanceAPI.get_server(zone=self.zone, server_id=server_id)

if s.state == "running":
logger.info(f"✅ Server {server_id} is running.")
break

time.sleep(interval)
Expand All @@ -76,7 +67,6 @@ def create_test_instance_server(self) -> Server:
dynamic_ip_required=True,
volumes=volume,
)
logger.info(f"✅ Created server: {server.id}")

self._server = server.server

Expand All @@ -91,7 +81,6 @@ def create_test_from_empty_volume(self, number) -> List[Volume]:
volume = self.blockAPI.create_volume(
from_empty=CreateVolumeRequestFromEmpty(size=10),
)
logger.info("✅ Created server: {volume.id}")

self.blockAPI.wait_for_volume(volume_id=volume.id, zone=self.zone)

Expand All @@ -110,22 +99,16 @@ def test_attach_aditionnal_volume(self):

self.assertIsNotNone(additional_volume.id)
self.assertEqual(additional_volume.size, 10)
logger.info(f"✅ Volume created with ID: {additional_volume.id}")

self.instanceAPI.attach_server_volume(
server_id=server.id, volume_id=additional_volume.id
)

self.blockAPI.wait_for_volume(volume_id=additional_volume.id, zone=self.zone)

logger.info(f"🔗 Attached volume {additional_volume.id} to server {server.id}")

updated_server = self.instanceAPI.get_server(
zone=self.zone, server_id=server.id
)
attached_volumes = updated_server.volumes or {}
attached_volume_ids = [v.volume.id for v in attached_volumes.values()]
self.assertIn(additional_volume.id, attached_volume_ids)
logger.info(
f"✅ Volume {additional_volume.id} is attached to server {server.id}"
)
3 changes: 3 additions & 0 deletions scaleway/tests/test_test_v1_marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ def _assert_raw_and_unmarshalled_human(
raw["updated_at"],
)

@unittest.skip("API test is not deployed")
def test_unmarshal_Human(self) -> None:
data = _mock_human_raw()
human = unmarshal_Human(data)
self._assert_raw_and_unmarshalled_human(data, human)

@unittest.skip("API test is not deployed")
def test_unmarshal_ListHumansResponse(self) -> None:
humans = [_mock_human_raw() for _ in range(10)]
data = {
Expand Down Expand Up @@ -164,6 +166,7 @@ def _assert_create_human_request_and_raw(
self.assertEqual(request.name, raw["name"])
self.assertEqual(request.shoe_size, raw["shoe_size"])

@unittest.skip("API test is not deployed")
def test_marshal_CreateHumanRequest(self) -> None:
request = _mock_create_human_request()
raw = marshal_CreateHumanRequest(request, utils.random_profile_defaults())
Expand Down
2 changes: 1 addition & 1 deletion scaleway/tests/test_total_count_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class TestTotalCountLegacy(unittest.TestCase):
def setUp(self) -> None:
self.client = Client()
self.client = Client.from_env()
self.instance_api = InstanceV1API(self.client, bypass_validation=True)

def test_list_servers_type(self):
Expand Down
91 changes: 91 additions & 0 deletions scaleway/tests/test_vpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import unittest
from scaleway.vpc.v2 import VpcV2API
from scaleway_core.api import ScalewayException
from scaleway_core.client import Client
from scaleway_core.utils import random_name

region = "fr-par"
tags = ["sdk-python", "regression-test"]
created_pn_count = 5
created_vpc_count = 1


class TestScalewayVPCV2(unittest.TestCase):
@classmethod
def setUpClass(self):
self.client = Client.from_env()
self.vpcAPI = VpcV2API(self.client)
self.project_id = self.client.default_project_id
self.region = region
self._pns_to_cleanup = []

self._vpc = self.vpcAPI.create_vpc(
enable_routing=True,
region=self.region,
project_id=self.project_id,
name=random_name("vpc-test-sdk-python"),
)

@classmethod
def tearDownClass(self):
for pn in self._pns_to_cleanup:
self.vpcAPI.delete_private_network(private_network_id=pn.id)

if self._vpc is not None:
self.vpcAPI.delete_vpc(vpc_id=self._vpc.id, region=self.region)

def test_delete_vpc(self):
vpc = self.vpcAPI.create_vpc(
enable_routing=True,
region=self.region,
project_id=self.project_id,
name=random_name("vpc-test-sdk-python"),
)

self.assertIsNotNone(vpc.id)
self.assertEqual(vpc.region, self.region)

self.vpcAPI.delete_vpc(vpc_id=vpc.id)

with self.assertRaises(ScalewayException):
self.vpcAPI.get_vpc(vpc_id=vpc.id)

def test_list_vpcs(self):
vpcs = self.vpcAPI.list_vp_cs(region=self.region)
self.assertIsInstance(vpcs.vpcs, list)
self.assertGreaterEqual(vpcs.total_count, created_vpc_count)

def test_create_private_network(self):
for i in range(created_pn_count):
pn = self.vpcAPI.create_private_network(
vpc_id=self._vpc.id,
default_route_propagation_enabled=True,
project_id=self.project_id,
name=random_name(f"sdk-python-pn-{i}"),
)
self._pns_to_cleanup.append(pn)

self.assertEqual(pn.vpc_id, self._vpc.id)

def test_list_private_network(self):
networks = self.vpcAPI.list_private_networks(region=self.region)
self.assertIsInstance(networks.private_networks, list)
self.assertGreaterEqual(networks.total_count, created_pn_count)

def test_get_vpc(self):
vpc = self.vpcAPI.get_vpc(vpc_id=self._vpc.id, region=self.region)

self.assertIsNotNone(vpc)
self.assertEqual(self._vpc.id, vpc.id)

def test_update_vpc(self):
vpc = self.vpcAPI.update_vpc(vpc_id=self._vpc.id, tags=tags)

self.assertEqual(vpc.tags, tags)
self.assertEqual(self._vpc.id, vpc.id)

def test_list_vpc_all(self):
vpcs = self.vpcAPI.list_vp_cs_all()

self.assertIsInstance(vpcs, list)
self.assertGreaterEqual(len(vpcs), created_vpc_count)