Convert to UNIX line endings

Fixes bug #972660

Change-Id: Iffe099504ae847ab2435e867860ab6bac6ca8252
This commit is contained in:
Sean Dague 2012-04-03 13:48:49 -04:00
parent 4a76996578
commit 70112368eb
13 changed files with 672 additions and 672 deletions

View File

@ -1,17 +1,17 @@
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Basic framework for constructing various simulated workloads for a
nova cluster."""
__author__ = "David Kranz and Eugene Shih"
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Basic framework for constructing various simulated workloads for a
nova cluster."""
__author__ = "David Kranz and Eugene Shih"

View File

@ -1,41 +1,41 @@
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Class to describe actions to be included in a stress test."""
class BasherAction(object):
"""
Used to describe each action that you would like to include in a test run.
"""
def __init__(self, test_case, probability, pargs=[], kargs={}):
"""
`test_case` : the name of the class that implements the action
`pargs` : positional arguments to the constructor of `test_case`
`kargs` : keyword arguments to the constructor of `test_case`
`probability`: frequency that each action
"""
self.test_case = test_case
self.pargs = pargs
self.kargs = kargs
self.probability = probability
def invoke(self, manager, state):
"""
Calls the `run` method of the `test_case`.
"""
return self.test_case.run(manager, state, *self.pargs, **self.kargs)
def __str__(self):
return self.test_case.__class__.__name__
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Class to describe actions to be included in a stress test."""
class BasherAction(object):
"""
Used to describe each action that you would like to include in a test run.
"""
def __init__(self, test_case, probability, pargs=[], kargs={}):
"""
`test_case` : the name of the class that implements the action
`pargs` : positional arguments to the constructor of `test_case`
`kargs` : keyword arguments to the constructor of `test_case`
`probability`: frequency that each action
"""
self.test_case = test_case
self.pargs = pargs
self.kargs = kargs
self.probability = probability
def invoke(self, manager, state):
"""
Calls the `run` method of the `test_case`.
"""
return self.test_case.run(manager, state, *self.pargs, **self.kargs)
def __str__(self):
return self.test_case.__class__.__name__

View File

@ -1,53 +1,53 @@
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import ConfigParser
class StressConfig(object):
"""Provides configuration information for whitebox stress tests."""
def __init__(self, conf):
self.conf = conf
def get(self, item_name, default_value=None):
try:
return self.conf.get("stress", item_name)
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
return default_value
@property
def host_private_key_path(self):
"""Path to ssh key for logging into compute nodes."""
return self.get("host_private_key_path", None)
@property
def host_admin_user(self):
"""Username for logging into compute nodes."""
return self.get("host_admin_user", None)
@property
def nova_logdir(self):
"""Directory containing log files on the compute nodes"""
return self.get("nova_logdir", None)
@property
def controller(self):
"""Controller host"""
return self.get("controller", None)
@property
def max_instances(self):
"""Maximum number of instances to create during test"""
return self.get("max_instances", 16)
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import ConfigParser
class StressConfig(object):
"""Provides configuration information for whitebox stress tests."""
def __init__(self, conf):
self.conf = conf
def get(self, item_name, default_value=None):
try:
return self.conf.get("stress", item_name)
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
return default_value
@property
def host_private_key_path(self):
"""Path to ssh key for logging into compute nodes."""
return self.get("host_private_key_path", None)
@property
def host_admin_user(self):
"""Username for logging into compute nodes."""
return self.get("host_admin_user", None)
@property
def nova_logdir(self):
"""Directory containing log files on the compute nodes"""
return self.get("nova_logdir", None)
@property
def controller(self):
"""Controller host"""
return self.get("controller", None)
@property
def max_instances(self):
"""Maximum number of instances to create during test"""
return self.get("max_instances", 16)

View File

