toil.test.lib.test_ec2¶
Attributes¶
Classes¶
A common base class for Toil tests. |
|
Test accessing the Flatcar AMI release feed, independent of the AWS API |
|
A common base class for Toil tests. |
Functions¶
|
Query AWS for all AMI names matching |
|
Check a Flatcar release feed for the latest flatcar AMI. |
|
Yield AMI IDs for the given architecture from the Flatcar release feed. |
|
Retrieve the flatcar AMI image to use as the base for all Toil autoscaling instances. |
|
Use as a decorator before test classes or methods to run only if AWS EC2 is usable. |
|
Use as a decorator before test classes or methods to run only if we are meant to talk to the Internet. |
Module Contents¶
- toil.test.lib.test_ec2.aws_marketplace_flatcar_ami_search(ec2_client, architecture='amd64')¶
Query AWS for all AMI names matching
Flatcar-stable-*and return the most recent one.
- toil.test.lib.test_ec2.feed_flatcar_ami_release(ec2_client, architecture='amd64', source='stable')¶
Check a Flatcar release feed for the latest flatcar AMI.
Verify it’s on AWS.
- Parameters:
ec2_client (botocore.client.BaseClient) – Boto3 EC2 Client
architecture (str) – The architecture type for the new AWS machine. Can be either amd64 or arm64
source (str) – can be set to a Flatcar release channel (‘stable’, ‘beta’, or ‘alpha’), ‘archive’ to check the Internet Archive for a feed, and ‘toil’ to check if the Toil project has put up a feed.
- Return type:
Optional[str]
- toil.test.lib.test_ec2.flatcar_release_feed_amis(region, architecture='amd64', source='stable')¶
Yield AMI IDs for the given architecture from the Flatcar release feed.
- Parameters:
- Return type:
Iterator[str]
Retries if the release feed cannot be fetched. If the release feed has a permanent error, yields nothing. If some entries in the release feed are unparseable, yields the others.
- toil.test.lib.test_ec2.get_flatcar_ami(ec2_client, architecture='amd64')¶
Retrieve the flatcar AMI image to use as the base for all Toil autoscaling instances.
AMI must be available to the user on AWS (attempting to launch will return a 403 otherwise).
- Priority is:
User specified AMI via TOIL_AWS_AMI
Official AMI from stable.release.flatcar-linux.net
Search the AWS Marketplace
If all of these sources fail, we raise an error to complain.
- class toil.test.lib.test_ec2.ToilTest(methodName='runTest')¶
Bases:
unittest.TestCaseA common base class for Toil tests.
Please have every test case directly or indirectly inherit this one.
When running tests you may optionally set the TOIL_TEST_TEMP environment variable to the path of a directory where you want temporary test files be placed. The directory will be created if it doesn’t exist. The path may be relative in which case it will be assumed to be relative to the project root. If TOIL_TEST_TEMP is not defined, temporary files and directories will be created in the system’s default location for such files and any temporary files or directories left over from tests will be removed automatically removed during tear down. Otherwise, left-over files will not be removed.
- setup_method(method)¶
- Parameters:
method (Any)
- Return type:
None
- classmethod setUpClass()¶
Hook method for setting up class fixture before running tests in the class.
- Return type:
None
- classmethod tearDownClass()¶
Hook method for deconstructing the class fixture after running all tests in the class.
- Return type:
None
- setUp()¶
Hook method for setting up the test fixture before exercising it.
- Return type:
None
- tearDown()¶
Hook method for deconstructing the test fixture after testing it.
- Return type:
None
- toil.test.lib.test_ec2.needs_aws_ec2(test_item)¶
Use as a decorator before test classes or methods to run only if AWS EC2 is usable.
- Parameters:
test_item (MT)
- Return type:
MT
- toil.test.lib.test_ec2.needs_online(test_item)¶
Use as a decorator before test classes or methods to run only if we are meant to talk to the Internet.
- Parameters:
test_item (MT)
- Return type:
MT
- toil.test.lib.test_ec2.logger¶
- class toil.test.lib.test_ec2.FlatcarFeedTest(methodName='runTest')¶
Bases:
toil.test.ToilTestTest accessing the Flatcar AMI release feed, independent of the AWS API
- test_parse_archive_feed()¶
Make sure we can get a Flatcar release from the Internet Archive.
- test_parse_beta_feed()¶
Make sure we can get a Flatcar release from the beta channel.
- test_parse_stable_feed()¶
Make sure we can get a Flatcar release from the stable channel.
- class toil.test.lib.test_ec2.AMITest(methodName='runTest')¶
Bases:
toil.test.ToilTestA common base class for Toil tests.
Please have every test case directly or indirectly inherit this one.
When running tests you may optionally set the TOIL_TEST_TEMP environment variable to the path of a directory where you want temporary test files be placed. The directory will be created if it doesn’t exist. The path may be relative in which case it will be assumed to be relative to the project root. If TOIL_TEST_TEMP is not defined, temporary files and directories will be created in the system’s default location for such files and any temporary files or directories left over from tests will be removed automatically removed during tear down. Otherwise, left-over files will not be removed.
- classmethod setUpClass()¶
Hook method for setting up class fixture before running tests in the class.
- test_fetch_flatcar()¶
- test_fetch_arm_flatcar()¶
Test flatcar AMI finder architecture parameter.