Changes the paths of all source code so that it exists under the dockerfile location
for each container. This way we can use COPY instead of git clone, as well as use the
existing JJB.
Change-Id: I883b2957d89659c164fff0a1ebc4d677c534796d
JIRA: STORPERF-188
Signed-off-by: mbeierl <mark.beierl@dell.com>
+++ /dev/null
-##############################################################################
-# Copyright (c) 2015 EMC and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-from setuptools import setup, find_packages
-
-
-setup(
- name="storperf",
- version="0.dev0",
- packages=find_packages(),
- include_package_data=True,
- package_data={
- 'storperf': [
- 'storperf/resources/hot/*'
- ]
- },
- url="https://www.opnfv.org",
- install_requires=["flask==0.10",
- "flask-restful==0.3.5",
- "flask-restful-swagger==0.19",
- "html2text==2016.1.8",
- "python-cinderclient==1.6.0",
- "python-glanceclient==1.1.0",
- "python-heatclient==0.8.0",
- "python-keystoneclient==1.6.0",
- "python-neutronclient==2.6.0",
- "python-novaclient==2.28.1",
- "pyyaml==3.10",
- "requests==2.13.0",
- "six==1.10.0"
- ],
- entry_points={
- 'console_scripts': [
- 'storperf=storperf.main:main',
- ],
- }
-)
pip install scp==0.10.2
pip install six==1.10.0
-python ci/setup.py develop
-
-flake8 storperf
+final_rc=0
+flake8 docker/storperf-*
flake8rc=$?
-nosetests --with-xunit \
- --with-coverage \
- --cover-package=storperf\
- --cover-xml \
- --cover-html \
- tests
-rc=$?
+for testdir in docker/storperf-*
+do
+ if [ -d $testdir/tests ]
+ then
+ cwd=$(pwd)
+ cd $testdir
+
+ nosetests --with-xunit \
+ --with-coverage \
+ --cover-package=storperf\
+ --cover-xml \
+ --cover-html \
+ tests
+ rc=$?
+ if [ $rc -ne 0 ]
+ then
+ final_rc=$rc
+ fi
+ cd $cwd
+ fi
+done
+
+cp ./docker/storperf-master/coverage.xml .
+cp ./docker/storperf-master/nosetests.xml .
deactivate
exit $flake8rc
fi
-exit $rc
+exit $final_rc
version: '2'
services:
- storperf:
- container_name: "storperf"
- image: "opnfv/storperf:${TAG}"
+ storperf-master:
+ container_name: "storperf-master"
+ image: "opnfv/storperf-master:${TAG}"
ports:
- "8000:8000"
env_file: ${ENV_FILE}
volumes:
- ${CARBON_DIR}:/opt/graphite/storage/whisper
- swagger-ui:
- container_name: "swagger-ui"
+ storperf-reporting:
+ container_name: "storperf-reporting"
+ image: "opnfv/storperf-reporting:${TAG}"
+ ports:
+ - "5080:5000"
+
+ storperf-swaggerui:
+ container_name: "storperf-swaggerui"
image: "schickling/swagger-ui"
- http-front-end:
- container_name: "http-front-end"
- image: nginx:stable-alpine
+ storperf-httpfrontend:
+ container_name: "storperf-httpfrontend"
+ image: "opnfv/storperf-httpfrontend:${TAG}"
ports:
- "5000:5000"
- volumes:
- - ./nginx.conf:/etc/nginx/nginx.conf:ro
links:
- - storperf
- - swagger-ui
\ No newline at end of file
+ - storperf-master
+ - storperf-reporting
+ - storperf-swaggerui
\ No newline at end of file
--- /dev/null
+##############################################################################
+# Copyright (c) 2017 Dell EMC and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+# Docker container for StorPerf HTTP Front ENd
+#
+# Build:
+# $ docker build -t opnfv/storperf-frontend:tag .
+##
+
+
+FROM nginx:stable-alpine
+MAINTAINER Mark Beierl <mark.beierl@dell.com>
+LABEL version="3.1" description="OPNFV Storperf HTTP Front End Container"
+
+ARG BRANCH=master
+
+COPY storperf-httpfrontend/nginx.conf /etc/nginx/nginx.conf
+COPY storperf-httpfrontend/html /etc/nginx/html
+
+EXPOSE 5000
#
# Maintained by Jose Lausuch, Mark Beierl
# Build:
-# $ docker build -t opnfv/storperf:tag .
+# $ docker build -t opnfv/storperf-master:tag .
#
-# Execution:
-# $ docker run -t opnfv/storperf /bin/bash
-#
-
FROM ubuntu:14.04
MAINTAINER Jose Lausuch <jose.lausuch@ericsson.com>
-LABEL version="0.1" description="OPNFV Storperf Docker container"
+LABEL version="5.0" description="OPNFV Storperf Docker container"
ARG BRANCH=master
WORKDIR /home/opnfv
+# Needed for Graphite installation
+RUN echo 'deb http://us.archive.ubuntu.com/ubuntu/ trusty universe' >> /etc/apt/sources.list
+
# Packaged dependencies
RUN apt-get update && apt-get install -y \
libaio1 \
libaio-dev \
zlib1g-dev \
supervisor \
-ssh \
libssl-dev \
libffi-dev \
-rsync \
git \
-wget \
-puppet \
build-essential \
python-dev \
python-pip \
--no-install-recommends
-
-# Allow root SSH access with 'storperf' as the password
-
-RUN echo 'root:storperf' | chpasswd
-RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
-
-# SSH login fix. Otherwise user is kicked off after login
-RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
-
-ENV NOTVISIBLE "in users profile"
-RUN echo "export VISIBLE=now" >> /etc/profile
-RUN mkdir -p /var/run/sshd
-
-RUN mkdir -p ${repos_dir}
RUN mkdir -p /root/.ssh
RUN chmod 700 /root/.ssh
-# Graphite installation
-RUN echo 'deb http://us.archive.ubuntu.com/ubuntu/ trusty universe' >> /etc/apt/sources.list
-RUN apt-get -y update
-
# Install required packages
+
RUN apt-get -y install python-ldap python-cairo python-django python-twisted python-django-tagging python-simplejson python-memcache python-pysqlite2 python-support python-tz python-pip gunicorn supervisor nginx-light
RUN pip install whisper==0.9.15
RUN pip install --install-option="--prefix=/var/lib/graphite" --install-option="--install-lib=/var/lib/graphite/lib" carbon==0.9.15
RUN pip install --install-option="--prefix=/var/lib/graphite" --install-option="--install-lib=/var/lib/graphite/webapp" graphite-web==0.9.15
-# Add system service config
-ADD graphite/nginx.conf /etc/nginx/nginx.conf
-
# Add graphite config
+
+ADD graphite/nginx.conf /etc/nginx/nginx.conf
ADD graphite/initial_data.json /var/lib/graphite/webapp/graphite/initial_data.json
ADD graphite/local_settings.py /var/lib/graphite/webapp/graphite/local_settings.py
ADD graphite/carbon.conf /var/lib/graphite/conf/carbon.conf
RUN chmod 0664 /var/lib/graphite/storage/graphite.db
RUN cd /var/lib/graphite/webapp/graphite && python manage.py syncdb --noinput
+
# Git configuration
RUN git config --global http.sslVerify false
-RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/storperf ${repos_dir}/storperf
RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng ${repos_dir}/releng
+
# Third party git fetches
RUN git clone http://git.kernel.dk/fio.git ${repos_dir}/fio
RUN cd ${repos_dir}/fio && git checkout tags/fio-2.2.10
-RUN cd ${repos_dir}/fio && make install
+#RUN cd ${repos_dir}/fio && make install
-RUN chmod 600 ${repos_dir}/storperf/storperf/resources/ssh/storperf_rsa
+# Install StorPerf
+COPY storperf-master ${repos_dir}/storperf
+RUN chmod 600 ${repos_dir}/storperf/storperf/resources/ssh/storperf_rsa
RUN pip install --upgrade setuptools==33.1.1
-RUN pip install -r ${repos_dir}/storperf/docker/requirements.pip
-
-
-# Open access to SSH if desired
-EXPOSE 22
+RUN pip install -r ${repos_dir}/storperf/requirements.pip
+COPY storperf-master/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Graphite
EXPOSE 8000
# ReST API
EXPOSE 5000
-COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["/usr/bin/supervisord"]
ARG BRANCH=master
-ENV repos_dir /home/opnfv/repos
-WORKDIR /home/opnfv
-
RUN apk add --update python py-pip
-COPY . /app
-WORKDIR /app
-RUN pip install -r requirements.txt
+COPY storperf-reporting /home/opnfv/storperf-reporting
+WORKDIR /home/opnfv/storperf-reporting
+
+RUN pip install -r /home/opnfv/storperf-reporting/requirements.txt
ENTRYPOINT ["python"]
-CMD ["./src/app.py"]
+CMD ["/home/opnfv/storperf-reporting/src/app.py"]
+
EXPOSE 5000
\ No newline at end of file
--- /dev/null
+<!DOCTYPE html>
+<html>
+<title>
+StorPerf Home
+</title>
+<body>
+<h1>StorPerf</h1>
+<ul>
+ <li><a href="/swagger">Interactive API</a></li>
+ <li><a href="/graphite">Graphite</a></li>
+ <li><a href="/reporting">Reporting</a></li>
+</ul>
+</body>
+</html>
\ No newline at end of file
listen 5000;
location /api/ {
- proxy_pass http://storperf:5000;
+ proxy_pass http://storperf-master:5000;
proxy_set_header Host $host:$proxy_port;
}
location /graphite/ {
- proxy_pass http://storperf:8000;
+ proxy_pass http://storperf-master:8000;
+ proxy_set_header Host $host:$proxy_port;
+ }
+
+ location /reporting/ {
+ proxy_pass http://storperf-reporting:5000/;
proxy_set_header Host $host:$proxy_port;
}
if ($containsurl = 0) {
return 302 $scheme://$host:$server_port$uri?url=http://$host:$server_port/api/spec.json$args;
}
- proxy_pass http://swagger-ui:80/;
+ proxy_pass http://storperf-swaggerui:80/;
}
}
}
},
{
"name": "metrics_type",
- "description": "The metrics_type of metrics to report. May be "
+ "description": "The metrics_type of metrics to report. May be "
"metrics (default), or metadata",
"required": False,
"metrics_type": "string",
return jsonify({'quota': quota})
-def setup_logging(default_path='storperf/logging.json',
+def setup_logging(default_path='logging.json',
default_level=logging.INFO, env_key='LOG_CFG'):
"""Setup logging configuration
"""
stderr_logfile = /var/log/supervisor/%(program_name)s.log
autorestart = true
-[program:sshd]
-user = root
-command = /usr/sbin/sshd -D
-stdout_logfile = /var/log/supervisor/%(program_name)s.log
-stderr_logfile = /var/log/supervisor/%(program_name)s.log
-autorestart = true
-
[program:storperf-webapp]
user = root
-directory = /home/opnfv/repos/storperf
-command = /usr/bin/python /home/opnfv/repos/storperf/rest_server.py
+directory = /home/opnfv/repos/storperf/
+command = /usr/bin/python rest_server.py
stdout_logfile = /var/log/supervisor/%(program_name)s.log
stderr_logfile = /var/log/supervisor/%(program_name)s.log
autorestart = true
from storperf.db.configuration_db import ConfigurationDB
import os
import unittest
-import sqlite3
class ConfigurationDBTest(unittest.TestCase):
def setUp(self):
- ConfigurationDB.db_name = "file::memory:?cache=shared"
- db = sqlite3.connect(ConfigurationDB.db_name)
+ ConfigurationDB.db_name = __name__ + '.db'
+ try:
+ os.remove(ConfigurationDB.db_name)
+ except OSError:
+ pass
self.config_db = ConfigurationDB()
+ def tearDown(self):
+ try:
+ os.remove(ConfigurationDB.db_name)
+ except OSError:
+ pass
+
def test_create_key(self):
expected = "ABCDE-12345"
class JobDBTest(unittest.TestCase):
def setUp(self):
-
JobDB.db_name = __name__ + '.db'
try:
os.remove(JobDB.db_name)
pass
self.job = JobDB()
+ def tearDown(self):
+ try:
+ os.remove(JobDB.db_name)
+ except OSError:
+ pass
+
@mock.patch("uuid.uuid4")
def test_create_job(self, mock_uuid):
expected = "ABCDE-12345"
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import os
+import unittest
+
from storperf.db.configuration_db import ConfigurationDB
from storperf.storperf_master import StorPerfMaster
-import unittest
-import sqlite3
class StorPerfMasterTest(unittest.TestCase):
def setUp(self):
- ConfigurationDB.db_name = "file::memory:?cache=shared"
- db = sqlite3.connect(ConfigurationDB.db_name)
+ ConfigurationDB.db_name = __name__ + '.db'
+ try:
+ os.remove(ConfigurationDB.db_name)
+ except OSError:
+ pass
self.storperf = StorPerfMaster()
+ def tearDown(self):
+ try:
+ os.remove(ConfigurationDB.db_name)
+ except OSError:
+ pass
+
def test_agent_count(self):
expected = 10
--- /dev/null
+##############################################################################
+# Copyright (c) 2017 Dell EMC and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from flask import Flask, redirect, url_for, request, render_template, session
+import urllib
+import json
+app = Flask(__name__)
+app.secret_key = 'storperf_graphing_module'
+
+
+@app.route('/success/')
+def success():
+ data = urllib.urlopen(session["url"]).read()
+ data = json.loads(data)
+ return render_template('plot_tables.html', data=data)
+
+
+@app.route('/url', methods=['POST', 'GET'])
+def url():
+ if request.method == 'POST':
+ url = request.form['url']
+ session["url"] = url
+ return redirect(url_for('success'))
+
+
+@app.route('/')
+def index():
+ return render_template('index.html')
+
+
+if __name__ == '__main__':
+ app.run(host="0.0.0.0", debug=True, threaded=True)
+++ /dev/null
-from flask import Flask
-app = Flask(__name__)
-
-@app.route('/')
-def hello_world():
- return 'Hello World'
-
-if __name__ == '__main__':
- app.run(debug=True, host='0.0.0.0', threaded=True)
+++ /dev/null
-from flask import Flask, redirect, url_for, request, render_template,jsonify, session
-import requests, json
-import urllib, json
-app = Flask(__name__)
-app.secret_key = 'storperf_graphing_module'
-#global url
-
-@app.route('/reporting/success/')
-def success():
- header = {'x-requested-with': 'XMLHttpRequest'}
- data = urllib.urlopen(session["url"]).read()
- data = json.loads(data)
- return render_template('plot_tables.html', data = data)
-
-@app.route('/reporting/url',methods = ['POST', 'GET'])
-def url():
- if request.method == 'POST':
-# global url
- url = request.form['url']
- session["url"] = url
- return redirect(url_for('success'))
-
-@app.route('/reporting/')
-def index():
- return render_template('index.html')
-
-if __name__ == '__main__':
- app.run(host="0.0.0.0", debug = True, threaded=True)
\ No newline at end of file