aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/__init__.py4
-rw-r--r--api/server.py14
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_nstat.py6
-rw-r--r--yardstick/common/constants.py1
4 files changed, 19 insertions, 6 deletions
diff --git a/api/__init__.py b/api/__init__.py
index dda12aa07..4622802df 100644
--- a/api/__init__.py
+++ b/api/__init__.py
@@ -57,9 +57,9 @@ class ApiResource(Resource):
class Url(object):
- def __init__(self, url, endpoint):
+ def __init__(self, url, target):
super(Url, self).__init__()
self.url = url
- self.endpoint = endpoint
+ self.target = target
common_utils.import_modules_from_package("api.resources")
diff --git a/api/server.py b/api/server.py
index 344874c77..c1548ca10 100644
--- a/api/server.py
+++ b/api/server.py
@@ -10,6 +10,7 @@ from __future__ import absolute_import
import inspect
import logging
+import socket
from six.moves import filter
from flasgger import Swagger
@@ -24,6 +25,12 @@ from api.urls import urlpatterns
from api import ApiResource
from yardstick import _init_logging
from yardstick.common import utils
+from yardstick.common import constants as consts
+
+try:
+ from urlparse import urljoin
+except ImportError:
+ from urllib.parse import urljoin
logger = logging.getLogger(__name__)
@@ -64,8 +71,13 @@ def app_wrapper(*args, **kwargs):
return app(*args, **kwargs)
+def get_endpoint(url):
+ ip = socket.gethostbyname(socket.gethostname())
+ return urljoin('http://{}:{}'.format(ip, consts.API_PORT), url)
+
+
for u in urlpatterns:
- api.add_resource(get_resource(u.endpoint), u.url, endpoint=u.endpoint)
+ api.add_resource(get_resource(u.target), u.url, endpoint=get_endpoint(u.url))
if __name__ == '__main__':
diff --git a/tests/unit/benchmark/scenarios/networking/test_nstat.py b/tests/unit/benchmark/scenarios/networking/test_nstat.py
index 131716727..d66e91790 100644
--- a/tests/unit/benchmark/scenarios/networking/test_nstat.py
+++ b/tests/unit/benchmark/scenarios/networking/test_nstat.py
@@ -43,7 +43,7 @@ class NstatTestCase(unittest.TestCase):
def test_nstat_successful_no_sla(self, mock_ssh):
options = {
- "duration": 60
+ "duration": 0.1
}
args = {
"options": options,
@@ -67,7 +67,7 @@ class NstatTestCase(unittest.TestCase):
def test_nstat_successful_sla(self, mock_ssh):
options = {
- "duration": 60
+ "duration": 0.1
}
sla = {
"IP_datagram_error_rate": 0.1
@@ -95,7 +95,7 @@ class NstatTestCase(unittest.TestCase):
def test_nstat_unsuccessful_cmd_error(self, mock_ssh):
options = {
- "duration": 60
+ "duration": 0.1
}
sla = {
"IP_datagram_error_rate": 0.1
diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py
index c5a37b605..d71975af4 100644
--- a/yardstick/common/constants.py
+++ b/yardstick/common/constants.py
@@ -84,6 +84,7 @@ GRAFANA_IMAGE = get_param('grafana.image', 'grafana/grafana')
GRAFANA_TAG = get_param('grafana.tag', '3.1.1')
# api
+API_PORT = 5000
DOCKER_URL = 'unix://var/run/docker.sock'
INSTALLERS = ['apex', 'compass', 'fuel', 'joid']
SQLITE = 'sqlite:////tmp/yardstick.db'