@ -1,207 +1,207 @@
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The entry point for the execution of a workloadTo execute a workload.
Users pass in a description of the workload and a nova manager object
to the bash_openstack function call"""
import random
import datetime
import time
# local imports
from test_case import *
from state import State
import utils.util
from config import StressConfig
# setup logging to file
logging.basicConfig(
format='%(asctime)s %(name)-20s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M:%S',
filename="stress.debug.log",
filemode="w",
level=logging.DEBUG,
)
# define a Handler which writes INFO messages or higher to the sys.stdout
_console = logging.StreamHandler()
_console.setLevel(logging.INFO)
# set a format which is simpler for console use
_formatter = logging.Formatter('%(name)-20s: %(levelname)-8s %(message)s')
# tell the handler to use this format
_console.setFormatter(_formatter)
# add the handler to the root logger
logging.getLogger('').addHandler(_console)
def _create_cases(choice_spec):
"""
Generate a workload of tests from workload description
"""
cases = []
count = 0
for choice in choice_spec:
p = choice.probability
for i in range(p):
cases.append(choice)
i = i + p
count = count + p
assert(count == 100)
return cases
def _get_compute_nodes(keypath, user, controller):
"""
Returns a list of active compute nodes. List is generated by running
nova-manage on the controller.
"""
nodes = []
if keypath == None or user == None:
return nodes
lines = utils.util.ssh(keypath, user, controller,
"nova-manage service list | grep ^nova-compute").\
split('\n')
# For example: nova-compute xg11eth0 nova enabled :-) 2011-10-31 18:57:46
# This is fragile but there is, at present, no other way to get this info.
for line in lines:
words = line.split()
if len(words) > 0 and words[4] == ":-)":
nodes.append(words[1])
return nodes
def _error_in_logs(keypath, logdir, user, nodes):
"""
Detect errors in the nova log files on the controller and compute nodes.
"""
grep = 'egrep "ERROR\|TRACE" %s/*.log' % logdir
for node in nodes:
errors = utils.util.ssh(keypath, user, node, grep, check=False)
if len(errors) > 0:
logging.error('%s: %s' % (node, errors))
return True
return False
def bash_openstack(manager,
choice_spec,
**kwargs):
"""
Workload driver. Executes a workload as specified by the `choice_spec`
parameter against a nova-cluster.
`manager` : Manager object
`choice_spec` : list of BasherChoice actions to run on the cluster
`kargs` : keyword arguments to the constructor of `test_case`
`duration` = how long this test should last (3 sec)
`sleep_time` = time to sleep between actions (in msec)
`test_name` = human readable workload description
(default: unnamed test)
`max_vms` = maximum number of instances to launch
(default: 32)
`seed` = random seed (default: None)
"""
stress_config = StressConfig(manager.config._conf)
# get keyword arguments
duration = kwargs.get('duration', datetime.timedelta(seconds=10))
seed = kwargs.get('seed', None)
sleep_time = float(kwargs.get('sleep_time', 3000)) / 1000
max_vms = int(kwargs.get('max_vms', stress_config.max_instances))
test_name = kwargs.get('test_name', 'unamed test')
keypath = stress_config.host_private_key_path
user = stress_config.host_admin_user
logdir = stress_config.nova_logdir
computes = _get_compute_nodes(keypath, user, manager.config.identity.host)
utils.util.execute_on_all(keypath, user, computes,
"rm -f %s/*.log" % logdir)
random.seed(seed)
cases = _create_cases(choice_spec)
test_end_time = time.time() + duration.seconds
state = State(max_vms=max_vms)
retry_list = []
last_retry = time.time()
cooldown = False
logcheck_count = 0
test_succeeded = True
logging.debug('=== Test \"%s\" on %s ===' %
(test_name, time.asctime(time.localtime())))
for kw in kwargs:
logging.debug('\t%s = %s', kw, kwargs[kw])
while True:
if not cooldown:
if time.time() < test_end_time:
case = random.choice(cases)
logging.debug('Chose %s' % case)
retry = case.invoke(manager, state)
if retry != None:
retry_list.append(retry)
else:
logging.info('Cooling down...')
cooldown = True
if cooldown and len(retry_list) == 0:
if _error_in_logs(keypath, logdir, user, computes):
test_succeeded = False
break
# Retry verifications every 5 seconds.
if time.time() - last_retry > 5:
logging.debug('retry verifications for %d tasks', len(retry_list))
new_retry_list = []
for v in retry_list:
if not v.retry():
new_retry_list.append(v)
retry_list = new_retry_list
last_retry = time.time()
time.sleep(sleep_time)
# Check error logs after 100 actions
if logcheck_count > 100:
if _error_in_logs(keypath, logdir, user, computes):
test_succeeded = False
break
else:
logcheck_count = 0
else:
logcheck_count = logcheck_count + 1
# Cleanup
logging.info('Cleaning up: terminating virtual machines...')
vms = state.get_instances()
active_vms = [v for _k, v in vms.iteritems() if v and v[1] == 'ACTIVE']
for target in active_vms:
manager.servers_client.delete_server(target[0]['id'])
# check to see that the server was actually killed
for target in active_vms:
kill_id = target[0]['id']
i = 0
while True:
try:
manager.servers_client.get_server(kill_id)
except Exception:
break
i += 1
if i > 60:
_error_in_logs(keypath, logdir, user, computes)
raise Exception("Cleanup timed out")
time.sleep(1)
logging.info('killed %s' % kill_id)
state.delete_instance_state(kill_id)
if test_succeeded:
logging.info('*** Test succeeded ***')
else:
logging.info('*** Test had errors ***')
return test_succeeded
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The entry point for the execution of a workloadTo execute a workload.
Users pass in a description of the workload and a nova manager object
to the bash_openstack function call"""
import random
import datetime
import time
# local imports
from test_case import *
from state import State
import utils.util
from config import StressConfig
# setup logging to file
logging.basicConfig(
format='%(asctime)s %(name)-20s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M:%S',
filename="stress.debug.log",
filemode="w",
level=logging.DEBUG,
)
# define a Handler which writes INFO messages or higher to the sys.stdout
_console = logging.StreamHandler()
_console.setLevel(logging.INFO)
# set a format which is simpler for console use
_formatter = logging.Formatter('%(name)-20s: %(levelname)-8s %(message)s')
# tell the handler to use this format
_console.setFormatter(_formatter)
# add the handler to the root logger
logging.getLogger('').addHandler(_console)
def _create_cases(choice_spec):
"""
Generate a workload of tests from workload description
"""
cases = []
count = 0
for choice in choice_spec:
p = choice.probability
for i in range(p):
cases.append(choice)
i = i + p
count = count + p
assert(count == 100)
return cases
def _get_compute_nodes(keypath, user, controller):
"""
Returns a list of active compute nodes. List is generated by running
nova-manage on the controller.
"""
nodes = []
if keypath == None or user == None:
return nodes
lines = utils.util.ssh(keypath, user, controller,
"nova-manage service list | grep ^nova-compute").\
split('\n')
# For example: nova-compute xg11eth0 nova enabled :-) 2011-10-31 18:57:46
# This is fragile but there is, at present, no other way to get this info.
for line in lines:
words = line.split()
if len(words) > 0 and words[4] == ":-)":
nodes.append(words[1])
return nodes
def _error_in_logs(keypath, logdir, user, nodes):
"""
Detect errors in the nova log files on the controller and compute nodes.
"""
grep = 'egrep "ERROR\|TRACE" %s/*.log' % logdir
for node in nodes:
errors = utils.util.ssh(keypath, user, node, grep, check=False)
if len(errors) > 0:
logging.error('%s: %s' % (node, errors))
return True
return False
def bash_openstack(manager,
choice_spec,
**kwargs):
"""
Workload driver. Executes a workload as specified by the `choice_spec`
parameter against a nova-cluster.
`manager` : Manager object
`choice_spec` : list of BasherChoice actions to run on the cluster
`kargs` : keyword arguments to the constructor of `test_case`
`duration` = how long this test should last (3 sec)
`sleep_time` = time to sleep between actions (in msec)
`test_name` = human readable workload description
(default: unnamed test)
`max_vms` = maximum number of instances to launch
(default: 32)
`seed` = random seed (default: None)
"""
stress_config = StressConfig(manager.config._conf)
# get keyword arguments
duration = kwargs.get('duration', datetime.timedelta(seconds=10))
seed = kwargs.get('seed', None)
sleep_time = float(kwargs.get('sleep_time', 3000)) / 1000
max_vms = int(kwargs.get('max_vms', stress_config.max_instances))
test_name = kwargs.get('test_name', 'unamed test')
keypath = stress_config.host_private_key_path
user = stress_config.host_admin_user
logdir = stress_config.nova_logdir
computes = _get_compute_nodes(keypath, user, manager.config.identity.host)
utils.util.execute_on_all(keypath, user, computes,
"rm -f %s/*.log" % logdir)
random.seed(seed)
cases = _create_cases(choice_spec)
test_end_time = time.time() + duration.seconds
state = State(max_vms=max_vms)
retry_list = []
last_retry = time.time()
cooldown = False
logcheck_count = 0
test_succeeded = True
logging.debug('=== Test \"%s\" on %s ===' %
(test_name, time.asctime(time.localtime())))
for kw in kwargs:
logging.debug('\t%s = %s', kw, kwargs[kw])
while True:
if not cooldown:
if time.time() < test_end_time:
case = random.choice(cases)
logging.debug('Chose %s' % case)
retry = case.invoke(manager, state)
if retry != None:
retry_list.append(retry)
else:
logging.info('Cooling down...')
cooldown = True
if cooldown and len(retry_list) == 0:
if _error_in_logs(keypath, logdir, user, computes):
test_succeeded = False
break
# Retry verifications every 5 seconds.
if time.time() - last_retry > 5:
logging.debug('retry verifications for %d tasks', len(retry_list))
new_retry_list = []
for v in retry_list:
if not v.retry():
new_retry_list.append(v)
retry_list = new_retry_list
last_retry = time.time()
time.sleep(sleep_time)
# Check error logs after 100 actions
if logcheck_count > 100:
if _error_in_logs(keypath, logdir, user, computes):
test_succeeded = False
break
else:
logcheck_count = 0
else:
logcheck_count = logcheck_count + 1
# Cleanup
logging.info('Cleaning up: terminating virtual machines...')
vms = state.get_instances()
active_vms = [v for _k, v in vms.iteritems() if v and v[1] == 'ACTIVE']
for target in active_vms:
manager.servers_client.delete_server(target[0]['id'])
# check to see that the server was actually killed
for target in active_vms:
kill_id = target[0]['id']
i = 0
while True:
try:
manager.servers_client.get_server(kill_id)
except Exception:
break
i += 1
if i > 60:
_error_in_logs(keypath, logdir, user, computes)
raise Exception("Cleanup timed out")
time.sleep(1)
logging.info('killed %s' % kill_id)
state.delete_instance_state(kill_id)
if test_succeeded:
logging.info('*** Test succeeded ***')
else:
logging.info('*** Test had errors ***')
return test_succeeded

