Commit Graph

54 Commits

Author SHA1 Message Date
Frode Nordahl cd29cee799 Merge pull request #79 from gnuoy/fix-stale-model-name
Update model name cache when switching models
2018-07-10 09:08:19 +02:00
Liam Young 3b738f279e Update model name cache when switching models
The model name cache needs to be updated when switching models
otherwise calls to get_juju_model get a stale results. Closes
2018-07-10 08:00:07 +01:00
Liam Young 294d8f5fd0 Cope with Workload status unknown messages
Some charms never implemented the workload status messages, these
charms have a wl status of unknown and wls message of ''. This fix
allows a wls of '' to be specified.
2018-07-09 15:17:07 +00:00
Chris MacNaughton 57ee4a3662 syntax fix and add unit test 2018-06-20 17:09:34 +02:00
Chris MacNaughton 063aadd4df add MODEL_NAME variable to determine model 2018-06-20 17:04:11 +02:00
Liam Young a5c15f9b7a Rebase 2018-06-15 10:49:39 +01:00
Liam Young 398c057007 Docstring tidy of zaza.model 2018-06-15 10:44:53 +01:00
Liam Young f0d91ae31b Fix caching of model name and remove debug lines 2018-06-14 06:23:26 +01:00
Liam Young 9b26376a19 A few fixes 2018-06-14 06:20:05 +01:00
Liam Young 9d06bb890f Move call to get_juju_model() down to run_in_model
Currently interacting with functions in zaza.model requires the
model to be passed in. This has resulted in multiple calls to
get_juju_model(). It is cleaner to push these calls down into
the model wrapper and make the model_name an optional
argument. In addition, the current model name is now cached
without having to check the os.env each time.

Unfortunately this has resulted in the signature changing on a
great many function so this diff is bigger than would normally
be desirable.
2018-06-14 06:19:26 +01:00
David Ames 7b10df57d8 Merge pull request #61 from gnuoy/remove-timeout-workaround
Remove workaround for libjuju timeout bug
2018-06-13 15:18:15 -07:00
Liam Young 0aa7c61719 Remove duplicate functions for add/remove model
Recently functions were added to zaza.model for adding and removing
models. These duplicated existing functions in zaza.controller.
Given these functions act against the controller, zaza.controller
feels like the correct location. In addition the implementations in
zaza.controller correctly handle disconnects which the new ones
did not.
This PR removes the duplicates and points any existing references
from zaza.model to zaza.controller. Finally, docstrings were added
and documentation links.
2018-06-13 09:49:33 +01:00
Frode Nordahl a0e9064f2b Merge pull request #62 from gnuoy/remove-model-subprocesses
Use libjuju for adding and removing models
2018-06-07 10:33:07 +02:00
Liam Young 0353d300e1 Fix typos 2018-06-07 09:25:07 +01:00
Liam Young 0568fd17b7 Fix lint 2018-06-07 09:06:13 +01:00
Liam Young 0b6f6d88dc Documentation fixes 2018-06-06 15:54:06 +01:00
Liam Young b21767ce52 Use libjuju for adding and removing models
libjuju supports adding and removing models so replace calls out
to subprocess with libjuju calls
2018-06-06 12:28:08 +01:00
Liam Young 01bd9b88c9 Remove workaround for libjuju timeout bug
The timeout bug for libjuju run has been resolved:

https://github.com/juju/python-libjuju/commit/462989bbd919f209ebb7454305f53e4b94714487

so remove workaround.
2018-06-06 09:53:16 +01:00
Liam Young 313f7bee02 Remove debug print 2018-05-22 15:34:58 +01:00
Liam Young 86d641e333 Minor tidy 2018-05-22 15:33:34 +01:00
Liam Young cbc14e32c6 Another batch of zaza.model helpers
This pr adds a number of new fuctions to zaza.model. As discussed
zaza.model needs to be broken up as it has become too large. I would
like to continue the discussion around that and submit a subsequent
patch for that at a later date.
2018-05-22 15:28:28 +01:00
Frode Nordahl 64b2d3de8b Infer ASn from deployment for BGP speaker test configuration 2018-05-15 21:59:19 +02:00
David Ames ea120ee0a5 Add controller module
The controller module allows us to run commands against the controller
including listing all models and getting the cloud configuration name.
2018-05-14 10:49:49 -07:00
Liam Young c7a8960036 Break up async_block_until_file_has_contents
Refactor so that async_block_until_file_has_contents
in a specialisation of async_block_until_file_ready
2018-05-08 12:19:21 +00:00
Liam Young 1cf86356dd Fixed a few docstring errors 2018-05-08 08:52:33 +00:00
Liam Young 458a7207d8 Add block_until_file_has_contents helper
Add a helper which will block until a string appears in a particular
file of an application.
2018-05-08 08:48:19 +00:00
David Ames ae257a0955 Functionality to enable mojo's use of zaza
Without introducing mojoisms into zaza there are some changes that are
required to enable mojo's use of zaza.

The goal is to keep mojo specific utilities in openstack-mojo-specs and
to move any generalized tools here in zaza.

