[test] Added tests for glance cookbook

This commit is contained in:
Maxim Kulkin 2012-08-13 19:19:14 +04:00
parent 7559cc66c7
commit 2b44ed70d1
2 changed files with 106 additions and 20 deletions

View File

@ -81,6 +81,20 @@ class OpenstackCommon(object):
klass.remote.reconnect()
rabbitmq_port = 5672
@classmethod
def setUpRabbitMq(klass):
klass.upload_cookbooks(['rabbitmq'])
klass.chef_solo({
'recipes': ['rabbitmq'],
'rabbitmq': {
'port': klass.rabbitmq_port
}
})
glance_registry_port = 9191
@classmethod
@ -94,27 +108,31 @@ class OpenstackCommon(object):
'recipes': ['glance::registry'],
'glance': {
'registry': {
'port': klass.glance_registry_port,
'admin': {
'host': str(klass.ip),
'port': klass.glance_registry_port,
},
},
},
'services': {
'glance_registry': {
'endpoints': {
'mysql': {
'host': str(klass.ip),
'port': klass.mysql_port,
'username': 'db_maker',
'password': 'secret',
},
'keystone_admin': {
'host': str(klass.ip),
'port': klass.keystone_admin_port,
'username': 'admin',
'token': 'keystone_secret',
},
}
'mysql': {
'admin': {
'host': str(klass.ip),
'port': klass.mysql_port,
'username': 'db_maker',
'password': 'secret'
}
},
'keystone': {
'admin_url': 'http://%s:%s/' %
(klass.ip, klass.keystone_admin_port),
'admin_token': klass.keystone_admin_token,
'service_tenant': 'admin',
'admin_role': 'admin',
'admin': {
'host': str(klass.ip),
'admin_port': klass.keystone_admin_port,
},
}
},
})
if not klass.node.has_snapshot('openstack-glance-registry'):
@ -123,3 +141,59 @@ class OpenstackCommon(object):
klass.node.restore_snapshot('openstack-glance-registry')
klass.remote.reconnect()
glance_api_port = 9292
@classmethod
def setUpGlanceApi(klass, reuse_cached=True):
if not klass.node.has_snapshot('openstack-glance-api') or not reuse_cached:
klass.setUpGlanceRegistry()
klass.setUpRabbitMq()
klass.upload_cookbooks(['chef-resource-groups', 'database', 'keystone', 'glance'])
klass.chef_solo({
'recipes': ['glance::api'],
'glance': {
'api': {
'admin': {
'host': str(klass.ip),
'port': klass.glance_api_port,
},
'public': {
'host': str(klass.ip),
'port': klass.glance_api_port,
},
},
'registry': {
'admin': {
'host': str(klass.ip),
'port': klass.glance_registry_port,
},
},
},
'keystone': {
'admin_url': 'http://%s:%s/' %
(klass.ip, klass.keystone_admin_port),
'admin_token': klass.keystone_admin_token,
'service_tenant': 'admin',
'admin_role': 'admin',
'admin': {
'host': str(klass.ip),
'admin_port': klass.keystone_admin_port,
},
},
'rabbitmq': {
'admin': {
'host': str(klass.ip),
'port': klass.rabbitmq_port,
},
},
})
if not klass.node.has_snapshot('openstack-glance-api'):
klass.node.save_snapshot('openstack-glance-api')
else:
klass.node.restore_snapshot('openstack-glance-api')
klass.remote.reconnect()

View File

@ -1,5 +1,6 @@
from . import CookbookTestCase
from openstack_common import OpenstackCommon
from devops.helpers import tcp_ping, wait
class TestGlanceRegistry(CookbookTestCase, OpenstackCommon):
cookbooks = ['chef-resource-groups', 'database', 'keystone', 'glance']
@ -9,6 +10,17 @@ class TestGlanceRegistry(CookbookTestCase, OpenstackCommon):
klass.setUpKeystone()
klass.setUpGlanceRegistry(reuse_cached=False)
def test_glance_registry(self):
pass
def test_glance_registry_port_open(self):
assert tcp_ping(self.ip, self.glance_registry_port)
class TestGlanceApi(CookbookTestCase, OpenstackCommon):
cookbooks = ['chef-resource-groups', 'database', 'keystone', 'glance']
@classmethod
def setUpState(klass):
klass.setUpGlanceRegistry()
klass.setUpGlanceApi(reuse_cached=False)
def test_glance_api_port_open(self):
assert tcp_ping(self.ip, self.glance_api_port)