View File

@ -1,41 +1,41 @@
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""A class to store the state of various persistent objects in the Nova
cluster, e.g. instances, volumes. Use methods to query to state which than
can be compared to the current state of the objects in Nova"""
class State(object):
def __init__(self, **kwargs):
self._max_vms = kwargs.get('max_vms', 32)
self._instances = {}
self._volumes = {}
# machine state methods
def get_instances(self):
"""return the instances dictionary that we believe are in cluster."""
return self._instances
def get_max_instances(self):
"""return the maximum number of instances we can create."""
return self._max_vms
def set_instance_state(self, key, val):
"""Store `val` in the dictionary indexed at `key`."""
self._instances[key] = val
def delete_instance_state(self, key):
"""Delete state indexed at `key`."""
del self._instances[key]
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""A class to store the state of various persistent objects in the Nova
cluster, e.g. instances, volumes. Use methods to query to state which than
can be compared to the current state of the objects in Nova"""
class State(object):
def __init__(self, **kwargs):
self._max_vms = kwargs.get('max_vms', 32)
self._instances = {}
self._volumes = {}
# machine state methods
def get_instances(self):
"""return the instances dictionary that we believe are in cluster."""
return self._instances
def get_max_instances(self):
"""return the maximum number of instances we can create."""
return self._max_vms
def set_instance_state(self, key, val):
"""Store `val` in the dictionary indexed at `key`."""
self._instances[key] = val
def delete_instance_state(self, key):
"""Delete state indexed at `key`."""
del self._instances[key]

