Functional tests for Chef and Puppet examples
This commit introduces some functional tests for Chef and Puppet example applications. Depends-On: I1363e46d655c8a641a1fa404faadc5f652f9fce4 Change-Id: I0a455d02a08d7c695f9f39e86b0dbb8b87deb5f2
This commit is contained in:
parent
a3c8e8a63c
commit
b7fac61172
|
@ -22,10 +22,12 @@ import time
|
|||
|
||||
from heatclient import client as heatclient
|
||||
from keystoneclient import exceptions as ks_exceptions
|
||||
from keystoneclient.v2_0 import client as ksclient
|
||||
import keystoneclient.v2_0 as keystoneclientv2
|
||||
import keystoneclient.v3 as keystoneclientv3
|
||||
from muranoclient import client as mclient
|
||||
import muranoclient.common.exceptions as exceptions
|
||||
from oslo_log import log as logging
|
||||
import re
|
||||
import yaml
|
||||
|
||||
from murano.services import states
|
||||
|
@ -77,6 +79,10 @@ class DeployTestMixin(zip_utils.ZipUtilsMixin):
|
|||
@memoize
|
||||
def keystone_client():
|
||||
region = CONF.murano.region_name
|
||||
if re.match(".*/v3/?$", CONF.murano.auth_url):
|
||||
ksclient = keystoneclientv3
|
||||
else:
|
||||
ksclient = keystoneclientv2
|
||||
return ksclient.Client(username=CONF.murano.user,
|
||||
password=CONF.murano.password,
|
||||
tenant_name=CONF.murano.tenant,
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
# image for linux services
|
||||
# linux_image = default_linux
|
||||
|
||||
# murano instance type
|
||||
# instance_type = io.murano.resources.LinuxMuranoInstance
|
||||
|
||||
# image for docker applications
|
||||
# docker_image = debian-8-docker.qcow2
|
||||
|
||||
|
|
|
@ -47,6 +47,9 @@ MuranoGroup = [
|
|||
cfg.StrOpt('linux_image',
|
||||
default='default_linux',
|
||||
help="image for linux services"),
|
||||
cfg.StrOpt('instance_type',
|
||||
default='io.murano.resources.LinuxMuranoInstance',
|
||||
help="murano instance type"),
|
||||
cfg.StrOpt('docker_image',
|
||||
default='ubuntu14.04-x64-docker',
|
||||
help="image for docker applications"),
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
Namespaces:
|
||||
=: io.murano.conflang.chef.ExampleChef
|
||||
std: io.murano
|
||||
res: io.murano.resources
|
||||
sys: io.murano.system
|
||||
|
||||
|
||||
Name: ExampleChef
|
||||
|
||||
Extends: std:Application
|
||||
|
||||
Properties:
|
||||
|
||||
instance:
|
||||
Contract: $.class(res:Instance).notNull()
|
||||
|
||||
|
||||
|
||||
Methods:
|
||||
initialize:
|
||||
Body:
|
||||
- $._environment: $.find(std:Environment).require()
|
||||
|
||||
deploy:
|
||||
Body:
|
||||
- If: not $.getAttr(deployed, false)
|
||||
Then:
|
||||
- $._environment.reporter.report($this, 'Creating VM for Chef example ')
|
||||
- $securityGroupIngress:
|
||||
- ToPort: 22
|
||||
FromPort: 22
|
||||
IpProtocol: tcp
|
||||
External: true
|
||||
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
||||
- $.instance.deploy()
|
||||
- $resources: new(sys:Resources)
|
||||
# Deploy Chef example
|
||||
- $template: $resources.yaml('DeployExampleChef.template')
|
||||
|
||||
- $._environment.reporter.report($this, 'Instance is created. Deploying Chef example')
|
||||
- $.instance.agent.call($template, $resources)
|
||||
- If: $.instance.assignFloatingIp
|
||||
Then:
|
||||
- $host: $.instance.floatingIpAddress
|
||||
Else:
|
||||
- $host: $.instance.ipAddresses[0]
|
||||
- $._environment.reporter.report($this, format('Chef example is installed at {0}', $host))
|
||||
- $.setAttr(deployed, true)
|
|
@ -0,0 +1,22 @@
|
|||
FormatVersion: 2.1.0
|
||||
Version: 1.0.0
|
||||
Name: Deploy Example Chef
|
||||
|
||||
Parameters:
|
||||
port: $port
|
||||
|
||||
Body: |
|
||||
return executeRecipe(args).stdout
|
||||
|
||||
Scripts:
|
||||
executeRecipe:
|
||||
Type: Chef
|
||||
Version: 1.0.0
|
||||
EntryPoint: test::install
|
||||
Files:
|
||||
- test/recipes/install.rb
|
||||
- test/metadata.rb
|
||||
- test/README.rdoc
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
|
@ -0,0 +1,7 @@
|
|||
= DESCRIPTION:
|
||||
|
||||
= REQUIREMENTS:
|
||||
|
||||
= ATTRIBUTES:
|
||||
|
||||
= USAGE:
|
|
@ -0,0 +1,8 @@
|
|||
#comment
|
||||
maintainer "Telefonica I+D"
|
||||
maintainer_email "henar@tid.es"
|
||||
name "test"
|
||||
license "All rights reserved"
|
||||
description "Default cookbook for testing"
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
|
||||
version "0.1.0"
|
|
@ -0,0 +1,10 @@
|
|||
script "install" do
|
||||
interpreter "bash"
|
||||
user "root"
|
||||
cwd "/opt"
|
||||
code <<-EOH
|
||||
echo test install
|
||||
EOH
|
||||
end
|
||||
|
||||
node.normal['test']['action_test'] = "install"
|
|
@ -0,0 +1,10 @@
|
|||
Format: 1.0
|
||||
Type: Application
|
||||
FullName: io.murano.conflang.chef.ExampleChef
|
||||
Name: ExampleChef
|
||||
Description: |
|
||||
Example Chef.
|
||||
Author: 'TID'
|
||||
Tags: [Test, Chef]
|
||||
Classes:
|
||||
io.murano.conflang.chef.ExampleChef: ExampleChef.yaml
|
|
@ -0,0 +1,46 @@
|
|||
Namespaces:
|
||||
=: io.murano.conflang.puppet.ExamplePuppet
|
||||
std: io.murano
|
||||
res: io.murano.resources
|
||||
sys: io.murano.system
|
||||
|
||||
|
||||
Name: ExamplePuppet
|
||||
|
||||
Extends: std:Application
|
||||
|
||||
Properties:
|
||||
|
||||
instance:
|
||||
Contract: $.class(res:Instance).notNull()
|
||||
|
||||
Methods:
|
||||
initialize:
|
||||
Body:
|
||||
- $._environment: $.find(std:Environment).require()
|
||||
|
||||
deploy:
|
||||
Body:
|
||||
- If: not $.getAttr(deployed, false)
|
||||
Then:
|
||||
- $._environment.reporter.report($this, 'Creating VM for Example Chef example ')
|
||||
- $securityGroupIngress:
|
||||
- ToPort: 22
|
||||
FromPort: 22
|
||||
IpProtocol: tcp
|
||||
External: true
|
||||
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
||||
- $.instance.deploy()
|
||||
- $resources: new(sys:Resources)
|
||||
# Deploy Puppet example
|
||||
- $template: $resources.yaml('DeployExamplePuppet.template')
|
||||
|
||||
- $._environment.reporter.report($this, 'Instance is created. Deploying Example Puppet')
|
||||
- $.instance.agent.call($template, $resources)
|
||||
- If: $.instance.assignFloatingIp
|
||||
Then:
|
||||
- $host: $.instance.floatingIpAddress
|
||||
Else:
|
||||
- $host: $.instance.ipAddresses[0]
|
||||
- $._environment.reporter.report($this, format('Example Puppet is installed at {0}', $host))
|
||||
- $.setAttr(deployed, true)
|
|
@ -0,0 +1,20 @@
|
|||
FormatVersion: 2.1.0
|
||||
Version: 1.0.0
|
||||
Name: Deploy Example Puppet
|
||||
|
||||
Parameters:
|
||||
port: $port
|
||||
|
||||
Body: |
|
||||
return executeRecipe(args).stdout
|
||||
|
||||
Scripts:
|
||||
executeRecipe:
|
||||
Type: Puppet
|
||||
Version: 1.0.0
|
||||
EntryPoint: test::install
|
||||
Files:
|
||||
- test/manifests/install.pp
|
||||
Options:
|
||||
captureStdout: true
|
||||
captureStderr: true
|
|
@ -0,0 +1,4 @@
|
|||
class test::install($version='default_version'){
|
||||
|
||||
notify {"version: test":}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
Format: 1.0
|
||||
Type: Application
|
||||
FullName: io.murano.conflang.puppet.ExamplePuppet
|
||||
Name: ExamplePuppet
|
||||
Description: |
|
||||
Example Chef
|
||||
Author: 'TID'
|
||||
Tags: [Test, Puppet]
|
||||
Classes:
|
||||
io.murano.conflang.puppet.ExamplePuppet: ExamplePuppet.yaml
|
|
@ -0,0 +1,87 @@
|
|||
# Copyright (c) 2015 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import murano.tests.functional.common.utils as common_utils
|
||||
import murano.tests.functional.engine.manager as core
|
||||
from nose.plugins.attrib import attr as tag
|
||||
|
||||
|
||||
class LanguageSupportTest(core.MuranoTestsCore):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(LanguageSupportTest, cls).setUpClass()
|
||||
cls.linux = core.CONF.murano.linux_image
|
||||
cls.flavor = core.CONF.murano.standard_flavor
|
||||
cls.keyname = core.CONF.murano.keyname
|
||||
cls.instance_type = core.CONF.murano.instance_type
|
||||
|
||||
try:
|
||||
# Upload the Murano test package.
|
||||
cls.upload_app('io.murano.conflang.chef.ExampleChef',
|
||||
'ExampleChef', {"tags": ["tag"]})
|
||||
cls.upload_app('io.murano.conflang.puppet.ExamplePuppet',
|
||||
'ExamplePuppet', {"tags": ["tag"]})
|
||||
except Exception as e:
|
||||
cls.tearDownClass()
|
||||
raise e
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
with common_utils.ignored(Exception):
|
||||
try:
|
||||
cls.purge_uploaded_packages()
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
def _test_deploy(self, environment_name, package_name, port):
|
||||
post_body = {
|
||||
"instance": {
|
||||
"flavor": self.flavor,
|
||||
"image": self.linux,
|
||||
"keyname": self.keyname,
|
||||
"assignFloatingIp": True,
|
||||
'name': environment_name,
|
||||
"?": {
|
||||
"type": self.instance_type,
|
||||
"id": str(uuid.uuid4())
|
||||
},
|
||||
},
|
||||
"name": environment_name,
|
||||
"port": port,
|
||||
"?": {
|
||||
"type": package_name,
|
||||
"id": str(uuid.uuid4())
|
||||
}
|
||||
}
|
||||
|
||||
environment_name = environment_name + uuid.uuid4().hex[:5]
|
||||
environment = self.create_environment(name=environment_name)
|
||||
session = self.create_session(environment)
|
||||
self.add_service(environment, post_body, session)
|
||||
self.deploy_environment(environment, session)
|
||||
self.wait_for_environment_deploy(environment)
|
||||
self.deployment_success_check(environment, port)
|
||||
|
||||
@tag('gate', 'all', 'coverage')
|
||||
def test_deploy_example_chef_example(self):
|
||||
self._test_deploy('chefExample',
|
||||
'io.murano.conflang.chef.ExampleChef', 22)
|
||||
|
||||
@tag('gate', 'all', 'coverage')
|
||||
def test_deploy_example_puppet_example(self):
|
||||
self._test_deploy('puppetExample',
|
||||
"io.murano.conflang.puppet.ExamplePuppet", 22)
|
Loading…
Reference in New Issue