Commit Graph

44 Commits

Author SHA1 Message Date
Samuel Walladge a2d8e96d8e Fix test to work with vault with raft backend (#827)
The tests here run a series of commands on the vault client,
without waiting in between.
This is usually fine, but with the raft backend,
there can be delays between initialising, unsealing,
and the raft cluster settling.
During this time, most vault commands will return errors.
2022-08-24 14:04:47 +01:00
Liam Young 14999ca1a1 Add two more auto initialise options (#664) 2021-10-28 11:16:58 +01:00
Liam Young 5b2ef5df9b Add auto_initialize_opportunistic
Add a method which will init vault if its present and skip if it
is not. This allows much simpler tests.yaml if all test and
config steps are the same for TLS and non-TLS test cases apart
from initialising vault.
2021-10-28 08:08:19 +00:00
Aurelien Lourot 66d08c0866 Make vault/setup/validate_ca() more robust 2021-08-16 13:59:45 +02:00
Aurelien Lourot 65d9d78420 Merge branch 'master' into retry-with-tenacity
Change-Id: Ifac26ffb6d53d75b9dbd314693252ad8b3364c5d
2021-07-16 11:54:08 +02:00
David Ames e9cb5aea5a Retry request on test csr for Vault 2021-06-14 20:49:22 +00:00
Nobuto Murata dee6032fc3 Skip test_vault_reload with enabling/disabling mlock in LXD
When Vault is running in a LXD container, test_vault_reload is expected
to fail because mlock cannot be enabled in LXD containers. Skip it when
running in containers is detected. It's useful for local development
environments with Juju's localhost/LXD provider. The test won't be
skipped in the OpenStack Charm CI since the Vault units will be run in
KVM, not in LXD containers.
2021-06-13 16:57:02 +09:00
David Ames 6645c60e93 Handle Vault running tests twice (#588)
Vault's runs its tests twice. In some circumstances the removal of the
vault key from the test_config dictionary can throw a KeyError. Do not
fail when this happens.
2021-06-09 11:20:53 +01:00
David Ames e5d2acc88c Fix test_vault_reload race condition
The test_vault_reload test was checking for running config without giving the
config-change time to complete. Simply adding an idle wait resolves the issue.

Closes Issue: #528
2021-03-26 16:58:08 +00:00
Alex Kavanagh c6e54dd505 Clean-up/correct docstrings in vault/utils.py 2021-03-09 18:09:37 +00:00
Bartosz Woronicz d7ec4fd0b8 fix formatting issues and docstring
That fixes the issues introduced in PR #512 #517
Now flake8 should not complain
2021-03-08 16:18:52 +01:00
Bartosz "mastier" Woronicz 79a78c2ca0 fix reload test for vault (#517)
The test was failing for xenial-ha-mysql bundle
This fixes the issue for cluster vault
by picking the right vault cluster leader
to run the commands against.

Co-authored-by: Bartosz Woronicz <bartosz.woronicz@canonical.com>
2021-03-08 08:59:23 +01:00
Bartosz Woronicz 73c78a0db3 add reload and restart action tests for vault 2021-03-04 11:58:32 +01:00
Liam Young 401829f0a7 Code tidy and docstrings 2021-01-24 17:24:20 +00:00
Liam Young 24fbc068c9 Correct args to block_until_ca_exists 2021-01-24 15:27:06 +00:00
Liam Young a20733cd14 Refactor ca functions 2021-01-24 14:31:29 +00:00
Liam Young a828774c48 Handle change of CA cert.
Closes issue #487
2021-01-23 16:17:54 +00: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
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
Chris MacNaughton c75f2fcb6d Ensure that zaza-openstack-tests can talk to an IPv6 Keystone
When configuring the address to use to talk to Keystone,
the format_addr helper should be used to ensure that an
IPv4 or IPv6 address can be correctly handled.
2020-09-08 11:11:13 +02:00
Chris MacNaughton 80995ccf23 Vault tests should leave Vault unsealed
When cleaning up after a Vault test case, Vault should be left
in the same state we found it, unsealed.

Closes-Bug: #379
2020-08-10 09:09:02 +02:00
Liam Young d0981d64af Add auto_initialize_no_validation_no_wait
When vault is in its own model with no clients then vault needs
to be initialised without waiting for clients to start executing
and without validating a client has recieved the cert. To achieve
this, this PR adds auto_initialize_no_validation_no_wait.
2020-07-07 08:57:40 +00:00
Frode Nordahl 37311df9c2 vault: fix formatting of IP addresses to support IPv6
At present an invalid URL to Vault will be produced in the event
of the IP address used being an IPv6 address.
2020-06-06 14:40:06 +02:00
Liam Young 2f6d6be3ef Update doc strings 2020-05-28 09:35:25 +00:00
Liam Young 362be92006 Retrieve ssl-ca from vault when using vault api
If the ssl-{key,chain,ca} charm config option have been set than
retrieve the ssl-ca from the vault charm and use it when making
called to the vault api.
2020-05-28 09:19:12 +00:00
Chris MacNaughton 27e5f7d8bc We must have async functions for the before/after callables 2020-04-10 16:51:41 +02:00
Alex Kavanagh 1919000fa4 Fix the vault pause/resume test
The pause/resume test paused the lead unit, but then checked
the first unit.  In an HA scenario, the lead unit may not be the
first unit.  This PR changes the test to check the lead unit after
the pause/resume test.

Depends On: https://github.com/openstack-charmers/zaza/pull/327
2020-02-07 10:56:52 +00:00
Liam Young 5fdde89be0 Tidyup docstring and method name 2020-02-04 12:48:00 +00:00
Liam Young 9c8a18b66f Fix path to get_unit_name_from_ip_address 2020-02-04 11:05:23 +00:00
Liam Young 5927878a03 Tidyup mojo cert unseal 2020-02-04 10:10:50 +00:00
Liam Young cac2f4c4a7 Fix MOJO_LOCAL_DIR name 2020-02-03 16:03:42 +00:00
Liam Young 83982a7aec Add unseal function for mojo use.
* Add an unseal function for mojo to use.
* Switch mojo to use new function after series upgrade reboot.
* Add fallback if vip client is unavailable (the case if all
  hacluster units are paused for series upgrade).
2020-02-03 13:39:17 +00:00
Sahid Orentino Ferdjaoui 70282da7c1 vault: add pause/resume test case
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
2019-11-21 16:38:29 +00:00
Frode Nordahl 9108059f71 vault: Extend workaround for LP: #1826382
We also need to restart consumers of the placement API on the
'nova-cloud-controller' unit.
2019-11-12 17:40:25 +01:00
Frode Nordahl 8d676bf9fa Make non-existent tests/tests.yaml non-fatal where possible
Not all test environments or runners are equal, don't crash on
non-existent test config.
2019-11-05 16:38:06 +01:00
Frode Nordahl a82979d145 vault: Await execution prior to validation step
Make it possible for consumers of the ``auto_initialize_no_validation``
function to execute subsequent setup and test code that require vault
and the consumers of the ``certificates`` relation to be ready.

With the current order of execution, it is not possible to use the
configure function in models where ``keystone`` application is not
present.
2019-10-18 11:05:18 +02:00
Liam Young 79a149bfc5 Facade for vault & basic_setup_and_unseal
Add a facade for interacting with vault and a function which
unseals vault units (useful when vault units have been rebooted).
2019-10-14 08:56:35 +00:00
Liam Young e0c10b5457 Search for vault credetials file.
During testing the vault credentials are stored on the lead unit.
Unfortunatly which unit is the designated leader can change during
the life of the test (particularly if the test involves rebooting
vault units). This change adds a function to search the units for
the credentials file rather than assuming its on the lead unit.
2019-10-14 07:50:55 +00:00
Joe Guo 09ee55efb1 use tenacity for retries
These code snippets were using a hard-coded sleep time, wrapped by a for loop
to retry, which is bad code smell.

Use tenacity retries to simplify the code, and be consistent with the
established approach to similar needs in other tests.

Closes #46

Signed-off-by: Joe Guo <guoqiao@gmail.com>
2019-09-05 00:07:21 +12:00
Ryan Beisner 9333b47a86 Flag existing time.sleep usage for refactor
https://github.com/openstack-charmers/zaza-openstack-tests/issues/46
2019-08-30 15:41:28 -05:00
Liam Young 025e1f4830 Ensure nova-compute is restarted when certs change
This is a temporary fix to work around a bug in nova-compute.
The bug causes nova-compute to cache the placement api endpoint
which causes placement api calls to fail when the endpoint switches
from http to https
2019-07-22 08:09:54 +00:00
Liam Young 11b55d5b4c Support initializing vault with no clients
Currently when vault auto_inititialize [sic] is called a validation
step is run at the end to check that clients connected to vault
have the correct setup. However in sometimes there are no clients
to run validation with (as with cross model relation testing). To
facilitate this expose a new method 'auto_initialize_no_validation'
which skip the client validation.

Also correct the spelling of auto_inititialize but add a partial
to support tests that are already using the old spelling.
2019-06-11 15:27:03 +00:00
Liam Young 278107e391 Merge pull request #229 from ChrisMacNaughton/bug/1826542
ensure we have a secret KV backend
2019-04-30 11:28:26 +02:00
Chris MacNaughton dd434e281e Add zaza namespacing, starting with openstack 2019-04-25 17:46:03 +02:00