View File

@ -1,29 +1,29 @@
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Abstract class for implementing an action. You only need to override
the `run` method which specifies all the actual nova API class you wish
to make."""
import logging
class StressTestCase(object):
def __init__(self):
self._logger = logging.getLogger(self.__class__.__name__)
def run(self, nova_manager, state_obj, *pargs, **kargs):
"""Nova API methods to call that would modify state of the cluster"""
return
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Abstract class for implementing an action. You only need to override
the `run` method which specifies all the actual nova API class you wish
to make."""
import logging
class StressTestCase(object):
def __init__(self):
self._logger = logging.getLogger(self.__class__.__name__)
def run(self, nova_manager, state_obj, *pargs, **kargs):
"""Nova API methods to call that would modify state of the cluster"""
return

View File

@ -1,35 +1,35 @@
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""More aggressive test that creates and destroys VMs with shorter
sleep times"""
from stress.test_servers import *
from stress.basher import BasherAction
from stress.driver import *
from tempest import openstack
choice_spec = [
BasherAction(TestCreateVM(), 50),
BasherAction(TestKillActiveVM(), 50)
]
nova = openstack.Manager()
bash_openstack(nova,
choice_spec,
duration=datetime.timedelta(seconds=180),
sleep_time=100, # in milliseconds
seed=int(time.time()),
test_name="create and delete",
)
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""More aggressive test that creates and destroys VMs with shorter
sleep times"""
from stress.test_servers import *
from stress.basher import BasherAction
from stress.driver import *
from tempest import openstack
choice_spec = [
BasherAction(TestCreateVM(), 50),
BasherAction(TestKillActiveVM(), 50)
]
nova = openstack.Manager()
bash_openstack(nova,
choice_spec,
duration=datetime.timedelta(seconds=180),
sleep_time=100, # in milliseconds
seed=int(time.time()),
test_name="create and delete",
)

