aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/mass-pnf-sim
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-05-20 02:07:39 -0700
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-05-20 02:07:39 -0700
commit50975a2d401f79a57f4a72cd6fa1b0591bf64d81 (patch)
tree185484159e42fccba3592d8e254d4f7ad95ad6bf /test/mocks/mass-pnf-sim
parent5717b5ee81cedfb3c1361cad6683cf585c90ae31 (diff)
Create setuptools based Python env setup for the scripts
Change-Id: I00095182de5532c28fd7d9605de2d9c8b29f6c1c Issue-ID: INT-1577 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test/mocks/mass-pnf-sim')
-rw-r--r--test/mocks/mass-pnf-sim/.gitignore1
-rw-r--r--test/mocks/mass-pnf-sim/README.md2
-rw-r--r--test/mocks/mass-pnf-sim/requirements.txt5
-rwxr-xr-xtest/mocks/mass-pnf-sim/setup.py36
-rwxr-xr-xtest/mocks/mass-pnf-sim/setup.sh15
-rw-r--r--test/mocks/mass-pnf-sim/tox.ini12
6 files changed, 57 insertions, 14 deletions
diff --git a/test/mocks/mass-pnf-sim/.gitignore b/test/mocks/mass-pnf-sim/.gitignore
index 6732c154c..229402740 100644
--- a/test/mocks/mass-pnf-sim/.gitignore
+++ b/test/mocks/mass-pnf-sim/.gitignore
@@ -3,3 +3,4 @@ pnf-sim-lw-*
pnf-sim-lightweight/logs/*
files/onap/*
__pycache__
+MassPnfSim.egg-info/
diff --git a/test/mocks/mass-pnf-sim/README.md b/test/mocks/mass-pnf-sim/README.md
index fc829f5d1..d79eccc75 100644
--- a/test/mocks/mass-pnf-sim/README.md
+++ b/test/mocks/mass-pnf-sim/README.md
@@ -15,6 +15,8 @@ The ipstart should align to a /28 Ip address range start (e.g. 10.11.0.16, 10.11
For debug purposes, you can use your own IP address as VES collector, use "ip" command to determine it.
+Run ./setup.sh to create pre-set Python virtualenv with all required dependencies for the scripts.
+
### Build simulator image
```
diff --git a/test/mocks/mass-pnf-sim/requirements.txt b/test/mocks/mass-pnf-sim/requirements.txt
deleted file mode 100644
index 27dd31c35..000000000
--- a/test/mocks/mass-pnf-sim/requirements.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-argparse
-ipaddress
-requests
-json
-shutil
diff --git a/test/mocks/mass-pnf-sim/setup.py b/test/mocks/mass-pnf-sim/setup.py
new file mode 100755
index 000000000..662976b03
--- /dev/null
+++ b/test/mocks/mass-pnf-sim/setup.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+# COPYRIGHT NOTICE STARTS HERE
+#
+# Copyright 2020 Samsung Electronics Co., Ltd.
+#
+# 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.
+#
+# COPYRIGHT NOTICE ENDS HERE
+
+# This file is only meant to be a single source of truth for package
+# dependencies. It's consumed by bin/setup.sh and tox hence shouldn't
+# be run directly for package builds as currently vcpe scripts are not
+# provided as a python package.
+
+import setuptools
+
+# Define MassPnfSim module dependencies below
+setuptools.setup(
+ name="MassPnfSim",
+ install_requires=[
+ 'argparse',
+ 'ipaddress',
+ 'requests'
+ ]
+)
diff --git a/test/mocks/mass-pnf-sim/setup.sh b/test/mocks/mass-pnf-sim/setup.sh
index 2c941361f..34481df1f 100755
--- a/test/mocks/mass-pnf-sim/setup.sh
+++ b/test/mocks/mass-pnf-sim/setup.sh
@@ -1,13 +1,10 @@
#!/bin/bash
-virtualenv --version > /dev/null || { echo 'Virtualenv command is not available, exiting' ; sleep 10; exit 1; }
-pip3 --version > /dev/null || { echo 'python3-pip package is not available, exiting' ; sleep 10; exit 1; }
+# Setup runtime environment for the Python scripts
+virtualenv --version > /dev/null 2>&1 || { echo 'Virtualenv command is not available, exiting'; exit 1; }
+pip3 --version > /dev/null 2>&1 || { echo 'python3-pip package is not available, exiting' ; exit 1; }
+tox --version > /dev/null 2>&1 || { echo 'tox command is not available, exiting' ; exit 1; }
-if [ -d ".env" ]; then
- echo ".env is prepared"
-else
- virtualenv -p python3 .env
-fi
-
-source .env/bin/activate && pip3 install -r requirements.txt
+tox -e MassPnfSim-runtime
+echo -e "\n\nNow run:\nsource .tox/MassPnfSim-runtime/bin/activate"
diff --git a/test/mocks/mass-pnf-sim/tox.ini b/test/mocks/mass-pnf-sim/tox.ini
new file mode 100644
index 000000000..98be4b667
--- /dev/null
+++ b/test/mocks/mass-pnf-sim/tox.ini
@@ -0,0 +1,12 @@
+[tox]
+envlist = pytest
+
+[testenv]
+deps = pytest
+
+[testenv:pytest]
+basepython = python3
+commands = pytest
+
+[testenv:MassPnfSim-runtime]
+basepython = python3