Allow CRC checking to be controlled via env var 18/21718/5
authorVratko Polak <vrpolak@cisco.com>
Wed, 4 Sep 2019 11:13:08 +0000 (13:13 +0200)
committerVratko Polak <vrpolak@cisco.com>
Thu, 5 Sep 2019 08:25:18 +0000 (08:25 +0000)
The plan is to override the default in some (but not all) jobs.
The csit-vpp jobs shall do the checking, but vpp-csit jobs shall not
(except api-crc job of course) in order to confirm benign changes.

Change-Id: If59d17991de3fb0e847113a87e0533a8ee62af7f
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
resources/libraries/python/PapiExecutor.py
tests/__init__.robot

index ef04787..0a714c1 100644 (file)
@@ -166,8 +166,20 @@ class PapiSocketExecutor(object):
         if self.vpp_instance:
             return
         cls = self.__class__  # Shorthand for setting class fields.
-        tmp_dir = tempfile.mkdtemp(dir="/tmp")
+        fail_on_mismatch = Constants.CRC_MISMATCH_FAILS_TEST
+        try:
+            from robot.libraries.BuiltIn import BuiltIn
+            from_robot = BuiltIn().get_variable_value(
+                "\${crc_mismatch_fails}", None)
+            if from_robot is not None:
+                # Robot interprets env vars as strings.
+                fail_on_mismatch = not from_robot.lower() in ("false", "n", "0")
+        except (ImportError, AttributeError):
+            # If robot is not installed or not running, or value is not string,
+            # the Constants value applies.
+            pass
         package_path = None
+        tmp_dir = tempfile.mkdtemp(dir="/tmp")
         try:
             # Pack, copy and unpack Python part of VPP installation from _node.
             # TODO: Use rsync or recursive version of ssh.scp_node instead?
@@ -187,7 +199,8 @@ class PapiSocketExecutor(object):
             api_json_directory = tmp_dir + "/usr/share/vpp/api"
             # Perform initial checks before .api.json files are gone,
             # by creating the checker instance.
-            cls.crc_checker = VppApiCrcChecker(api_json_directory)
+            cls.crc_checker = VppApiCrcChecker(
+                api_json_directory, fail_on_mismatch=fail_on_mismatch)
             # When present locally, we finally can find the installation path.
             package_path = glob.glob(tmp_dir + installed_papi_glob)[0]
             # Package path has to be one level above the vpp_papi directory.
index 2e17675..e409114 100644 (file)
 
 *** Settings ***
 | Documentation | Set global variables common to all tests.
+| # The two paths below assume working directory when pybot is started,
+| # but we cannot use ${CURDIR} as this file may be copied under generated/.
 | Resource | resources/libraries/robot/robot_enhancements.robot
+| Variables | resources/libraries/python/Constants.py
 | Suite Setup | Set Common Variables
 
 *** Keywords ***
@@ -33,3 +36,5 @@
 | | Ensure Global Variable | perf_trial_multiplicity | 10
 | | Ensure Global Variable | perf_trial_duration | 1
 | | Ensure Global Variable | dut1_uuid | ${EMPTY}
+| | # Avoiding dangers of case insensitive Robot variable names.
+| | Ensure Global Variable | crc_mismatch_fails | ${CRC_MISMATCH_FAILS_TEST}