View File

@ -1,37 +1,37 @@
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Test that reboots random instances in a Nova cluster"""
from stress.test_servers import *
from stress.test_server_actions import *
from stress.basher import BasherAction
from stress.driver import *
from tempest import openstack
choice_spec = [
BasherAction(TestCreateVM(), 50),
BasherAction(TestRebootVM(), 50,
kargs={'type': 'HARD'})
]
nova = openstack.Manager()
bash_openstack(nova,
choice_spec,
duration=datetime.timedelta(seconds=180),
sleep_time=500, # in milliseconds
seed=int(time.time()),
test_name="hard reboots",
)
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Test that reboots random instances in a Nova cluster"""
from stress.test_servers import *
from stress.test_server_actions import *
from stress.basher import BasherAction
from stress.driver import *
from tempest import openstack
choice_spec = [
BasherAction(TestCreateVM(), 50),
BasherAction(TestRebootVM(), 50,
kargs={'type': 'HARD'})
]
nova = openstack.Manager()
bash_openstack(nova,
choice_spec,
duration=datetime.timedelta(seconds=180),
sleep_time=500, # in milliseconds
seed=int(time.time()),
test_name="hard reboots",
)

View File

@ -1,38 +1,38 @@
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Sample stress test that creates a few virtual machines and then
destroys them"""
from stress.test_servers import *
from stress.basher import BasherAction
from stress.driver import *
from tempest import openstack
choice_spec = [
BasherAction(TestCreateVM(), 50,
kargs={'timeout': '60'}),
BasherAction(TestKillActiveVM(), 50)
]
nova = openstack.Manager()
bash_openstack(nova,
choice_spec,
duration=datetime.timedelta(seconds=10),
sleep_time=1000, # in milliseconds
seed=None,
test_name="simple create and delete",
max_vms=4)
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Sample stress test that creates a few virtual machines and then
destroys them"""
from stress.test_servers import *
from stress.basher import BasherAction
from stress.driver import *
from tempest import openstack
choice_spec = [
BasherAction(TestCreateVM(), 50,
kargs={'timeout': '60'}),
BasherAction(TestKillActiveVM(), 50)
]
nova = openstack.Manager()
bash_openstack(nova,
choice_spec,
duration=datetime.timedelta(seconds=10),
sleep_time=1000, # in milliseconds
seed=None,
test_name="simple create and delete",
max_vms=4)

View File

@ -1,54 +1,54 @@
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from novaclient.v1_1 import client
import tempest.config
# get the environment variables for credentials
identity = tempest.config.TempestConfig().identity
compute = tempest.config.TempestConfig().compute
nt = client.Client(compute.username, compute.password,
compute.tenant_name, identity.auth_url)
flavor_list = nt.flavors.list()
server_list = nt.servers.list()
images_list = nt.images.list()
keypairs_list = nt.keypairs.list()
floating_ips_list = nt.floating_ips.list()
print "total servers: %3d, total flavors: %3d, total images: %3d," % \
(len(server_list),
len(flavor_list),
len(images_list)),
print "total keypairs: %3d, total floating ips: %3d" % \
(len(keypairs_list),
len(floating_ips_list))
print "deleting all servers"
for s in server_list:
s.delete()
print "deleting all keypairs"
for s in keypairs_list:
s.delete()
print "deleting all floating_ips"
for s in floating_ips_list:
s.delete()
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from novaclient.v1_1 import client
import tempest.config
# get the environment variables for credentials
identity = tempest.config.TempestConfig().identity
compute = tempest.config.TempestConfig().compute
nt = client.Client(compute.username, compute.password,
compute.tenant_name, identity.auth_url)
flavor_list = nt.flavors.list()
server_list = nt.servers.list()
images_list = nt.images.list()
keypairs_list = nt.keypairs.list()
floating_ips_list = nt.floating_ips.list()
print "total servers: %3d, total flavors: %3d, total images: %3d," % \
(len(server_list),
len(flavor_list),
len(images_list)),
print "total keypairs: %3d, total floating ips: %3d" % \
(len(keypairs_list),
len(floating_ips_list))
print "deleting all servers"
for s in server_list:
s.delete()
print "deleting all keypairs"
for s in keypairs_list:
s.delete()
print "deleting all floating_ips"
for s in floating_ips_list:
s.delete()

