-
Notifications
You must be signed in to change notification settings - Fork 14
tests(vpc): add regression tests and mute instance #1043
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
Closed
Closed
Changes from 6 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
caa6889
add modul
Laure-di af7604d
rm module
Laure-di 5e6138c
feat(tem): add blocklisted flag (#830)
scaleway-bot e8541fd
tests: add regression tests vpc and mute instance
Laure-di c75cd1b
chore: activate tests in workflow
Laure-di d702461
tests: fix client setup
Laure-di a2714f2
tests: remove logs
Laure-di f596866
tests(vpc): check len methods list
Laure-di ce4379e
chore: update python version checks.yml
Laure-di cac0bcd
Delete docs/module.rst
Laure-di 63eb66d
test(vpc): add assert and remove redundant initialization
Laure-di c3d41bd
chore: add python 3.10
Laure-di 8ce47b1
chore: add secrets to env
Laure-di 05390bb
tests(vpc): change init Client method
Laure-di 880b885
tests(vpc): change init Client method
Laure-di 69277f6
tests(vpc): change init Client method
Laure-di File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Laure-di marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import logging | ||
| import sys | ||
| 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 | ||
|
|
||
| logger = logging.getLogger() | ||
| logger.level = logging.DEBUG | ||
| stream_handler = logging.StreamHandler(sys.stdout) | ||
| logger.addHandler(stream_handler) | ||
|
|
||
| region = "fr-par" | ||
| tags = ["sdk-python", "regression-test"] | ||
|
|
||
|
|
||
| class TestScalewayVPCV2(unittest.TestCase): | ||
| @classmethod | ||
| def setUpClass(self): | ||
| self.client = Client.from_config_file_and_env() | ||
| self.vpcAPI = VpcV2API(self.client) | ||
| self.project_id = self.client.default_project_id | ||
| self.region = region | ||
| self._vpc = None | ||
Laure-di marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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"), | ||
| ) | ||
| logger.info(f"✅ VPC {self._vpc.id} has been created") | ||
|
|
||
| @classmethod | ||
| def tearDownClass(self): | ||
| for pn in self._pns_to_cleanup: | ||
| self.vpcAPI.delete_private_network(private_network_id=pn.id) | ||
| logger.info(f"🧹 Deleted Private Network {pn.id}") | ||
|
|
||
| if self._vpc is not None: | ||
| self.vpcAPI.delete_vpc(vpc_id=self._vpc.id, region=self.region) | ||
| logger.info(f"🧹 Deleted VPC {self._vpc.id}") | ||
|
|
||
| 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"), | ||
| ) | ||
| logger.info(f"✅ VPC {vpc.id} has been created") | ||
| self.assertIsNotNone(vpc.id) | ||
| self.assertEqual(vpc.region, self.region) | ||
|
|
||
| self.vpcAPI.delete_vpc(vpc_id=vpc.id) | ||
| logger.info(f"🗑️ VPC {vpc.id} deletion requested") | ||
Laure-di marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| with self.assertRaises(ScalewayException): | ||
| self.vpcAPI.get_vpc(vpc_id=vpc.id) | ||
| logger.info(f"✅ VPC {vpc.id} has been deleted successfully") | ||
|
|
||
| def test_list_vpcs(self): | ||
| vpcs = self.vpcAPI.list_vp_cs(region=self.region).vpcs | ||
| logger.info(f"🔎 Listed {len(vpcs)} VPC(s) in region: {self.region}") | ||
| self.assertIsInstance(vpcs, list) | ||
Laure-di marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def test_create_private_network(self): | ||
| for i in range(5): | ||
| 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"pn-{i}"), | ||
| ) | ||
| self._pns_to_cleanup.append(pn) | ||
| logger.info(f"✅ PN {i + 1}/5: {pn.id} created in VPC {self._vpc.id}") | ||
| self.assertEqual(pn.vpc_id, self._vpc.id) | ||
|
|
||
| def test_list_private_network(self): | ||
| networks = self.vpcAPI.list_private_networks(region=self.region) | ||
| logger.info( | ||
| f"🔎 Listed {networks.total_count} private network(s) in region: {self.region}" | ||
| ) | ||
| self.assertIsInstance(networks.private_networks, list) | ||
|
|
||
| def test_get_vpc(self): | ||
| vpc = self.vpcAPI.get_vpc(vpc_id=self._vpc.id, region=self.region) | ||
| logger.info(f"📥 Retrieved VPC {vpc.id}") | ||
| 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) | ||
| logger.info(f"🛠️ Updated VPC {vpc.id} with 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() | ||
| logger.info(f"📥 Retrieved total of {len(vpcs)} VPC(s) across all regions") | ||
| self.assertIsInstance(vpcs, list) | ||
Laure-di marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.