This change updates some generalized zaza tools to enable mojo to use
them.
2018-04-30 16:13:50 +00:00
Liam Young a314a82d27 Always use startswith for checking WL status msgs (#42)
Currently there is no way for the tests.yaml to specify if the
expected workload status message should be checked as a prefix
or as an exact match. I think the prefix approach actually covers
all our use cases so rather than complicate the tests.yaml
options lets just always use startswith for checks.
2018-04-26 11:30:19 +01:00
Liam Young 34b6f5638a Bump deploy timeout 2018-04-25 18:32:35 +00:00
Liam Young d00af5028e Fix race in checking deployment complete
If the deployment state is assessed before any units have been
provisioned then the checks passes as there are no active units
or units with bad states etc. So, wait for at least one unit to
be provisioned before running checks
2018-04-25 10:32:46 +00:00
Liam Young 68114544bd Add the ability to wait for bespoke statuses (#38)
* Add the ability to wait for bespoke statuses

This change adds the ability to wait for bespoke work load
statuses and messages. These are defined in the charms tests.yaml

* Add unit tests

* Remove debug print

* Fix typos and add checks for  errored units

* Restore juju_wait as openstack_utils imports it
2018-04-25 09:48:31 +01:00
Liam Young a58029fe46 Update doc string 2018-04-20 13:45:41 +00:00
Liam Young 9861ca6f4d Vault charm action needs to be run on leader
The vault charm action to authorise the charm within vault needs to
be run on the leader. This mp adds run_action_on_leader to support
that and updates the tests.
2018-04-20 13:40:52 +00:00
Liam Young bcfd6aaf30 Add tests for vault authorize-charm action
Add tests for the authorize-charm action on the vault app. To
support this add get_action method to return an applications
actions. However, this is not implemented in libjuju yet so
fallback to subprocess
2018-04-19 11:41:09 +00:00
Frode Nordahl be24513e1c Merge pull request #29 from gnuoy/feature/add-run-action
Add juju run_action support
2018-04-18 21:54:40 +02:00
Liam Young 769a6b9cc4 Fix doc string 2018-04-18 19:51:43 +00:00
Liam Young 7e07abb4c4 Fix doc string lint as per tinwoods comments 2018-04-18 16:24:04 +00:00
Liam Young 4cec473ede Remove old run_in_model_old method and fix param ordering in doc strings 2018-04-18 15:39:04 +00:00
Liam Young acbcf98d68 Add juju run_action support 2018-04-18 15:34:27 +00:00
Liam Young d65dd96f26 Use async_generator pkg to simplify async calls
Use the async_generator, yield_, asynccontextmanager methods from
async_generator to simplify the creation of sync wrappers around
async libjuju calls
2018-04-18 13:36:13 +00:00
David Ames 44920b9790 Remove dynamic default arguments 2018-04-13 07:48:21 -07:00
David Ames bcf8a21c35 Fix set_appliction_config 2018-04-12 16:28:48 -07:00
David Ames 6eae8a0fbb Use libjuju unit.run for juju_run
Use libjuju for juju run commands
Add unit test for model.run_on_unit
2018-04-12 10:43:35 -07:00
David Ames 22e7ffc1e1 Bring over network specific utilities
Bring over only those utilities required to run network_setup.py from
openstack-mojo-specs. These utilities have been generalized and python3
configured. Use libjuju whenever possible and pre-deprecate anything
else.

Add addition functions to the model.
2018-03-30 16:41:17 -07:00
Liam Young 117ae4127d Add function to scp file to all units 2018-03-29 05:35:49 +00:00
Liam Young 59a9b7f0cb Add helper utils for interacting with juju environment 2018-03-29 05:35:49 +00:00
Liam Young 353559528b s/charm_testing/charm_lifecycle/ and unit tests 2018-03-27 12:35:38 +00:00
Liam Young 12c7363b34 Remove new unit_ips from mp, will add in as a seperate mp 2018-03-26 08:31:26 +00:00
Liam Young 458a76f05a Add helps for charm functional tests
The idea of this change is to put together helpers for including
functional tests for charms in a central location. The charm
declares the tests and bundles to be run to complete a
functional tests but the tests themselves live here in zaza.

To use this code the charm should have the following:

1) zaza in the test-requirements.txt
2) tox.ini should include a target like:
```
[testenv:func35]
  basepython = python3
  commands =
    functest-bundle-deploy
```

3) Bundles which are to be used for the tests:
```
ls -1 tests/bundles/*
tests/bundles/xenial.yaml
```

4) A tests/tests.yaml file that describes the bundles to be run and
   the tests
```
charm_name: vault
tests:
  - zaza.charms_tests.vault.VaultTest
gate_bundles:
  - xenial
dev_bundles:
  - bionic
```

Tests can be run without running a deployment using functest-run-tests
with the list of test classes to be run:

```
functest-run-tests -t zaza.charms_tests.vault.VaultTest
```

Known Issues:

 - The deploy_bundle and add_model methods should be using libjuju
 - DEV_BUNDLES is currently ignored
 - VaultUtils and VaultTest should probably be in separate files.
 - When skipIfNotHA skips a test unittest does not pick up it has
   been skipped
 - A new model is created for each bundle even if an existing empty
   model exists
 - No model cleanup is performed.
2018-03-26 08:31:26 +00:00
Liam Young 5e613051bc Remove new unit_ips from mp, will add in as a seperate mp 2018-03-26 08:28:10 +00:00