Commit Graph

253 Commits

Author SHA1 Message Date
Alex Kavanagh
b7c5b5a54d Modify test code to be less brittle
The test for log function against ObjectRetrierWraps class is too
brittle to the number of log calls. This commit makes it less brittle.
2024-07-02 10:50:54 +01:00
Alex Kavanagh
1f0808e238 Fix ObjectRetrierWraps recursive wrapping
In order to ensure that an object that contains other objects that are
called (e.g. the VolumeManager object on the Cinder client object), the
ObjectRetrierWraps class needs to more agressively wrap non builtin
classes.
2024-07-02 10:50:54 +01:00
Billy Olsen
a64d2c6b03 Use zaza.model.run_on_unit for ca checks
Existing code uses the python libjuju unit.run in order to execute
a wait check for ca readiness across the units. The behavior of libjuju
changed between 2.x and 3.x and causes this functionality to break. This
is abstracted and handled in the zaza library, so use that code instead
as it properly handles the differences.

Signed-off-by: Billy Olsen <billy.olsen@canonical.com>
2024-03-18 12:27:04 -07:00
Felipe Reyes
d28b885f7a Set tempdir to a directory under ~/
When juju 3.x is used (installed from a snap in strict confinement) the
temporary directory of the system (e.g. /tmp) can't be read by 'juju',
this is used by zaza-openstack-tests to write testing policy files
among other transitory files that are passed to juju's CLI.

This change moves Python's default temporary file to ~/tmp unless
overriden by the environment variable TEST_TMPDIR.
2024-02-19 11:03:16 -03:00
Corey Bryant
1bb67ab122 Improve charm_upgrade imports and remove test pprints 2023-10-26 12:23:33 +00:00
Corey Bryant
0684a62383 Updates for charm/openstack upgrade testing
Updates charm upgrades to use channels, tracks, and risks instead
of URLs.

Currently these tests only upgrade OpenStack charms and packages.
The OVN, ceph, and misc charms and payloads are not upgraded.

