<feed xmlns='http://www.w3.org/2005/Atom'>
<title>vyos-cloud-init.git/tests/unittests/helpers.py, branch rolling</title>
<subtitle> (mirror of https://github.com/vyos/vyos-cloud-init.git)
</subtitle>
<id>https://git.amelek.net/vyos/vyos-cloud-init.git/atom?h=rolling</id>
<link rel='self' href='https://git.amelek.net/vyos/vyos-cloud-init.git/atom?h=rolling'/>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/vyos-cloud-init.git/'/>
<updated>2021-12-16T02:16:38+00:00</updated>
<entry>
<title>Adopt Black and isort (SC-700) (#1157)</title>
<updated>2021-12-16T02:16:38+00:00</updated>
<author>
<name>James Falcon</name>
<email>james.falcon@canonical.com</email>
</author>
<published>2021-12-16T02:16:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/vyos-cloud-init.git/commit/?id=bae9b11da9ed7dd0b16fe5adeaf4774b7cc628cf'/>
<id>urn:sha1:bae9b11da9ed7dd0b16fe5adeaf4774b7cc628cf</id>
<content type='text'>
Applied Black and isort, fixed any linting issues, updated tox.ini
and CI.
</content>
</entry>
<entry>
<title>factor out function for getting top level directory of cloudinit (#1136)</title>
<updated>2021-12-08T21:27:37+00:00</updated>
<author>
<name>Brett Holman</name>
<email>bholman.devel@gmail.com</email>
</author>
<published>2021-12-08T21:27:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/vyos-cloud-init.git/commit/?id=65c2cfd7f21758746444c8c79444994a4638d563'/>
<id>urn:sha1:65c2cfd7f21758746444c8c79444994a4638d563</id>
<content type='text'>
Add a test helper to get top level directory

Many tests need to get the location of files &amp; dirs within the cloud-init
project directory.

Tests implement this in various different ways, and often those ways
depend on the current working directory of the pytest invocation.
Create helper functions (and tests) that gets the path of the top
directory or any sub directory under the top directory. This function
does not depend on the environment.</content>
</entry>
<entry>
<title>Reorganize unit test locations under tests/unittests (#1126)</title>
<updated>2021-12-03T20:11:46+00:00</updated>
<author>
<name>Brett Holman</name>
<email>bholman.devel@gmail.com</email>
</author>
<published>2021-12-03T20:11:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/vyos-cloud-init.git/commit/?id=039c40f9b3d88ee8158604bb18ca4bf2fb5d5e51'/>
<id>urn:sha1:039c40f9b3d88ee8158604bb18ca4bf2fb5d5e51</id>
<content type='text'>
This attempts to standardize unit test file location under test/unittests/
such that any source file located at cloudinit/path/to/file.py may have a
corresponding unit test file at test/unittests/path/to/test_file.py.

Noteworthy Comments:
====================
Four different duplicate test files existed:
test_{gpg,util,cc_mounts,cc_resolv_conf}.py
Each of these duplicate file pairs has been merged together. This is a
break in git history for these files.

The test suite appears to have a dependency on test order. Changing test
order causes some tests to fail. This should be rectified, but for now
some tests have been modified in
tests/unittests/config/test_set_passwords.py.

A helper class name starts with "Test" which causes pytest to try
executing it as a test case, which then throws warnings "due to Class
having __init__()".  Silence by changing the name of the class.

# helpers.py is imported in many test files, import paths change
cloudinit/tests/helpers.py -&gt; tests/unittests/helpers.py

# Move directories:
cloudinit/distros/tests -&gt; tests/unittests/distros
cloudinit/cmd/devel/tests -&gt; tests/unittests/cmd/devel
cloudinit/cmd/tests -&gt; tests/unittests/cmd/
cloudinit/sources/helpers/tests -&gt; tests/unittests/sources/helpers
cloudinit/sources/tests -&gt; tests/unittests/sources
cloudinit/net/tests -&gt; tests/unittests/net
cloudinit/config/tests -&gt; tests/unittests/config
cloudinit/analyze/tests/ -&gt; tests/unittests/analyze/

# Standardize tests already in tests/unittests/
test_datasource -&gt; sources
test_distros -&gt; distros
test_vmware -&gt; sources/vmware
test_handler -&gt; config        # this contains cloudconfig module tests
test_runs -&gt; runs</content>
</entry>
<entry>
<title>relocate tests/unittests/helpers.py to cloudinit/tests</title>
<updated>2017-09-05T17:03:59+00:00</updated>
<author>
<name>Lars Kellogg-Stedman</name>
<email>lars@redhat.com</email>
</author>
<published>2017-09-05T17:03:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/vyos-cloud-init.git/commit/?id=a3649e03206a3596131413956ea7ecc18790ec73'/>
<id>urn:sha1:a3649e03206a3596131413956ea7ecc18790ec73</id>
<content type='text'>
This moves the base test case classes into into cloudinit/tests and
updates all the corresponding imports.
</content>
</entry>
<entry>
<title>ec2: Allow Ec2 to run in init-local using dhclient in a sandbox.</title>
<updated>2017-08-10T03:55:52+00:00</updated>
<author>
<name>Chad Smith</name>
<email>chad.smith@canonical.com</email>
</author>
<published>2017-08-10T03:55:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/vyos-cloud-init.git/commit/?id=d5f855dd96ccbea77f61b0515b574ad2c43d116d'/>
<id>urn:sha1:d5f855dd96ccbea77f61b0515b574ad2c43d116d</id>
<content type='text'>
This branch is a prerequisite for IPv6 support in AWS by allowing Ec2
datasource to query the metadata source version 2016-09-02 about whether
or not it needs to configure IPv6 on interfaces. If version 2016-09-02
is not present, fallback to the min_metadata_version of 2009-04-04. The
DataSourceEc2Local not run on FreeBSD because dhclient in doesn't
support the -sf flag allowing us to run dhclient without filesystem
side-effects.

To query AWS' metadata address @ 169.254.169.254, the instance must have
a dhcp-allocated address configured. Configuring IPv4 link-local
addresses result in timeouts from the metadata service. We introduced a
DataSourceEc2Local subclass which will perform a sandboxed dhclient
discovery which obtains an authorized IP address on eth0 and crawl
metadata about full instance network configuration.

Since ec2 IPv6 metadata is not sufficient in itself to tell us all the
ipv6 knownledge we need, it only be used as a boolean to tell us which
nics need IPv6. Cloud-init will then configure desired interfaces to
DHCPv6 versus DHCPv4.

Performance side note: Shifting the dhcp work into init-local for Ec2
actually gets us 1 second faster deployments by skipping init-network
phase of alternate datasource checks because Ec2Local is configured in
an ealier boot stage. In 3 test runs prior to this change: cloud-init
runs were 5.5 seconds, with the change we now average 4.6 seconds.

This efficiency could be even further improved if we avoiding dhcp
discovery in order to talk to the metadata service from an AWS
authorized dhcp address if there were some way to advertize the dhcp
configuration via DMI/SMBIOS or system environment variables.

Inspecting time costs of the dhclient setup/teardown in 3 live runs the
time cost for the dhcp setup round trip on AWS is:
test 1: 76 milliseconds
         dhcp discovery + metadata: 0.347 seconds
         metadata alone: 0.271 seconds
test 2: 88 milliseconds
         dhcp discovery + metadata: 0.388 seconds
         metadata alone: 0.300 seconds
test 3: 75 milliseconds
         dhcp discovery + metadata: 0.366 seconds
         metadata alone: 0.291 seconds

LP: #1709772
</content>
</entry>
<entry>
<title>locale: Do not re-run locale-gen if provided locale is system default.</title>
<updated>2017-07-25T17:56:10+00:00</updated>
<author>
<name>Scott Moser</name>
<email>smoser@ubuntu.com</email>
</author>
<published>2017-06-08T20:42:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/vyos-cloud-init.git/commit/?id=0ef61b289472665f4e3059a24a8b9b91246f06ee'/>
<id>urn:sha1:0ef61b289472665f4e3059a24a8b9b91246f06ee</id>
<content type='text'>
If the system configure default in /etc/default/locale is set to the same
value that is provided for cloud-init's "locale" setting, then do not
re-run locale-gen. This allows images built with a locale already
generated to not re-run locale-gen (which can be very heavy).

Also here is a fix to invoke update-locale correctly and remove the
internal writing of /etc/default/locale. We were calling
  update-locale &lt;locale&gt;
This ends up having no affect. The more correct invocation is:
  update-locale LANG=&lt;locale&gt;

Also added some support here should we ever want to change setting
LANG to setting LC_ALL (or any other key).

Lastly, a test change to allow us to use assert_not_called from mock.
Versions of mock in CentOS 6 do not have assert_not_called.
</content>
</entry>
<entry>
<title>tests: fixes for issues uncovered when moving to python 3.6.</title>
<updated>2017-07-19T11:53:10+00:00</updated>
<author>
<name>Scott Moser</name>
<email>smoser@ubuntu.com</email>
</author>
<published>2017-07-13T00:16:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/vyos-cloud-init.git/commit/?id=865e941f3f88c7daeafbf1eab856e02ce2b6a5f7'/>
<id>urn:sha1:865e941f3f88c7daeafbf1eab856e02ce2b6a5f7</id>
<content type='text'>
This includes a few fixes found when testing with python 3.6.
 - fix eni renderer when target is None
   This just uses the util.target_path() in the event that target is None.
 - change test cases to not rely on the cached result of
   util.get_cmdline() and other cached globals. Update the base TestCase
   to unset that cache.
 - mock calls to system_is_snappy from the create_users test cases.
 - drop unused _pp_root in test_simple_run.py

LP: #1703697
</content>
</entry>
<entry>
<title>write_file(s): Print permissions as octal, not decimal</title>
<updated>2017-06-15T17:20:58+00:00</updated>
<author>
<name>Andrew Jorgensen</name>
<email>ajorgens@amazon.com</email>
</author>
<published>2014-12-05T22:34:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/vyos-cloud-init.git/commit/?id=0fe6a0607408d387f4b0d4482b95afbc5d3f3909'/>
<id>urn:sha1:0fe6a0607408d387f4b0d4482b95afbc5d3f3909</id>
<content type='text'>
Unix file modes are usually represented as octal, but they were being
interpreted as decimal, for example 0o644 would be printed as '420'.

Reviewed-by: Tom Kirchner &lt;tjk@amazon.com&gt;
</content>
</entry>
<entry>
<title>ntp: Add schema definition and passive schema validation.</title>
<updated>2017-05-31T20:43:12+00:00</updated>
<author>
<name>Chad Smith</name>
<email>chad.smith@canonical.com</email>
</author>
<published>2017-05-25T17:04:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/vyos-cloud-init.git/commit/?id=0a448dd034883c07f85091dbfc9117de7227eb8d'/>
<id>urn:sha1:0a448dd034883c07f85091dbfc9117de7227eb8d</id>
<content type='text'>
cloud-config files are very flexible and permissive.
This adds a jsonsschema definition to the cc_ntp module and validation
functions in cloudinit/config/schema which will log warnings about
invalid configuration values in the ntp section.

A cmdline tools/cloudconfig-schema is added which can be used in our dev
environments to quickly attempt to exercise the ntp schema.
It is also exposed as a main in cloudinit.config.schema.
(python3 -m cloudinit.config.schema)

LP: #1692916
</content>
</entry>
<entry>
<title>cc_ntp: Restructure cc_ntp unit tests.</title>
<updated>2017-05-24T16:38:58+00:00</updated>
<author>
<name>Chad Smith</name>
<email>chad.smith@canonical.com</email>
</author>
<published>2017-05-23T05:11:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/vyos-cloud-init.git/commit/?id=fd0c88cf8e8aa015eadb5ab842e872cb627197ec'/>
<id>urn:sha1:fd0c88cf8e8aa015eadb5ab842e872cb627197ec</id>
<content type='text'>
Any CiTestCase subclass can now set a class attribute with_logs = True and
tests can now make assertions on self.logs.getvalue(). This branch
restructures a bit of cc_ntp module to get better test coverage of the
module. It also restructures the handler_cc_ntp unit tests to avoid nested
mocks where possible. Deeply nested mocks cause a couple of issues:
  - greater risk: mocks are permanent within the scope, so multiple
    call-sites could be affected by package mocks
  - less legible tests: each mock doesn't advertise the actual call-site
  - tight coupling: the unit test logic to tightly bound to the actual
    implementation in remote (unrelated) modules which makes it more
    costly to maintain code
  - false success: we should be testing the expected behavior not specific
    remote method names as we want to know if that underlying behavior
    changes and breaks us.

LP: #1692794
</content>
</entry>
</feed>
