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 TASK_LOG_DIR = get_param('dir.tasklog', '/var/log/yardstick/')
68 CONF_SAMPLE_DIR = join(REPOS_DIR, 'etc/yardstick/')
69 ANSIBLE_DIR = join(REPOS_DIR, 'ansible')
70 SAMPLE_CASE_DIR = join(REPOS_DIR, 'samples')
71 TESTCASE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_cases/')
72 TESTSUITE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_suites/')
73 DOCS_DIR = join(REPOS_DIR, 'docs/testing/user/userguide/')
74 OPENSTACK_CONF_DIR = '/etc/openstack'
77 OPENRC = get_param('file.openrc', '/etc/yardstick/openstack.creds')
78 ETC_HOSTS = get_param('file.etc_hosts', '/etc/hosts')
79 CONF_FILE = join(CONF_DIR, 'yardstick.conf')
80 POD_FILE = join(CONF_DIR, 'pod.yaml')
81 CLOUDS_CONF = join(OPENSTACK_CONF_DIR, 'clouds.yml')
82 K8S_CONF_FILE = join(CONF_DIR, 'admin.conf')
83 CONF_SAMPLE_FILE = join(CONF_SAMPLE_DIR, 'yardstick.conf.sample')
84 FETCH_SCRIPT = get_param('file.fetch_script', 'utils/fetch_os_creds.sh')
85 FETCH_SCRIPT = join(RELENG_DIR, FETCH_SCRIPT)
86 CLEAN_IMAGES_SCRIPT = get_param('file.clean_image_script',
87 'tests/ci/clean_images.sh')
88 CLEAN_IMAGES_SCRIPT = join(REPOS_DIR, CLEAN_IMAGES_SCRIPT)
89 LOAD_IMAGES_SCRIPT = get_param('file.load_image_script',
90 'tests/ci/load_images.sh')
91 LOAD_IMAGES_SCRIPT = join(REPOS_DIR, LOAD_IMAGES_SCRIPT)
92 DEFAULT_OUTPUT_FILE = get_param('file.output_file', '/tmp/yardstick.out')
93 DEFAULT_HTML_FILE = get_param('file.html_file', '/tmp/yardstick.htm')
94 REPORTING_FILE = get_param('file.reporting_file', '/tmp/report.html')
97 INFLUXDB_IP = get_param('influxdb.ip', SERVER_IP)
98 INFLUXDB_PORT = get_param('influxdb.port', 8086)
99 INFLUXDB_USER = get_param('influxdb.username', 'root')
100 INFLUXDB_PASS = get_param('influxdb.password', 'root')
101 INFLUXDB_DB_NAME = get_param('influxdb.db_name', 'yardstick')
102 INFLUXDB_IMAGE = get_param('influxdb.image', 'tutum/influxdb')
103 INFLUXDB_TAG = get_param('influxdb.tag', '0.13')
104 INFLUXDB_DASHBOARD_PORT = 8083
107 GRAFANA_IP = get_param('grafana.ip', SERVER_IP)
108 GRAFANA_PORT = get_param('grafana.port', 3000)
109 GRAFANA_USER = get_param('grafana.username', 'admin')
110 GRAFANA_PASS = get_param('grafana.password', 'admin')
111 GRAFANA_IMAGE = get_param('grafana.image', 'grafana/grafana')
112 GRAFANA_TAG = get_param('grafana.tag', '4.4.3')
113 GRAFANA_MAPPING_PORT = 1948
117 DOCKER_URL = 'unix://var/run/docker.sock'
118 INSTALLERS = ['apex', 'compass', 'fuel', 'joid']
119 SQLITE = 'sqlite:////tmp/yardstick.db'
127 BASE_URL = 'http://localhost:5000'
128 ENV_ACTION_API = BASE_URL + '/yardstick/env/action'
129 ASYNC_TASK_API = BASE_URL + '/yardstick/asynctask'
132 TESTCASE_PRE = 'opnfv_yardstick_'
133 TESTSUITE_PRE = 'opnfv_'