def _wrapped(*args, **kwargs): try: fcn(*args, **kwargs) except: screen_path = os.path.join(get_current_bunch_dir(), 'screenshots-%s__%s.png' % (args[0].scenario.name, args[0].original_sentence )) world.selenium['browser'].get_screenshot_as_file(screen_path) raise
def ssh_instance_key(step, target_host, key_priv): try: target = world.instances[target_host]['ip'] except: target = target_host out = bash("""ssh %s -A -f -L 11111:%s:22 root@%s 'sleep 10' && ssh %s -i %s -p 11111 root@localhost 'hostname' || exit 1""" % (SSH_OPTS, target, config['cloud']['master'], SSH_OPTS, os.path.join(get_current_bunch_dir(), key_priv))) StepAssert(step).assert_true(out.successful())
def screenshot(step, name): world.selenium['browser'].get_screenshot_as_file(os.path.join(get_current_bunch_dir(), 'screen_%s.png' % name))
def setup_browser(step): webdriver.DesiredCapabilities.FIREFOX['webdriver.log.file']="%s/firefox_console" % get_current_bunch_dir() world.selenium['browser'] = webdriver.Remote(config['selenium'], webdriver.DesiredCapabilities.FIREFOX) world.selenium['wait'] = WebDriverWait(world.selenium['browser'], 10) world.selenium['srv'] = config['focus'] world.selenium['browser'].maximize_window()
def current_bunch_path(): # global __file__ # return __file__ return get_current_bunch_dir()
def mapping_file(mapping_name): return os.path.join(get_current_bunch_dir(), mapping_name + '.map')
from datetime import datetime from lettuce import step, world from nose.tools import assert_equals, assert_true, assert_false from time import sleep import re import os import lettuce_bunch.special from openstack_core_test import utils from openstack_core_test.utils import onfailure, debug, conf from lettuce_bunch.special import get_current_bunch_dir get_current_bunch_dir() dir_path = conf.get_current_module_path(__file__) conf.init(dir_path) config_file = os.path.join(dir_path, "config.yaml") config = conf.load_yaml_config(config_file) bunch_working_dir = dir_path def dump(obj): for attr in dir(obj): print "obj.%s = %s" % (attr, getattr(obj, attr)) mysql_admin = config['db']['admin'] mysql_admin_pwd = config['db']['admin_pwd'] class step_assert(object): def __init__(self, step): self.step = step
from collections import namedtuple import collections import yaml import string import conf from lettuce import step, world, before, after from lettuce_bunch.special import get_current_bunch_dir from selenium import webdriver from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support.ui import Select from pdb import Pdb dir_path = get_current_bunch_dir() conf.init(dir_path) config_file = os.path.join(dir_path, "config.yaml") config = conf.load_yaml_config(config_file) bunch_working_dir = dir_path OUTPUT_GARBAGE = ['DeprecationWarning', 'import md5', 'import sha', 'DEBUG nova.utils', 'is deprecated', 'Warning:', 'PowmInsecureWarning:', 'RandomPool_DeprecationWarning:'] SSH_PRIVATE_KEY_PATH = os.path.join(get_current_bunch_dir(), config['keypair']['private-file']) SSH_OPTS = '-T -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' def trace_me(*args, **kwargs): import pdb; pdb.set_trace()
from lettuce import step, world from nose.tools import assert_equals, assert_true, assert_false import utils from utils import onfailure import os import lettuce_bunch.special import conf from lettuce_bunch.special import get_current_bunch_dir get_current_bunch_dir() dir_path = conf.get_current_module_path(__file__) conf.init(dir_path) config_file = os.path.join(dir_path, "config.yaml") config = conf.load_yaml_config(config_file) bunch_working_dir = dir_path def dump(obj): for attr in dir(obj): print "obj.%s = %s" % (attr, getattr(obj, attr)) mysql_admin = config['db']['admin'] mysql_admin_pwd = config['db']['admin_pwd'] class step_assert(object): def __init__(self, step): self.step = step
def __init__(self, dst_dir=None, **kwargs): self.dst_dir = get_current_bunch_dir() if dst_dir is None else dst_dir
def __init__(self, dst_dir=None, **kwargs): self.dst_dir = get_current_bunch_dir() if dst_dir is None else dst_dir
def current_bunch_path(): return get_current_bunch_dir()
def current_bunch_path(): return get_current_bunch_dir()