summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testapi/docker/Dockerfile50
-rwxr-xr-xtestapi/docker/prepare-env.sh24
-rw-r--r--testapi/opnfv_testapi/tests/unit/executor.py6
-rw-r--r--testapi/opnfv_testapi/tests/unit/fake_pymongo.py6
-rw-r--r--testapi/requirements.txt19
-rw-r--r--testapi/setup.py22
-rw-r--r--testapi/test-requirements.txt12
-rw-r--r--testapi/tox.ini5
-rw-r--r--testapi/upper-constraints.txt9
9 files changed, 90 insertions, 63 deletions
diff --git a/testapi/docker/Dockerfile b/testapi/docker/Dockerfile
index 9c8115f..03b15e8 100644
--- a/testapi/docker/Dockerfile
+++ b/testapi/docker/Dockerfile
@@ -23,37 +23,31 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
-FROM ubuntu:14.04
+FROM ubuntu:18.04
MAINTAINER SerenaFeng <feng.xiaowei@zte.com.cn>
LABEL version="v1" description="OPNFV TestAPI Docker container"
-ENV HOME /home
+ARG user=ubuntu
+ARG group=ubuntu
-# Packaged dependencies
RUN apt-get update && apt-get install -y \
-curl \
-git \
-gcc \
-wget \
-python-dev \
-python-pip \
-crudini \
-libxslt-dev \
-zlib1g-dev \
---no-install-recommends
-
-RUN pip install --upgrade requests
-
-RUN git config --global http.sslVerify false
-RUN git clone https://gerrit.opnfv.org/gerrit/releng-testresults /home/releng-testresults
-
-WORKDIR /home/releng-testresults/testapi
-RUN pip install -r requirements.txt
-
-# bugfix
-# SSLError: hostname 'identity.linuxfoundation.org' doesn't match 'c.sni.fastly.net'
-# hope it is a temprary, try to fix it in upstream python-cas lib
-RUN sed -i '152,152s/)/,\ verify=False)/g' /usr/local/lib/python2.7/dist-packages/cas.py
-
-RUN python setup.py install
+ curl git gcc wget python-dev python-pip python-wheel python-setuptools \
+ crudini libxslt-dev zlib1g-dev --no-install-recommends && \
+ groupadd -r $group && useradd -ms /bin/bash $user -g $group && \
+ git clone https://gerrit.opnfv.org/gerrit/releng-testresults \
+ /home/ubuntu/releng-testresults && \
+ pip install -r /home/ubuntu/releng-testresults/testapi/requirements.txt \
+ -c /home/ubuntu/releng-testresults/testapi/upper-constraints.txt \
+ -c https://raw.githubusercontent.com/openstack/requirements/stable/ussuri/upper-constraints.txt && \
+ sed -i '152,152s/)/,\ verify=False)/g' \
+ /usr/local/lib/python2.7/dist-packages/cas.py && \
+ cd /home/ubuntu/releng-testresults/testapi/ && python setup.py install && \
+ for i in /home/ubuntu/releng-testresults /etc/opnfv_testapi /usr/local/share/opnfv_testapi; do \
+ mkdir -p $i && chown -R $user:$group $i && \
+ find $i -type d |xargs chmod 777 && \
+ find $i -type f |xargs chmod 666 ; done && \
+ apt-get remove --purge -y python-dev libxslt-dev zlib1g-dev && \
+ apt-get autoremove --purge -y && apt-get clean && rm -rf /var/lib/apt/lists/*
+WORKDIR /home/ubuntu/releng-testresults/testapi
+USER ubuntu
CMD ["bash", "docker/start-server.sh"]
diff --git a/testapi/docker/prepare-env.sh b/testapi/docker/prepare-env.sh
index 9086e77..3b061d2 100755
--- a/testapi/docker/prepare-env.sh
+++ b/testapi/docker/prepare-env.sh
@@ -2,18 +2,20 @@
FILE=/etc/opnfv_testapi/config.ini
-if [ "$mongodb_url" != "" ]; then
- sudo crudini --set --existing $FILE mongo url $mongodb_url
-fi
+[[ "${mongodb_url}" == "" ]] && mongodb_url=mongodb://mongo:27017/
+[[ "${base_url}" == "" ]] && base_url=http://localhost:8000
+[[ ! "${auth}" =~ [f|F]alse ]] && auth=true
-if [ "$base_url" != "" ]; then
- sudo crudini --set --existing $FILE api url $base_url/api/v1
- sudo crudini --set --existing $FILE ui url $base_url
- sudo cat > /usr/local/share/opnfv_testapi/testapi-ui/config.json << EOF
+auth_server=`echo ${auth:0:1} | tr '[:lower:]' '[:upper:]'``echo ${auth:1} | tr '[:upper:]' '[:lower:]'`
+auth_web=`echo ${auth} | tr '[:upper:]' '[:lower:]'`
+crudini --set --existing ${FILE} mongo url ${mongodb_url}
+crudini --set --existing ${FILE} api url ${base_url}/api/v1
+crudini --set --existing ${FILE} ui url ${base_url}
+crudini --set --existing ${FILE} api authenticate ${auth_server}
+
+cat > /usr/local/share/opnfv_testapi/testapi-ui/config.json << EOF
{
- "testapiApiUrl": "$base_url/api/v1",
- "authenticate": true
+ "testapiApiUrl": "${base_url}/api/v1",
+ "authenticate": ${auth_web}
}
EOF
-
-fi
diff --git a/testapi/opnfv_testapi/tests/unit/executor.py b/testapi/opnfv_testapi/tests/unit/executor.py
index 5a8d688..7c8cb8a 100644
--- a/testapi/opnfv_testapi/tests/unit/executor.py
+++ b/testapi/opnfv_testapi/tests/unit/executor.py
@@ -18,9 +18,9 @@ O_get_secure_cookie = (
def thread_execute(method, *args, **kwargs):
- with ThreadPoolExecutor(max_workers=2) as executor:
- result = executor.submit(method, *args, **kwargs)
- return result
+ with ThreadPoolExecutor(max_workers=2) as executor:
+ result = executor.submit(method, *args, **kwargs)
+ return result
def mock_invalid_lfid():
diff --git a/testapi/opnfv_testapi/tests/unit/fake_pymongo.py b/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
index 041e6e8..631e9ac 100644
--- a/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
+++ b/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
@@ -15,9 +15,9 @@ from concurrent.futures import ThreadPoolExecutor
def thread_execute(method, *args, **kwargs):
- with ThreadPoolExecutor(max_workers=2) as executor:
- result = executor.submit(method, *args, **kwargs)
- return result
+ with ThreadPoolExecutor(max_workers=2) as executor:
+ result = executor.submit(method, *args, **kwargs)
+ return result
class MemCursor(object):
diff --git a/testapi/requirements.txt b/testapi/requirements.txt
index f551d48..9dba746 100644
--- a/testapi/requirements.txt
+++ b/testapi/requirements.txt
@@ -2,12 +2,13 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-pbr>=2.0.0,!=2.1.0 # Apache-2.0
-setuptools>=16.0,!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2 # PSF/ZPL
-tornado>=3.1,<=4.3 # Apache-2.0
-epydoc>=0.3.1
-six>=1.9.0 # MIT
-motor==1.2.2 # Apache-2.0
-python-cas==1.2.0
-requests[security]
-futures \ No newline at end of file
+pbr!=2.1.0 # Apache-2.0
+setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0;python_version>='3.5' # PSF/ZPL
+setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,<45.0.0;python_version<='2.7' # PSF/ZPL
+tornado<=4.3,>=3.1 # Apache-2.0
+epydoc
+six # MIT
+motor # Apache-2.0
+python-cas
+requests[security]!=2.20.0 # Apache-2.0
+futures!=0.17.0;python_version=='2.7' or python_version=='2.6' # PSF
diff --git a/testapi/setup.py b/testapi/setup.py
index f9d95a3..566d844 100644
--- a/testapi/setup.py
+++ b/testapi/setup.py
@@ -1,13 +1,29 @@
-import setuptools
+# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-__author__ = 'serena'
+# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
+import setuptools
+# In python < 2.7.4, a lazy loading of package `pbr` will break
+# setuptools if some other modules registered functions in `atexit`.
+# solution from: http://bugs.python.org/issue15881#msg170215
try:
import multiprocessing # noqa
except ImportError:
pass
-
setuptools.setup(
setup_requires=['pbr>=2.0.0'],
pbr=True)
diff --git a/testapi/test-requirements.txt b/testapi/test-requirements.txt
index 233f465..67fd8f0 100644
--- a/testapi/test-requirements.txt
+++ b/testapi/test-requirements.txt
@@ -2,9 +2,9 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-coverage>=4.0,!=4.4 # Apache-2.0
-mock>=2.0 # BSD
-nose # LGPL
-pytest # MIT
-pytest-cov # MIT
-pytest-mock # MIT
+coverage!=4.4 # Apache-2.0
+mock!=4.0.0,!=4.0.1 # BSD
+nose # LGPL
+pytest # MIT
+pytest-cov
+pytest-mock
diff --git a/testapi/tox.ini b/testapi/tox.ini
index 9a06355..0478e23 100644
--- a/testapi/tox.ini
+++ b/testapi/tox.ini
@@ -14,6 +14,8 @@ install_command = pip install -U {opts} {packages}
deps =
-rrequirements.txt
-rtest-requirements.txt
+ -chttps://raw.githubusercontent.com/openstack/requirements/stable/ussuri/upper-constraints.txt
+ -cupper-constraints.txt
commands=
py.test \
--basetemp={envtmpdir} \
@@ -30,10 +32,12 @@ basepython=python2.7
commands = sphinx-build -W -b html docs/ docs/_build
[testenv:pep8]
+basepython=python2.7
deps = flake8
commands = flake8 {toxinidir}
[flake8]
+basepython=python2.7
# H803 skipped on purpose per list discussion.
# E123, E125 skipped as they are invalid PEP-8.
@@ -43,5 +47,6 @@ builtins = _
exclude = build,dist,doc,legacy,.eggs,.git,.tox,.venv,testapi_venv,venv
[pytest]
+basepython=python2.7
testpaths = opnfv_testapi/tests
python_functions = test_*
diff --git a/testapi/upper-constraints.txt b/testapi/upper-constraints.txt
new file mode 100644
index 0000000..5226f48
--- /dev/null
+++ b/testapi/upper-constraints.txt
@@ -0,0 +1,9 @@
+epydoc===3.0.1
+motor===1.2.2
+python-cas===1.2.0
+argparse===1.2.1
+backports-abc===0.5
+backports.ssl-match-hostname===3.5.0.1
+html5lib===0.999
+singledispatch===3.4.0.3
+wsgiref===0.1.2