sync /next
This commit is contained in:
commit
10e7fcd5ae
1
Makefile
1
Makefile
|
@ -13,6 +13,7 @@ test:
|
|||
|
||||
functional_test:
|
||||
@echo Starting Amulet tests...
|
||||
@tests/setup/00-setup
|
||||
@juju test -v -p AMULET_HTTP_PROXY,AMULET_OS_VIP --timeout 2700
|
||||
|
||||
bin/charm_helpers_sync.py:
|
||||
|
|
|
@ -25,6 +25,11 @@ options:
|
|||
description: |
|
||||
Key ID to import to the apt keyring to support use with arbitary source
|
||||
configuration from outside of Launchpad archives or PPA's.
|
||||
port:
|
||||
type: int
|
||||
default: 80
|
||||
description: |
|
||||
The port that the RADOS Gateway will listen on.
|
||||
# Keystone integration
|
||||
operator-roles:
|
||||
default: "Member,Admin"
|
||||
|
|
|
@ -22,18 +22,17 @@ class HAProxyContext(context.HAProxyContext):
|
|||
|
||||
def __call__(self):
|
||||
ctxt = super(HAProxyContext, self).__call__()
|
||||
port = config('port')
|
||||
|
||||
# Apache ports
|
||||
a_cephradosgw_api = determine_apache_port(80,
|
||||
singlenode_mode=True)
|
||||
a_cephradosgw_api = determine_apache_port(port, singlenode_mode=True)
|
||||
|
||||
port_mapping = {
|
||||
'cephradosgw-server': [
|
||||
80, a_cephradosgw_api]
|
||||
'cephradosgw-server': [port, a_cephradosgw_api]
|
||||
}
|
||||
|
||||
ctxt['cephradosgw_bind_port'] = determine_api_port(
|
||||
80,
|
||||
port,
|
||||
singlenode_mode=True,
|
||||
)
|
||||
|
||||
|
@ -101,6 +100,8 @@ class MonContext(context.OSContextGenerator):
|
|||
'use_syslog': str(config('use-syslog')).lower(),
|
||||
'embedded_webserver': config('use-embedded-webserver'),
|
||||
'loglevel': config('loglevel'),
|
||||
'port': determine_apache_port(config('port'),
|
||||
singlenode_mode=True)
|
||||
}
|
||||
|
||||
certs_path = '/var/lib/ceph/nss'
|
||||
|
|
|
@ -39,6 +39,9 @@ from charmhelpers.core.host import (
|
|||
lsb_release,
|
||||
restart_on_change,
|
||||
)
|
||||
from charmhelpers.contrib.hahelpers.cluster import (
|
||||
determine_apache_port,
|
||||
)
|
||||
from utils import (
|
||||
render_template,
|
||||
enable_pocket,
|
||||
|
@ -70,6 +73,8 @@ from charmhelpers.contrib.storage.linux.ceph import (
|
|||
is_request_complete,
|
||||
)
|
||||
|
||||
APACHE_PORTS_CONF = '/etc/apache2/ports.conf'
|
||||
|
||||
hooks = Hooks()
|
||||
CONFIGS = register_configs()
|
||||
|
||||
|
@ -142,7 +147,8 @@ def install():
|
|||
|
||||
def emit_apacheconf():
|
||||
apachecontext = {
|
||||
"hostname": unit_get('private-address')
|
||||
"hostname": unit_get('private-address'),
|
||||
"port": determine_apache_port(config('port'), singlenode_mode=True)
|
||||
}
|
||||
site_conf = '/etc/apache2/sites-available/rgw'
|
||||
if is_apache_24():
|
||||
|
@ -169,7 +175,11 @@ def apache_reload():
|
|||
|
||||
|
||||
def apache_ports():
|
||||
shutil.copy('files/ports.conf', '/etc/apache2/ports.conf')
|
||||
portscontext = {
|
||||
"port": determine_apache_port(config('port'), singlenode_mode=True)
|
||||
}
|
||||
with open(APACHE_PORTS_CONF, 'w') as portsconf:
|
||||
portsconf.write(render_template('ports.conf', portscontext))
|
||||
|
||||
|
||||
def setup_keystone_certs(unit=None, rid=None):
|
||||
|
@ -211,13 +221,14 @@ def setup_keystone_certs(unit=None, rid=None):
|
|||
|
||||
# CA
|
||||
try:
|
||||
# Kilo and newer
|
||||
ca_cert = keystone.certificates.get_ca_certificate()
|
||||
except AttributeError:
|
||||
# Juno and older
|
||||
ca_cert = requests.request('GET', auth_endpoint +
|
||||
'/certificates/ca').text
|
||||
except ConnectionRefused:
|
||||
try:
|
||||
# Kilo and newer
|
||||
ca_cert = keystone.certificates.get_ca_certificate()
|
||||
except AttributeError:
|
||||
# Juno and older
|
||||
ca_cert = requests.request('GET', auth_endpoint +
|
||||
'/certificates/ca').text
|
||||
except (ConnectionRefused, requests.exceptions.ConnectionError):
|
||||
log("Error connecting to keystone - skipping ca/signing cert setup",
|
||||
level=WARNING)
|
||||
return
|
||||
|
@ -238,13 +249,14 @@ def setup_keystone_certs(unit=None, rid=None):
|
|||
|
||||
# Signing cert
|
||||
try:
|
||||
# Kilo and newer
|
||||
signing_cert = keystone.certificates.get_signing_certificate()
|
||||
except AttributeError:
|
||||
# Juno and older
|
||||
signing_cert = requests.request('GET', auth_endpoint +
|
||||
'/certificates/signing').text
|
||||
except ConnectionRefused:
|
||||
try:
|
||||
# Kilo and newer
|
||||
signing_cert = keystone.certificates.get_signing_certificate()
|
||||
except AttributeError:
|
||||
# Juno and older
|
||||
signing_cert = requests.request('GET', auth_endpoint +
|
||||
'/certificates/signing').text
|
||||
except (ConnectionRefused, requests.exceptions.ConnectionError):
|
||||
log("Error connecting to keystone - skipping ca/signing cert setup",
|
||||
level=WARNING)
|
||||
return
|
||||
|
@ -304,22 +316,22 @@ def mon_relation():
|
|||
@hooks.hook('gateway-relation-joined')
|
||||
def gateway_relation():
|
||||
relation_set(hostname=unit_get('private-address'),
|
||||
port=80)
|
||||
port=config('port'))
|
||||
|
||||
|
||||
def start():
|
||||
subprocess.call(['service', 'radosgw', 'start'])
|
||||
open_port(port=80)
|
||||
open_port(port=config('port'))
|
||||
|
||||
|
||||
def stop():
|
||||
subprocess.call(['service', 'radosgw', 'stop'])
|
||||
open_port(port=80)
|
||||
open_port(port=config('port'))
|
||||
|
||||
|
||||
def restart():
|
||||
subprocess.call(['service', 'radosgw', 'restart'])
|
||||
open_port(port=80)
|
||||
open_port(port=config('port'))
|
||||
|
||||
|
||||
@hooks.hook('identity-service-relation-joined')
|
||||
|
@ -328,7 +340,7 @@ def identity_joined(relid=None):
|
|||
log('Integration with keystone requires ceph >= 0.55')
|
||||
sys.exit(1)
|
||||
|
||||
port = 80
|
||||
port = config('port')
|
||||
admin_url = '%s:%i/swift' % (canonical_url(None, ADMIN), port)
|
||||
internal_url = '%s:%s/swift/v1' % \
|
||||
(canonical_url(None, INTERNAL), port)
|
||||
|
|
|
@ -18,7 +18,7 @@ keyring = /etc/ceph/keyring.rados.gateway
|
|||
rgw socket path = /tmp/radosgw.sock
|
||||
log file = /var/log/ceph/radosgw.log
|
||||
{% if embedded_webserver %}
|
||||
rgw frontends = civetweb port=70
|
||||
rgw frontends = civetweb port={{ port }}
|
||||
{% elif disable_100_continue %}
|
||||
# Turn off 100-continue optimization as stock mod_fastcgi
|
||||
# does not support it
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Listen 70
|
||||
Listen {{ port }}
|
||||
|
||||
<IfModule ssl_module>
|
||||
Listen 443
|
|
@ -2,7 +2,7 @@
|
|||
FastCgiExternalServer /var/www/s3gw.fcgi -socket /tmp/radosgw.sock
|
||||
</IfModule>
|
||||
|
||||
<VirtualHost *:70>
|
||||
<VirtualHost *:{{ port }}>
|
||||
ServerName {{ hostname }}
|
||||
ServerAdmin ceph@ubuntu.com
|
||||
DocumentRoot /var/www
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
"""Amulet tests on a basic ceph-radosgw deployment on trusty-liberty."""
|
||||
|
||||
from basic_deployment import CephRadosGwBasicDeployment
|
||||
|
||||
if __name__ == '__main__':
|
||||
deployment = CephRadosGwBasicDeployment(series='trusty',
|
||||
openstack='cloud:trusty-liberty',
|
||||
source='cloud:trusty-updates/liberty')
|
||||
deployment.run_tests()
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
"""Amulet tests on a basic ceph-radosgw deployment on trusty-mitaka."""
|
||||
|
||||
from basic_deployment import CephRadosGwBasicDeployment
|
||||
|
||||
if __name__ == '__main__':
|
||||
deployment = CephRadosGwBasicDeployment(series='trusty',
|
||||
openstack='cloud:trusty-mitaka',
|
||||
source='cloud:trusty-updates/mitaka')
|
||||
deployment.run_tests()
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
"""Amulet tests on a basic ceph-radosgw deployment on vivid-kilo."""
|
||||
"""Amulet tests on a basic ceph-radosgw deployment on wily-liberty."""
|
||||
|
||||
from basic_deployment import CephRadosGwBasicDeployment
|
||||
|
||||
if __name__ == '__main__':
|
||||
deployment = CephRadosGwBasicDeployment(series='vivid')
|
||||
deployment = CephRadosGwBasicDeployment(series='wily')
|
||||
deployment.run_tests()
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
"""Amulet tests on a basic ceph-radosgw deployment on xenial-mitaka."""
|
||||
|
||||
from basic_deployment import CephRadosGwBasicDeployment
|
||||
|
||||
if __name__ == '__main__':
|
||||
deployment = CephRadosGwBasicDeployment(series='xenial')
|
||||
deployment.run_tests()
|
120
tests/README
120
tests/README
|
@ -1,53 +1,113 @@
|
|||
This directory provides Amulet tests that focus on verification of
|
||||
ceph-radosgw deployments.
|
||||
This directory provides Amulet tests to verify basic deployment functionality
|
||||
from the perspective of this charm, its requirements and its features, as
|
||||
exercised in a subset of the full OpenStack deployment test bundle topology.
|
||||
|
||||
In order to run tests, you'll need charm-tools installed (in addition to
|
||||
juju, of course):
|
||||
Reference: lp:openstack-charm-testing for full test bundles.
|
||||
|
||||
A single topology and configuration is defined and deployed, once for each of
|
||||
the defined Ubuntu:OpenStack release combos. The ongoing goal is for this
|
||||
charm to always possess tests and combo definitions for all currently-supported
|
||||
release combinations of U:OS.
|
||||
|
||||
test_* methods are called in lexical sort order, as with most runners. However,
|
||||
each individual test method should be idempotent and expected to pass regardless
|
||||
of run order or Ubuntu:OpenStack combo. When writing or modifying tests,
|
||||
ensure that every individual test is not dependent on another test_ method.
|
||||
|
||||
Test naming convention, purely for code organization purposes:
|
||||
1xx service and endpoint checks
|
||||
2xx relation checks
|
||||
3xx config checks
|
||||
4xx functional checks
|
||||
9xx restarts, config changes, actions and other final checks
|
||||
|
||||
In order to run tests, charm-tools and juju must be installed:
|
||||
sudo add-apt-repository ppa:juju/stable
|
||||
sudo apt-get update
|
||||
sudo apt-get install charm-tools
|
||||
sudo apt-get install charm-tools juju juju-deployer amulet
|
||||
|
||||
If you use a web proxy server to access the web, you'll need to set the
|
||||
AMULET_HTTP_PROXY environment variable to the http URL of the proxy server.
|
||||
Alternatively, tests may be exercised with proposed or development versions
|
||||
of juju and related tools:
|
||||
|
||||
# juju proposed version
|
||||
sudo add-apt-repository ppa:juju/proposed
|
||||
sudo apt-get update
|
||||
sudo apt-get install charm-tools juju juju-deployer
|
||||
|
||||
# juju development version
|
||||
sudo add-apt-repository ppa:juju/devel
|
||||
sudo apt-get update
|
||||
sudo apt-get install charm-tools juju juju-deployer
|
||||
|
||||
Some tests may need to download files. If a web proxy server is required in
|
||||
the environment, the AMULET_HTTP_PROXY environment variable must be set and
|
||||
passed into the juju test command. This is unrelated to juju's http proxy
|
||||
settings or behavior.
|
||||
|
||||
The following examples demonstrate different ways that tests can be executed.
|
||||
All examples are run from the charm's root directory.
|
||||
|
||||
* To run all tests (starting with 00-setup):
|
||||
* To run all +x tests in the tests directory:
|
||||
|
||||
make test
|
||||
bzr branch lp:charms/trusty/foo
|
||||
cd foo
|
||||
make functional_test
|
||||
|
||||
* To run a specific test module (or modules):
|
||||
* To run the tests against a specific release combo as defined in tests/:
|
||||
|
||||
juju test -v -p AMULET_HTTP_PROXY 15-basic-trusty-icehouse
|
||||
bzr branch lp:charms/trusty/foo
|
||||
cd foo
|
||||
juju test -v -p AMULET_HTTP_PROXY 015-basic-trusty-icehouse
|
||||
|
||||
* To run a specific test module (or modules), and keep the environment
|
||||
deployed after a failure:
|
||||
* To run tests and keep the juju environment deployed after a failure:
|
||||
|
||||
juju test --set-e -v -p AMULET_HTTP_PROXY 15-basic-trusty-icehouse
|
||||
bzr branch lp:charms/trusty/foo
|
||||
cd foo
|
||||
juju test --set-e -v -p AMULET_HTTP_PROXY 015-basic-trusty-icehouse
|
||||
|
||||
* To re-run a test module against an already deployed environment (one
|
||||
that was deployed by a previous call to 'juju test --set-e'):
|
||||
|
||||
./tests/15-basic-trusty-icehouse
|
||||
./tests/015-basic-trusty-icehouse
|
||||
|
||||
For debugging and test development purposes, all code should be idempotent.
|
||||
In other words, the code should have the ability to be re-run without changing
|
||||
the results beyond the initial run. This enables editing and re-running of a
|
||||
test module against an already deployed environment, as described above.
|
||||
* Even with --set-e, `juju test` will tear down the deployment when all
|
||||
tests pass. The following work flow may be more effective when
|
||||
iterating on test writing.
|
||||
|
||||
Manual debugging tips:
|
||||
bzr branch lp:charms/trusty/foo
|
||||
cd foo
|
||||
./tests/setup/00-setup
|
||||
juju bootstrap
|
||||
./tests/015-basic-trusty-icehouse
|
||||
# make some changes, run tests again
|
||||
./tests/015-basic-trusty-icehouse
|
||||
# make some changes, run tests again
|
||||
./tests/015-basic-trusty-icehouse
|
||||
|
||||
* Set the following env vars before using the OpenStack CLI as admin:
|
||||
export OS_AUTH_URL=http://`juju-deployer -f keystone 2>&1 | tail -n 1`:5000/v2.0
|
||||
export OS_TENANT_NAME=admin
|
||||
* There may be test definitions in the tests/ dir which are not set +x
|
||||
executable. This is generally true for deprecated releases, or for
|
||||
upcoming releases which are not yet validated and enabled. To enable
|
||||
and run these tests:
|
||||
bzr branch lp:charms/trusty/foo
|
||||
cd foo
|
||||
ls tests
|
||||
chmod +x tests/017-basic-trusty-kilo
|
||||
./tests/setup/00-setup
|
||||
juju bootstrap
|
||||
./tests/017-basic-trusty-kilo
|
||||
|
||||
|
||||
Additional notes:
|
||||
|
||||
* Use DEBUG to turn on debug logging, use ERROR otherwise.
|
||||
u = OpenStackAmuletUtils(ERROR)
|
||||
u = OpenStackAmuletUtils(DEBUG)
|
||||
|
||||
* To interact with the deployed environment:
|
||||
export OS_USERNAME=admin
|
||||
export OS_PASSWORD=openstack
|
||||
export OS_TENANT_NAME=admin
|
||||
export OS_REGION_NAME=RegionOne
|
||||
|
||||
* Set the following env vars before using the OpenStack CLI as demoUser:
|
||||
export OS_AUTH_URL=http://`juju-deployer -f keystone 2>&1 | tail -n 1`:5000/v2.0
|
||||
export OS_TENANT_NAME=demoTenant
|
||||
export OS_USERNAME=demoUser
|
||||
export OS_PASSWORD=password
|
||||
export OS_REGION_NAME=RegionOne
|
||||
export OS_AUTH_URL=${OS_AUTH_PROTOCOL:-http}://`juju-deployer -e trusty -f keystone`:5000/v2.0
|
||||
keystone user-list
|
||||
glance image-list
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
bootstrap: true
|
||||
reset: true
|
||||
reset: false
|
||||
virtualenv: true
|
||||
makefile:
|
||||
- lint
|
||||
|
@ -9,6 +9,7 @@ sources:
|
|||
packages:
|
||||
- amulet
|
||||
- distro-info-data
|
||||
- python-ceilometerclient
|
||||
- python-cinderclient
|
||||
- python-distro-info
|
||||
- python-glanceclient
|
||||
|
|
|
@ -168,6 +168,7 @@ class MonContextTest(CharmTestCase):
|
|||
'old_auth': False,
|
||||
'use_syslog': 'false',
|
||||
'loglevel': 1,
|
||||
'port': 70
|
||||
}
|
||||
self.assertEqual(expect, mon_ctxt())
|
||||
|
||||
|
@ -202,6 +203,7 @@ class MonContextTest(CharmTestCase):
|
|||
'old_auth': False,
|
||||
'use_syslog': 'false',
|
||||
'loglevel': 1,
|
||||
'port': 70
|
||||
}
|
||||
self.assertEqual(expect, mon_ctxt())
|
||||
|
||||
|
@ -228,5 +230,6 @@ class MonContextTest(CharmTestCase):
|
|||
'old_auth': False,
|
||||
'use_syslog': 'false',
|
||||
'loglevel': 1,
|
||||
'port': 70
|
||||
}
|
||||
self.assertEqual(expect, mon_ctxt())
|
||||
|
|
|
@ -127,6 +127,7 @@ class CephRadosGWTests(CharmTestCase):
|
|||
self.unit_get.return_value = '10.0.0.1'
|
||||
apachecontext = {
|
||||
"hostname": '10.0.0.1',
|
||||
"port": 70,
|
||||
}
|
||||
vhost_file = '/etc/apache2/sites-available/rgw.conf'
|
||||
with patch_open() as (_open, _file):
|
||||
|
@ -167,6 +168,7 @@ class CephRadosGWTests(CharmTestCase):
|
|||
]
|
||||
self.subprocess.call.assert_has_calls(calls)
|
||||
|
||||
@patch.object(ceph_hooks, 'apache_ports', lambda *args: True)
|
||||
@patch.object(ceph_hooks, 'mkdir', lambda *args: None)
|
||||
def test_config_changed(self):
|
||||
_install_packages = self.patch('install_packages')
|
||||
|
|
Loading…
Reference in New Issue