1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from __future__ import absolute_import
11 from functools import reduce
15 from yardstick.common.utils import parse_yaml
17 dirname = os.path.dirname
18 abspath = os.path.abspath
25 def get_param(key, default=''):
27 # we have to defer this to runtime so that we can mock os.environ.get in unittests
28 conf_file = os.environ.get('CONF_FILE', '/etc/yardstick/yardstick.yaml')
30 # don't re-parse yaml for each lookup
32 CONF.update(parse_yaml(conf_file))
34 return reduce(lambda a, b: a[b], key.split('.'), CONF)
42 SERVER_IP = get_param('api.server_ip')
45 from pyroute2 import IPDB
47 SERVER_IP = '172.17.0.1'
51 SERVER_IP = ip.routes['default'].gateway
53 # during unittests ip.routes['default'] can be invalid
54 SERVER_IP = '127.0.0.1'
57 SERVER_IP = '127.0.0.1'
61 CONF_DIR = get_param('dir.conf', '/etc/yardstick')
62 REPOS_DIR = get_param('dir.repos', '/home/opnfv/repos/yardstick')
63 RELENG_DIR = get_param('dir.releng', '/home/opnfv/repos/releng')
64 LOG_DIR = get_param('dir.log', '/tmp/yardstick/')
65 YARDSTICK_ROOT_PATH = dirname(
66 dirname(abspath(pkg_resources.resource_filename(__name__, "")))) + sep
67 CONF_SAMPLE_DIR = join(REPOS_DIR, 'etc/yardstick/')
68 ANSIBLE_DIR = join(REPOS_DIR, 'ansible')
69 SAMPLE_CASE_DIR = join(REPOS_DIR, 'samples')
70 TESTCASE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_cases/')
71 TESTSUITE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_suites/')
72 DOCS_DIR = join(REPOS_DIR, 'docs/testing/user/userguide/')
73 OPENSTACK_CONF_DIR = '/etc/openstack'
76 OPENRC = get_param('file.openrc', '/etc/yardstick/openstack.creds')
77 ETC_HOSTS = get_param('file.etc_hosts', '/etc/hosts')
78 CONF_FILE = join(CONF_DIR, 'yardstick.conf')
79 POD_FILE = join(CONF_DIR, 'pod.yaml')
80 CLOUDS_CONF = join(OPENSTACK_CONF_DIR, 'clouds.yml')
81 K8S_CONF_FILE = join(CONF_DIR, 'admin.conf')
82 CONF_SAMPLE_FILE = join(CONF_SAMPLE_DIR, 'yardstick.conf.sample')
83 FETCH_SCRIPT = get_param('file.fetch_script', 'utils/fetch_os_creds.sh')
84 FETCH_SCRIPT = join(RELENG_DIR, FETCH_SCRIPT)
85 CLEAN_IMAGES_SCRIPT = get_param('file.clean_image_script',
86 'tests/ci/clean_images.sh')
87 CLEAN_IMAGES_SCRIPT = join(REPOS_DIR, CLEAN_IMAGES_SCRIPT)
88 LOAD_IMAGES_SCRIPT = get_param('file.load_image_script',
89 'tests/ci/load_images.sh')
90 LOAD_IMAGES_SCRIPT = join(REPOS_DIR, LOAD_IMAGES_SCRIPT)
91 DEFAULT_OUTPUT_FILE = get_param('file.output_file', '/tmp/yardstick.out')
92 DEFAULT_HTML_FILE = get_param('file.html_file', '/tmp/yardstick.htm')
95 INFLUXDB_IP = get_param('influxdb.ip', SERVER_IP)
96 INFLUXDB_PORT = get_param('influxdb.port', 8086)
97 INFLUXDB_USER = get_param('influxdb.username', 'root')
98 INFLUXDB_PASS = get_param('influxdb.password', 'root')
99 INFLUXDB_DB_NAME = get_param('influxdb.db_name', 'yardstick')
100 INFLUXDB_IMAGE = get_param('influxdb.image', 'tutum/influxdb')
101 INFLUXDB_TAG = get_param('influxdb.tag', '0.13')
102 INFLUXDB_DASHBOARD_PORT = 8083
105 GRAFANA_IP = get_param('grafana.ip', SERVER_IP)
106 GRAFANA_PORT = get_param('grafana.port', 3000)
107 GRAFANA_USER = get_param('grafana.username', 'admin')
108 GRAFANA_PASS = get_param('grafana.password', 'admin')
109 GRAFANA_IMAGE = get_param('grafana.image', 'grafana/grafana')
110 GRAFANA_TAG = get_param('grafana.tag', '3.1.1')
111 GRAFANA_MAPPING_PORT = 1948
115 DOCKER_URL = 'unix://var/run/docker.sock'
116 INSTALLERS = ['apex', 'compass', 'fuel', 'joid']
117 SQLITE = 'sqlite:////tmp/yardstick.db'
125 BASE_URL = 'http://localhost:5000'
126 ENV_ACTION_API = BASE_URL + '/yardstick/env/action'
127 ASYNC_TASK_API = BASE_URL + '/yardstick/asynctask'
130 TESTCASE_PRE = 'opnfv_yardstick_'
131 TESTSUITE_PRE = 'opnfv_'