Add new deployment tests
-Add test which checks postgresql deployment -Add test which checks tomcat deployment Change-Id: Ie02c7eac383d232bed0c03481a0833b6a5edea93
This commit is contained in:
parent
744eee2a84
commit
a265520b71
@ -13,6 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
import requests
|
||||
import testresources
|
||||
import testtools
|
||||
@ -30,13 +31,12 @@ CONF = cfg.cfg.CONF
|
||||
|
||||
class Client(object):
|
||||
|
||||
def __init__(self, user, password, tenant, auth_url):
|
||||
def __init__(self, user, password, tenant, auth_url, murano_url):
|
||||
|
||||
self.auth = ksclient.Client(username=user, password=password,
|
||||
tenant_name=tenant, auth_url=auth_url)
|
||||
|
||||
self.endpoint = self.auth.service_catalog.url_for(
|
||||
service_type='application_catalog', endpoint_type='publicURL')
|
||||
self.endpoint = murano_url
|
||||
|
||||
self.headers = {
|
||||
'X-Auth-Token': self.auth.auth_token,
|
||||
@ -130,7 +130,48 @@ class MuranoBase(testtools.TestCase, testtools.testcase.WithAttributes,
|
||||
cls.client = Client(user=CONF.murano.user,
|
||||
password=CONF.murano.password,
|
||||
tenant=CONF.murano.tenant,
|
||||
auth_url=CONF.murano.auth_url)
|
||||
auth_url=CONF.murano.auth_url,
|
||||
murano_url=CONF.murano.murano_url)
|
||||
|
||||
cls.location = os.path.realpath(
|
||||
os.path.join(os.getcwd(), os.path.dirname(__file__)))
|
||||
|
||||
cls.packages_path = '/'.join(cls.location.split('/')[:-1:])
|
||||
|
||||
def upload_package(package_name, body, app):
|
||||
files = {'%s' % package_name: open(
|
||||
os.path.join(cls.packages_path, app), 'rb')}
|
||||
|
||||
post_body = {'JsonString': json.dumps(body)}
|
||||
request_url = '{endpoint}{url}'.format(
|
||||
endpoint=CONF.murano.murano_url,
|
||||
url='catalog/packages')
|
||||
|
||||
return requests.post(request_url,
|
||||
files=files,
|
||||
data=post_body,
|
||||
headers=cls.client.headers).json()['id']
|
||||
|
||||
cls.postgre_id = upload_package(
|
||||
'PostgreSQL',
|
||||
{"categories": ["Databases"], "tags": ["tag"]},
|
||||
'murano-app-incubator/io.murano.apps.PostgreSql.zip')
|
||||
cls.apache_id = upload_package(
|
||||
'Apache',
|
||||
{"categories": ["Application Servers"], "tags": ["tag"]},
|
||||
'murano-app-incubator/io.murano.apps.apache.Apache.zip')
|
||||
cls.tomcat_id = upload_package(
|
||||
'Tomcat',
|
||||
{"categories": ["Application Servers"], "tags": ["tag"]},
|
||||
'murano-app-incubator/io.murano.apps.apache.Tomcat.zip')
|
||||
cls.telnet_id = upload_package(
|
||||
'Telnet',
|
||||
{"categories": ["Web"], "tags": ["tag"]},
|
||||
'murano-app-incubator/io.murano.apps.linux.Telnet.zip')
|
||||
cls.ad_id = upload_package(
|
||||
'Active Directory',
|
||||
{"categories": ["Microsoft Services"], "tags": ["tag"]},
|
||||
'murano-app-incubator/io.murano.windows.ActiveDirectory.zip')
|
||||
|
||||
def setUp(self):
|
||||
super(MuranoBase, self).setUp()
|
||||
@ -138,6 +179,7 @@ class MuranoBase(testtools.TestCase, testtools.testcase.WithAttributes,
|
||||
self.environments = []
|
||||
|
||||
def tearDown(self):
|
||||
super(MuranoBase, self).tearDown()
|
||||
|
||||
for env in self.environments:
|
||||
try:
|
||||
@ -151,16 +193,13 @@ class MuranoBase(testtools.TestCase, testtools.testcase.WithAttributes,
|
||||
"flavor": "m1.medium",
|
||||
"image": self.client.linux,
|
||||
"?": {
|
||||
"type": "io.murano.resources.Instance",
|
||||
"type": "io.murano.resources.LinuxMuranoInstance",
|
||||
"id": str(uuid.uuid4())
|
||||
},
|
||||
"name": "testMurano"
|
||||
},
|
||||
"name": "teMurano",
|
||||
"?": {
|
||||
"_{id}".format(id=uuid.uuid4().hex): {
|
||||
"name": "Telnet"
|
||||
},
|
||||
"type": "io.murano.apps.linux.Telnet",
|
||||
"id": str(uuid.uuid4())
|
||||
}
|
||||
@ -188,16 +227,13 @@ class MuranoBase(testtools.TestCase, testtools.testcase.WithAttributes,
|
||||
"flavor": "m1.medium",
|
||||
"image": self.client.linux,
|
||||
"?": {
|
||||
"type": "io.murano.resources.Instance",
|
||||
"type": "io.murano.resources.LinuxMuranoInstance",
|
||||
"id": str(uuid.uuid4())
|
||||
},
|
||||
"name": "testMurano"
|
||||
},
|
||||
"name": "teMurano",
|
||||
"?": {
|
||||
"_{id}".format(id=uuid.uuid4().hex): {
|
||||
"name": "Apache"
|
||||
},
|
||||
"type": "io.murano.apps.apache.Apache",
|
||||
"id": str(uuid.uuid4())
|
||||
}
|
||||
@ -218,3 +254,71 @@ class MuranoBase(testtools.TestCase, testtools.testcase.WithAttributes,
|
||||
deployments = self.client.deployments_list(environment['id'])
|
||||
for deployment in deployments:
|
||||
self.assertEqual('success', deployment['state'])
|
||||
|
||||
def test_deploy_postgresql(self):
|
||||
post_body = {
|
||||
"instance": {
|
||||
"flavor": "m1.medium",
|
||||
"image": self.client.linux,
|
||||
"?": {
|
||||
"type": "io.murano.resources.LinuxMuranoInstance",
|
||||
"id": str(uuid.uuid4())
|
||||
},
|
||||
"name": "testMurano"
|
||||
},
|
||||
"name": "teMurano",
|
||||
"?": {
|
||||
"type": "io.murano.apps.PostgreSql",
|
||||
"id": str(uuid.uuid4())
|
||||
}
|
||||
}
|
||||
|
||||
environment = self.client.create_environment('Postgreenv')
|
||||
self.environments.append(environment['id'])
|
||||
|
||||
session = self.client.create_session(environment['id'])
|
||||
|
||||
self.client.create_service(environment['id'], session['id'], post_body)
|
||||
self.client.deploy_session(environment['id'], session['id'])
|
||||
|
||||
status = self.client.status_check(environment['id'])
|
||||
|
||||
self.assertEqual('OK', status)
|
||||
|
||||
deployments = self.client.deployments_list(environment['id'])
|
||||
for deployment in deployments:
|
||||
self.assertEqual('success', deployment['state'])
|
||||
|
||||
def test_deploy_tomcat(self):
|
||||
post_body = {
|
||||
"instance": {
|
||||
"flavor": "m1.medium",
|
||||
"image": self.client.linux,
|
||||
"?": {
|
||||
"type": "io.murano.resources.LinuxMuranoInstance",
|
||||
"id": str(uuid.uuid4())
|
||||
},
|
||||
"name": "testMurano"
|
||||
},
|
||||
"name": "teMurano",
|
||||
"?": {
|
||||
"type": "io.murano.apps.apache.Tomcat",
|
||||
"id": str(uuid.uuid4())
|
||||
}
|
||||
}
|
||||
|
||||
environment = self.client.create_environment('Tomcatenv')
|
||||
self.environments.append(environment['id'])
|
||||
|
||||
session = self.client.create_session(environment['id'])
|
||||
|
||||
self.client.create_service(environment['id'], session['id'], post_body)
|
||||
self.client.deploy_session(environment['id'], session['id'])
|
||||
|
||||
status = self.client.status_check(environment['id'])
|
||||
|
||||
self.assertEqual('OK', status)
|
||||
|
||||
deployments = self.client.deployments_list(environment['id'])
|
||||
for deployment in deployments:
|
||||
self.assertEqual('success', deployment['state'])
|
||||
|
@ -3,3 +3,4 @@ auth_url = http://127.0.0.1:5000/v2.0/
|
||||
user = admin
|
||||
password = admin
|
||||
tenant = admin
|
||||
murano_url = http://127.0.0.1:8082/v1/
|
||||
|
@ -31,7 +31,10 @@ MuranoGroup = [
|
||||
help="password for keystone user"),
|
||||
cfg.StrOpt('tenant',
|
||||
default='admin',
|
||||
help='keystone tenant')
|
||||
help='keystone tenant'),
|
||||
cfg.StrOpt('murano_url',
|
||||
default='http://127.0.0.1:8082/v1/',
|
||||
help="murano url")
|
||||
]
|
||||
|
||||
|
||||
@ -40,7 +43,10 @@ def register_config(config, config_group, config_opts):
|
||||
config.register_group(config_group)
|
||||
config.register_opts(config_opts, config_group)
|
||||
|
||||
path = os.path.join("%s/config.conf" % os.getcwd())
|
||||
__location = os.path.realpath(os.path.join(os.getcwd(),
|
||||
os.path.dirname(__file__)))
|
||||
|
||||
path = os.path.join(__location, "config.conf")
|
||||
|
||||
if os.path.exists(path):
|
||||
cfg.CONF([], project='muranointegration', default_config_files=[path])
|
||||
|
Loading…
Reference in New Issue
Block a user