View File

@ -1,50 +1,50 @@
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from novaclient.v1_1 import client
import tempest.config
# get the environment variables for credentials
identity = tempest.config.TempestConfig().identity
compute = tempest.config.TempestConfig().compute
print compute.username, compute.password,\
compute.tenant_name, identity.auth_url
nt = client.Client(compute.username, compute.password,
compute.tenant_name, identity.auth_url)
flavor_list = nt.flavors.list()
server_list = nt.servers.list()
images_list = nt.images.list()
keypairs_list = nt.keypairs.list()
floating_ips_list = nt.floating_ips.list()
print "total servers: %3d, total flavors: %3d, total images: %3d" % \
(len(server_list),
len(flavor_list),
len(images_list))
print "total keypairs: %3d, total floating ips: %3d" % \
(len(keypairs_list),
len(floating_ips_list))
print "flavors:\t", flavor_list
print "servers:\t", server_list
print "images: \t", images_list
print "keypairs:\t", keypairs_list
print "floating ips:\t", floating_ips_list
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from novaclient.v1_1 import client
import tempest.config
# get the environment variables for credentials
identity = tempest.config.TempestConfig().identity
compute = tempest.config.TempestConfig().compute
print compute.username, compute.password,\
compute.tenant_name, identity.auth_url
nt = client.Client(compute.username, compute.password,
compute.tenant_name, identity.auth_url)
flavor_list = nt.flavors.list()
server_list = nt.servers.list()
images_list = nt.images.list()
keypairs_list = nt.keypairs.list()
floating_ips_list = nt.floating_ips.list()
print "total servers: %3d, total flavors: %3d, total images: %3d" % \
(len(server_list),
len(flavor_list),
len(images_list))
print "total keypairs: %3d, total floating ips: %3d" % \
(len(keypairs_list),
len(floating_ips_list))
print "flavors:\t", flavor_list
print "servers:\t", server_list
print "images: \t", images_list
print "keypairs:\t", keypairs_list
print "floating ips:\t", floating_ips_list

View File

@ -1,15 +1,15 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@ -1,55 +1,55 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import subprocess
import shlex
SSH_OPTIONS = (" -q" +
" -o UserKnownHostsFile=/dev/null" +
" -o StrictHostKeyChecking=no -i ")
def get_ssh_options(keypath):
return SSH_OPTIONS + keypath
def scp(keypath, args):
options = get_ssh_options(keypath)
return subprocess.check_call(shlex.split("scp" + options + args))
def ssh(keypath, user, node, command, check=True):
command = 'sudo ' + command
command = "ssh %s %s@%s %s" % (get_ssh_options(keypath), user,
node, command)
popenargs = shlex.split(command)
process = subprocess.Popen(popenargs, stdout=subprocess.PIPE)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode and check:
raise Exception("%s: ssh failed with retcode: %s" % (node, retcode))
return output
def execute_on_all(keypath, user, nodes, command):
for node in nodes:
ssh(keypath, user, node, command)
def enum(*sequential, **named):
"""Create auto-incremented enumerated types"""
enums = dict(zip(sequential, range(len(sequential))), **named)
return type('Enum', (), enums)
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import subprocess
import shlex
SSH_OPTIONS = (" -q" +
" -o UserKnownHostsFile=/dev/null" +
" -o StrictHostKeyChecking=no -i ")
def get_ssh_options(keypath):
return SSH_OPTIONS + keypath
def scp(keypath, args):
options = get_ssh_options(keypath)
return subprocess.check_call(shlex.split("scp" + options + args))
def ssh(keypath, user, node, command, check=True):
command = 'sudo ' + command
command = "ssh %s %s@%s %s" % (get_ssh_options(keypath), user,
node, command)
popenargs = shlex.split(command)
process = subprocess.Popen(popenargs, stdout=subprocess.PIPE)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode and check:
raise Exception("%s: ssh failed with retcode: %s" % (node, retcode))
return output
def execute_on_all(keypath, user, nodes, command):
for node in nodes:
ssh(keypath, user, node, command)
def enum(*sequential, **named):
"""Create auto-incremented enumerated types"""
enums = dict(zip(sequential, range(len(sequential))), **named)
return type('Enum', (), enums)