Create setuptools based Python env setup for the scripts 48/107948/1
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>
Wed, 20 May 2020 09:07:39 +0000 (02:07 -0700)
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>
Wed, 20 May 2020 09:07:39 +0000 (02:07 -0700)
Change-Id: I00095182de5532c28fd7d9605de2d9c8b29f6c1c
Issue-ID: INT-1577
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
test/mocks/mass-pnf-sim/.gitignore
test/mocks/mass-pnf-sim/README.md
test/mocks/mass-pnf-sim/requirements.txt [deleted file]
test/mocks/mass-pnf-sim/setup.py [new file with mode: 0755]
test/mocks/mass-pnf-sim/setup.sh
test/mocks/mass-pnf-sim/tox.ini [new file with mode: 0644]

index 6732c15..2294027 100644 (file)
@@ -3,3 +3,4 @@ pnf-sim-lw-*
 pnf-sim-lightweight/logs/*
 files/onap/*
 __pycache__
+MassPnfSim.egg-info/
index fc829f5..d79eccc 100644 (file)
@@ -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 (file)
index 27dd31c..0000000
+++ /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 (executable)
index 0000000..662976b
--- /dev/null
@@ -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'
+    ]
+)
index 2c94136..34481df 100755 (executable)
@@ -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 (file)
index 0000000..98be4b6
--- /dev/null
@@ -0,0 +1,12 @@
+[tox]
+envlist = pytest
+
+[testenv]
+deps = pytest
+
+[testenv:pytest]
+basepython = python3
+commands = pytest
+
+[testenv:MassPnfSim-runtime]
+basepython = python3