summaryrefslogtreecommitdiff
path: root/tests/cloud_tests
AgeCommit message (Collapse)Author
2019-04-01cloud_tests: fix apt_pipelining test-casesRyan Harper
The apt_pipelining test-cases were broken but until cloud-init changed it's default behavior to not disable, these silently passed as both only ever checked if pipelinging was disabled. First, the tests used the 'apt' namespace, which is not for configuring pipelining, rather that requires 'apt_pipelining' as the namespace. Second, the 'os' variant needs to check that cloud-init does not write a configuration file; it was a copy-and-paste error from the disable test-case. This branch fixes the config and collection to validate both scenarios.
2019-02-22tests: integration test failure summary to use traceback if empty errorChad Smith
When integration tests verification fails, the object returned contains has 'error' and 'traceback' keys. Each key can contain empty strings. If the simplified 'error' message is empty, fallback and use the more verbose full 'traceback' text in the failure summary.
2018-12-11tests: add Disco releaseJoshua Powers
2018-10-10tests: meta_data key changed to meta-data in ec2 instance-data.jsonChad Smith
LP: #1797231
2018-10-10tests: fix kvm integration test to assert flexible config-disk pathChad Smith
Make integration test for flexible using regexp in case disk changes. LP: #1797199
2018-10-09instance-data: Add standard keys platform and subplatform. Refactor ec2.Chad Smith
Add the following instance-data.json standardized keys: * v1._beta_keys: List any v1 keys in beta development, e.g. ['subplatform']. * v1.public_ssh_keys: List of any cloud-provided ssh keys for the instance. * v1.platform: String representing the cloud platform api supporting the datasource. For example: 'ec2' for aws, aliyun and brightbox cloud names. * v1.subplatform: String with more details about the source of the metadata consumed. For example, metadata uri, config drive device path or seed directory. To support the new platform and subplatform standardized instance-data, DataSource and its subclasses grew platform and subplatform attributes. The platform attribute defaults to the lowercase string datasource name at self.dsname. This method is overridden in NoCloud, Ec2 and ConfigDrive datasources. The subplatform attribute calls a _get_subplatform method which will return a string containing a simple slug for subplatform type such as metadata, seed-dir or config-drive followed by a detailed uri, device or directory path where the datasource consumed its configuration. As part of this work, DatasourceEC2 methods _get_data and _crawl_metadata have been refactored for a few reasons: - crawl_metadata is now a read-only operation, persisting no attributes on the datasource instance and returns a dictionary of consumed metadata. - crawl_metadata now closely represents the raw stucture of the ec2 metadata consumed, so that end-users can leverage public ec2 metadata documentation where possible. - crawl_metadata adds a '_metadata_api_version' key to the crawled ds.metadata to advertise what version of EC2's api was consumed by cloud-init. - _get_data now does all the processing of crawl_metadata and saves datasource instance attributes userdata_raw, metadata etc. Additional drive-bys: * unit test rework for test_altcloud and test_azure to simplify mocks and make use of existing util and test_helpers functions.
2018-10-07tests: fix apt_configure_primary to be more flexibleChad Smith
Commit d3e803ad316e6796e5d83e7e8f8f4f7224b92df9 added deb-src comments to the cloud-init apt templates. This doubled the number of matching entries seen in /etc/apt/sources.list in apt_configure_primary integration test. This test was really asserting that GaTech urls were present in /etc//apt/sources.list instead of archive.ubuntu.com. Fix the test to be a bit more flexible in case cloud-init changes its bas apt template again.
2018-10-01tests: allow skipping an entire cloud_test without running.Scott Moser
Individual skipTest or setUp SkipTest will still launch the instance. This allows us to stop the running of the instance so we don't waste cycles or boot systems that are known to fail. Also replace remaining unittest usage in tests/cloud_tests/ with unittest2.
2018-09-28tests: disable lxd tests on cosmicScott Moser
Skip lxd tests on cosmic for two reasons: a.) bug 1795036 - 'lxd init' fails on cosmic kernel. b.) apt install lxd installs via snap which can be slow     as that will download core snap and lxd.
2018-09-27cii-tests: use unittest2.SkipTest in ntp_chrony due to new depsChad Smith
Git commitish fc4b966ba928b30b1c586407e752e0b51b1031e8 changed integration test dependencies from unittest to unittest2. Use unittest2.SkipTest in test_chrony to avoid causing tracebacks.
2018-09-26lxd: adjust to snap installed lxd.Scott Moser
Relax expectation on path to lxc and lxd. The deb path still does install them in /usr/bin/ but that is overly pedantic. Add a 'lxd waitready' (present since lxd 0.5) to wait until lxd is ready before operating on it.
2018-09-26tests: fix ec2 integration tests. process meta_data instead of meta-dataChad Smith
Commitish c7555762f3a30190ce7726b4d013bc3e83c7e4b6 changed the variable names in instance-data.json from hyphenated to underscore delimited. In the shuffle, meta-data -> meta_data was missed.
2018-09-25cli: add cloud-init query subcommand to query instance metadataChad Smith
Cloud-init caches any cloud metadata crawled during boot in the file /run/cloud-init/instance-data.json. Cloud-init also standardizes some of that metadata across all clouds. The command 'cloud-init query' surfaces a simple CLI to query or format any cached instance metadata so that scripts or end-users do not have to write tools to crawl metadata themselves. Since 'cloud-init query' is runnable by non-root users, redact any sensitive data from instance-data.json and provide a root-readable unredacted instance-data-sensitive.json. Datasources can now define a sensitive_metadata_keys tuple which will redact any matching keys which could contain passwords or credentials from instance-data.json. Also add the following standardized 'v1' instance-data.json keys:   - user_data: The base64encoded user-data provided at instance launch   - vendor_data: Any vendor_data provided to the instance at launch   - underscore_delimited versions of existing hyphenated keys:     instance_id, local_hostname, availability_zone, cloud_name
2018-09-11user-data: jinja template to render instance-data.json in cloud-configChad Smith
Allow users to provide '## template: jinja' as the first line or their #cloud-config or custom script user-data parts. When this header exists, the cloud-config or script will be rendered as a jinja template. All instance metadata keys and values present in /run/cloud-init/instance-data.json will be available as jinja variables for the template. This means any cloud-config module or script can reference any standardized instance data in templates and scripts. Additionally, any standardized instance-data.json keys scoped below a '<v#>' key will be promoted as a top-level key for ease of reference in templates. This means that '{{ local_hostname }}' is the same as using the latest '{{ v#.local_hostname }}'. Since instance-data is written to /run/cloud-init/instance-data.json, make sure it is persisted across reboots when the cached datasource opject is reloaded. LP: #1791781
2018-08-23tests: disable other snap test as wellJoshua Powers
The snap test requires access to a proxy and currently the integration tests do not handle this scenario. I am disabling the test until I can loop back around and fix this.
2018-08-20tests: disable snap, fix write_files binaryJoshua Powers
The snap test requires access to a proxy and currently the integration tests do not handle this scenario. I am disabling the test untill I can loop back around and fix this. The write_files test, specifically, the binary test is failing on cosmic because the "binary" file we were writting was not a complete elf executable, but we expected 'file' to identify it as such. The change here is to simply use some 24 bytes of random, non-utf data and check that file was written correctly via expected checksum.
2018-07-27tests: improve LXDInstance trying to workaround or catch bug.Scott Moser
Described in bug 1783198 we have seen some transient failures when using pylxd -> lxd api. This does: * adds a str() representation of LXDInstance * checks the value of the pylxd_container object on instantion * sets pylxd_container object to None on deletion. * adds retry logic to shutdown()
2018-07-23tests: Collect build_info from system if available.Scott Moser
This adds a script to always get the /etc/cloud/build.info file if it exists, and a hook when preparing the image to log the information if it is available. INFO - setting up ubuntu-cosmic (build_name=server serial=20180718) This is just useful for debug and reproduce.
2018-06-28tests: drop salt-minion integration testScott Moser
The salt minion integration test as we had it did not do a whole lot more than the unit tests on that module did. Additionally, it caused some transient failures at least in Ubuntu 18.04. At a future date we may choose to add an integration test that installs salt-minion and salt server and configures it to be a better test. LP: #1778737
2018-06-12tests: fix salt_minion integration test on bionic and laterChad Smith
In ubuntu, the salt-minion package version 2017.7.4+dfsg1-1 or later automatically moves any seed keys from /etc/salt/pki/minion/ to /var/lib/salt/pki/minion/. Fix integration tests to collect either files in either /etc/salt/pki/minion/ or /var/lib/salt/pki/minion/.
2018-06-12tests: provide human-readable integration test summary when --verboseChad Smith
Integration tests will now provide a brief summary for test failures listed by platform and distribution. The failure summary will only consist of failed test name and assert error message. Drop the verbose dictionary of all integration test output because this content is unreadable given the large number of integration test results listed within this dictionary.
2018-06-12tests: skip chrony integration tests on lxd running artful or olderChad Smith
A fix for chrony support per LP: #1589780 is not expected in Artful or older series. Skip the chrony suite of tests when running on a container and ubuntu series represented is <= artful as errors are expected.
2018-06-12test: add optional --preserve-instance arg to integraiton testsChad Smith
By default, integration tests destroy the test instances after each test run. To aid debug and development of integration tests, support a --preserve-instance argument which will leave the modified test instance in a stopped state for further debug.
2018-05-22tests: enable Ubuntu Cosmic in integration testsJoshua Powers
2018-05-17cloud_tests: help pylintRyan Harper
pylint missed finding a typo in the lxd platform because it could not determine that the variable was being used was a string. The variable was set by loading a yaml file which pylint couldn't know that it would be a string. In these cases, we can be more explicit.
2018-05-16tests: restructure SSH and initial connectionsJoshua Powers
The SSH function was retrying and waiting for SSH for over an hour when an SSH connection was failing to be established. This reduces the amount of retries and time between each retry to prevent tests from running for hours. Also restructures how waiting for the system works: the system will attempt to SSH up to the boot timeout time by catching SSH connection failures and retrying until the timeout is reached. If the limit is reached now an exception is thrown to abort the test. Drive by - this also fixes printing of the instance name when collecting the console log, rather than showing a Python object address. Fixes LP: #1758409
2018-05-09tests: fix package and ca_cert cloud_tests on bionicChad Smith
package_update_upgrade_install was failing as htop is now included in Bionic images. Switch this test to install 'sl' instead. ca_certs integration test fails on cert_count test because bionic update-ca-certificates on bionic generates less symlinks for a given cert. Integration tests now collect dpkg-query --show output on every instance. Add a new assertPackageInstalled helper method which finds the package or package version installed on the instance. Adapt existing byobu, package_update_upgrade_install, ntp and salt_minion tests to use assertPackageInstalled method. LP: #1769985
2018-04-19pylint: pay attention to unused variable warnings.Scott Moser
This enables warnings produced by pylint for unused variables (W0612), and fixes the existing errors.
2018-04-18pycodestyle: Fix invalid escape sequences in string literals.Scott Moser
Python has deprecated these invalid string literals now https://bugs.python.org/issue27364 and pycodestyle is identifying them with a W605 warning. https://github.com/PyCQA/pycodestyle/pull/676 So basically, any use of \ not followed by one of [\'"abfnrtv] or \ooo (octal) \xhh (hex) or a newline is invalid. This is most comomnly seen for us in regex. To solve, you either: a.) use a raw string r'...' b.) correctly escape the \ that was not intended to be interpreted.
2018-04-12Implement ntp client spec with auto support for distro selectionRyan Harper
Add a base NTP client configuration dictionary and allow Distro specific changes to be merged. Add a select client function which implements logic to preferr installed clients over clients which need to be installed. Also allow distributions to override the cloud-init defaults. LP: #1749722
2018-04-07tests: fix ec2 integration network metadata validationChad Smith
Fix integraiton test logic for ec2 to look for network and availability-zone data under the key path 'ds'=>'meta-data' instead of just 'ds' when parsing instance-data.json.
2018-04-03tests: fix integration tests to support lxd 3.0 releaseChad Smith
Integration tests previously had a logic path that was unexercised on jenkins because we were on an older version of lxc. With an upgrade to lxd version 3.0 we need to bump pylxd dependency pin and fix a typo in integration tests which checked the lxd version.
2018-04-03correct documentation to match correct attribute name usage.Dominic Schlegel
LP: #1420018
2018-03-16cc_snap: Add new module to install and configure snapd and snap packages.Chad Smith
Support installing and configuring snaps on ubuntu systems. Now, cloud-config files can provide a list or dictionary of snap:assertions which will be allow configuration of snapd on a system via 'snap ack' calls. The snap:commands configuration option supports arbitrary system commands intended to interact with snappy's cli. This allows users to run arbitrary snappy commands to create users, download, install and configure snap packages and snapd. This branch also deprecates old snappy and snap_config modules leaving warnings in documentation and runtime for consumers of these modules. Deprecated snap* modules will be dropped in cloud-init v.18.2 release.
2018-03-15tests: fix run_tree and bddebScott Moser
This was broken probably when we inserted the ssh keys into Platform.   tox -e citest tree_run and   tox -e citest bddeb would fail with KeyError in Platform.init due to lack of a data_dir. Also here are a few fixes found from attempting to make it work.
2018-03-15tests: Fix some warnings in tests that popped up with newer python.Scott Moser
When running 'tox -e pylint' on a bionic system (python 3.6.4) I started seeing errors today like: tests/cloud_tests/platforms/__init__.py:5: [E0401(import-error), ] Unable to import 'tests.cloud_tests.platforms.ec2' The fix for those first errors was simply to create the __init__.py. The second set of changes fixes fallout found from actually now having pylint properly run on more of the cloud_tests.
2018-03-08Make salt minion module work on FreeBSD.Dominic Schlegel
Previously the module was not working under FreeBSD due to a different package name and some different paths. The module now has OS specific default values which can even be customized via corresponding cloud config variables. LP: #1721503
2018-02-23salt: configure grains in grains file rather than in minion config.Daniel Wallace
While salt grains can be configured in the minion config file, it is usually better to configure it in the /etc/salt/grains file. This allows that to be done.
2018-02-12tests: add support for logs with lxd from snap and future lxd 3.Scott Moser
This puts in place detection for if 'show-log' will work with lxc client, and uses that if present. The 'lxc console --show-log' is not expected to work until lxd/liblxc3.0. That should come in a few months. The hope is that when that function arrives, this code will move over to using it. For other scenarios (all current lxd installs) this will now support getting logs from a snap installed lxd or a package installed lxd via the old 'lxc.console.logfile'. If installed from snap, a platform error will be raised until the user does: sudo mkdir --mode=1777 -p /var/snap/lxd/common/consoles LP: #1745663
2018-01-25tests: Collect script output as binary, collect systemd journal, fix lxd.Scott Moser
This adds collection a gzip compressed systemd journal on systemd systems. The file can later be reviewed with:   zcat system.journal.gz > system.journal   journalctl --file=system.journal [-o short-monotonic ..] To support this:   * modify test harness infrastructure to not assume content is utf-8.   * fix lxd platform to support make '_execute' return bytes rather     than a string. https://github.com/lxc/pylxd/issues/268 Also switched the base collectors to use /bin/sh as others already did.
2018-01-23tests: Fix EC2 Platform to return console output as bytes.Scott Moser
The EC2 test platform uses boto, and boto decodes console output with decode('utf-8', 'replace). It is known that Ubuntu consoles contain non-utf8 characters, making this call lossy. The change here is to patch the boto session to include a OutputBytes entry in the console_output response, and then to utilize that in console_log. More information on problem and solution at: https://github.com/boto/botocore/issues/1351
2018-01-23tests: when querying ntp server, do not do dns resolution.Scott Moser
Tests run on EC2 would successfully resolve the ipv4 dns address and that caused false positives on failure reports. Basically, dns lookup of 172.16.15.14 would return ip-172-16-15-14.us-east-2.compute.internal. which then shows up in the ntpq output unless you provide -n.
2018-01-18tests: remove zesty as supported OS to testJoshua Powers
Zesty goes EOL as of January 13, 2017. This removes it as a valid OS for testing.
2018-01-09tests: update apt sources list testJoshua Powers
Due to additional platforms getting added this test was not taking into account platform specific mirrors nor was it checking that no additional entries were added.
2018-01-09tests: clean up image propertiesJoshua Powers
This fixes the incorrectly named 'family' value for images as 'os'. Families are already defined in util.py:OS_FAMILY_MAPPING and a family is a collection of OSes. This makes the properties function part of the super class of image as it is only overrided by the lxd backend.
2018-01-09tests: rename test ssh keys to avoid appearance of leaking private keys.Joshua Powers
While the generated ssh keys are throw away keys, generating SSH keys with the default name (e.g. id_rsa) can trigger security scanners or draw unnecessary attention. The change here simply renames 'id_rsa' to 'cloud_init_rsa' to avoid a false positive reported by a scanning tool.
2018-01-05tests: Enable AWS EC2 Integration TestingJoshua Powers
This enables integration tests to utilize AWS EC2 as a testing platform by utilizing the boto3 Python library. Usage will create and delete a custom VPC for every run. All resources will be tagged with the ec2 tag, 'cii', and the date (e.g. cii-20171220-102452). The VPC is setup with both IPv4 and IPv6 capabilities, but will only hand out IPv4 addresses by default. Instances will have complete Internet access and have full ingress and egress access (i.e. no firewall). SSH keys are generated with each run of the integration tests with the key getting uploaded to AWS at the start of tests and deleted on exit. To enable creation when the platform is setup the SSH generation code is moved to be completed by the platform setup and not during image setup. The nocloud-kvm platform was updated with this change. Creating a custom image will utilize the same clean script, boot_clean_script, that the LXD platform uses as well. The custom AMI is generated, used, and de-registered after a test run. The default instance type is set to t2.micro. This is one of the smallest instance types and is free tier eligible. The default timeout for ec2 was increased to 300 from 120 as many tests hit up against the 2 minute timeout and depending on region load can go over. Documentation for the AWS platform was added with the expected configuration files for the platform to be used. There are some additional whitespace changes included as well. pylint exception was added for paramiko and simplestreams. In the past these were not already flagged due to no __init__.py in the subdirectories of files that used these. boto3 was added to the list of dependencies in the tox ci-test runner. In order to grab console logs on EC2 the harness will now shut down an instance before terminating and before collecting the console log. This is to address a behavior of EC2 where the console log is refreshed very infrequently, but one point when it is refreshed is after shutdown.
2017-12-12tests: fix collect_console when not implementedJoshua Powers
The exception was incorrectly creating a string and not a bytes object.
2017-12-07citest: In NoCloudKVM provide keys via metadata not userdata.Scott Moser
The NoCloudKVM platform was inserting ssh keys via user-data rather than through meta-data like it is done on other platforms. This way we are not forced to change the user-data provided. Also, provide meta-data including a uuid as the instance-id.
2017-12-07pylint: Update pylint to 1.7.1, run on tests/ and tools and fix complaints.Ryan Harper
The motivation for this is that a.) 1.7.1 runs with python 3.6 (bionic) b.) we want to run pylint on tests/ and tools for the same reasons that we want to run it on cloudinit/ The changes are described below. - Update tox.ini to invoke pylint v1.7.1. - Modify .pylintrc generated-members ignore mocked object members (m_.*) - Replace "dangerous" params defaulting to {} - Fix up cloud_tests use of platforms - Cast some instance objects to with dict() - Handle python2.7 vs 3+ ConfigParser use of readfp (deprecated) - Update use of assertEqual(<boolean>, value) to assert<Boolean>(value) - replace depricated assertRegexp -> assertRegex - Remove useless test-class calls to super class - Assign class property accessors a result and use it - Fix missing class member in CepkoResultTests - Fix Cheetah test import