Skip to content

Commit

Permalink
Migrate from Amulet to Zaza
Browse files Browse the repository at this point in the history
This patch migrate tests from Amulet to Zaza, and Python3 only.

func-test-pr: openstack-charmers/zaza-openstack-tests#55

Partial-Bug: 1828424

Change-Id: I4dacf33d3ab4dedbbe62a36b1b2ce5606e51d234
Signed-off-by: Joe Guo <guoqiao@gmail.com>
  • Loading branch information
guoqiao committed Sep 11, 2019
1 parent 77fab98 commit 4609bf3
Show file tree
Hide file tree
Showing 35 changed files with 765 additions and 1,140 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/make
PYTHON := /usr/bin/env python
PYTHON := /usr/bin/env python3

lint:
@tox -e pep8

test:
@echo Starting unit tests...
@tox -e py27
@tox -e py3

functional_test:
@echo Starting functional tests...
@tox -e func27
@tox -e func

bin/charm_helpers_sync.py:
@mkdir -p bin
Expand Down
1 change: 1 addition & 0 deletions hooks/certificates-relation-changed
1 change: 1 addition & 0 deletions hooks/certificates-relation-joined
22 changes: 22 additions & 0 deletions hooks/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ def _add_path(path):
set_unit_paused,
set_unit_upgrading,
)

from charmhelpers.contrib.openstack.templating import OSConfigRenderer

from charmhelpers.contrib.charmsupport import nrpe

from charmhelpers.contrib.openstack.cert_utils import (
get_certificate_request,
process_certificates,
)

CONF_FILE_DIR = '/etc/glance-simplestreams-sync'
USR_SHARE_DIR = '/usr/share/glance-simplestreams-sync'

Expand Down Expand Up @@ -96,6 +102,7 @@ def __call__(self):
ssl_ca = hookenv.config('ssl_ca')
if ctxt and ssl_ca:
ctxt['ssl_ca'] = ssl_ca
ctxt['auth_protocol'] = 'https'
return ctxt


Expand Down Expand Up @@ -353,6 +360,21 @@ def post_series_upgrade():
hookenv.status_set("active", "")


@hooks.hook('certificates-relation-joined')
def certs_joined(relation_id=None):
hookenv.relation_set(
relation_id=relation_id,
relation_settings=get_certificate_request())


@hooks.hook('certificates-relation-changed')
def certs_changed(relation_id=None, unit=None):
process_certificates('glance-simplestreams-sync', relation_id, unit)
configs = get_configs()
configs.write_all()
identity_service_changed()


if __name__ == '__main__':
try:
hooks.execute(sys.argv)
Expand Down
2 changes: 2 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ requires:
interface: keystone
amqp:
interface: rabbitmq
certificates:
interface: tls-certificates
14 changes: 9 additions & 5 deletions scripts/glance-simplestreams-sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,12 @@ def _setup_connection(self):
return False

try:
url = "amqp://{}:{}@{}/{}".format(id_conf['rabbit_userid'],
id_conf['rabbit_password'],
host,
id_conf['rabbit_virtual_host'])
# amqp:// implies librabbitmq if available, otherwise pyamqp
# librabbitmq doesn't support SSL
# use pyamqp:// explicitly for SSL
url = "pyamqp://{}:{}@{}/{}".format(
id_conf['rabbit_userid'], id_conf['rabbit_password'],
host, id_conf['rabbit_virtual_host'])

ssl = None
if 'rabbit_use_ssl' in id_conf:
Expand Down Expand Up @@ -503,7 +505,9 @@ def main():
"message": "Sync starting."})
do_sync(charm_conf, status_exchange)
ts = time.strftime("%x %X")
completed_msg = "Sync completed at {}".format(ts)
# "Unit is ready" is one of approved message prefixes
# Prefix the message with it will help zaza to check.
completed_msg = "Unit is ready. Sync completed at {}".format(ts)
status_exchange.send_message({"status": "Done",
"message": completed_msg})
status_set('active', completed_msg)
Expand Down
27 changes: 4 additions & 23 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
charm-tools>=2.4.4
requests>=2.18.4
coverage>=3.6
mock>=1.2
flake8>=2.2.4,<=2.4.1
stestr>=2.2.0
requests>=2.18.4
# BEGIN: Amulet OpenStack Charm Helper Requirements
# Liberty client lower constraints
amulet>=1.14.3,<2.0;python_version=='2.7'
bundletester>=0.6.1,<1.0;python_version=='2.7'
python-ceilometerclient>=1.5.0
python-cinderclient>=1.4.0
python-glanceclient>=1.1.0
python-heatclient>=0.8.0
python-keystoneclient>=1.7.1
python-neutronclient>=3.1.0
python-novaclient>=2.30.1
python-openstackclient>=1.7.0
python-swiftclient>=2.6.0
pika>=0.10.0,<1.0
distro-info
git+https://github.com/juju/charm-helpers.git#egg=charmhelpers
# END: Amulet OpenStack Charm Helper Requirements
# NOTE: workaround for 14.04 pip/tox
pytz
pyudev # for ceph-* charm unit tests (not mocked?)

git+https://github.com/openstack-charmers/zaza.git#egg=zaza;python_version>='3.0'
git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack
9 changes: 0 additions & 9 deletions tests/README.md

This file was deleted.

0 comments on commit 4609bf3

Please sign in to comment.