Generate some manifests at test start

Use async command execution

Fix networks

Delete unused helpers

Don't manage networks in tests

Prepare class

Tar for upload recipies

Renaming tests

Template class

Hiera.yaml for master

Don't stop selinux in tests

Ignore package managers warnings

Add master role

Manifest class

Delete obsolete tests

Settings for interfaces with order

Using network pools

Cleanup settings

Require new devops
This commit is contained in:
vic 2013-01-23 19:22:45 +04:00
parent ce2fd4ad63
commit ca05da215f
49 changed files with 1207 additions and 1979 deletions

View File

@ -1,11 +1,8 @@
import logging
import unittest
from abc import abstractproperty
from devops.helpers import ssh
import re
from fuel_test.ci.ci_base import CiBase
from fuel_test.settings import ERROR_PREFIX, WARNING_PREFIX, EMPTY_SNAPSHOT
from helpers import load, execute, write_config, sync_time, safety_revert_nodes, upload_recipes, upload_keys, update_pm
from fuel_test.settings import ERROR_PREFIX, WARNING_PREFIX
from helpers import upload_recipes, upload_keys
class BaseTestCase(unittest.TestCase):
@abstractproperty
@ -15,40 +12,21 @@ class BaseTestCase(unittest.TestCase):
"""
pass
def setUp(self):
self.environment = self.ci().get_environment_or_create()
self.nodes = self.ci().nodes()
master = self.environment.node['master']
self.revert_snapshots()
self.master_remote = ssh(master.ip_address_by_network['public'],
username='root',
def environment(self):
return self.ci().environment()
def nodes(self):
return self.ci().nodes()
def remote(self):
return self.environment().node_by_name('master').remote(
'public',
login='root',
password='r00tme')
upload_recipes(self.master_remote)
upload_keys(self.master_remote)
def revert_snapshots(self):
safety_revert_nodes(self.environment.nodes, EMPTY_SNAPSHOT)
for node in self.environment.nodes:
remote = ssh(node.ip_address_by_network['internal'], username='root', password='r00tme')
sync_time(remote.sudo.ssh)
update_pm(remote.sudo.ssh)
def replace(self, template, **kwargs):
for key in kwargs:
value = kwargs.get(key)
template, count = re.subn(
'^(\$' + str(key) + ')\s*=.*', "\\1 = " + str(value),
template,
flags=re.MULTILINE)
if count == 0:
raise Exception("Variable ${0:>s} is not found".format(key))
return template
def write_site_pp_manifest(self, path, **kwargs):
site_pp = load(path)
site_pp = self.replace(site_pp, **kwargs)
write_config(self.master_remote, '/etc/puppet/manifests/site.pp',
site_pp)
def update_modules(self):
upload_recipes(self.remote())
upload_keys(self.remote())
def assertResult(self, result):
self.assertEqual([], result['stderr'], result['stderr'])
@ -60,19 +38,21 @@ class BaseTestCase(unittest.TestCase):
errors = []
warnings = []
for line in out:
logging.info(line)
if (line.find(ERROR_PREFIX) < 15) and (line.find(ERROR_PREFIX) !=-1):
if (line.find(ERROR_PREFIX) < 15) and (
line.find(ERROR_PREFIX) != -1):
errors.append(line)
if (line.find(WARNING_PREFIX) < 15) and (line.find(WARNING_PREFIX) !=-1):
if line.find('# Warning: Disabling this option means that a compromised guest can') == -1:
if (line.find(WARNING_PREFIX) < 15) and (
line.find(WARNING_PREFIX) != -1):
if line.find(
'# Warning: Disabling this option means that a compromised guest can') == -1:
warnings.append(line)
return errors, warnings
def do(self, nodes, command):
results = []
for node in nodes:
remote = ssh(node.ip_address_by_network['internal'], username='root', password='r00tme')
results.append(execute(remote.sudo.ssh, command))
remote = node.remote('internal', login='root', password='r00tme')
results.append(remote.sudo.ssh.execute(command, verbose=True))
return results
def validate(self, nodes, command):

View File

@ -1,11 +1,8 @@
import logging
from time import sleep
import traceback
from abc import abstractproperty, abstractmethod
import devops
from devops.model import Node, Disk, Interface, Environment
from devops.helpers import tcp_ping, wait, ssh
from fuel_test.helpers import write_config, sign_all_node_certificates, change_host_name, request_cerificate, setup_puppet_client, setup_puppet_master, add_nmap, switch_off_ip_tables, add_to_hosts, only_private_interface, kill_dhcpclient
from devops.manager import Manager
from ipaddr import IPNetwork
from fuel_test.helpers import write_config, change_host_name, request_cerificate, setup_puppet_client, setup_puppet_master, add_nmap, switch_off_ip_tables, add_to_hosts
from fuel_test.node_roles import NodeRoles, Nodes
from fuel_test.settings import BASE_IMAGE, EMPTY_SNAPSHOT
from fuel_test.root import root
@ -13,6 +10,32 @@ from fuel_test.helpers import load
class CiBase(object):
def __init__(self):
self.manager = Manager()
self.base_image = self.manager.volume_get_predefined(BASE_IMAGE)
self._environment = None
def _get_or_create(self):
try:
return self.manager.environment_get(self.env_name())
except:
self._environment = self.describe_environment()
self._environment.define()
return self._environment
def get_empty_state(self):
if self.environment().has_snapshot(EMPTY_SNAPSHOT):
self.environment().revert(EMPTY_SNAPSHOT)
else:
self.setup_environment()
def environment(self):
"""
:rtype : devops.models.Environment
"""
self._environment = self._environment or self._get_or_create()
return self._environment
@abstractproperty
def env_name(self):
"""
@ -23,7 +46,7 @@ class CiBase(object):
@abstractmethod
def describe_environment(self):
"""
:rtype : Environment
:rtype : devops.models.Environment
"""
pass
@ -34,61 +57,46 @@ class CiBase(object):
"""
pass
def quantum_nodes(self):
return []
def nodes(self):
return Nodes(self.environment(), self.node_roles())
def nodes(self, environment=None):
return Nodes(environment or self.environment, self.node_roles())
def add_empty_volume(self, node, name):
self.manager.node_attach_volume(
node=node,
volume=self.manager.volume_create(
name=name, capacity=20 * 1024 * 1024 * 1024,
environment=self.environment()))
def __init__(self):
self.base_image = BASE_IMAGE
self.environment = None
self.environment_name = self.env_name()
try:
self.environment = devops.load(self.environment_name)
logging.info("Successfully loaded existing environment")
except Exception, e:
logging.info(
"Failed to load existing %s environment: " % self.environment_name + str(
e) + "\n" + traceback.format_exc())
pass
def get_environment(self):
return self.environment
def get_environment_or_create(self):
if self.get_environment():
return self.get_environment()
self.setup_environment()
return self.environment
def add_node(self, memory, name):
return self.manager.node_create(
name=name,
memory=memory,
environment=self.environment())
def describe_node(self, name, networks, memory=1024):
node = Node(name)
node.memory = memory
node.vnc = True
node = self.add_node(memory, name)
for network in networks:
node.interfaces.append(Interface(network))
# node.bridged_interfaces.append(BridgedInterface('br0'))
node.disks.append(Disk(base_image=self.base_image, format='qcow2'))
node.disks.append(Disk(size=20*1024*1024*1024, format='qcow2'))
node.boot = ['disk']
self.manager.interface_create(network, node=node)
self.manager.node_attach_volume(
node=node,
volume=self.manager.volume_create_child(
name=name + '-system', backing_store=self.base_image,
environment=self.environment()))
self.add_empty_volume(node, name + '-cinder')
return node
def describe_empty_node(self, name, networks, memory=1024):
node = Node(name)
node.memory = memory
node.vnc = True
node = self.add_node(memory, name)
for network in networks:
node.interfaces.append(Interface(network))
# node.bridged_interfaces.append(BridgedInterface('br0'))
node.disks.append(Disk(size=8589934592, format='qcow2'))
node.disks.append(Disk(size=20*1024*1024*1024, format='qcow2'))
node.boot = ['disk']
self.manager.interface_create(network, node=node)
self.add_empty_volume(node, name + '-system')
self.add_empty_volume(node, name + '-cinder')
return node
def add_nodes_to_hosts(self, remote, nodes):
for node in nodes:
add_to_hosts(remote, node.ip_address_by_network['internal'], node.name,
add_to_hosts(remote,
node.get_ip_address_by_network_name('internal'), node.name,
node.name + '.your-domain-name.com')
def setup_master_node(self, master_remote, nodes):
@ -102,83 +110,45 @@ class CiBase(object):
root('fuel_test', 'config', 'puppet.agent.config'))
for node in nodes:
if node.name != 'master':
remote = ssh(
node.ip_address_by_network['public'], username='root',
remote = node.remote('public', login='root',
password='r00tme')
self.add_nodes_to_hosts(remote, self.environment.nodes)
self.add_nodes_to_hosts(remote, self.environment().nodes)
setup_puppet_client(remote)
write_config(remote, '/etc/puppet/puppet.conf', agent_config)
request_cerificate(remote)
def make_vms(self):
if not self.base_image:
raise Exception(
"Base image path is missing while trying to build %s environment" % self.environment_name)
logging.info("Building %s environment" % self.environment_name)
environment = self.describe_environment()
# todo environment should be saved before build
devops.build(environment)
devops.save(environment)
logging.info("Environment has been saved")
return environment
def rename_nodes(self, nodes):
for node in nodes:
remote = ssh(node.ip_address_by_network['public'], username='root', password='r00tme')
change_host_name(remote, node.name, node.name + '.your-domain-name.com')
remote = node.remote('public', login='root', password='r00tme')
change_host_name(remote, node.name,
node.name + '.your-domain-name.com')
logging.info("Renamed %s" % node.name)
@abstractmethod
def setup_environment(self):
environment = self.make_vms()
self.environment = environment
"""
:rtype : None
"""
pass
logging.info("Starting test nodes ...")
for node in environment.nodes:
node.start()
for node in environment.nodes:
logging.info("Waiting ssh... %s" % node.ip_address_by_network['internal'])
wait(lambda: tcp_ping(node.ip_address_by_network['internal'], 22), timeout=1800)
self.rename_nodes(environment.nodes)
master_node = environment.node['master']
master_remote = ssh(master_node.ip_address_by_network['internal'], username='root',
password='r00tme')
kill_dhcpclient(environment.nodes)
self.setup_master_node(master_remote, environment.nodes)
self.setup_agent_nodes(environment.nodes)
only_private_interface(self.quantum_nodes())
sleep(5)
sign_all_node_certificates(master_remote)
sleep(5)
for node in environment.nodes:
logging.info("Creating snapshot %s" % EMPTY_SNAPSHOT)
node.save_snapshot(EMPTY_SNAPSHOT)
logging.info("Test node is ready at %s" % node.ip_address_by_network['internal'])
def internal_virtual_ip(self):
return str(IPNetwork(
self.environment().network_by_name('internal').ip_network)[-3])
def public_virtual_ip(self):
return str(
IPNetwork(self.environment().network_by_name('public').ip_network)[
-3])
def floating_network(self):
return str(
IPNetwork(self.environment().network_by_name('public').ip_network).subnet(
new_prefix=27)[0])
def destroy_environment(self):
if self.environment:
devops.destroy(self.environment)
def get_internal_virtual_ip(self):
return self.environment.network['internal'].ip_addresses[-3]
def get_public_virtual_ip(self):
return self.environment.network['public'].ip_addresses[-3]
def get_floating_network(self):
return '.'.join(
str(self.environment.network['public'].ip_addresses[-1]).split(
'.')[:-1]) + '.128/27'
def get_fixed_network(self):
return '.'.join(
str(self.environment.network['private'].ip_addresses[-1]).split(
'.')[:-1]) + '.128/27'
def get_internal_network(self):
network = self.environment.network['internal']
return str(network.ip_addresses[1]) + '/' + str(
network.ip_addresses.prefixlen)
def fixed_network(self):
return str(
IPNetwork(self.environment().network_by_name('private').ip_network).subnet(
new_prefix=27)[0])
def internal_network(self):
return str(IPNetwork(self.environment().network_by_name('internal').ip_network))

View File

@ -1,30 +1,28 @@
import logging
from time import sleep
from devops.helpers import wait, tcp_ping, ssh
from devops.model import Environment, Network
from ipaddr import IPNetwork
import os
from fuel_test.ci.ci_base import CiBase
from fuel_test.helpers import sign_all_node_certificates, write_static_ip, execute
from fuel_test.node_roles import NodeRoles
from fuel_test.settings import COBBLER_CONTROLLERS, COBBLER_COMPUTES, \
COBBLER_SWIFTS, COBBLER_PROXIES, \
COBBLER_QUANTUM, COBBLER_KEYSTONE, \
EMPTY_SNAPSHOT
from fuel_test.settings import CONTROLLERS, COMPUTES,\
STORAGES, PROXIES,\
EMPTY_SNAPSHOT, POOLS, INTERFACE_ORDER
class CiCobbler(CiBase):
def node_roles(self):
return NodeRoles(
master_names=['master'],
cobbler_names=['fuel-cobbler'],
controller_names=['fuel-controller-%02d' % x for x in
range(1, 1 + COBBLER_CONTROLLERS)],
range(1, 1 + CONTROLLERS)],
compute_names=['fuel-compute-%02d' % x for x in range(
1, 1 + COBBLER_COMPUTES)],
1, 1 + COMPUTES)],
storage_names=['fuel-swift-%02d' % x for x in range(
1, 1 + COBBLER_SWIFTS)],
1, 1 + STORAGES)],
proxy_names=['fuel-swiftproxy-%02d' % x for x in range(
1, 1 + COBBLER_PROXIES)],
quantum_names=['fuel-quantum'] if COBBLER_QUANTUM else [],
keystone_names=['keystone'] if COBBLER_KEYSTONE else [],
1, 1 + PROXIES)],
quantum_names=['fuel-quantum'],
stomp_names=['fuel-mcollective']
)
@ -32,81 +30,43 @@ class CiCobbler(CiBase):
return os.environ.get('ENV_NAME', 'cobbler')
def describe_environment(self):
environment = Environment(self.environment_name)
public = Network(name='public', dhcp_server=True)
environment.networks.append(public)
internal = Network(name='internal', dhcp_server=False)
environment.networks.append(internal)
private = Network(name='private', dhcp_server=False)
environment.networks.append(private)
master_node = self.describe_node('master', [public, internal, private])
environment.nodes.append(master_node)
for node_name in self.node_roles().cobbler_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().stomp_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().controller_names:
client = self.describe_empty_node(node_name,
[public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().compute_names:
client = self.describe_empty_node(
node_name, [public, internal, private], memory=1024)
environment.nodes.append(client)
for node_name in self.node_roles().storage_names:
client = self.describe_empty_node(
node_name, [public, internal, private], memory=1024)
environment.nodes.append(client)
for node_name in self.node_roles().proxy_names:
client = self.describe_empty_node(
node_name, [public, internal, private], memory=1024)
environment.nodes.append(client)
for node_name in self.node_roles().quantum_names:
client = self.describe_empty_node(
node_name, [public, internal, private], memory=1024)
environment.nodes.append(client)
for node_name in self.node_roles().keystone_names:
client = self.describe_empty_node(
node_name, [public, internal, private], memory=1024)
environment.nodes.append(client)
"""
:rtype : Environment
"""
environment = self.manager.environment_create(self.env_name())
networks = []
for name in INTERFACE_ORDER:
network = IPNetwork(POOLS.get(name)[0])
new_prefix = int(POOLS.get(name)[1])
pool = self.manager.create_network_pool(
networks=[network], prefix=int(new_prefix))
networks.append(self.manager.network_create(
name=name, environment=environment, pool=pool))
for name in self.node_roles().master_names + self.node_roles().cobbler_names + self.node_roles().stomp_names:
self.describe_node(name, networks)
for name in self.node_roles().compute_names:
self.describe_empty_node(name, networks, memory=4096)
for name in self.node_roles().controller_names + self.node_roles().storage_names + self.node_roles().quantum_names + self.node_roles().proxy_names:
self.describe_empty_node(name, networks)
return environment
def get_start_nodes(self):
return [self.environment.node['master']] + self.nodes().cobblers + self.nodes().stomps
def get_startup_nodes(self):
return self.nodes().masters + self.nodes().cobblers + self.nodes().stomps
def client_nodes(self):
return self.nodes().controllers + self.nodes().computes + self.nodes().storages + self.nodes().proxies + self.nodes().quantums
def setup_environment(self):
self.environment = self.make_vms()
master_node = self.environment.node['master']
master_node = self.nodes().masters[0]
logging.info("Starting test nodes ...")
start_nodes = self.get_start_nodes()
start_nodes = self.get_startup_nodes()
self.environment().start(start_nodes)
for node in start_nodes:
node.start()
for node in start_nodes:
logging.info("Waiting ssh... %s" % node.ip_address_by_network['public'])
wait(lambda: tcp_ping(node.ip_address_by_network['public'], 22),
timeout=1800)
gateway = self.environment.network['internal'].ip_addresses[1]
net_mask = '255.255.255.0'
for node in start_nodes:
remote = ssh(node.ip_address_by_network['public'], username='root',
password='r00tme')
execute(remote, 'ifdown eth1')
write_static_ip(remote, node.ip_address_by_network['internal'],
net_mask, gateway)
execute(remote, 'ifup eth1')
master_remote = ssh(
master_node.ip_address_by_network['public'], username='root',
node.await('public')
master_remote = master_node.remote('public', login='root',
password='r00tme')
self.rename_nodes(start_nodes)
self.setup_master_node(master_remote, self.environment.nodes)
self.setup_master_node(master_remote, self.environment().nodes)
self.setup_agent_nodes(start_nodes)
sleep(5)
sign_all_node_certificates(master_remote)
sleep(5)
for node in self.environment.nodes:
logging.info("Creating snapshot %s" % EMPTY_SNAPSHOT)
node.save_snapshot(EMPTY_SNAPSHOT)
logging.info("Test node is ready at %s" % node.ip_address_by_network['internal'])
sleep(10)
self.environment().snapshot(EMPTY_SNAPSHOT)

View File

@ -1,45 +0,0 @@
from devops.model import Environment, Network
import os
from fuel_test.ci.ci_base import CiBase
from fuel_test.node_roles import NodeRoles
class CiOpenStack(CiBase):
def node_roles(self):
return NodeRoles(
controller_names=['fuel-controller-01', 'fuel-controller-02'],
compute_names=['fuel-compute-01', 'fuel-compute-02'],
quantum_names=['fuel-quantum'],
)
def env_name(self):
return os.environ.get('ENV_NAME', 'recipes')
def quantum_nodes(self):
return self.nodes().quantums
def describe_environment(self):
environment = Environment(self.environment_name)
public = Network(name='public', dhcp_server=True)
environment.networks.append(public)
internal = Network(name='internal', dhcp_server=True)
environment.networks.append(internal)
private = Network(name='private', dhcp_server=False)
environment.networks.append(private)
master = self.describe_node('master', [public, internal, private])
environment.nodes.append(master)
for node_name in self.node_roles().controller_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().quantum_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().compute_names:
client = self.describe_node(
node_name, [public, internal, private], memory=4096)
environment.nodes.append(client)
return environment

View File

@ -1,36 +0,0 @@
from devops.model import Environment, Network
import os
from fuel_test.ci.ci_base import CiBase
from fuel_test.node_roles import NodeRoles
class CiOpenStackSimple(CiBase):
def node_roles(self):
return NodeRoles(
controller_names=['fuel-controller-01'],
compute_names=['fuel-compute-01','fuel-compute-02', 'fuel-compute-03']
)
def env_name(self):
return os.environ.get('ENV_NAME', 'recipes-simple')
def describe_environment(self):
environment = Environment(self.environment_name)
public = Network(name='public', dhcp_server=True)
environment.networks.append(public)
internal = Network(name='internal', dhcp_server=True)
environment.networks.append(internal)
private = Network(name='private', dhcp_server=False)
environment.networks.append(private)
master = self.describe_node('master', [public, internal, private])
environment.nodes.append(master)
for node_name in self.node_roles().controller_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().compute_names:
client = self.describe_node(
node_name, [public, internal, private], memory=4096)
environment.nodes.append(client)
return environment

View File

@ -1,51 +0,0 @@
from devops.model import Environment, Network
import os
from fuel_test.ci.ci_base import CiBase
from fuel_test.node_roles import NodeRoles
class CiOpenStackSwift(CiBase):
def node_roles(self):
return NodeRoles(
controller_names=['fuel-controller-01', 'fuel-controller-02'],
compute_names=['fuel-compute-01', 'fuel-compute-02'],
storage_names=['fuel-swift-01', 'fuel-swift-02', 'fuel-swift-03'],
proxy_names=['fuel-swiftproxy-01', 'fuel-swiftproxy-02'],
quantum_names=['fuel-quantum'],
)
def env_name(self):
return os.environ.get('ENV_NAME', 'recipes-swift')
def quantum_nodes(self):
return self.nodes().quantums
def describe_environment(self):
environment = Environment(self.environment_name)
public = Network(name='public', dhcp_server=True)
environment.networks.append(public)
internal = Network(name='internal', dhcp_server=True)
environment.networks.append(internal)
private = Network(name='private', dhcp_server=False)
environment.networks.append(private)
master = self.describe_node('master', [public, internal, private])
environment.nodes.append(master)
for node_name in self.node_roles().controller_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().quantum_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().compute_names:
client = self.describe_node(
node_name, [public, internal, private], memory=4096)
environment.nodes.append(client)
for node_name in self.node_roles().storage_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().proxy_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
return environment

View File

@ -1,45 +0,0 @@
from devops.model import Environment, Network
import os
from fuel_test.ci.ci_base import CiBase
from fuel_test.node_roles import NodeRoles
class CiOpenStackSwiftCompact(CiBase):
def node_roles(self):
return NodeRoles(
controller_names=['fuel-controller-01', 'fuel-controller-02', 'fuel-controller-03'],
compute_names=['fuel-compute-01', 'fuel-compute-02'],
quantum_names=['fuel-quantum'],
)
def env_name(self):
return os.environ.get('ENV_NAME', 'recipes-swift-compact')
def quantum_nodes(self):
return self.nodes().quantums
def describe_environment(self):
environment = Environment(self.environment_name)
public = Network(name='public', dhcp_server=True)
environment.networks.append(public)
internal = Network(name='internal', dhcp_server=True)
environment.networks.append(internal)
private = Network(name='private', dhcp_server=False)
environment.networks.append(private)
master = self.describe_node('master', [public, internal, private])
environment.nodes.append(master)
for node_name in self.node_roles().controller_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().quantum_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().compute_names:
client = self.describe_node(
node_name, [public, internal, private], memory=4096)
environment.nodes.append(client)
return environment

View File

@ -1,37 +0,0 @@
from devops.model import Environment, Network
import os
from fuel_test.ci.ci_base import CiBase
from fuel_test.node_roles import NodeRoles
class CiSwift(CiBase):
def node_roles(self):
return NodeRoles(
storage_names=['fuel-swift-01', 'fuel-swift-02', 'fuel-swift-03'],
proxy_names=['fuel-swiftproxy-01'],
keystone_names=['keystone']
)
def env_name(self):
return os.environ.get('ENV_NAME', 'swift')
def describe_environment(self):
environment = Environment(self.environment_name)
public = Network(name='public', dhcp_server=True)
environment.networks.append(public)
internal = Network(name='internal', dhcp_server=True)
environment.networks.append(internal)
private = Network(name='private', dhcp_server=False)
environment.networks.append(private)
master = self.describe_node('master', [public, internal, private])
environment.nodes.append(master)
for node_name in self.node_roles().keystone_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().storage_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
for node_name in self.node_roles().proxy_names:
client = self.describe_node(node_name, [public, internal, private])
environment.nodes.append(client)
return environment

View File

@ -1,7 +1,11 @@
from time import sleep
import unittest
from fuel_test.base_test_case import BaseTestCase
from fuel_test.ci.ci_cobbler import CiCobbler
from fuel_test.root import root
from fuel_test.cobbler.cobbler_client import CobblerClient
from fuel_test.helpers import tcp_ping, sync_time, udp_ping, build_astute, install_astute, add_to_hosts, await_node_deploy, update_pms
from fuel_test.manifest import Manifest, Template
from fuel_test.settings import PUPPET_VERSION, OS_FAMILY
class CobblerTestCase(BaseTestCase):
def ci(self):
@ -9,40 +13,206 @@ class CobblerTestCase(BaseTestCase):
self._ci = CiCobbler()
return self._ci
def generate_manifests(self):
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.minimal(), ci=self.ci(),
controllers=self.nodes().controllers,
swift=False,
quantum=True)
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.compact(), ci=self.ci(),
controllers=self.nodes().controllers,
quantum=False, loopback=False, use_syslog=False)
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.compact(), ci=self.ci(),
controllers=self.nodes().controllers,
quantum=False)
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.full(), ci=self.ci(),
controllers=self.nodes().controllers,
proxies=self.nodes().proxies,
quantum=True)
Manifest().write_openstack_simple_manifest(
remote=self.remote(),
ci=self.ci(),
controllers=self.nodes().controllers)
def setUp(self):
self.environment = self.ci().get_environment_or_create()
self.nodes = self.ci().nodes()
self.get_nodes_deployed_state()
self.generate_manifests()
self.update_modules()
remotes = [node.remote('internal', login='root', password='r00tme') for node in self.environment().nodes]
sync_time(remotes)
update_pms(remotes)
def get_nodes_deployed_state(self):
if self.environment().has_snapshot('nodes-deployed'):
self.environment().revert('nodes-deployed')
else:
self.ci().get_empty_state()
self.update_modules()
self.prepare_cobbler_environment()
for node in self.nodes():
node.await('internal')
def revert_snapshots(self):
pass
def prepare_cobbler_environment(self):
self.deploy_cobbler()
self.configure_cobbler()
self.deploy_stomp_node()
self.deploy_nodes()
def write_cobbler_manifest(self):
cobbler = self.nodes.cobblers[0]
cobbler_address = cobbler.ip_address_by_network['internal']
self.write_site_pp_manifest(
root('deployment', 'puppet', 'cobbler', 'examples',
'server_site.pp'),
server="'%s'" % cobbler_address,
name_server="'%s'" % cobbler_address,
next_server="'%s'" % cobbler_address,
dhcp_start_address="'%s'" % self.environment.network[
'internal'].ip_addresses[10],
dhcp_end_address="'%s'" %
self.environment.network['internal'].ip_addresses[
-5],
dhcp_netmask="'%s'" % '255.255.255.0',
dhcp_gateway="'%s'" %
self.environment.network['internal'].ip_addresses[1],
pxetimeout = '3000'
def deploy_cobbler(self):
Manifest().write_cobbler_manifest(self.remote(), self.ci(),
self.nodes().cobblers)
self.validate(
self.nodes().cobblers,
'puppet agent --test')
for node in self.nodes().cobblers:
self.assert_cobbler_ports(
node.get_ip_address_by_network_name('internal'))
self.environment().snapshot('cobbler', force=True)
def assert_cobbler_ports(self, ip):
closed_tcp_ports = filter(
lambda port: not tcp_ping(
self.remote().sudo.ssh,
ip,
port), [22, 53, 80, 443])
closed_udp_ports = filter(
lambda port: not udp_ping(
self.remote().sudo.ssh,
ip, port), [53, 67, 68, 69])
self.assertEquals(
{'tcp': [], 'udp': []},
{'tcp': closed_tcp_ports, 'udp': closed_udp_ports})
def deploy_stomp_node(self):
Manifest().write_stomp_manifest(self.remote())
self.validate(
self.nodes().stomps,
'puppet agent --test')
def install_astute_gem(self):
build_astute()
install_astute(self.nodes().stomps[0].remote('public',
login='root',
password='r00tme'))
def get_ks_meta(self, puppet_master, mco_host):
return ("puppet_auto_setup=1 "
"puppet_master=%(puppet_master)s "
"puppet_version=%(puppet_version)s "
"puppet_enable=0 "
"mco_auto_setup=1 "
"ntp_enable=1 "
"mco_pskey=un0aez2ei9eiGaequaey4loocohjuch4Ievu3shaeweeg5Uthi "
"mco_stomphost=%(mco_host)s "
"mco_stompport=61613 "
"mco_stompuser=mcollective "
"mco_stomppassword=AeN5mi5thahz2Aiveexo "
"mco_enable=1 "
"interface_extra_eth0_peerdns=no "
"interface_extra_eth1_peerdns=no "
"interface_extra_eth2_peerdns=no "
"interface_extra_eth2_promisc=yes "
"interface_extra_eth2_userctl=yes "
) % {'puppet_master': puppet_master,
'puppet_version': PUPPET_VERSION,
'mco_host': mco_host
}
def add_fake_nodes(self):
cobbler = self.ci().nodes().cobblers[0]
stomp_name = self.ci().nodes().stomps[0].name
client = CobblerClient(
cobbler.get_ip_address_by_network_name('internal'))
token = client.login('cobbler', 'cobbler')
for i in range(1, 100):
for j in range(1, 100):
self._add_node(
client, token, cobbler,
node_name='fake' + str(i),
node_mac0="00:17:3e:{0:02x}:{1:02x}:01".format(i, j),
node_mac1="00:17:3e:{0:02x}:{1:02x}:02".format(i, j),
node_mac2="00:17:3e:{0:02x}:{1:02x}:03".format(i, j),
node_ip="192.168.{0:d}.{1:d}".format(i, j),
stomp_name=stomp_name
)
def write_stomp_manifest(self):
self.write_site_pp_manifest(
root('deployment', 'puppet', 'mcollective', 'examples',
'site.pp'),
def _add_node(self, client, token, cobbler, node_name, node_mac0, node_mac1,
node_mac2, node_ip, stomp_name):
system_id = client.new_system(token)
if OS_FAMILY == 'centos':
profile = 'centos63_x86_64'
else:
profile = 'ubuntu_1204_x86_64'
client.modify_system_args(
system_id, token,
ks_meta=self.get_ks_meta('master.your-domain-name.com',
stomp_name),
name=node_name,
hostname=node_name + ".your-domain-name.com",
name_servers=cobbler.get_ip_address_by_network_name('internal'),
name_servers_search="your-domain-name.com",
profile=profile,
netboot_enabled="1")
client.modify_system(system_id, 'modify_interface', {
"macaddress-eth0": str(node_mac0),
"static-eth0": "0",
"macaddress-eth1": str(node_mac1),
"ipaddress-eth1": str(node_ip),
"dnsname-eth1": node_name + ".your-domain-name.com",
"static-eth1": "1",
"macaddress-eth2": str(node_mac2),
"static-eth2": "0"
}, token)
client.save_system(system_id, token)
client.sync(token)
def add_node(self, client, token, cobbler, node):
node_name = node.name
node_mac0 = str(node.interfaces[0].mac_address)
node_mac1 = str(node.interfaces[1].mac_address)
node_mac2 = str(node.interfaces[2].mac_address)
node_ip = str(node.get_ip_address_by_network_name('internal'))
self._add_node(
client, token, cobbler, node_name,
node_mac0, node_mac1, node_mac2, node_ip,
stomp_name=self.ci().nodes().stomps[0].name
)
def configure_cobbler(self):
cobbler = self.ci().nodes().cobblers[0]
client = CobblerClient(
cobbler.get_ip_address_by_network_name('internal'))
token = client.login('cobbler', 'cobbler')
for node in self.ci().client_nodes():
self.add_node(client, token, cobbler, node)
master = self.environment().node_by_name('master')
remote = master.remote('internal',
login='root',
password='r00tme')
add_to_hosts(
remote,
master.get_ip_address_by_network_name('internal'),
master.name,
master.name + ".your-domain-name.com")
self.environment().snapshot('cobbler-configured', force=True)
def deploy_nodes(self):
cobbler = self.ci().nodes().cobblers[0]
for node in self.ci().client_nodes():
node.start()
for node in self.ci().client_nodes():
await_node_deploy(
cobbler.get_ip_address_by_network_name('internal'), node.name)
sleep(20)
self.environment().snapshot('nodes-deployed', force=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,11 @@
import unittest
from fuel_test.cobbler.cobbler_test_case import CobblerTestCase
class NoopTestCase(CobblerTestCase):
def test_apply_all_modules_with_noop(self):
result = self.remote().execute(
"for i in `find /etc/puppet/modules/ | grep tests/.*pp`; do puppet apply --modulepath=/etc/puppet/modules/ --noop $i ; done")
self.assertResult(result)
if __name__ == '__main__':
unittest.main()

View File

@ -1,389 +1,8 @@
from time import sleep
import unittest
from devops.helpers import ssh
from fuel_test.cobbler.cobbler_client import CobblerClient
from fuel_test.cobbler.cobbler_test_case import CobblerTestCase
from fuel_test.helpers import tcp_ping, udp_ping, safety_revert_nodes, add_to_hosts, sign_all_node_certificates, sync_time, upload_recipes, upload_keys, await_node_deploy, build_astute, install_astute, write_config, execute, update_pm
from fuel_test.settings import EMPTY_SNAPSHOT, OS_FAMILY, PUPPET_VERSION, PUBLIC_INTERFACE, INTERNAL_INTERFACE, PRIVATE_INTERFACE
from fuel_test.root import root
class CobblerCase(CobblerTestCase):
def configure_master_remote(self):
master = self.environment.node['master']
self.master_remote = ssh(master.ip_address_by_network['public'],
username='root',
password='r00tme')
upload_recipes(self.master_remote)
upload_keys(self.master_remote)
def test_deploy_cobbler(self):
safety_revert_nodes(self.environment.nodes, EMPTY_SNAPSHOT)
self.configure_master_remote()
for node in [self.environment.node['master']] + self.nodes.cobblers:
remote = ssh(node.ip_address_by_network['public'], username='root', password='r00tme')
sync_time(remote.sudo.ssh)
update_pm(remote.sudo.ssh)
self.write_cobbler_manifest()
self.validate(
self.nodes.cobblers,
'puppet agent --test')
for node in self.nodes.cobblers:
self.assert_cobbler_ports(node.ip_address_by_network['internal'])
for node in self.environment.nodes:
node.save_snapshot('cobbler', force=True)
def install_astute_gem(self):
build_astute()
install_astute(self.nodes.stomps[0].ip_address_by_network['public'])
def deploy_stomp_node(self):
self.configure_master_remote()
self.write_stomp_manifest()
self.validate(
self.nodes.stomps,
'puppet agent --test')
def get_ks_meta(self, puppet_master, mco_host):
return ("puppet_auto_setup=1 "
"puppet_master=%(puppet_master)s "
"puppet_version=%(puppet_version)s "
"puppet_enable=0 "
"mco_auto_setup=1 "
"ntp_enable=1 "
"mco_pskey=un0aez2ei9eiGaequaey4loocohjuch4Ievu3shaeweeg5Uthi "
"mco_stomphost=%(mco_host)s "
"mco_stompport=61613 "
"mco_stompuser=mcollective "
"mco_stomppassword=AeN5mi5thahz2Aiveexo "
"mco_enable=1 "
"interface_extra_eth0_peerdns=no "
"interface_extra_eth1_peerdns=no "
"interface_extra_eth2_peerdns=no "
"interface_extra_eth2_promisc=yes "
"interface_extra_eth2_userctl=yes "
) % {'puppet_master': puppet_master,
'puppet_version': PUPPET_VERSION,
'mco_host': mco_host
}
def add_fake_nodes(self):
cobbler = self.ci().nodes().cobblers[0]
stomp_name = self.ci().nodes().stomps[0].name
client = CobblerClient(cobbler.ip_address_by_network['internal'])
token = client.login('cobbler', 'cobbler')
for i in range(1,100):
for j in range(1,100):
self._add_node(
client, token, cobbler,
node_name='fake' + str(i),
node_mac0="00:17:3e:{0:02x}:{1:02x}:01".format(i, j),
node_mac1="00:17:3e:{0:02x}:{1:02x}:02".format(i, j),
node_mac2="00:17:3e:{0:02x}:{1:02x}:03".format(i, j),
node_ip="192.168.{0:d}.{1:d}".format(i, j),
stomp_name=stomp_name
)
def _add_node(self, client, token, cobbler, node_name, node_mac0, node_mac1, node_mac2, node_ip, stomp_name):
system_id = client.new_system(token)
if OS_FAMILY=='centos':
profile='centos63_x86_64'
else:
profile='ubuntu_1204_x86_64'
client.modify_system_args(
system_id, token,
ks_meta=self.get_ks_meta('master.your-domain-name.com',
stomp_name),
name=node_name,
hostname=node_name + ".your-domain-name.com",
name_servers=cobbler.ip_address_by_network['internal'],
name_servers_search="your-domain-name.com",
profile=profile,
netboot_enabled="1")
client.modify_system(system_id, 'modify_interface', {
"macaddress-eth0": str(node_mac0),
"static-eth0": "0",
"macaddress-eth1": str(node_mac1),
"ipaddress-eth1": str(node_ip),
"dnsname-eth1": node_name + ".your-domain-name.com",
"static-eth1": "1",
"macaddress-eth2": str(node_mac2),
"static-eth2": "0"
}, token)
client.save_system(system_id, token)
client.sync(token)
def add_node(self, client, token, cobbler, node):
node_name=node.name
node_mac0=str(node.interfaces[0].mac_address)
node_mac1=str(node.interfaces[1].mac_address)
node_mac2=str(node.interfaces[2].mac_address)
node_ip=str(node.ip_address_by_network['internal'])
self._add_node(
client, token, cobbler, node_name,
node_mac0, node_mac1, node_mac2, node_ip,
stomp_name=self.ci().nodes().stomps[0].name
)
def test_configure_cobbler(self):
safety_revert_nodes(self.ci().environment.nodes, 'cobbler')
client_nodes = self.ci().nodes().controllers + self.ci().nodes().computes
cobbler = self.ci().nodes().cobblers[0]
client = CobblerClient(cobbler.ip_address_by_network['internal'])
token = client.login('cobbler', 'cobbler')
for node in client_nodes:
self.add_node(client, token, cobbler, node)
master = self.ci().environment.node['master']
remote = ssh(
self.ci().nodes().cobblers[0].ip_address_by_network['internal'],
username='root',
password='r00tme')
add_to_hosts(
remote,
master.ip_address_by_network['internal'],
master.name,
master.name + ".your-domain-name.com")
for node in self.environment.nodes:
node.save_snapshot('cobbler-configured', force=True)
def test_deploy_nodes(self):
cobbler = self.ci().nodes().cobblers[0]
safety_revert_nodes(self.environment.nodes,
snapsot_name='cobbler-configured')
for node in self.environment.nodes:
node.start()
for node in self.ci().nodes().computes + self.ci().nodes().controllers:
await_node_deploy(
cobbler.ip_address_by_network['internal'], node.name)
sleep(20)
master = self.environment.node['master']
master_remote = ssh(master.ip_address_by_network['public'],
username='root',
password='r00tme')
sign_all_node_certificates(master_remote)
def test_orchestrating_minimal(self):
self.configure_master_remote()
controller1 = self.nodes.controllers[0]
controller2 = self.nodes.controllers[1]
self.write_site_pp_manifest(
root('deployment', 'puppet', 'openstack', 'examples',
'site.pp'),
internal_virtual_ip="'%s'" % self.ci().get_internal_virtual_ip(),
public_virtual_ip="'%s'" % self.ci().get_public_virtual_ip(),
floating_range="'%s'" % self.ci().get_floating_network(),
fixed_range="'%s'" % self.ci().get_fixed_network(),
master_hostname="'%s'" % controller1.name,
mirror_type="'internal'",
controller_public_addresses="{ '%s' => '%s', '%s' => '%s' }"
% (
controller1.name, controller1.ip_address_by_network['public'],
controller2.name, controller2.ip_address_by_network['public']),
controller_internal_addresses="{ '%s' => '%s', '%s' => '%s' }"
% (
controller1.name, controller1.ip_address_by_network['internal'],
controller2.name,
controller2.ip_address_by_network['internal']),
controller_hostnames=[
"%s" % controller1.name,
"%s" % controller2.name],
public_interface="'%s'" % PUBLIC_INTERFACE,
internal_interface="'%s'" % INTERNAL_INTERFACE,
private_interface="'%s'" % PRIVATE_INTERFACE,
nv_physical_volume= ["/dev/vdb"]
)
config_text = (
"use_case: minimal\n"
"fuel-controller-01.your-domain-name.com:\n"
" role: controller\n"
"fuel-controller-02.your-domain-name.com:\n"
" role: controller\n"
"fuel-compute-01.your-domain-name.com:\n"
" role: compute\n"
"fuel-compute-02.your-domain-name.com:\n"
" role: compute\n"
)
remote = ssh(self.nodes.stomps[0].ip_address_by_network['public'], username='root',
password='r00tme')
write_config(remote, '/tmp/nodes.yaml', config_text)
execute(remote, 'astute_run /tmp/nodes.yaml')
def test_orchestrating_simple(self):
self.configure_master_remote()
controller = self.nodes.controllers[0]
self.write_site_pp_manifest(
root('deployment', 'puppet', 'openstack', 'examples',
'site_simple.pp'),
floating_range="'%s'" % self.ci().get_floating_network(),
fixed_network_range="'%s'" % self.ci().get_fixed_network(),
public_interface="'%s'" % PUBLIC_INTERFACE,
internal_interface="'%s'" % INTERNAL_INTERFACE,
private_interface="'%s'" % PRIVATE_INTERFACE,
mirror_type="'internal'",
controller_node_address="'%s'" % controller.ip_address_by_network[
'internal'],
controller_node_public="'%s'" % controller.ip_address_by_network[
'public'],
nv_physical_volume=["/dev/vdb"]
)
config_text = (
"use_case: simple\n"
"fuel-controller-01.your-domain-name.com:\n"
" role: controller\n"
"fuel-controller-02.your-domain-name.com:\n"
" role: controller\n"
"fuel-compute-01.your-domain-name.com:\n"
" role: compute\n"
"fuel-compute-02.your-domain-name.com:\n"
" role: compute\n"
)
remote = ssh(self.nodes.stomps[0].ip_address_by_network['public'], username='root',
password='r00tme')
write_config(remote, '/tmp/nodes.yaml', config_text)
execute(remote, 'astute_run /tmp/nodes.yaml')
def test_orchestrating_compact(self):
controllers = self.nodes.controllers
proxies = self.nodes.proxies
self.configure_master_remote()
controller_public_addresses="{"
controller_internal_addresses="{"
for controller in controllers:
controller_public_addresses +="'%s' => '%s'" % (controller.name,controller.ip_address_by_network['public'])
if controller != controllers[-1]:
controller_public_addresses +=","
else:
controller_public_addresses +="}"
for controller in controllers:
controller_internal_addresses +="'%s' => '%s'" % (controller.name,controller.ip_address_by_network['internal'])
if controller != controllers[-1]:
controller_internal_addresses +=","
else:
controller_internal_addresses +="}"
self.write_site_pp_manifest(
root('deployment', 'puppet', 'openstack', 'examples',
'site_openstack_swift_compact.pp'),
internal_virtual_ip="'%s'" % self.ci().get_internal_virtual_ip(),
public_virtual_ip="'%s'" % self.ci().get_public_virtual_ip(),
floating_range="'%s'" % self.ci().get_floating_network(),
fixed_range="'%s'" % self.ci().get_fixed_network(),
master_hostname = "'%s'" % controllers[0].name,
swift_master = "%s" % controllers[0].name,
controller_public_addresses = controller_public_addresses,
controller_internal_addresses = controller_internal_addresses,
controller_hostnames=["%s" % controller.name for controller in controllers],
public_interface="'%s'" % PUBLIC_INTERFACE,
internal_interface="'%s'" % INTERNAL_INTERFACE,
private_interface="'%s'" % PRIVATE_INTERFACE,
mirror_type ="'internal'",
nv_physical_volume= ["/dev/vdb"]
)
config_text = (
"use_case: compact\n"
"fuel-controller-01.your-domain-name.com:\n"
" role: controller\n"
"fuel-controller-02.your-domain-name.com:\n"
" role: controller\n"
"fuel-controller-03.your-domain-name.com:\n"
" role: controller\n"
"fuel-compute-01.your-domain-name.com:\n"
" role: compute\n"
"fuel-compute-02.your-domain-name.com:\n"
" role: compute\n"
)
remote = ssh(self.nodes.stomps[0].ip_address_by_network['public'], username='root',
password='r00tme')
write_config(remote, '/tmp/nodes.yaml', config_text)
execute(remote, 'astute_run /tmp/nodes.yaml')
def test_orchestrating_full(self):
self.configure_master_remote()
controllers = self.nodes.controllers
proxies = self.nodes.proxies
controller_public_addresses="{"
controller_internal_addresses="{"
swift_proxies="{"
for controller in controllers:
controller_public_addresses +="'%s' => '%s'" % (controller.name,controller.ip_address_by_network['public'])
if controller != controllers[-1]:
controller_public_addresses +=","
else:
controller_public_addresses +="}"
for controller in controllers:
controller_internal_addresses +="'%s' => '%s'" % (controller.name,controller.ip_address_by_network['internal'])
if controller != controllers[-1]:
controller_internal_addresses +=","
else:
controller_internal_addresses +="}"
for proxy in proxies:
swift_proxies +="'%s' => '%s'" % (proxy.name,proxy.ip_address_by_network['internal'])
if proxy != proxies[-1]:
swift_proxies +=","
else:
swift_proxies +="}"
self.write_site_pp_manifest(
root('deployment', 'puppet', 'openstack', 'examples',
'site_openstack_swift_standalone.pp'),
internal_virtual_ip="'%s'" % self.ci().get_internal_virtual_ip(),
public_virtual_ip="'%s'" % self.ci().get_public_virtual_ip(),
floating_range="'%s'" % self.ci().get_floating_network(),
fixed_range="'%s'" % self.ci().get_fixed_network(),
master_hostname="'%s'" % controllers[0].name,
controller_public_addresses = controller_public_addresses,
controller_internal_addresses = controller_internal_addresses,
swift_proxies = swift_proxies,
mirror_type = "'internal'",
controller_hostnames=["%s" % controller.name for controller in controllers],
public_interface="'%s'" % PUBLIC_INTERFACE,
internal_interface="'%s'" % INTERNAL_INTERFACE,
private_interface="'%s'" % PRIVATE_INTERFACE,
nv_physical_volume= ["/dev/vdb"]
)
config_text = (
"use_case: full\n"
"fuel-controller-01.your-domain-name.com:\n"
" role: controller\n"
"fuel-controller-02.your-domain-name.com:\n"
" role: controller\n"
"fuel-compute-01.your-domain-name.com:\n"
" role: compute\n"
"fuel-compute-02.your-domain-name.com:\n"
" role: compute\n"
"fuel-swift-01.your-domain-name.com:\n"
" role: storage\n"
"fuel-swift-02.your-domain-name.com:\n"
" role: storage\n"
"fuel-swift-03.your-domain-name.com:\n"
" role: storage\n"
"fuel-swiftproxy-01.your-domain-name.com:\n"
" role: proxy\n"
"fuel-swiftproxy-02.your-domain-name.com:\n"
" role: proxy\n"
)
remote = ssh(self.nodes.stomps[0].ip_address_by_network['public'], username='root',
password='r00tme')
write_config(remote, '/tmp/nodes.yaml', config_text)
execute(remote, 'astute_run /tmp/nodes.yaml')
def assert_cobbler_ports(self, ip):
closed_tcp_ports = filter(
lambda port: not tcp_ping(
self.master_remote.sudo.ssh,
ip,
port), [22, 53, 80, 443])
closed_udp_ports = filter(
lambda port: not udp_ping(
self.master_remote.sudo.ssh,
ip, port), [53, 67, 68, 69])
self.assertEquals(
{'tcp': [], 'udp': []},
{'tcp': closed_tcp_ports, 'udp': closed_udp_ports})
#tests against empty environment
class MyTestCase(unittest.TestCase):
def test_something(self):
self.assertEqual(True, True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,48 @@
from fuel_test.cobbler.cobbler_test_case import CobblerTestCase
from fuel_test.helpers import is_not_essex
import unittest
from fuel_test.manifest import Manifest, Template
class CompactTestCase(CobblerTestCase):
def deploy_compact(self, quantum=True, loopback=True):
self.do(self.nodes().controllers[:1], 'puppet agent --test')
self.do(self.nodes().controllers[1:], 'puppet agent --test')
if loopback:
self.do(self.nodes().controllers, 'puppet agent --test')
self.do(self.nodes().controllers[1:], 'puppet agent --test')
self.do(self.nodes().controllers[:1], 'puppet agent --test')
self.validate(self.nodes().controllers, 'puppet agent --test')
if quantum:
self.validate(self.nodes().quantums, 'puppet agent --test')
self.validate(self.nodes().computes, 'puppet agent --test')
@unittest.skipUnless(is_not_essex(), 'Quantum in essex is not supported')
def test_deploy_compact_quantum(self):
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.compact(), ci=self.ci(),
controllers=self.nodes().controllers,
quantum=True)
self.deploy_compact()
self.environment().snapshot('compact', force=True)
def test_deploy_compact_wo_quantum(self):
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.compact(), ci=self.ci(),
controllers=self.nodes().controllers,
quantum=False)
self.deploy_compact(quantum=False)
self.environment().snapshot('compact_wo_quantum', force=True)
def test_deploy_compact_wo_loopback(self):
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.compact(), ci=self.ci(),
controllers=self.nodes().controllers,
quantum=False, loopback=False, use_syslog=False)
self.deploy_compact(quantum=False, loopback=False)
self.environment().snapshot('compact_woloopback', force=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,28 @@
import unittest
from fuel_test.cobbler.cobbler_test_case import CobblerTestCase
from fuel_test.helpers import is_not_essex
from fuel_test.manifest import Manifest, Template
class FullTestCase(CobblerTestCase):
def test_full(self):
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.full(), ci=self.ci(),
controllers=self.nodes().controllers,
proxies=self.nodes().proxies,
quantum=True)
self.validate(self.nodes().controllers[:1], 'puppet agent --test')
self.validate(self.nodes().controllers[1:], 'puppet agent --test')
self.validate(self.nodes().controllers[:1], 'puppet agent --test')
if is_not_essex():
self.validate(self.nodes().quantums, 'puppet agent --test')
self.validate(self.nodes().computes, 'puppet agent --test')
self.do(self.nodes().storages, 'puppet agent --test')
self.do(self.nodes().storages, 'puppet agent --test')
self.do(self.nodes().proxies, 'puppet agent --test')
self.validate(self.nodes().storages, 'puppet agent --test')
self.validate(self.nodes().proxies, 'puppet agent --test')
self.environment().snapshot('full', force=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,23 @@
import unittest
from fuel_test.cobbler.cobbler_test_case import CobblerTestCase
from fuel_test.helpers import is_not_essex
from fuel_test.manifest import Manifest, Template
class MinimalTestCase(CobblerTestCase):
def test_minimal(self):
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.minimal(), ci=self.ci(),
controllers=self.nodes().controllers,
swift=False,
quantum=True)
self.validate(self.nodes().controllers[:1], 'puppet agent --test')
self.validate(self.nodes().controllers[1:], 'puppet agent --test')
self.validate(self.nodes().controllers[:1], 'puppet agent --test')
if is_not_essex():
self.validate(self.nodes().quantums, 'puppet agent --test')
self.validate(self.nodes().computes, 'puppet agent --test')
self.environment().snapshot('minimal', force=True)
if __name__ == '__main__':
unittest.main()

View File

@ -1,53 +1,52 @@
import unittest
from fuel_test.openstack.openstack_test_case import OpenStackTestCase
from fuel_test.cobbler.cobbler_test_case import CobblerTestCase
class NovaSubClassesTestCase(OpenStackTestCase):
class NovaSubClassesTestCase(CobblerTestCase):
def test_deploy_nova_compute(self):
self.validate(
[self.nodes.computes[0], ],
[self.nodes().computes[0], ],
'puppet agent --test --tags openstack::repo::yum,%s' % "nova::compute")
def test_deploy_nova_api_compute(self):
self.validate(
[self.nodes.computes[0], ],
[self.nodes().computes[0], ],
'puppet agent --test --tags openstack::repo::yum,%s' % "nova::api")
def test_deploy_nova_api_controller(self):
self.validate(
[self.nodes.controllers[0], ],
[self.nodes().controllers[0], ],
'puppet agent --test --tags openstack::repo::yum,%s' % "nova::api")
def test_deploy_nova_network(self):
self.validate(
[self.nodes.computes[0], ],
[self.nodes().computes[0], ],
'puppet agent --test --tags openstack::repo::yum,%s' % "nova::network")
def test_deploy_nova_consoleauth(self):
self.validate(
[self.nodes.controllers[0], self.nodes.controllers[1]],
[self.nodes().controllers[0], self.nodes().controllers[1]],
'puppet agent --test --tags openstack::repo::yum,%s' % "nova::consoleauth")
def test_deploy_nova_rabbitmq(self):
self.validate(
[self.nodes.controllers[0], self.nodes.controllers[1]],
[self.nodes().controllers[0], self.nodes().controllers[1]],
'puppet agent --test --tags openstack::repo::yum,%s' % "nova::rabbitmq")
def test_deploy_nova_utilities(self):
self.validate(
[self.nodes.computes[0], ],
[self.nodes().computes[0], ],
'puppet agent --test --tags openstack::repo::yum,%s' % "nova::utilities")
def test_deploy_nova_vncproxy(self):
self.validate(
[self.nodes.controllers[0], ],
[self.nodes().controllers[0], ],
'puppet agent --test --tags openstack::repo::yum,%s' % "nova::vncproxy")
def test_deploy_nova_volume(self):
self.validate(
[self.nodes.computes[0], ],
[self.nodes().computes[0], ],
'puppet agent --test --tags openstack::repo::yum,%s' % "nova::volume")
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,110 @@
import unittest
from fuel_test.cobbler.cobbler_test_case import CobblerTestCase
from fuel_test.helpers import write_config
from fuel_test.manifest import Manifest, Template
class CobblerCase(CobblerTestCase):
def test_orchestrating_minimal(self):
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.minimal(), ci=self.ci(),
controllers=self.nodes().controllers[:2],
swift=False,
quantum=True)
config_text = (
"use_case: minimal\n"
"fuel-controller-01.your-domain-name.com:\n"
" role: controller\n"
"fuel-controller-02.your-domain-name.com:\n"
" role: controller\n"
"fuel-compute-01.your-domain-name.com:\n"
" role: compute\n"
"fuel-compute-02.your-domain-name.com:\n"
" role: compute\n"
)
remote = self.nodes().stomps[0].remote('public', login='root',
password='r00tme')
write_config(remote, '/tmp/nodes.yaml', config_text)
remote.check_stderr('astute_run /tmp/nodes.yaml')
def test_orchestrating_simple(self):
Manifest().write_openstack_simple_manifest(
remote=self.remote(),
ci=self.ci(),
controllers=self.nodes().controllers[:1])
config_text = (
"use_case: simple\n"
"fuel-controller-01.your-domain-name.com:\n"
" role: controller\n"
"fuel-controller-02.your-domain-name.com:\n"
" role: controller\n"
"fuel-compute-01.your-domain-name.com:\n"
" role: compute\n"
"fuel-compute-02.your-domain-name.com:\n"
" role: compute\n"
)
remote = self.nodes().stomps[0].remote('public', login='root',
password='r00tme')
write_config(remote, '/tmp/nodes.yaml', config_text)
remote.check_stderr('astute_run /tmp/nodes.yaml')
def test_orchestrating_compact(self):
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.compact(), ci=self.ci(),
controllers=self.nodes().controllers,
quantum=True)
config_text = (
"use_case: compact\n"
"fuel-controller-01.your-domain-name.com:\n"
" role: controller\n"
"fuel-controller-02.your-domain-name.com:\n"
" role: controller\n"
"fuel-controller-03.your-domain-name.com:\n"
" role: controller\n"
"fuel-compute-01.your-domain-name.com:\n"
" role: compute\n"
"fuel-compute-02.your-domain-name.com:\n"
" role: compute\n"
)
remote = self.nodes().stomps[0].remote('public', login='root',
password='r00tme')
write_config(remote, '/tmp/nodes.yaml', config_text)
remote.check_stderr('astute_run /tmp/nodes.yaml')
def test_orchestrating_full(self):
Manifest().write_openstack_manifest(
remote=self.remote(),
template=Template.full(), ci=self.ci(),
controllers=self.nodes().controllers,
proxies=self.nodes().proxies,
quantum=True)
config_text = (
"use_case: full\n"
"fuel-controller-01.your-domain-name.com:\n"
" role: controller\n"
"fuel-controller-02.your-domain-name.com:\n"
" role: controller\n"
"fuel-compute-01.your-domain-name.com:\n"
" role: compute\n"
"fuel-compute-02.your-domain-name.com:\n"
" role: compute\n"
"fuel-swift-01.your-domain-name.com:\n"
" role: storage\n"
"fuel-swift-02.your-domain-name.com:\n"
" role: storage\n"
"fuel-swift-03.your-domain-name.com:\n"
" role: storage\n"
"fuel-swiftproxy-01.your-domain-name.com:\n"
" role: proxy\n"
"fuel-swiftproxy-02.your-domain-name.com:\n"
" role: proxy\n"
)
remote = self.nodes().stomps[0].remote(login='root',
password='r00tme')
write_config(remote, '/tmp/nodes.yaml', config_text)
remote.check_stderr('astute_run /tmp/nodes.yaml')
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,18 @@
import unittest
from fuel_test.cobbler.cobbler_test_case import CobblerTestCase
from fuel_test.manifest import Manifest
from fuel_test.settings import OPENSTACK_SNAPSHOT
class SimpleTestCase(CobblerTestCase):
def test_simple(self):
Manifest().write_openstack_simple_manifest(
remote=self.remote(),
ci=self.ci(),
controllers=self.nodes().controllers)
self.validate(
self.nodes().controllers + self.nodes().computes,
'puppet agent --test')
self.environment().snapshot(OPENSTACK_SNAPSHOT, force=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,16 @@
import unittest
from fuel_test.cobbler.cobbler_test_case import CobblerTestCase
from fuel_test.manifest import Manifest
class SwiftCase(CobblerTestCase):
def test_swift(self):
Manifest().write_swift_manifest(remote=self.remote(),
controllers=self.nodes().controllers)
self.validate(self.nodes().controllers[0], 'puppet agent --test')
self.do(self.nodes().storages, 'puppet agent --test')
self.do(self.nodes().storages, 'puppet agent --test')
self.validate(self.nodes().proxies[0], 'puppet agent --test')
self.validate(self.nodes().storages, 'puppet agent --test')
if __name__ == '__main__':
unittest.main()

View File

@ -1,7 +0,0 @@
DEVICE=%(interface)s
ONBOOT="yes"
TYPE="Ethernet"
BOOTPROTO="static"
IPADDR=%(ip)s
NETMASK=%(net_mask)s
GATEWAY=%(gateway)s

View File

@ -1,15 +0,0 @@
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0 eth1 eth2
iface eth0 inet dhcp
iface eth1 inet static
address %(ip)s
netmask %(net_mask)s
gateway %(gateway)s
iface eth2 inet dhcp

View File

@ -1,3 +0,0 @@
DEVICE=eth0
ONBOOT="yes"
TYPE="Ethernet"

View File

@ -1,14 +0,0 @@
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0 eth1 eth2
iface eth0 inet manual
up ifconfig $IFACE 0.0.0.0 up
down ifconfig $IFACE down
iface eth1 inet dhcp
iface eth2 inet dhcp

View File

@ -1,12 +0,0 @@
fuel-controller-01:
role: controller
fuel-compute-01:
role: compute #controller
fuel-compute-02:
role: compute
fuel-compute-03:
role: compute

View File

@ -1,41 +1,21 @@
import logging
import subprocess
import tarfile
from time import sleep
from devops.helpers import ssh, os, wait
import keystoneclient.v2_0
from devops.helpers.helpers import wait, SSHClient
import os
import re
from fuel_test.cobbler.cobbler_client import CobblerClient
from fuel_test.settings import OS_FAMILY, PUPPET_CLIENT_PACKAGE, PUPPET_VERSION, PUPPET_MASTER_SERVICE, ADMIN_USERNAME, ADMIN_PASSWORD, ADMIN_TENANT_FOLSOM, ADMIN_TENANT_ESSEX, CIRROS_IMAGE, OPENSTACK_SNAPSHOT
from fuel_test.settings import OS_FAMILY, PUPPET_CLIENT_PACKAGE, PUPPET_VERSION, PUPPET_MASTER_SERVICE
from root import root
import glanceclient.client
def get_file_as_string(path):
with open(path) as f:
return f.read()
def execute(remote, command):
chan, stdin, stderr, stdout = execute_async(remote, command)
result = {
'stdout': [],
'stderr': [],
'exit_code': 0
}
for line in stdout:
result['stdout'].append(line)
print line
for line in stderr:
result['stderr'].append(line)
print line
result['exit_code'] = chan.recv_exit_status()
chan.close()
return result
def udp_ping(remote, host, port):
result = execute(remote, 'nmap -PU -sU -p%s %s' % (port, host))
result = remote.check_stderr('nmap -PU -sU -p%s %s' % (port, host))
for line in result['stdout']:
if line.find('udp open') != -1:
return True
@ -43,7 +23,7 @@ def udp_ping(remote, host, port):
def tcp_ping(remote, host, port):
result = execute(remote, 'nmap -PU -p%s %s' % (port, host))
result = remote.check_stderr('nmap -PU -p%s %s' % (port, host))
for line in result['stdout']:
if line.find('tcp open') != -1:
return True
@ -55,196 +35,17 @@ def load(path):
return f.read()
def execute_async(remote, command):
logging.debug("Executing command: '%s'" % command.rstrip())
chan = remote._ssh.get_transport().open_session()
stdin = chan.makefile('wb')
stdout = chan.makefile('rb')
stderr = chan.makefile_stderr('rb')
cmd = "%s\n" % command
if remote.sudo_mode:
cmd = 'sudo -S bash -c "%s"' % cmd.replace('"', '\\"')
chan.exec_command(cmd)
if stdout.channel.closed is False:
stdin.write('%s\n' % remote.password)
stdin.flush()
return chan, stdin, stderr, stdout
def extract_virtual_ips(ipaout):
pattern = '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*(eth\d{1,}):ka'
return dict((v, k) for k, v in re.findall(pattern, ipaout))
def tempest_build_config_folsom(host, image_ref, image_ref_alt,
path_to_private_key,
compute_db_uri='mysql://user:pass@localhost/nova'):
sample = load(
root('fuel_test', 'config', 'tempest.conf.folsom.sample'))
config = sample % {
'IDENTITY_USE_SSL': 'false',
'IDENTITY_HOST': host,
'IDENTITY_PORT': '5000',
'IDENTITY_API_VERSION': 'v2.0',
'IDENTITY_PATH': 'tokens',
'IDENTITY_STRATEGY': 'keystone',
'COMPUTE_ALLOW_TENANT_ISOLATION': 'true',
'COMPUTE_ALLOW_TENANT_REUSE': 'true',
'USERNAME': 'tempest1',
'PASSWORD': 'secret',
'TENANT_NAME': 'tenant1',
'ALT_USERNAME': 'tempest2',
'ALT_PASSWORD': 'secret',
'ALT_TENANT_NAME': 'tenant2',
'IMAGE_ID': image_ref,
'IMAGE_ID_ALT': image_ref_alt,
'FLAVOR_REF': '1',
'FLAVOR_REF_ALT': '2',
'COMPUTE_BUILD_INTERVAL': '10',
'COMPUTE_BUILD_TIMEOUT': '600',
'RUN_SSH':'false',
'NETWORK_FOR_SSH':'novanetwork',
'COMPUTE_CATALOG_TYPE': 'compute',
'COMPUTE_CREATE_IMAGE_ENABLED': 'true',
'COMPUTE_RESIZE_AVAILABLE': 'true',
'COMPUTE_CHANGE_PASSWORD_AVAILABLE': 'false',
'COMPUTE_LOG_LEVEL': 'DEBUG',
'COMPUTE_WHITEBOX_ENABLED': 'true',
'COMPUTE_SOURCE_DIR': '/opt/stack/nova',
'COMPUTE_CONFIG_PATH': '/etc/nova/nova.conf',
'COMPUTE_BIN_DIR': '/usr/local/bin',
'COMPUTE_PATH_TO_PRIVATE_KEY': path_to_private_key,
'COMPUTE_DB_URI': compute_db_uri,
'IMAGE_CATALOG_TYPE': 'image',
'IMAGE_API_VERSION': '1',
'IMAGE_HOST': host,
'IMAGE_PORT': '9292',
'IMAGE_USERNAME': 'tempest1',
'IMAGE_PASSWORD': 'secret',
'IMAGE_TENANT_NAME': 'tenant1',
'COMPUTE_ADMIN_USERNAME': ADMIN_USERNAME,
'COMPUTE_ADMIN_PASSWORD': ADMIN_PASSWORD,
'COMPUTE_ADMIN_TENANT_NAME': ADMIN_TENANT_FOLSOM,
'IDENTITY_ADMIN_USERNAME': ADMIN_USERNAME,
'IDENTITY_ADMIN_PASSWORD': ADMIN_PASSWORD,
'IDENTITY_ADMIN_TENANT_NAME': ADMIN_TENANT_FOLSOM,
'VOLUME_CATALOG_TYPE': 'volume',
'VOLUME_BUILD_INTERVAL': '10',
'VOLUME_BUILD_TIMEOUT': '300',
'NETWORK_CATALOG_TYPE': 'network',
'NETWORK_API_VERSION': 'v2.0',
}
return config
def tempest_build_config_essex(host, image_ref, image_ref_alt):
sample = load(
root('fuel_test', 'config', 'tempest.conf.essex.sample'))
config = sample % {
'HOST': host,
'USERNAME': 'tempest1',
'PASSWORD': 'secret',
'TENANT_NAME': 'tenant1',
'ALT_USERNAME': 'tempest2',
'ALT_PASSWORD': 'secret',
'ALT_TENANT_NAME': 'tenant2',
'IMAGE_ID': image_ref,
'IMAGE_ID_ALT': image_ref_alt,
'ADMIN_USERNAME': ADMIN_USERNAME,
'ADMIN_PASSWORD': ADMIN_PASSWORD,
'ADMIN_TENANT_NAME': ADMIN_TENANT_ESSEX,
}
return config
def tempest_write_config(config):
with open(root('..', 'tempest.conf'), 'w') as f:
f.write(config)
def get_auth_url(auth_host):
auth_url = 'http://%s:5000/v2.0/' % auth_host
print auth_url
return auth_url
def _get_identity_client(auth_host, username, password, tenant_name):
keystone = retry(10, keystoneclient.v2_0.client.Client,
username=username, password=password, tenant_name=tenant_name,
auth_url=get_auth_url(auth_host))
return keystone
def _get_image_client(auth_host, username, password, tenant_name):
keystone = _get_identity_client(auth_host, username, password, tenant_name)
token = keystone.auth_token
endpoint = keystone.service_catalog.url_for(service_type='image',
endpoint_type='publicURL')
return glanceclient.Client('1', endpoint=endpoint, token=token)
def make_tempest_objects(auth_host, username, password, tenant_name):
keystone = _get_identity_client(auth_host, username, password, tenant_name)
tenant1 = retry(10, keystone.tenants.create, tenant_name='tenant1')
tenant2 = retry(10, keystone.tenants.create, tenant_name='tenant2')
retry(10, keystone.users.create, name='tempest1', password='secret',
email='tempest1@example.com', tenant_id=tenant1.id)
retry(10, keystone.users.create, name='tempest2', password='secret',
email='tempest2@example.com', tenant_id=tenant2.id)
image_ref, image_ref_alt = tempest_add_images(
auth_host,
username,
password,
tenant_name)
return image_ref, image_ref_alt
def upload(glance, name, path):
image = glance.images.create(
name=name,
is_public=True,
container_format='bare',
disk_format='qcow2')
image.update(data=open(path, 'rb'))
return image.id
def tempest_add_images(auth_host, username, password, tenant_name):
if not os.path.isfile('cirros-0.3.0-x86_64-disk.img'):
subprocess.check_call(['wget', CIRROS_IMAGE])
glance = _get_image_client(auth_host, username, password, tenant_name)
return upload(glance, 'cirros_0.3.0', 'cirros-0.3.0-x86_64-disk.img'),\
upload(glance, 'cirros_0.3.0', 'cirros-0.3.0-x86_64-disk.img')
def tempest_share_glance_images(remote, network):
if OS_FAMILY == "centos":
execute(remote, 'chkconfig rpcbind on')
execute(remote, '/etc/init.d/rpcbind restart')
execute(remote,
'echo "/var/lib/glance/images %s(rw,no_root_squash)" >> /etc/exports' % network)
execute(remote, '/etc/init.d/nfs restart')
else:
install_packages(remote, 'nfs-kernel-server nfs-common portmap')
execute(remote,
'echo "/var/lib/glance/images %s(rw,no_root_squash)" >> /etc/exports' % network)
execute(remote, '/etc/init.d/nfs-kernel-server restart')
def tempest_mount_glance_images(remote, host):
if OS_FAMILY == "centos":
execute(remote, 'chkconfig rpcbind on')
execute(remote, '/etc/init.d/rpcbind restart')
execute(remote,
'mount %s:/var/lib/glance/images /var/lib/glance/images' % host)
else:
install_packages(remote, 'nfs-common portmap')
execute(remote,
'mount %s:/var/lib/glance/images /var/lib/glance/images' % host)
def sync_time(remote):
install_packages(remote, 'ntpdate')
execute(remote, '/etc/init.d/ntpd stop')
execute(remote, 'ntpdate 0.centos.pool.ntp.org')
execute(remote, '/etc/init.d/ntpd start')
def sync_time(remotes):
install_packages2(remotes, 'ntpdate')
for remote in remotes:
remote.execute('/etc/init.d/ntpd stop')
remote.check_stderr('ntpdate 0.centos.pool.ntp.org')
remote.execute('/etc/init.d/ntpd start')
def write_config(remote, path, text):
@ -266,17 +67,35 @@ def retry(count, func, **kwargs):
sleep(1)
def install_packages2(remotes, packages):
if OS_FAMILY == "centos":
cmd = 'yum -y install %s' % packages
else:
cmd = 'DEBIAN_FRONTEND=noninteractive apt-get -y install %s' % packages
SSHClient.execute_together(remotes, cmd)
def install_packages(remote, packages):
if OS_FAMILY == "centos":
execute(remote.sudo.ssh, 'yum -y install %s' % packages)
remote.sudo.ssh.check_call('yum -y install %s' % packages)
else:
execute(remote.sudo.ssh, 'DEBIAN_FRONTEND=noninteractive apt-get -y install %s' % packages)
remote.sudo.ssh.check_call(
'DEBIAN_FRONTEND=noninteractive apt-get -y install %s' % packages)
def update_pms(remotes):
if OS_FAMILY == "centos":
cmd = 'yum makecache'
else:
cmd = 'apt-get update'
SSHClient.execute_together(remotes, cmd)
def update_pm(remote):
if OS_FAMILY == "centos":
execute(remote.sudo.ssh, 'yum makecache')
remote.sudo.ssh.check_call('yum makecache')
else:
execute(remote.sudo.ssh, 'apt-get update')
remote.sudo.ssh.check_call('apt-get update')
def add_nmap(remote):
install_packages(remote, "nmap")
@ -284,31 +103,31 @@ def add_nmap(remote):
def add_epel_repo_yum(remote):
if OS_FAMILY == "centos":
execute(remote.sudo.ssh,
remote.sudo.ssh.check_call(
'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm')
def delete_epel_repo_yum(remote):
execute(remote.sudo.ssh,
remote.sudo.ssh.check_call(
'rpm --erase epel-release-6-8.noarch.rpm')
def add_puppet_lab_repo(remote):
if OS_FAMILY == "centos":
execute(
remote.sudo.ssh,
remote.sudo.ssh.check_call(
'rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-5.noarch.rpm')
else:
execute(remote.sudo.ssh,
remote.sudo.ssh.check_call(
'wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb -O /tmp/puppetlabs-release-precise.deb')
execute(remote.sudo.ssh, 'dpkg -i /tmp/puppetlabs-release-precise.deb')
remote.sudo.ssh.check_call(
'dpkg -i /tmp/puppetlabs-release-precise.deb')
def remove_puppetlab_repo(remote):
if OS_FAMILY == "centos":
execute(remote.sudo.ssh, 'rpm --erase puppetlabs-release-6-5.noarch')
remote.sudo.ssh.check_call('rpm --erase puppetlabs-release-6-5.noarch')
else:
execute(remote.sudo.ssh, 'dpkg -r puppetlabs-release-precise')
remote.sudo.ssh.check_call('dpkg -r puppetlabs-release-precise')
def setup_puppet_client(remote):
@ -328,8 +147,8 @@ def start_puppet_agent(remote):
'puppet resource service puppet ensure=running enable=true')
def sign_all_node_certificates(remote):
remote.sudo.ssh.execute('puppet cert sign --all')
#def sign_all_node_certificates(remote):
# remote.sudo.ssh.execute('puppet cert sign --all')
def request_cerificate(remote):
@ -341,7 +160,7 @@ def switch_off_ip_tables(remote):
def puppet_apply(remote, script, module_path="/tmp/puppet/modules/"):
execute(remote.sudo.ssh,
remote.sudo.ssh.check_stderr(
"puppet apply --modulepath %s -e '%s'" % (module_path, script))
@ -351,7 +170,7 @@ def setup_puppet_master(remote):
update_pm(remote)
install_packages(remote, PUPPET_CLIENT_PACKAGE)
upload_recipes(remote.sudo.ssh, "/tmp/puppet/modules/")
execute(remote.sudo.ssh, 'setenforce 0')
write_config(remote.sudo.ssh, '/etc/puppet/hiera.yaml', '')
puppet_apply(remote.sudo.ssh,
'class {puppet: puppet_master_version => "%s"}'
'-> class {puppet::thin:}'
@ -363,15 +182,22 @@ def setup_puppet_master(remote):
'class {puppetdb:}')
puppet_apply(remote.sudo.ssh,
'class {puppetdb::master::config: puppet_service_name=>"%s"}' % PUPPET_MASTER_SERVICE)
execute(remote.sudo.ssh, "service %s restart" % PUPPET_MASTER_SERVICE)
remote.sudo.ssh.check_stderr("service %s restart" % PUPPET_MASTER_SERVICE)
def upload_recipes(remote, remote_dir="/etc/puppet/modules/"):
recipes_dir = root('deployment', 'puppet')
for dir in os.listdir(recipes_dir):
recipe_dir = os.path.join(recipes_dir, dir)
file = None
try:
file = remote.open('/tmp/recipes.tar', 'wb')
with tarfile.open(fileobj=file, mode='w') as tar:
tar.add(recipes_dir, arcname='')
remote.mkdir(remote_dir)
remote.upload(recipe_dir, remote_dir)
remote.check_call('tar -xf /tmp/recipes.tar -C %s' % remote_dir)
finally:
if file:
file.close()
def upload_keys(remote, remote_dir="/var/lib/puppet/"):
ssh_keys_dir = root('fuel_test', 'config', 'ssh_keys')
@ -388,12 +214,12 @@ def change_host_name(remote, short, long):
def update_host_name_centos(remote, short):
execute(remote.sudo.ssh,
remote.sudo.ssh.check_stderr(
'echo HOSTNAME=%s >> /etc/sysconfig/network' % short)
def update_host_name_ubuntu(remote, short):
execute(remote.sudo.ssh,
remote.sudo.ssh.check_stderr(
'echo %s > /etc/hostname' % short)
@ -401,91 +227,26 @@ def add_to_hosts(remote, ip, short, long):
remote.sudo.ssh.execute('echo %s %s %s >> /etc/hosts' % (ip, long, short))
def safety_revert_nodes(nodes, snapsot_name=OPENSTACK_SNAPSHOT):
for node in nodes:
try:
node.stop()
except:
pass
for node in nodes:
node.restore_snapshot(snapsot_name)
sleep(2)
def make_shared_storage(remote, host, client_nodes, access_network):
tempest_share_glance_images(remote, access_network)
switch_off_ip_tables(remote)
execute(remote, '/etc/init.d/iptables stop')
sleep(15)
for controller in client_nodes:
remote_controller = ssh(
controller.ip_address_by_network['internal'], username='root',
password='r00tme').sudo.ssh
tempest_mount_glance_images(remote_controller, host)
sleep(60)
def write_static_ip(remote, ip, net_mask, gateway, interface='eth1'):
if OS_FAMILY == 'centos':
path = '/etc/sysconfig/network-scripts/ifcfg-%s' % interface
text = load(root('fuel_test', 'config', 'ifcfg-eth0.config')) % {
'ip': str(ip), 'net_mask': str(net_mask),
'gateway': str(gateway), 'interface': str(interface)}
write_config(remote, path, text)
else:
path = '/etc/network/interfaces'
text = load(root('fuel_test', 'config', 'interfaces.config')) % {
'ip': str(ip), 'net_mask': str(net_mask),
'gateway': str(gateway)}
write_config(remote, path, text)
def only_private_interface(nodes):
for node in nodes:
remote = ssh(node.ip_address_by_network['internal'], username='root',
password='r00tme')
execute(remote, 'ifdown eth0')
if OS_FAMILY == 'centos':
path = '/etc/sysconfig/network-scripts/ifcfg-eth0'
write_config(remote, path, load(root('fuel_test', 'config', 'interfaces_quantum_centos.config')))
else:
path = '/etc/network/interfaces'
write_config(remote, path, load(root('fuel_test', 'config', 'interfaces_quantum_ubuntu.config')))
execute(remote, 'ifup eth0')
execute(remote, 'dhclient eth1')
if OS_FAMILY == 'centos':
execute(remote, 'killall dhclient')
else:
execute(remote, 'killall dhclient3')
def kill_dhcpclient(nodes):
for node in nodes:
remote = ssh(node.ip_address_by_network['public'], username='root', password='r00tme')
if OS_FAMILY == 'centos':
execute(remote, 'killall dhclient')
else:
execute(remote, 'killall dhclient3')
logging.info("Killed dhcp %s" % node.name)
def await_node_deploy(ip, name):
client = CobblerClient(ip)
token = client.login('cobbler', 'cobbler')
# todo does cobbler require authorization?
wait(
lambda : client.get_system(name, token)['netboot_enabled'] == False,
timeout=30*60*60)
lambda: client.get_system(name, token)['netboot_enabled'] == False,
timeout=30 * 60)
def build_astute():
subprocess.check_output(
['gem', 'build', 'astute.gemspec'],
cwd=root('deployment', 'mcollective', 'astute'))
def install_astute(ip):
remote = ssh(ip,
username='root',
password='r00tme')
def install_astute(remote):
remote.upload(
root('deployment', 'mcollective', 'astute', 'astute-0.0.1.gem'),
'/tmp/astute-0.0.1.gem')
execute(remote, 'gem install /tmp/astute-0.0.1.gem')
remote.check_stderr('gem install /tmp/astute-0.0.1.gem')
def is_not_essex():
return os.environ.get('ENV_NAME', 'folsom').find('essex') == -1

View File

@ -1,33 +0,0 @@
import logging
import argparse
import devops
import os
def get_params():
parser = argparse.ArgumentParser(description="Integration test suite")
parser.add_argument('command',
choices=('setup', 'destroy', 'resume', 'suspend'),
default='setup',
help="command to execute")
return parser.parse_args()
def main():
params = get_params()
logging.getLogger().setLevel(logging.DEBUG)
name = os.environ.get('ENV_NAME', 'recipes')
environment = devops.load(name)
if params.command == 'destroy':
devops.destroy(environment)
if params.command == 'suspend':
for node in environment.nodes:
node.suspend()
if params.command == 'resume':
for node in environment.nodes:
node.resume()
if __name__ == "__main__":
main()

225
fuel_test/manifest.py Normal file
View File

@ -0,0 +1,225 @@
from ipaddr import IPNetwork
import re
from fuel_test.helpers import load, write_config, is_not_essex
from fuel_test.root import root
from fuel_test.settings import INTERFACES, OS_FAMILY
class Template(object):
def __init__(self, path):
super(Template, self).__init__()
self.value = load(path)
def p_(self, value):
"""
:rtype : str
"""
if isinstance(value, dict):
return self._hash(value)
if isinstance(value, list):
return self._list(value)
if isinstance(value, bool):
return self._bool(value)
if isinstance(value, int):
return str(value)
if isinstance(value, type(None)):
return 'undef'
return self._str(value)
def _hash(self, value):
return '{%s}' % ','.join(
["%s => %s" % (self.p_(k), self.p_(v)) for k, v in value.items()])
def _list(self, value):
return '[%s]' % ','.join(["%s" % self.p_(k) for k in value])
def _str(self, value):
ret = str(value)
if ret.startswith('$'):
return ret
return "'%s'" % ret
def _bool(self, value):
if not value: return 'false'
return 'true'
def _replace(self, template, **kwargs):
for key, value in kwargs.items():
template, count = re.subn(
'^(\$' + str(key) + ')\s*=.*', "\\1 = " + self.p_(value),
template,
flags=re.MULTILINE)
if count == 0:
raise Exception("Variable ${0:>s} not found".format(key))
return template
def replace(self, **kwargs):
self.value = self._replace(self.value, **kwargs)
def __str__(self):
return str(self.value)
@classmethod
def stomp(cls):
return cls(root('deployment', 'puppet', 'mcollective', 'examples',
'site.pp'))
@classmethod
def minimal(cls):
return cls(root('deployment', 'puppet', 'openstack', 'examples',
'site.pp'))
@classmethod
def compact(cls):
return cls(root('deployment', 'puppet', 'openstack', 'examples',
'site_openstack_swift_compact.pp'))
@classmethod
def full(cls):
return cls(root('deployment', 'puppet', 'openstack', 'examples',
'site_openstack_swift_standalone.pp'))
class Manifest(object):
def mirror_type(self):
if OS_FAMILY == 'centos':
return 'internal-stage'
else:
return 'internal'
def write_manifest(self, remote, manifest):
write_config(remote, '/etc/puppet/manifests/site.pp',
str(manifest))
def public_addresses(self, controllers):
return dict(map(
lambda x: (x.name, x.get_ip_address_by_network_name('public')),
controllers))
def internal_addresses(self, controllers):
return dict(map(
lambda x: (x.name, x.get_ip_address_by_network_name('internal')),
controllers))
def hostnames(self, controllers):
return [x.name for x in controllers]
def public_interface(self):
return INTERFACES['public']
def internal_interface(self):
return INTERFACES['internal']
def private_interface(self):
return INTERFACES['private']
def physical_volumes(self):
return ["/dev/vdb"]
def loopback(self, loopback):
return "loopback" if loopback else False
def write_openstack_simple_manifest(self, remote, ci, controllers,
use_syslog=True,
quantum=True,
cinder=True):
template = Template(
root(
'deployment', 'puppet', 'openstack', 'examples',
'site_simple.pp')).replace(
floating_range=ci.floating_network(),
fixed_range=ci.fixed_network(),
public_interface=self.public_interface(),
internal_interface=self.internal_interface(),
private_interface=self.private_interface(),
mirror_type=self.mirror_type(),
controller_node_address=controllers[
0].get_ip_address_by_network_name(
'internal'),
controller_node_public=controllers[
0].get_ip_address_by_network_name(
'public'),
nv_physical_volume=self.physical_volumes(),
use_syslog=use_syslog
)
self.write_manifest(remote, template)
def write_openstack_manifest(self, remote, template, ci, controllers,
proxies=None, use_syslog=True,
quantum=True, loopback=True,
cinder=True, swift=True):
template.replace(
internal_virtual_ip=ci.internal_virtual_ip(),
public_virtual_ip=ci.public_virtual_ip(),
floating_range=ci.floating_network(),
fixed_range=ci.fixed_network(),
master_hostname=controllers[0].name,
mirror_type=self.mirror_type(),
controller_public_addresses=self.public_addresses(
controllers),
controller_internal_addresses=self.internal_addresses(
controllers),
controller_hostnames=self.hostnames(controllers),
public_interface=self.public_interface(),
internal_interface=self.internal_interface(),
private_interface=self.private_interface(),
nv_physical_volume=self.physical_volumes(),
use_syslog=use_syslog,
cinder=cinder,
)
if swift:
template.replace(swift_loopback=self.loopback(loopback))
if proxies:
template.replace(
swift_master=proxies[0].name,
swift_proxies=self.internal_addresses(proxies)
)
else:
template.replace(
swift_master="%s" % controllers[0].name,
swift_proxies=self.internal_addresses(controllers)
)
if is_not_essex():
template.replace(
quantum=quantum,
)
self.write_manifest(remote, template)
def write_swift_manifest(self, remote, controllers,
proxies=None):
template = Template(
root('deployment', 'puppet', 'swift', 'examples',
'site.pp'))
template.replace(
swift_proxy_address=proxies[0].get_ip_address_by_network_name(
'internal'),
controller_node_public=controllers[
0].get_ip_address_by_network_name(
'public'),
)
self.write_manifest(remote, template)
def write_cobbler_manifest(self, remote, ci, cobblers):
site_pp = Template(root('deployment', 'puppet', 'cobbler', 'examples',
'server_site.pp'))
cobbler = cobblers[0]
cobbler_address = cobbler.get_ip_address_by_network_name('internal')
network = IPNetwork(ci.environment().network_by_name(
'internal').ip_network)
site_pp.replace(
server=cobbler_address,
name_server=cobbler_address,
next_server=cobbler_address,
dhcp_start_address=network[5],
dhcp_end_address=network[-1],
dhcp_netmask=network.netmask,
dhcp_gateway=network[1],
pxetimeout='3000'
)
self.write_manifest(remote, site_pp)
def write_stomp_manifest(self, remote):
self.write_manifest(remote, Template.stomp())

View File

@ -5,45 +5,50 @@ class NodeRoles(object):
storage_names=None,
proxy_names=None,
cobbler_names=None,
keystone_names=None,
stomp_names=None,
quantum_names=None):
quantum_names=None,
master_names=None):
self.master_names = master_names or []
self.controller_names = controller_names or []
self.compute_names = compute_names or []
self.storage_names = storage_names or []
self.proxy_names = proxy_names or []
self.cobbler_names = cobbler_names or []
self.keystone_names = keystone_names or []
self.stomp_names = stomp_names or []
self.quantum_names = quantum_names or []
class Nodes(object):
def __init__(self, devops_environment, node_roles):
def __init__(self, environment, node_roles):
self.controllers = []
self.computes = []
self.storages = []
self.proxies = []
self.keystones = []
self.cobblers = []
self.stomps = []
self.quantums = []
self.masters = []
for node_name in node_roles.master_names:
self.masters.append(environment.node_by_name(node_name))
for node_name in node_roles.controller_names:
self.controllers.append(devops_environment.node[node_name])
self.controllers.append(environment.node_by_name(node_name))
for node_name in node_roles.compute_names:
self.computes.append(devops_environment.node[node_name])
self.computes.append(environment.node_by_name(node_name))
for node_name in node_roles.storage_names:
self.storages.append(devops_environment.node[node_name])
self.storages.append(environment.node_by_name(node_name))
for node_name in node_roles.proxy_names:
self.proxies.append(devops_environment.node[node_name])
self.proxies.append(environment.node_by_name(node_name))
for node_name in node_roles.cobbler_names:
self.cobblers.append(devops_environment.node[node_name])
for node_name in node_roles.keystone_names:
self.keystones.append(devops_environment.node[node_name])
self.cobblers.append(environment.node_by_name(node_name))
for node_name in node_roles.stomp_names:
self.stomps.append(devops_environment.node[node_name])
self.stomps.append(environment.node_by_name(node_name))
for node_name in node_roles.quantum_names:
self.quantums.append(devops_environment.node[node_name])
self.quantums.append(environment.node_by_name(node_name))
self.all = self.controllers + self.computes + self.storages +\
self.proxies + self.cobblers + self.stomps +\
self.quantums + self.masters
def __iter__(self):
return self.all.__iter__()

View File

@ -1 +0,0 @@
__author__ = 'vic'

View File

@ -1,57 +0,0 @@
import unittest
from fuel_test.base_test_case import BaseTestCase
from fuel_test.ci.ci_openstack import CiOpenStack
from fuel_test.root import root
from fuel_test.settings import PUBLIC_INTERFACE, INTERNAL_INTERFACE, PRIVATE_INTERFACE, OS_FAMILY, USE_SYSLOG
class OpenStackTestCase(BaseTestCase):
def ci(self):
if not hasattr(self, '_ci'):
self._ci = CiOpenStack()
return self._ci
def setUp(self):
super(OpenStackTestCase, self).setUp()
self.write_openstack_sitepp(self.nodes.controllers[0],
self.nodes.controllers[1])
def write_openstack_sitepp(self, controller1, controller2):
if OS_FAMILY == 'centos':
mirror_type = "'internal-stage'"
else:
mirror_type = "'internal'"
self.write_site_pp_manifest(
root('deployment', 'puppet', 'openstack', 'examples',
'site.pp'),
internal_virtual_ip="'%s'" % self.ci().get_internal_virtual_ip(),
public_virtual_ip="'%s'" % self.ci().get_public_virtual_ip(),
floating_range="'%s'" % self.ci().get_floating_network(),
fixed_range="'%s'" % self.ci().get_fixed_network(),
master_hostname="'%s'" % controller1.name,
mirror_type=mirror_type,
controller_public_addresses="{ '%s' => '%s', '%s' => '%s' }"
% (
controller1.name, controller1.ip_address_by_network['public'],
controller2.name, controller2.ip_address_by_network['public']),
controller_internal_addresses="{ '%s' => '%s', '%s' => '%s' }"
% (
controller1.name, controller1.ip_address_by_network['internal'],
controller2.name,
controller2.ip_address_by_network['internal']),
controller_hostnames=[
"%s" % controller1.name,
"%s" % controller2.name],
public_interface="'%s'" % PUBLIC_INTERFACE,
internal_interface="'%s'" % INTERNAL_INTERFACE,
private_interface="'%s'" % PRIVATE_INTERFACE,
nv_physical_volume= ["/dev/vdb"],
use_syslog = "%s" % USE_SYSLOG
)
if __name__ == '__main__':
unittest.main()

View File

@ -1,65 +0,0 @@
from devops.helpers import ssh
import unittest
from fuel_test.helpers import safety_revert_nodes, make_shared_storage, make_tempest_objects, tempest_write_config, tempest_build_config_essex, tempest_build_config_folsom
from fuel_test.openstack.openstack_test_case import OpenStackTestCase
from fuel_test.root import root
from fuel_test.settings import ADMIN_USERNAME, ADMIN_PASSWORD, ADMIN_TENANT_ESSEX, ADMIN_TENANT_FOLSOM
class PrepareOpenStackForTempest(OpenStackTestCase):
def setUp(self):
self.environment = self.ci().get_environment()
def revert(self):
safety_revert_nodes(self.environment.nodes, 'openstack')
def prepare_for_tempest(self):
auth_host = self.ci().get_public_virtual_ip()
remote = ssh(
self.ci().nodes().controllers[0].ip_address_by_network['internal'], username='root',
password='r00tme').sudo.ssh
make_shared_storage(
remote,
self.ci().nodes().controllers[0].name,
self.ci().nodes().controllers[1:],
self.ci().get_internal_network()
)
image_ref, image_ref_alt = make_tempest_objects(
auth_host,
username=ADMIN_USERNAME,
password=ADMIN_PASSWORD,
tenant_name=ADMIN_TENANT_ESSEX,
)
tempest_write_config(tempest_build_config_essex(auth_host, image_ref, image_ref_alt))
def prepare_for_tempest_folsom(self):
auth_host = self.ci().get_public_virtual_ip()
remote = ssh(
self.ci().nodes().controllers[0].ip_address_by_network['internal'], username='root',
password='r00tme').sudo.ssh
make_shared_storage(
remote,
self.ci().nodes().controllers[0].name,
self.ci().nodes().controllers[1:],
self.ci().get_internal_network()
)
compute_db_uri = 'mysql://nova:nova@%s/nova' % self.ci().get_internal_virtual_ip()
image_ref, image_ref_alt = make_tempest_objects(
auth_host,
username=ADMIN_USERNAME,
password=ADMIN_PASSWORD,
tenant_name=ADMIN_TENANT_FOLSOM,
)
tempest_write_config(
tempest_build_config_folsom(
host=auth_host,
image_ref=image_ref,
image_ref_alt=image_ref_alt,
path_to_private_key=root('fuel_test', 'config', 'ssh_keys', 'openstack'),
compute_db_uri=compute_db_uri
))
if __name__ == '__main__':
unittest.main()

View File

@ -1,101 +0,0 @@
from devops.helpers import ssh
from fuel_test.helpers import execute
from fuel_test.openstack.openstack_test_case import OpenStackTestCase
from fuel_test.root import root
import unittest
#todo raise exception if remote command writes to stderr or returns non-zero exit code
#todo pretty output
#todo async command execution
from fuel_test.settings import PUBLIC_INTERFACE, INTERNAL_INTERFACE, PRIVATE_INTERFACE
class MyTestCase(OpenStackTestCase):
def test_apply_all_modules_with_noop(self):
result = self.master_remote.execute(
"for i in `find /etc/puppet/modules/ | grep tests/.*pp`; do puppet apply --modulepath=/etc/puppet/modules/ --noop $i ; done")
self.assertResult(result)
def test_deploy_controller_nodes(self):
internal_virtual_ip = self.environment.network['internal'].ip_addresses[
-3]
public_virtual_ip = self.environment.network['public'].ip_addresses[-3]
self.write_site_pp_manifest(
root('deployment', 'puppet', 'openstack', 'examples',
'site.pp'),
internal_virtual_ip="'%s'" % internal_virtual_ip,
public_virtual_ip="'%s'" % public_virtual_ip,
master_hostname="'%s'" % self.nodes.controllers[0].name,
controller_public_addresses=[
"%s" % self.nodes.controllers[0].ip_address_by_network[
'public'],
"%s" % self.nodes.controllers[1].ip_address_by_network['public']
],
controller_internal_addresses=[
"%s" % self.nodes.controllers[0].ip_address_by_network[
'internal'],
"%s" % self.nodes.controllers[1].ip_address_by_network[
'internal']
],
controller_hostnames=[
"%s" % self.nodes.controllers[0].name,
"%s" % self.nodes.controllers[1].name],
public_interface="'%s'" % PUBLIC_INTERFACE,
internal_interface="'%s'" % INTERNAL_INTERFACE,
private_interface="'%s'" % PRIVATE_INTERFACE
)
remote = ssh(self.nodes.controllers[0].ip_address_by_network['internal'], username='root',
password='r00tme')
result = execute(remote.sudo.ssh, 'puppet agent --test')
self.assertResult(result)
def test_deploy_mysql_with_galera(self):
self.write_site_pp_manifest(
root('deployment', 'puppet', 'mysql', 'examples',
'site.pp'),
master_hostname="'%s'" % self.nodes.controllers[0].name,
galera_master_ip="'%s'" %
self.nodes.controllers[0].ip_address_by_network[
'internal'],
galera_node_addresses=[
"%s" % self.nodes.controllers[0].ip_address_by_network[
'internal'],
"%s" % self.nodes.controllers[1].ip_address_by_network[
'internal']
],
)
remote = ssh(self.nodes.controllers[0].ip_address_by_network['internal'], username='root',
password='r00tme')
result = remote.sudo.ssh.execute('puppet agent --test')
self.assertResult(result)
remote = ssh(self.nodes.controllers[1].ip_address_by_network['internal'], username='root',
password='r00tme')
result = execute(remote.sudo.ssh, 'puppet agent --test')
self.assertResult(result)
# self.assertTrue(tcp_ping(node01.ip_address_by_network['internal'], 3306))
def test_deploy_nova_rabbitmq(self):
self.write_site_pp_manifest(
root('deployment', 'puppet', 'nova', 'examples',
'nova_rabbitmq_site.pp'),
cluster='true',
cluster_nodes=[
"%s" % self.nodes.controllers[0].ip_address_by_network[
'internal'],
"%s" % self.nodes.controllers[1].ip_address_by_network[
'internal']
],
)
remote = ssh(self.nodes.controllers[0].ip_address_by_network['internal'], username='root',
password='r00tme')
result1 = execute(remote.sudo.ssh, 'puppet agent --test')
remote2 = ssh(self.nodes.controllers[1].ip_address_by_network['internal'], username='root',
password='r00tme')
result2 = execute(remote2.sudo.ssh, 'puppet agent --test')
self.assertResult(result1)
self.assertResult(result2)
if __name__ == '__main__':
unittest.main()

View File

@ -1,18 +0,0 @@
import unittest
from fuel_test.helpers import is_not_essex
from fuel_test.openstack.openstack_test_case import OpenStackTestCase
from fuel_test.settings import OPENSTACK_SNAPSHOT
class OpenStackCase(OpenStackTestCase):
def test_deploy_open_stack(self):
self.validate(self.nodes.controllers[:1], 'puppet agent --test')
self.validate(self.nodes.controllers[1:], 'puppet agent --test')
self.validate(self.nodes.controllers[:1], 'puppet agent --test')
if is_not_essex():
self.validate(self.nodes.quantums, 'puppet agent --test')
self.validate(self.nodes.computes, 'puppet agent --test')
for node in self.environment.nodes:
node.save_snapshot(OPENSTACK_SNAPSHOT, force=True)
if __name__ == '__main__':
unittest.main()

View File

@ -1 +0,0 @@
__author__ = 'vic'

View File

@ -1,45 +0,0 @@
import unittest
from fuel_test.base_test_case import BaseTestCase
from fuel_test.ci.ci_openstack_simple import CiOpenStackSimple
from fuel_test.root import root
from fuel_test.settings import PUBLIC_INTERFACE, INTERNAL_INTERFACE, PRIVATE_INTERFACE, OS_FAMILY, USE_SYSLOG
class OpenStackSimpleTestCase(BaseTestCase):
def ci(self):
if not hasattr(self, '_ci'):
self._ci = CiOpenStackSimple()
return self._ci
def setUp(self):
super(OpenStackSimpleTestCase, self).setUp()
self.write_openstack_sitepp(self.nodes.controllers[0])
def write_openstack_sitepp(self, controller):
if OS_FAMILY == 'centos':
mirror_type = "'internal-stage'"
else:
mirror_type = "'internal'"
self.write_site_pp_manifest(
root('deployment', 'puppet', 'openstack', 'examples',
'site_simple.pp'),
floating_range="'%s'" % self.ci().get_floating_network(),
fixed_range="'%s'" % self.ci().get_fixed_network(),
public_interface="'%s'" % PUBLIC_INTERFACE,
internal_interface="'%s'" % INTERNAL_INTERFACE,
private_interface="'%s'" % PRIVATE_INTERFACE,
mirror_type=mirror_type,
controller_node_address="'%s'" % controller.ip_address_by_network[
'internal'],
controller_node_public="'%s'" % controller.ip_address_by_network[
'public'],
nv_physical_volume=["/dev/vdb"],
use_syslog = "%s" % USE_SYSLOG
)
if __name__ == '__main__':
unittest.main()

View File

@ -1,14 +0,0 @@
import unittest
from fuel_test.openstack_simple.openstack_simple_test_case import OpenStackSimpleTestCase
from fuel_test.settings import OPENSTACK_SNAPSHOT
class OpenStackSimpleCase(OpenStackSimpleTestCase):
def test_deploy_open_stack_simple(self):
self.validate(
self.nodes.controllers + self.nodes.computes,
'puppet agent --test')
for node in self.environment.nodes:
node.save_snapshot(OPENSTACK_SNAPSHOT, force=True)
if __name__ == '__main__':
unittest.main()

View File

@ -1 +0,0 @@
__author__ = 'vic'

View File

@ -1,74 +0,0 @@
from fuel_test.base_test_case import BaseTestCase
from fuel_test.ci.ci_openstack_swift import CiOpenStackSwift
from fuel_test.root import root
from fuel_test.settings import PUBLIC_INTERFACE, INTERNAL_INTERFACE, PRIVATE_INTERFACE, OS_FAMILY, USE_SYSLOG
class OpenStackSwiftTestCase(BaseTestCase):
def ci(self):
if not hasattr(self, '_ci'):
self._ci = CiOpenStackSwift()
return self._ci
def setUp(self):
super(OpenStackSwiftTestCase, self).setUp()
self.write_openstack_sitepp(self.nodes.controllers, self.nodes.proxies)
def write_openstack_sitepp(self, controllers, proxies):
controller_public_addresses="{"
controller_internal_addresses="{"
swift_proxies="{"
for controller in controllers:
controller_public_addresses +="'%s' => '%s'" % (controller.name,controller.ip_address_by_network['public'])
if controller != controllers[-1]:
controller_public_addresses +=","
else:
controller_public_addresses +="}"
for controller in controllers:
controller_internal_addresses +="'%s' => '%s'" % (controller.name,controller.ip_address_by_network['internal'])
if controller != controllers[-1]:
controller_internal_addresses +=","
else:
controller_internal_addresses +="}"
for proxy in proxies:
swift_proxies +="'%s' => '%s'" % (proxy.name,proxy.ip_address_by_network['internal'])
if proxy != proxies[-1]:
swift_proxies +=","
else:
swift_proxies +="}"
if OS_FAMILY == 'centos':
mirror_type = "'internal-stage'"
else:
mirror_type = "'internal'"
self.write_site_pp_manifest(
root('deployment', 'puppet', 'openstack', 'examples',
'site_openstack_swift_standalone.pp'),
internal_virtual_ip="'%s'" % self.ci().get_internal_virtual_ip(),
public_virtual_ip="'%s'" % self.ci().get_public_virtual_ip(),
floating_range="'%s'" % self.ci().get_floating_network(),
fixed_range="'%s'" % self.ci().get_fixed_network(),
master_hostname="'%s'" % controllers[0].name,
swift_master="'%s'" % proxies[0].name,
controller_public_addresses = controller_public_addresses,
controller_internal_addresses = controller_internal_addresses,
swift_proxies = swift_proxies,
mirror_type = mirror_type,
# controller_public_addresses="{ '%s' => '%s', '%s' => '%s' }"
# % (
# node01.name, node01.ip_address_by_network['public'],
# node02.name,
# node02.ip_address_by_network['public']),
# controller_internal_addresses="{ '%s' => '%s', '%s' => '%s' }"
# % (
# node01.name, node01.ip_address_by_network['internal'],
# node02.name,
# node02.ip_address_by_network['internal']),
controller_hostnames=["%s" % controller.name for controller in controllers],
public_interface="'%s'" % PUBLIC_INTERFACE,
internal_interface="'%s'" % INTERNAL_INTERFACE,
private_interface="'%s'" % PRIVATE_INTERFACE,
nv_physical_volume= ["/dev/vdb"],
use_syslog = "%s" % USE_SYSLOG
)

View File

@ -1,45 +0,0 @@
from fuel_test.helpers import safety_revert_nodes, tempest_write_config, make_tempest_objects, tempest_build_config_essex, tempest_build_config_folsom
from fuel_test.openstack_swift.openstack_swift_test_case import OpenStackSwiftTestCase
import unittest
from fuel_test.root import root
from fuel_test.settings import ADMIN_USERNAME, ADMIN_PASSWORD, ADMIN_TENANT_ESSEX, ADMIN_TENANT_FOLSOM
class PrepareOpenStackSwiftForTempest(OpenStackSwiftTestCase):
def setUp(self):
self.environment = self.ci().get_environment()
def revert(self):
safety_revert_nodes(self.environment.nodes, 'openstack')
def prepare_for_tempest_if_swift(self):
auth_host = self.ci().get_public_virtual_ip()
image_ref, image_ref_alt = make_tempest_objects(
auth_host,
username=ADMIN_USERNAME,
password=ADMIN_PASSWORD,
tenant_name=ADMIN_TENANT_ESSEX,
)
tempest_write_config(tempest_build_config_essex(auth_host, image_ref, image_ref_alt))
def prepare_for_tempest_if_swift_folsom(self):
auth_host = self.ci().get_public_virtual_ip()
image_ref, image_ref_alt = make_tempest_objects(
auth_host,
username=ADMIN_USERNAME,
password=ADMIN_PASSWORD,
tenant_name=ADMIN_TENANT_FOLSOM,
)
compute_db_uri = 'mysql://nova:nova@%s/nova' % self.ci().get_internal_virtual_ip()
tempest_write_config(
tempest_build_config_folsom(
host=auth_host,
image_ref=image_ref,
image_ref_alt=image_ref_alt,
path_to_private_key=root('fuel_test', 'config', 'ssh_keys', 'openstack'),
compute_db_uri=compute_db_uri
))
if __name__ == '__main__':
unittest.main()

View File

@ -1,23 +0,0 @@
import unittest
from fuel_test.helpers import is_not_essex
from fuel_test.openstack_swift.openstack_swift_test_case import OpenStackSwiftTestCase
from fuel_test.settings import OPENSTACK_SNAPSHOT
class OpenStackSwiftCase(OpenStackSwiftTestCase):
def test_deploy_open_stack_swift(self):
self.validate(self.nodes.controllers[:1], 'puppet agent --test')
self.validate(self.nodes.controllers[1:], 'puppet agent --test')
self.validate(self.nodes.controllers[:1], 'puppet agent --test')
if is_not_essex():
self.validate(self.nodes.quantums, 'puppet agent --test')
self.validate(self.nodes.computes, 'puppet agent --test')
self.do(self.nodes.storages, 'puppet agent --test')
self.do(self.nodes.storages, 'puppet agent --test')
self.do(self.nodes.proxies, 'puppet agent --test')
self.validate(self.nodes.storages, 'puppet agent --test')
self.validate(self.nodes.proxies, 'puppet agent --test')
for node in self.environment.nodes:
node.save_snapshot(OPENSTACK_SNAPSHOT, force=True)
if __name__ == '__main__':
unittest.main()

View File

@ -1 +0,0 @@
__author__ = 'vic'

View File

@ -1,82 +0,0 @@
from fuel_test.base_test_case import BaseTestCase
from fuel_test.ci.ci_openstack_swift_compact import CiOpenStackSwiftCompact
from fuel_test.helpers import is_not_essex
from fuel_test.root import root
from fuel_test.settings import PUBLIC_INTERFACE, INTERNAL_INTERFACE, PRIVATE_INTERFACE, OS_FAMILY, USE_SYSLOG
class OpenStackSwiftCompactTestCase(BaseTestCase):
def ci(self):
if not hasattr(self, '_ci'):
self._ci = CiOpenStackSwiftCompact()
return self._ci
def setUp(self):
super(OpenStackSwiftCompactTestCase, self).setUp()
def write_openstack_sitepp(self, controllers, quantum=False, loopback=True):
controller_public_addresses="{"
controller_internal_addresses="{"
for controller in controllers:
controller_public_addresses +="'%s' => '%s'" % (controller.name,controller.ip_address_by_network['public'])
if controller != controllers[-1]:
controller_public_addresses +=","
else:
controller_public_addresses +="}"
for controller in controllers:
controller_internal_addresses +="'%s' => '%s'" % (controller.name,controller.ip_address_by_network['internal'])
if controller != controllers[-1]:
controller_internal_addresses +=","
else:
controller_internal_addresses +="}"
if OS_FAMILY == 'centos':
mirror_type = "'internal-stage'"
else:
mirror_type = "'internal'"
if is_not_essex():
self.write_site_pp_manifest(
root('deployment', 'puppet', 'openstack', 'examples',
'site_openstack_swift_compact.pp'),
internal_virtual_ip="'%s'" % self.ci().get_internal_virtual_ip(),
public_virtual_ip="'%s'" % self.ci().get_public_virtual_ip(),
floating_range="'%s'" % self.ci().get_floating_network(),
fixed_range="'%s'" % self.ci().get_fixed_network(),
master_hostname = "'%s'" % controllers[0].name,
swift_master = "%s" % controllers[0].name,
controller_public_addresses = controller_public_addresses,
controller_internal_addresses = controller_internal_addresses,
controller_hostnames=["%s" % controller.name for controller in controllers],
public_interface="'%s'" % PUBLIC_INTERFACE,
internal_interface="'%s'" % INTERNAL_INTERFACE,
private_interface="'%s'" % PRIVATE_INTERFACE,
mirror_type = mirror_type,
nv_physical_volume= ["/dev/vdb"],
quantum = "true" if quantum else "false",
swift_loopback = "'loopback'" if loopback else "false",
use_syslog = "%s" % USE_SYSLOG
)
else:
self.write_site_pp_manifest(
root('deployment', 'puppet', 'openstack', 'examples',
'site_openstack_swift_compact.pp'),
internal_virtual_ip="'%s'" % self.ci().get_internal_virtual_ip(),
public_virtual_ip="'%s'" % self.ci().get_public_virtual_ip(),
floating_range="'%s'" % self.ci().get_floating_network(),
fixed_range="'%s'" % self.ci().get_fixed_network(),
master_hostname = "'%s'" % controllers[0].name,
swift_master = "%s" % controllers[0].name,
controller_public_addresses = controller_public_addresses,
controller_internal_addresses = controller_internal_addresses,
controller_hostnames=["%s" % controller.name for controller in controllers],
public_interface="'%s'" % PUBLIC_INTERFACE,
internal_interface="'%s'" % INTERNAL_INTERFACE,
private_interface="'%s'" % PRIVATE_INTERFACE,
mirror_type = mirror_type,
nv_physical_volume= ["/dev/vdb"],
use_syslog = "%s" % USE_SYSLOG
)

View File

@ -1,48 +0,0 @@
import unittest
from devops.helpers import ssh
from fuel_test.helpers import safety_revert_nodes, tempest_write_config, make_tempest_objects, tempest_build_config_essex, tempest_build_config_folsom
from fuel_test.openstack_swift_compact.openstack_swift_compact_test_case import OpenStackSwiftCompactTestCase
from fuel_test.root import root
from fuel_test.settings import ADMIN_USERNAME, ADMIN_PASSWORD, ADMIN_TENANT_ESSEX, ADMIN_TENANT_FOLSOM
class PrepareOpenStackSwiftCompactForTempest(OpenStackSwiftCompactTestCase):
def setUp(self):
self.environment = self.ci().get_environment()
def revert(self):
safety_revert_nodes(self.environment.nodes, 'openstack')
def prepare_for_tempest_if_swift(self):
auth_host = self.ci().get_public_virtual_ip()
remote = ssh(
self.ci().nodes().controllers[0].ip_address_by_network['internal'], username='root',
password='r00tme').sudo.ssh
image_ref, image_ref_alt = make_tempest_objects(
auth_host,
username=ADMIN_USERNAME,
password=ADMIN_PASSWORD,
tenant_name=ADMIN_TENANT_ESSEX,
)
tempest_write_config(tempest_build_config_essex(auth_host, image_ref, image_ref_alt))
def prepare_for_tempest_if_swift_folsom(self):
auth_host = self.ci().get_public_virtual_ip()
image_ref, image_ref_alt = make_tempest_objects(
auth_host,
username=ADMIN_USERNAME,
password=ADMIN_PASSWORD,
tenant_name=ADMIN_TENANT_FOLSOM,
)
compute_db_uri = 'mysql://nova:nova@%s/nova' % self.ci().get_internal_virtual_ip()
tempest_write_config(
tempest_build_config_folsom(
host=auth_host,
image_ref=image_ref,
image_ref_alt=image_ref_alt,
path_to_private_key=root('fuel_test', 'config', 'ssh_keys', 'openstack'),
compute_db_uri=compute_db_uri
))
if __name__ == '__main__':
unittest.main()

View File

@ -1,33 +0,0 @@
from fuel_test.helpers import is_not_essex
import unittest
from fuel_test.openstack_swift_compact.openstack_swift_compact_test_case import OpenStackSwiftCompactTestCase
from fuel_test.settings import OPENSTACK_SNAPSHOT
class OpenStackSwiftCompactCase(OpenStackSwiftCompactTestCase):
def deploy_compact(self, quantum=True):
self.do(self.nodes.controllers[:1], 'puppet agent --test')
self.do(self.nodes.controllers[1:], 'puppet agent --test')
self.do(self.nodes.controllers, 'puppet agent --test')
self.do(self.nodes.controllers[:1], 'puppet agent --test')
self.validate(self.nodes.controllers, 'puppet agent --test')
if quantum:
if is_not_essex():
self.validate(self.nodes.quantums, 'puppet agent --test')
self.validate(self.nodes.computes, 'puppet agent --test')
for node in self.environment.nodes:
node.save_snapshot(OPENSTACK_SNAPSHOT, force=True)
def test_deploy_compact(self):
self.write_openstack_sitepp(self.nodes.controllers, quantum=True)
self.deploy_compact()
def test_deploy_compact_wo_quantum(self):
self.write_openstack_sitepp(self.nodes.controllers, quantum=False)
self.deploy_compact(quantum=False)
def test_deploy_compact_wo_loopback(self):
self.write_openstack_sitepp(self.nodes.controllers, quantum=False, loopback=False)
self.deploy_compact(quantum=False)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
nose
python-glanceclient
python-keystoneclient
devops
git+ssh://git@gitlab.vm.mirantis.net/devops.git

239
fuel_test/prepare.py Normal file
View File

@ -0,0 +1,239 @@
import subprocess
from time import sleep
import unittest
from devops.helpers.helpers import ssh
import glanceclient
import keystoneclient.v2_0
import os
from fuel_test.ci.ci_cobbler import CiCobbler
from fuel_test.helpers import load, retry, install_packages, switch_off_ip_tables, is_not_essex
from fuel_test.root import root
from fuel_test.settings import ADMIN_USERNAME, ADMIN_PASSWORD, ADMIN_TENANT_ESSEX, ADMIN_TENANT_FOLSOM, OS_FAMILY, CIRROS_IMAGE
class Prepare():
def __init__(self):
self.public_ip = self.ci().public_virtual_ip()
self.internal_ip = self.ci().public_virtual_ip()
self.controllers = self.ci().nodes().controllers()
def remote(self):
return ssh(self.public_ip,
login='root',
password='r00tme').sudo.ssh
def ci(self):
if not hasattr(self, '_ci'):
self._ci = CiCobbler()
return self._ci
def username(self):
return ADMIN_USERNAME
def password(self):
return ADMIN_PASSWORD
def tenant(self):
if is_not_essex():
return ADMIN_TENANT_FOLSOM
return ADMIN_TENANT_ESSEX
def get_auth_url(self):
return 'http://%s:5000/v2.0/' % self.public_ip
def make_shared_storage(self):
self._make_shared_storage(
self.ci().nodes().controllers[0].name,
self.ci().nodes().controllers[1:],
self.ci().internal_network()
)
def prepare_tempest_essex_minimal(self):
self.make_shared_storage()
self.prepare_tempest_essex()
def prepare_tempest_folsom_minimal(self):
self.make_shared_storage()
self.prepare_tempest_folsom()
def prepare_tempest_essex(self):
image_ref, image_ref_alt = self.make_tempest_objects()
self.tempest_write_config(
self.tempest_config_essex(image_ref, image_ref_alt))
def prepare_tempest_folsom(self):
image_ref, image_ref_alt = self.make_tempest_objects()
self.tempest_write_config(
self.tempest_config_folsom(
image_ref=image_ref,
image_ref_alt=image_ref_alt,
path_to_private_key=root('fuel_test', 'config', 'ssh_keys',
'openstack'),
compute_db_uri='mysql://nova:nova@%s/nova' % self.ci().internal_virtual_ip()
))
def tempest_config_folsom(self, image_ref, image_ref_alt,
path_to_private_key,
compute_db_uri='mysql://user:pass@localhost/nova'):
sample = load(
root('fuel_test', 'config', 'tempest.conf.folsom.sample'))
config = sample % {
'IDENTITY_USE_SSL': 'false',
'IDENTITY_HOST': self.public_ip,
'IDENTITY_PORT': '5000',
'IDENTITY_API_VERSION': 'v2.0',
'IDENTITY_PATH': 'tokens',
'IDENTITY_STRATEGY': 'keystone',
'COMPUTE_ALLOW_TENANT_ISOLATION': 'true',
'COMPUTE_ALLOW_TENANT_REUSE': 'true',
'USERNAME': 'tempest1',
'PASSWORD': 'secret',
'TENANT_NAME': 'tenant1',
'ALT_USERNAME': 'tempest2',
'ALT_PASSWORD': 'secret',
'ALT_TENANT_NAME': 'tenant2',
'IMAGE_ID': image_ref,
'IMAGE_ID_ALT': image_ref_alt,
'FLAVOR_REF': '1',
'FLAVOR_REF_ALT': '2',
'COMPUTE_BUILD_INTERVAL': '10',
'COMPUTE_BUILD_TIMEOUT': '600',
'RUN_SSH': 'false',
'NETWORK_FOR_SSH': 'novanetwork',
'COMPUTE_CATALOG_TYPE': 'compute',
'COMPUTE_CREATE_IMAGE_ENABLED': 'true',
'COMPUTE_RESIZE_AVAILABLE': 'true',
'COMPUTE_CHANGE_PASSWORD_AVAILABLE': 'true',
'COMPUTE_LOG_LEVEL': 'DEBUG',
'COMPUTE_WHITEBOX_ENABLED': 'true',
'COMPUTE_SOURCE_DIR': '/opt/stack/nova',
'COMPUTE_CONFIG_PATH': '/etc/nova/nova.conf',
'COMPUTE_BIN_DIR': '/usr/local/bin',
'COMPUTE_PATH_TO_PRIVATE_KEY': path_to_private_key,
'COMPUTE_DB_URI': compute_db_uri,
'IMAGE_CATALOG_TYPE': 'image',
'IMAGE_API_VERSION': '1',
'IMAGE_HOST': self.public_ip,
'IMAGE_PORT': '9292',
'IMAGE_USERNAME': 'tempest1',
'IMAGE_PASSWORD': 'secret',
'IMAGE_TENANT_NAME': 'tenant1',
'COMPUTE_ADMIN_USERNAME': ADMIN_USERNAME,
'COMPUTE_ADMIN_PASSWORD': ADMIN_PASSWORD,
'COMPUTE_ADMIN_TENANT_NAME': ADMIN_TENANT_FOLSOM,
'IDENTITY_ADMIN_USERNAME': ADMIN_USERNAME,
'IDENTITY_ADMIN_PASSWORD': ADMIN_PASSWORD,
'IDENTITY_ADMIN_TENANT_NAME': ADMIN_TENANT_FOLSOM,
'VOLUME_CATALOG_TYPE': 'volume',
'VOLUME_BUILD_INTERVAL': '10',
'VOLUME_BUILD_TIMEOUT': '300',
'NETWORK_CATALOG_TYPE': 'network',
'NETWORK_API_VERSION': 'v2.0',
}
return config
def tempest_config_essex(self, image_ref, image_ref_alt):
sample = load(
root('fuel_test', 'config', 'tempest.conf.essex.sample'))
config = sample % {
'HOST': self.public_ip,
'USERNAME': 'tempest1',
'PASSWORD': 'secret',
'TENANT_NAME': 'tenant1',
'ALT_USERNAME': 'tempest2',
'ALT_PASSWORD': 'secret',
'ALT_TENANT_NAME': 'tenant2',
'IMAGE_ID': image_ref,
'IMAGE_ID_ALT': image_ref_alt,
'ADMIN_USERNAME': ADMIN_USERNAME,
'ADMIN_PASSWORD': ADMIN_PASSWORD,
'ADMIN_TENANT_NAME': ADMIN_TENANT_ESSEX,
}
return config
def tempest_write_config(self, config):
with open(root('..', 'tempest.conf'), 'w') as f:
f.write(config)
def make_tempest_objects(self, ):
keystone = self._get_identity_client()
tenant1 = retry(10, keystone.tenants.create, tenant_name='tenant1')
tenant2 = retry(10, keystone.tenants.create, tenant_name='tenant2')
retry(10, keystone.users.create, name='tempest1', password='secret',
email='tempest1@example.com', tenant_id=tenant1.id)
retry(10, keystone.users.create, name='tempest2', password='secret',
email='tempest2@example.com', tenant_id=tenant2.id)
image_ref, image_ref_alt = self.tempest_add_images()
return image_ref, image_ref_alt
def _get_identity_client(self):
keystone = retry(10, keystoneclient.v2_0.client.Client,
username=self.username(), password=self.password(),
tenant_name=self.tenant(),
auth_url=self.get_auth_url())
return keystone
def _get_image_client(self):
keystone = self._get_identity_client()
endpoint = keystone.service_catalog.url_for(service_type='image',
endpoint_type='publicURL')
return glanceclient.Client('1', endpoint=endpoint,
token=keystone.auth_token)
def upload(self, glance, name, path):
image = glance.images.create(
name=name,
is_public=True,
container_format='bare',
disk_format='qcow2')
image.update(data=open(path, 'rb'))
return image.id
def tempest_add_images(self):
if not os.path.isfile('cirros-0.3.0-x86_64-disk.img'):
subprocess.check_call(['wget', CIRROS_IMAGE])
glance = self._get_image_client()
return self.upload(glance, 'cirros_0.3.0',
'cirros-0.3.0-x86_64-disk.img'),\
self.upload(glance, 'cirros_0.3.0',
'cirros-0.3.0-x86_64-disk.img')
def tempest_share_glance_images(self, network):
if OS_FAMILY == "centos":
self.remote().check_stderr('chkconfig rpcbind on')
self.remote().check_stderr('/etc/init.d/rpcbind restart')
self.remote().check_stderr(
'echo "/var/lib/glance/images %s(rw,no_root_squash)" >> /etc/exports' % network)
self.remote().check_stderr('/etc/init.d/nfs restart')
else:
install_packages(self.remote(),
'nfs-kernel-server nfs-common portmap')
self.remote().check_stderr(
'echo "/var/lib/glance/images %s(rw,no_root_squash)" >> /etc/exports' % network)
self.remote().check_stderr('/etc/init.d/nfs-kernel-server restart')
def tempest_mount_glance_images(self, remote, host):
if OS_FAMILY == "centos":
remote.check_stderr('chkconfig rpcbind on')
remote.check_stderr('/etc/init.d/rpcbind restart')
remote.check_stderr(
'mount %s:/var/lib/glance/images /var/lib/glance/images' % host)
else:
install_packages(remote, 'nfs-common portmap')
remote.check_stderr(
'mount %s:/var/lib/glance/images /var/lib/glance/images' % host)
def _make_shared_storage(self, nfs_server, nfs_clients, access_network):
self.tempest_share_glance_images(access_network)
switch_off_ip_tables(self.remote())
self.remote().check_stderr('/etc/init.d/iptables stop')
sleep(15)
for client in nfs_clients:
remote = client.remote(
'internal', login='root',
password='r00tme').sudo.ssh
self.tempest_mount_glance_images(remote, nfs_server)
sleep(60)
if __name__ == '__main__':
unittest.main()

View File

@ -1,6 +1,7 @@
import os
here = lambda * x: os.path.join(os.path.abspath(os.path.dirname(__file__)), *x)
here = lambda *x: os.path.join(os.path.abspath(os.path.dirname(__file__)), *x)
REPOSITORY_ROOT = here('..')
root = lambda * x: os.path.join(os.path.abspath(REPOSITORY_ROOT), *x)
root = lambda *x: os.path.join(os.path.abspath(REPOSITORY_ROOT), *x)

View File

@ -1,7 +1,7 @@
import os
OS_FAMILY = os.environ.get('OS_FAMILY', "centos")
PUPPET_GEN = os.environ.get('PUPPET_GEN', "2")
PUPPET_GEN = os.environ.get('PUPPET_GEN', "3")
DEFAULT_IMAGES = {
'centos': '/var/lib/libvirt/images/centos63-cobbler-base.qcow2',
@ -57,43 +57,41 @@ ADMIN_PASSWORD = 'nova'
ADMIN_TENANT_ESSEX = 'openstack'
ADMIN_TENANT_FOLSOM = 'admin'
CIRROS_IMAGE ='http://srv08-srt.srt.mirantis.net/cirros-0.3.0-x86_64-disk.img'
COBBLER_CONTROLLERS = int(os.environ.get('COBBLER_CONTROLLERS', 3))
COBBLER_COMPUTES = int(os.environ.get('COBBLER_COMPUTES', 3))
COBBLER_SWIFTS = int(os.environ.get('COBBLER_SWIFTS', 0))
COBBLER_PROXIES = int(os.environ.get('COBBLER_PROXIES', 0))
COBBLER_QUANTUM = int(os.environ.get('COBBLER_QUANTUM', 0))
COBBLER_KEYSTONE = int(os.environ.get('COBBLER_KEYSTONE', 0))
COBBLER_USECASE = str(os.environ.get('COBBLER_USECASE', ""))
if COBBLER_USECASE == "simple":
COBBLER_CONTROLLERS = 1
COBBLER_COMPUTES = 3
COBBLER_SWIFTS = 0
COBBLER_PROXIES = 0
COBBLER_QUANTUM = 0
elif COBBLER_USECASE == "minimal":
COBBLER_CONTROLLERS = 2
COBBLER_COMPUTES = 2
COBBLER_SWIFTS = 0
COBBLER_PROXIES = 0
COBBLER_QUANTUM = 0
elif COBBLER_USECASE == "compact":
COBBLER_CONTROLLERS = 3
COBBLER_COMPUTES = 2
COBBLER_SWIFTS = 0
COBBLER_PROXIES = 0
COBBLER_QUANTUM = 0
elif COBBLER_USECASE == "full":
COBBLER_CONTROLLERS = 2
COBBLER_COMPUTES = 2
COBBLER_SWIFTS = 3
COBBLER_PROXIES = 2
COBBLER_QUANTUM = 1
CIRROS_IMAGE = 'http://srv08-srt.srt.mirantis.net/cirros-0.3.0-x86_64-disk.img'
CONTROLLERS = int(os.environ.get('CONTROLLERS', 3))
COMPUTES = int(os.environ.get('COMPUTES', 3))
STORAGES = int(os.environ.get('STORAGES', 3))
PROXIES = int(os.environ.get('PROXIES', 2))
EMPTY_SNAPSHOT = os.environ.get('EMPTY_SNAPSHOT', 'empty')
OPENSTACK_SNAPSHOT = os.environ.get('OPENSTACK_SNAPSHOT', 'openstack')
PUBLIC_INTERFACE='eth0'
INTERNAL_INTERFACE = 'eth1'
PRIVATE_INTERFACE = 'eth2'
USE_SYSLOG = os.environ.get('USE_SYSLOG','false')
INTERFACE_ORDER = ('public', 'internal', 'private')
INTERFACES = {
'public': 'eth0',
'internal': 'eth1',
'private': 'eth2',
}
DEFAULT_POOLS = {
'centos': {
'public': '172.18.95.0/24:27',
'private': '10.108.0.0/16:24',
'internal': '10.108.0.0/16:24',
},
'ubuntu': {
'public': '172.18.94.0/24:27',
'private': '10.107.0.0/16:24',
'internal': '10.107.0.0/16:24',
},
}
POOLS = {
'public': os.environ.get('PUBLIC_POOL',
DEFAULT_POOLS.get(OS_FAMILY).get('public')).split(':'),
'private': os.environ.get('PRIVATE_POOL',
DEFAULT_POOLS.get(OS_FAMILY).get('private')).split(':'),
'internal': os.environ.get('INTERNAL_POOL',
DEFAULT_POOLS.get(OS_FAMILY).get('internal')).split(':')
}

View File

@ -1 +0,0 @@
__author__ = 'vic'

View File

@ -1,45 +0,0 @@
from devops.helpers import ssh
from fuel_test.base_test_case import BaseTestCase
from fuel_test.ci.ci_swift import CiSwift
from fuel_test.helpers import execute
from fuel_test.root import root
import unittest
class SwiftCase(BaseTestCase):
def ci(self):
if not hasattr(self, '_ci'):
self._ci = CiSwift()
return self._ci
def test_deploy_swift(self):
self.write_site_pp_manifest(
root('deployment', 'puppet', 'swift', 'examples',
'site.pp'),
swift_proxy_address="'%s'" %
self.nodes.proxies[0].ip_address_by_network[
'public'],
controller_node_public="'%s'" % self.nodes.keystones[
0].ip_address_by_network['public'],
)
results = []
#install keystone
remote = ssh(self.nodes.keystones[0].ip_address_by_network['internal'], username='root',
password='r00tme')
results.append(execute(remote.sudo.ssh, 'puppet agent --test'))
for node in self.nodes.storages:
remote = ssh(node.ip_address_by_network['internal'], username='root', password='r00tme')
results.append(execute(remote.sudo.ssh, 'puppet agent --test'))
results.append(execute(remote.sudo.ssh, 'puppet agent --test'))
remote = ssh(self.nodes.proxies[0].ip_address_by_network['internal'], username='root',
password='r00tme')
results.append(execute(remote.sudo.ssh, 'puppet agent --test'))
for node in self.nodes.storages:
remote = ssh(node.ip_address_by_network['internal'], username='root', password='r00tme')
results.append(execute(remote.sudo.ssh, 'puppet agent --test'))
# for result in results:
# self.assertResult(result)
if __name__ == '__main__':
unittest.main()