From da799981f5373b09398319df12e77e2efc75caa6 Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Tue, 26 Feb 2019 15:46:02 +0100 Subject: [PATCH] Rename to Constants.py Motivation: Make the constants available also for Robot. Restraint: Robotframework user guide says: Because variable files are always imported using a file system path, creating them as classes has some restrictions: Python classes must have the same name as the module they are located. Change-Id: I638ef3fe045db132e366de2e2699638b8637e45e Signed-off-by: Vratko Polak --- docs/test_code_guidelines.rst | 2 +- resources/libraries/python/{constants.py => Constants.py} | 7 ++++++- resources/libraries/python/ContainerUtils.py | 2 +- resources/libraries/python/CoreDumpUtil.py | 2 +- resources/libraries/python/DPDK/DPDKTools.py | 2 +- resources/libraries/python/DPDK/L2fwdTest.py | 2 +- resources/libraries/python/DPDK/L3fwdTest.py | 2 +- resources/libraries/python/DUTSetup.py | 2 +- resources/libraries/python/IPUtil.py | 2 +- resources/libraries/python/IPv6Setup.py | 2 +- resources/libraries/python/KubernetesUtils.py | 2 +- resources/libraries/python/PapiExecutor.py | 2 +- resources/libraries/python/QemuUtils.py | 2 +- resources/libraries/python/SFC/SFCTest.py | 2 +- resources/libraries/python/SFC/SetupSFCTest.py | 2 +- resources/libraries/python/SetupFramework.py | 2 +- resources/libraries/python/TrafficGenerator.py | 2 +- resources/libraries/python/TrafficScriptExecutor.py | 2 +- resources/libraries/python/VPPUtil.py | 2 +- resources/libraries/python/VatExecutor.py | 2 +- resources/libraries/python/VppConfigGenerator.py | 2 +- resources/libraries/python/honeycomb/BGP.py | 2 +- resources/libraries/python/honeycomb/HcPersistence.py | 2 +- resources/libraries/python/honeycomb/HoneycombSetup.py | 2 +- resources/libraries/python/honeycomb/HoneycombUtil.py | 2 +- resources/libraries/python/honeycomb/Performance.py | 2 +- resources/tools/wrk/wrk.py | 2 +- 27 files changed, 32 insertions(+), 27 deletions(-) rename resources/libraries/python/{constants.py => Constants.py} (91%) diff --git a/docs/test_code_guidelines.rst b/docs/test_code_guidelines.rst index b455c924c4..24544b93de 100644 --- a/docs/test_code_guidelines.rst +++ b/docs/test_code_guidelines.rst @@ -284,7 +284,7 @@ and unrelated ones such as PAL) if there are any (in addition to library ones). + It is NOT RECOMMENDED to use hard-coded constants (e.g. numbers, paths without any description). It is RECOMMENDED to use - configuration file(s), like /csit/resources/libraries/python/constants.py, + configuration file(s), like /csit/resources/libraries/python/Constants.py, with appropriate comments. + The code SHALL log at the lowest possible level of implementation, diff --git a/resources/libraries/python/constants.py b/resources/libraries/python/Constants.py similarity index 91% rename from resources/libraries/python/constants.py rename to resources/libraries/python/Constants.py index b4a96694b1..b89f50c4df 100644 --- a/resources/libraries/python/constants.py +++ b/resources/libraries/python/Constants.py @@ -15,7 +15,12 @@ class Constants(object): - """Constants used in CSIT.""" + """Constants used in CSIT. + + TODO: Yaml files are easier for humans to edit. + Figure out how to set the attributes by parsing a file + that works regardless of current working directory. + """ # OpenVPP testing directory location at topology nodes REMOTE_FW_DIR = '/tmp/openvpp-testing' diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py index 9c42a3c99c..1530657edf 100644 --- a/resources/libraries/python/ContainerUtils.py +++ b/resources/libraries/python/ContainerUtils.py @@ -19,7 +19,7 @@ from collections import OrderedDict, Counter from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.topology import Topology from resources.libraries.python.VppConfigGenerator import VppConfigGenerator diff --git a/resources/libraries/python/CoreDumpUtil.py b/resources/libraries/python/CoreDumpUtil.py index ea79124faa..9fd8b24822 100644 --- a/resources/libraries/python/CoreDumpUtil.py +++ b/resources/libraries/python/CoreDumpUtil.py @@ -15,7 +15,7 @@ from time import time -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.DUTSetup import DUTSetup from resources.libraries.python.LimitUtil import LimitUtil from resources.libraries.python.SysctlUtil import SysctlUtil diff --git a/resources/libraries/python/DPDK/DPDKTools.py b/resources/libraries/python/DPDK/DPDKTools.py index ec70b40270..25d221772c 100644 --- a/resources/libraries/python/DPDK/DPDKTools.py +++ b/resources/libraries/python/DPDK/DPDKTools.py @@ -15,7 +15,7 @@ """This module implements initialization and cleanup of DPDK environment.""" from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.topology import NodeType, Topology diff --git a/resources/libraries/python/DPDK/L2fwdTest.py b/resources/libraries/python/DPDK/L2fwdTest.py index aaa44358c3..70ca93c512 100644 --- a/resources/libraries/python/DPDK/L2fwdTest.py +++ b/resources/libraries/python/DPDK/L2fwdTest.py @@ -16,7 +16,7 @@ DUT nodes. """ from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.topology import NodeType, Topology diff --git a/resources/libraries/python/DPDK/L3fwdTest.py b/resources/libraries/python/DPDK/L3fwdTest.py index 0a22fe6b91..623075297b 100644 --- a/resources/libraries/python/DPDK/L3fwdTest.py +++ b/resources/libraries/python/DPDK/L3fwdTest.py @@ -16,7 +16,7 @@ This module exists to provide the l3fwd test for DPDK on topology nodes. """ from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.topology import NodeType, Topology diff --git a/resources/libraries/python/DUTSetup.py b/resources/libraries/python/DUTSetup.py index 631bff4e4a..69594ef36a 100644 --- a/resources/libraries/python/DUTSetup.py +++ b/resources/libraries/python/DUTSetup.py @@ -15,7 +15,7 @@ from robot.api import logger -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.ssh import SSH, exec_cmd_no_error from resources.libraries.python.topology import NodeType, Topology diff --git a/resources/libraries/python/IPUtil.py b/resources/libraries/python/IPUtil.py index e215b301b9..cf7034c0fd 100644 --- a/resources/libraries/python/IPUtil.py +++ b/resources/libraries/python/IPUtil.py @@ -18,7 +18,7 @@ import re from ipaddress import IPv4Network, ip_address from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.ssh import exec_cmd_no_error, exec_cmd from resources.libraries.python.topology import Topology diff --git a/resources/libraries/python/IPv6Setup.py b/resources/libraries/python/IPv6Setup.py index 260c08b198..72aeb305a2 100644 --- a/resources/libraries/python/IPv6Setup.py +++ b/resources/libraries/python/IPv6Setup.py @@ -18,7 +18,7 @@ from robot.api import logger from resources.libraries.python.ssh import SSH from resources.libraries.python.topology import NodeType, Topology -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.VatExecutor import VatTerminal, VatExecutor diff --git a/resources/libraries/python/KubernetesUtils.py b/resources/libraries/python/KubernetesUtils.py index 7a4784d42f..c3ebb4c095 100644 --- a/resources/libraries/python/KubernetesUtils.py +++ b/resources/libraries/python/KubernetesUtils.py @@ -15,7 +15,7 @@ from time import sleep -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.topology import NodeType from resources.libraries.python.ssh import SSH, exec_cmd_no_error from resources.libraries.python.CpuUtils import CpuUtils diff --git a/resources/libraries/python/PapiExecutor.py b/resources/libraries/python/PapiExecutor.py index 75bdde0ddf..ad0de27b82 100644 --- a/resources/libraries/python/PapiExecutor.py +++ b/resources/libraries/python/PapiExecutor.py @@ -19,7 +19,7 @@ import json from paramiko.ssh_exception import SSHException from robot.api import logger -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.PapiErrors import PapiInitError, \ PapiJsonFileError, PapiCommandError, PapiCommandInputError # TODO: from resources.libraries.python.PapiHistory import PapiHistory diff --git a/resources/libraries/python/QemuUtils.py b/resources/libraries/python/QemuUtils.py index 037d0de58c..6fad6ed8b7 100644 --- a/resources/libraries/python/QemuUtils.py +++ b/resources/libraries/python/QemuUtils.py @@ -23,7 +23,7 @@ from distutils.version import StrictVersion from robot.api import logger from resources.libraries.python.ssh import SSH, SSHTimeout -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.DUTSetup import DUTSetup from resources.libraries.python.topology import NodeType, Topology diff --git a/resources/libraries/python/SFC/SFCTest.py b/resources/libraries/python/SFC/SFCTest.py index d4f77baa52..3794d3a2a1 100644 --- a/resources/libraries/python/SFC/SFCTest.py +++ b/resources/libraries/python/SFC/SFCTest.py @@ -17,7 +17,7 @@ the NSH SFC functional test. """ from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants as con +from resources.libraries.python.Constants import Constants as con from resources.libraries.python.topology import Topology diff --git a/resources/libraries/python/SFC/SetupSFCTest.py b/resources/libraries/python/SFC/SetupSFCTest.py index 0ba197115d..7daf49c82d 100644 --- a/resources/libraries/python/SFC/SetupSFCTest.py +++ b/resources/libraries/python/SFC/SetupSFCTest.py @@ -26,7 +26,7 @@ from robot.api import logger from robot.libraries.BuiltIn import BuiltIn from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants as con +from resources.libraries.python.Constants import Constants as con from resources.libraries.python.topology import NodeType from resources.libraries.python.topology import Topology diff --git a/resources/libraries/python/SetupFramework.py b/resources/libraries/python/SetupFramework.py index 46b8597e87..9b50b90bc5 100644 --- a/resources/libraries/python/SetupFramework.py +++ b/resources/libraries/python/SetupFramework.py @@ -27,7 +27,7 @@ from robot.api import logger from robot.libraries.BuiltIn import BuiltIn from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants as con +from resources.libraries.python.Constants import Constants as con from resources.libraries.python.topology import NodeType __all__ = ["SetupFramework"] diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index 10fee9afbf..ea587d7558 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -17,7 +17,7 @@ from robot.api import logger from robot.libraries.BuiltIn import BuiltIn from .DropRateSearch import DropRateSearch -from .constants import Constants +from .Constants import Constants from .ssh import SSH from .topology import NodeType from .topology import NodeSubTypeTG diff --git a/resources/libraries/python/TrafficScriptExecutor.py b/resources/libraries/python/TrafficScriptExecutor.py index db5e434b42..7b5368fa9f 100644 --- a/resources/libraries/python/TrafficScriptExecutor.py +++ b/resources/libraries/python/TrafficScriptExecutor.py @@ -13,7 +13,7 @@ """Traffic script executor library.""" -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.ssh import SSH __all__ = ['TrafficScriptExecutor'] diff --git a/resources/libraries/python/VPPUtil.py b/resources/libraries/python/VPPUtil.py index 82fded30b4..b3f471a33d 100644 --- a/resources/libraries/python/VPPUtil.py +++ b/resources/libraries/python/VPPUtil.py @@ -17,7 +17,7 @@ import time from robot.api import logger -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.DUTSetup import DUTSetup from resources.libraries.python.PapiExecutor import PapiExecutor from resources.libraries.python.PapiErrors import PapiError diff --git a/resources/libraries/python/VatExecutor.py b/resources/libraries/python/VatExecutor.py index 1f7a6f8d6d..0e40266f1c 100644 --- a/resources/libraries/python/VatExecutor.py +++ b/resources/libraries/python/VatExecutor.py @@ -20,7 +20,7 @@ from paramiko.ssh_exception import SSHException from robot.api import logger from resources.libraries.python.ssh import SSH, SSHTimeout -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.VatHistory import VatHistory __all__ = ['VatExecutor'] diff --git a/resources/libraries/python/VppConfigGenerator.py b/resources/libraries/python/VppConfigGenerator.py index db21875f3c..154e2e9095 100644 --- a/resources/libraries/python/VppConfigGenerator.py +++ b/resources/libraries/python/VppConfigGenerator.py @@ -17,7 +17,7 @@ import re import time from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.DUTSetup import DUTSetup from resources.libraries.python.topology import NodeType from resources.libraries.python.topology import Topology diff --git a/resources/libraries/python/honeycomb/BGP.py b/resources/libraries/python/honeycomb/BGP.py index fa51b8727b..37a9cb6558 100644 --- a/resources/libraries/python/honeycomb/BGP.py +++ b/resources/libraries/python/honeycomb/BGP.py @@ -13,7 +13,7 @@ """Keywords to manipulate BGP configuration using Honeycomb REST API.""" -from resources.libraries.python.constants import Constants as Const +from resources.libraries.python.Constants import Constants as Const from resources.libraries.python.HTTPRequest import HTTPCodes from resources.libraries.python.honeycomb.HoneycombSetup import HoneycombError from resources.libraries.python.honeycomb.HoneycombUtil \ diff --git a/resources/libraries/python/honeycomb/HcPersistence.py b/resources/libraries/python/honeycomb/HcPersistence.py index ffa850fc9e..1627375f72 100644 --- a/resources/libraries/python/honeycomb/HcPersistence.py +++ b/resources/libraries/python/honeycomb/HcPersistence.py @@ -15,7 +15,7 @@ from robot.api import logger -from resources.libraries.python.constants import Constants as Const +from resources.libraries.python.Constants import Constants as Const from resources.libraries.python.honeycomb.HoneycombUtil import HoneycombError from resources.libraries.python.ssh import SSH from resources.libraries.python.topology import NodeType diff --git a/resources/libraries/python/honeycomb/HoneycombSetup.py b/resources/libraries/python/honeycomb/HoneycombSetup.py index 45050747ee..b4617eb42a 100644 --- a/resources/libraries/python/honeycomb/HoneycombSetup.py +++ b/resources/libraries/python/honeycomb/HoneycombSetup.py @@ -22,7 +22,7 @@ from robot.api import logger from resources.libraries.python.HTTPRequest import HTTPRequest, HTTPCodes, \ HTTPRequestError -from resources.libraries.python.constants import Constants as Const +from resources.libraries.python.Constants import Constants as Const from resources.libraries.python.honeycomb.HoneycombUtil import HoneycombError from resources.libraries.python.honeycomb.HoneycombUtil \ import HoneycombUtil as HcUtil diff --git a/resources/libraries/python/honeycomb/HoneycombUtil.py b/resources/libraries/python/honeycomb/HoneycombUtil.py index 52670b5390..59483f4672 100644 --- a/resources/libraries/python/honeycomb/HoneycombUtil.py +++ b/resources/libraries/python/honeycomb/HoneycombUtil.py @@ -29,7 +29,7 @@ from robot.api import logger from resources.libraries.python.ssh import SSH from resources.libraries.python.HTTPRequest import HTTPRequest -from resources.libraries.python.constants import Constants as Const +from resources.libraries.python.Constants import Constants as Const @unique diff --git a/resources/libraries/python/honeycomb/Performance.py b/resources/libraries/python/honeycomb/Performance.py index 391607ff04..b81b9fd3db 100644 --- a/resources/libraries/python/honeycomb/Performance.py +++ b/resources/libraries/python/honeycomb/Performance.py @@ -14,7 +14,7 @@ """Implementation of keywords for testing Honeycomb performance.""" from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants as Const +from resources.libraries.python.Constants import Constants as Const from resources.libraries.python.honeycomb.HoneycombUtil import HoneycombError diff --git a/resources/tools/wrk/wrk.py b/resources/tools/wrk/wrk.py index a891fd6ae9..43355b99fb 100644 --- a/resources/tools/wrk/wrk.py +++ b/resources/tools/wrk/wrk.py @@ -24,7 +24,7 @@ from robot.api import logger from resources.libraries.python.ssh import SSH from resources.libraries.python.topology import NodeType from resources.libraries.python.CpuUtils import CpuUtils -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.tools.wrk.wrk_traffic_profile_parser import WrkTrafficProfile from resources.tools.wrk.wrk_errors import WrkError -- 2.16.6