Remove instance creation since tempest can be used to verify the
cloud.
2023-10-25 19:28:23 +00:00
Rodrigo Barbieri
e0498d6a16 Convert images to raw if ceph image backend (#1078)
Convert images to raw if ceph image backend

We are currently uploading qcow2 images, and
Nova is converting them to raw when running
the tests, sometimes timing out the tests.

With this change we are pre-converting the
images and uploading them as raw, so Nova
does not have to convert them.
2023-08-21 14:15:51 +01:00
Corey Bryant
95fcad2a0a Change skipVersion decorator to a function
The skipVersion decorator was proving to be tricky to use because
it took an application name which we didn't want to hard-code,
since it is in hacluster/tests.py. One alternative was to pass a
charm name instead of application name, but if there were mutiple
hacluster applications in the model (e.g. keystone-hacluster and
nova-hacluster) we would have to pick just one to test the package
version on. After further discussion we decided to change the
decorator to a function so that we could use existing class
variables to generate the desired hacluster application name.
2023-04-19 18:28:22 +00:00
Felipe Reyes
7205e31753 Add CompareOpenStack class.
The CompareOpenStack class allows the comparison of OpenStack codenames.
2023-03-28 15:01:56 -03:00
Felipe Reyes
a81376183f Skip test_930_scaleback on crmsh-4.4.0-1ubuntu1
The crmsh package available in kinetic fails to put a cluster node in
maintenance mode, this is part of the scaleback process, more details on
the failure available at the related bug.

This change introduces a new decorator skipVersion() that allows to
provide a list of package versions with an operation flag on how dpkg
should compare the version(s).

The test HaclusterTest.test_930_scaleback() is disabled when running
crmsh-4.4.0-1ubuntu1, at the moment this would be kinetic, although if
any new package gets released this test will be re-enabled automatically
allowing us catch early if the test got fixed or not.

Related-Bug: http://pad.lv/1972730
2023-02-27 15:36:04 -03:00
Felipe Reyes
2cd18b484d Replace assertEquals with assertEqual.
DeprecationWarning: Please use assertEqual instead.
2023-02-14 14:45:20 -03:00
Felipe Reyes
fa09a20b4b Add support for Magnum to use different images per release.
OpenStack Magnum relies on specific versions of Fedora CoreOS, this
patch addresses this maintaining a map of images per release according
to the upstream documentation[0]

The images are expected to be stored in the object store pointed out by
TEST_SWIFT_IP[1] environment variable in a container named 'magnum'. A
bash script to upload images can be found at
./zaza/openstack/charm_tests/magnum/upload_fedora_coreos_images.sh

[0] https://docs.openstack.org/magnum/latest/user/index.html#supported-versions
[1] https://github.com/openstack-charmers/zosci-config/pull/262
2023-02-14 14:45:11 -03:00
Bas de Bruijne
9fb488efef Update series upgrade automation (#952)
* update series upgrade test

* bug fixes

* bug fixes
2023-01-23 12:39:10 +00:00
Alex Kavanagh
22e0311243 Try to get tests to pass with assertions 2023-01-11 13:48:29 +00:00
Alex Kavanagh
b53c782ed0 Fix bad asserting in Series Upgrade test 2023-01-11 13:01:32 +00:00
Liam Young
99186a6651 Add k8s compatible method for keystone auth (#945)
* Add k8s compatible method for keystone auth

* Mock out is_k8s_deployment
2022-10-03 18:27:56 +01:00
Liam Young
65cc55a5db Remove liberty special case (#944)
* Remove liberty special case

* Update unit test
2022-10-03 12:52:30 +01:00
Liam Young
17234c9e15 Respect model in get_swift_storage_topology
Change 0af4c93d causes the target model to be ignored when a
model_name was specified. This in turn is causing the swift
cmr tests to fail as an ip of None is being recorded for
units in a different model.
2022-09-02 14:17:07 +00:00
Liam Young
b4b645ab9a Add fallback ubuntu image location 2022-09-02 14:09:57 +00:00
Alex Kavanagh
7c8a190e7a Ensure unittests use zaza non-threaded
zaza normally runs libjuju async functions in a background thread
to enable zaza to be blocking, but keep the libjuju async functions
'ticking over' between blocking calls.

This can break unit tests as starting the zaza background thread will
hang unless it is cleaned up.  A simple solution is just to use zaza in
non-threaded mode in the unit tests, and zaza provides a mechanism for
this via zaza.RUN_LIBJUJU_IN_THREAD = False.
2022-07-08 11:03:04 +01:00
Frode Nordahl
e8aacf959b Write private SSH key with appropriate permissions
Fixes #583
2022-05-25 15:32:54 +02:00
Frode Nordahl
3f711ff6da openstack: Add update subnet DHCP helper 2022-04-21 14:08:55 +02:00
Alex Kavanagh
70ae1ab605 Remove commented out line. 2022-01-14 15:40:41 +00:00
Alex Kavanagh
1d415da690 Update test_get_keystone_ip__from_unit() test
Update the test to mock zaza.model.get_unit_public_address() to match
the associated changes in zaza for getting public address with juju 2.9
2022-01-14 15:21:32 +00:00
Alex Kavanagh
0af4c93d52 Switch unit.public_address to unit.get_public_address()
Due to the bug [1] on OpenStack providers, unit.public_address doesn't
actually work reliably.  The fix [2] is only for the async function
unit.get_public_address().  Sadly, zaza relied on unit.public_address
and so it needs this patch for juju 2.9 support on OpenStack providers.

This patch relies on an associated patch in zaza [3]; thus this will
fails its tests until that passes.

[1]: https://github.com/juju/python-libjuju/issues/551
[2]: https://github.com/juju/python-libjuju/pull/600
[3]: https://github.com/openstack-charmers/zaza/pull/468
2022-01-14 15:21:32 +00:00
Alex Kavanagh
1fbd505e27 Enable get_keystone_ip() to work with multiple vips config
The keystone charm allows multiple VIP addresses to be configured via
the 'vip' config parameter.  Unfortunately, get_keystone_ip() didn't
support this.  This patch adds that support, plus the missing tests.

Closes: #689
2022-01-07 16:56:22 +00:00
Aurelien Lourot
0e13f606be Merge pull request #679 from ajkavanagh/filter-percona-at-focal
Ensure that series upgrades ignore percona at focal
2021-12-08 10:15:50 +01:00
hemanthnakkina
1a1dc0a79e Add glance tests for Cinder Storage backend (#680)
Add zaza tests for charm glance when cinder is configured
as storage backend.

Related-Bug: LP#1905042

Co-authored-by: Hemanth Nakkina <hemanth.nakkina@canonical.com>
2021-12-01 10:20:08 +00:00
Alex Kavanagh
d4d415c859 Ensure that series upgrades ignore percona at focal
When doing a series upgrade from bionic to focal, the percona-cluster
charm needs to be avoided.  This filters the applications for percona if
the target is focal.  Note if percona is placed on the same unit as
something else that needs to be upgraded (bad idea) then it may still
get 'upgraded' and the operation will fail.
2021-11-30 18:50:14 +00:00
coreycb
6c834770ed Add neutron setup for VLAN provider network (#639)
This adds a new setup function that will setup a VLAN provider network.
It can be called by tests.yaml after basic_overcloud_network:
- zaza.openstack.charm_tests.neutron.setup.basic_overcloud_network
- zaza.openstack.charm_tests.neutron.setup.vlan_provider_overcloud_network
2021-10-08 16:05:36 +02:00
Aurelien Lourot
b7e4bbf0fc Allow several tempest runs with different config
This deprecates:

    configure:
      - zaza.openstack.charm_tests.tempest.setup.render_tempest_config_keystone_v3
    tests:
      - zaza.openstack.charm_tests.tempest.tests.TempestTest

by allowing multiple runs with different config:

    tests:
      - zaza.openstack.charm_tests.tempest.tests.TempestTestWithKeystoneV2
      - zaza.openstack.charm_tests.openstack_upgrade.tests.OpenStackUpgradeTestsByOption
      - zaza.openstack.charm_tests.tempest.tests.TempestTestWithKeystoneV3
2021-09-16 10:00:06 +02:00
Frode Nordahl
6e8201f696 Only configure one interface on MAAS provider
The Zaza MAAS code selects interfaces that are attached to the
provided CIDR, set up as unconfigured and has link.

In the event a machine has multiple unconfigured interfaces
attached to the same physical network, adding them all to the
configuration might lead to undesired side effects such as network
loops.
2021-08-13 08:46:27 +02:00
Hernan Garcia
e67b0ea1e1 added glance functional test for image-conversion config 2021-05-31 03:45:45 -05:00
Corey Bryant
0b401de17f Get OpenStack codename from /etc/openstack-release
In newer versions of Ubuntu and the Cloud Archive (currently Hirsute,
Wallaby, and above), there is an openstack-release package that, if
installed, specifies the current OpenStack release in
/etc/openstack-release.

Also adds wallaby definitions to non-version definitions in
os_versions.py.

Fixes #560
2021-04-20 10:31:04 -04:00
Alex Kavanagh
e9f11da5df Fix typo and rename class for better understanding
Fixes a typo (None -> not None) and renames the class from
ObjectRetrier -> ObjectRetrierWraps to make it clearer that the class
instantiation is to wrap and object with the retrier code rather than do
retries at that moment.
2021-03-25 14:47:42 +00:00
Alex Kavanagh
c041042fe2 Add function to just retry on keystone ConnectFailure
The main failure that seems to occur with clients is the
ConnectFailure, which according to the docs, is retry-able.  Thus
provide a function that adds that exception condition automatically.
Also fix the import problem in octavia test for the object retrier that
is being used to validate the ObjectRetrier feature.
2021-03-10 09:41:10 +00:00
Alex Kavanagh
45146b6c45 Add ObjectRetrier to perform retries on openstack client calls
This adds a wrapper class that detects if a callable object in any of
the descendent objects raises an Exception.  If so, then it retries that
exception.

This is to attempt to make the zaza tests a little more robust in the
face of small network failures or strange restarts.  This is a test, and
robust logging a reporting should be used to determine whether it is
covering up actual bugs rather than CI system issues.

Related Bug: (zot repo)#348
2021-03-10 09:40:03 +00:00
Frode Nordahl
2ab9cebbf6 Use per-model tmp-dir to store local copy of CA cert (#493)
The current approach of storing the deployment CA certificate in
the 'test/' relative path does not allow for executing tests for
multiple targets from the same environment.

We have previously moved (7a90110) the local copy of the SSH
private key for similar reasons.

Remove the global constants as we cannot build them without making
function calls, and we'd rather avoid doing that at module import
time. Code using the location of the local CA certificate has
already been changed to use helper functions.
2021-02-04 08:48:17 +01:00
Garrett Thompson
7878523e34 Rename zaza_juju to be consistent with all of repo 2021-02-03 18:01:28 +00:00
Liam Young
93a9aff927 Fix context manager mock 2021-01-25 11:47:42 +00:00
Liam Young
e047150f5b Add unit tests 2021-01-25 09:21:00 +00:00
Frode Nordahl
ec63732974 Support configuring networknig charms on MAAS
When on MAAS support doing charm based configuration of OVS by
retrieving MAC address of ports attached to external network
from MAAS.

Note that we should extend the MAAS support to also work with
deployments where MAAS does the OVS configuration for us.
2021-01-13 18:47:08 +01:00
Frode Nordahl
ee0dd80cec Split configure_gateway_ext_port function
The function does three separate things today, and two of its
tasks are useful for other provider types such as MAAS.

Also fix create_additional_port_for_machines idempotency.

We previously added a run time assertion to fail early when
attempting to configure networking for an invalid bundle. The
check had the side effect of prohibiting subsequent runs on
already configured models.
2021-01-13 18:47:05 +01:00
Alex Kavanagh
282b8be577 Update openstack upgrade tests for focal (#476)
This patch modifies the existing openstack upgrade tests so that they
work with focal (by explicitly supporting mysql-innodb-cluster), and are
also interruptable and resumable (at a charm level).  It also makes them
work with the udpated 'get_upgrade_groups()' that ultimately gets a List
of Tuples rather than a dictionary.
2021-01-06 14:09:41 +01:00
Liam Young
a35ba0917e Allow an app to be set when calling get_os_release (#477)
Ceph deployments may not contain a keystone service which causes
calls to get_os_release to fail as it calls get_current_os_release_pair
without sepecifying an application (keystone is the default).
2021-01-06 12:26:01 +01:00
Alex Kavanagh
7ced54b382 Concurrent series upgrade updates (#466)
* Updates to concurrent series upgrade

Updates to make it run more in parallel and spend less time waiting on
the whole model when updating machines.

* Make the concurrent series upgrade tests work

This is a number of changes to get the concurrent (here called
'parallel' historically) series upgrade tests to work.  A number of
changes were required which included limiting the number of concurrent
async co-routines (futures) that could be run as with large models it
hits the limits of the Py3 runtime.

* Fix the tests and change pause order in maybe_pause_things

Due to an additional model helper call, an additional model AsyncMock is
required.  Also the pause order had changed, and this is restored to
ensure the original design is retained (for pause order).

Clean up some commented out code and sort out a few PEP8 errors.

* Update comment to reflect code (3 -> 4)

* Fix tests that fail on bionic but pass on focal

Essentially, asyncio.gather has different behaviour on bionic that
focal.  Although this doesn't affect testing, it does affect the unit
tests.  These changes are simply to normalise the behaviour of unit
tests on focal and bionic.
2020-12-02 11:22:00 +01:00
Aurelien Lourot
44e62803e5 Merge pull request #458 from rodrigogansobarbieri/improve_keystone_ldap
Update Keystone LDAP tests
2020-11-23 23:20:15 +01:00
Rodrigo Barbieri
7404b0cb9b Update Keystone LDAP tests
- Reversed ldap-config-flags vs charm configs precedence
  for https://review.opendev.org/748364
- Added new functional test to validate the precedence
- Added zaza helper function to assist handling charm configs
  that do not accept "" (like booleans and ints), and reverting
  to unset values through config_change()
- Fixed zaza reset helper function that apparently never
  worked ({}.keys() returns dict_keys which is not a sequence)
2020-11-23 12:33:32 -03:00
Alex Kavanagh
f94f2be31d Merge pull request #462 from gnuoy/nova-client-version
Support nova client micro versions
2020-11-18 16:00:05 +00:00
Liam Young
dfecc58f5a Extend resource_reaches_status
The resource_reaches_status assumes that the attribute to be checked
is called 'status' but this can vary between resource types so allow
the name of the attribute to specified.
2020-11-18 12:13:59 +00:00