FIX: Static variables all over the place for per patch 05/17705/1
authorPeter Mikus <pmikus@cisco.com>
Wed, 20 Feb 2019 06:26:05 +0000 (06:26 +0000)
committerPeter Mikus <pmikus@cisco.com>
Wed, 20 Feb 2019 06:26:05 +0000 (06:26 +0000)
- Incredible why is it so hard to write scripts not hardcoding
anything.

Change-Id: I48cf2cc3d25f9665a9ff7ca26756d3b70cdd2f9c
Signed-off-by: Peter Mikus <pmikus@cisco.com>
resources/libraries/bash/entry/per_patch_device.sh
resources/libraries/bash/function/per_patch.sh
resources/tools/scripts/compare_perpatch.py

index 3f52bcb..1120331 100644 (file)
@@ -53,5 +53,5 @@ select_vpp_device_tags || die
 compose_pybot_arguments || die
 run_pybot || die
 copy_archives || die
 compose_pybot_arguments || die
 run_pybot || die
 copy_archives || die
-archive_parse_test_results "csit_current" || die
+archive_test_results "csit_current" || die
 die_on_pybot_error || die
 die_on_pybot_error || die
index 83e8427..27fa0cf 100644 (file)
 
 set -exuo pipefail
 
 
 set -exuo pipefail
 
-# This library defines functions used mainly by "per_patch_perf.sh" entry script.
+# This library defines functions used mainly by per patch entry scripts.
 # Generally, the functions assume "common.sh" library has been sourced already.
 
 # Keep functions ordered alphabetically, please.
 
 # Generally, the functions assume "common.sh" library has been sourced already.
 
 # Keep functions ordered alphabetically, please.
 
-# TODO: Add a link to bash style guide.
-
-
-function archive_parse_test_results () {
+function archive_test_results () {
 
     set -exuo pipefail
 
     # Arguments:
     # - ${1}: Directory to archive to. Required. Parent has to exist.
 
     set -exuo pipefail
 
     # Arguments:
     # - ${1}: Directory to archive to. Required. Parent has to exist.
+    # Variable set:
+    # - TARGET - Target directory.
     # Variables read:
     # - ARCHIVE_DIR - Path to where robot result files are created in.
     # - VPP_DIR - Path to existing directory, root for to relative paths.
     # Variables read:
     # - ARCHIVE_DIR - Path to where robot result files are created in.
     # - VPP_DIR - Path to existing directory, root for to relative paths.
@@ -34,17 +33,33 @@ function archive_parse_test_results () {
     # - ${1} - Created, and robot and parsing files are moved/created there.
     # Functions called:
     # - die - Print to stderr and exit, defined in common.sh
     # - ${1} - Created, and robot and parsing files are moved/created there.
     # Functions called:
     # - die - Print to stderr and exit, defined in common.sh
-    # - parse_bmrr_results - See definition in this file.
 
     cd "${VPP_DIR}" || die "Change directory command failed."
 
     cd "${VPP_DIR}" || die "Change directory command failed."
-    target="$(readlink -f "$1")"
-    mkdir -p "${target}" || die "Directory creation failed."
+    TARGET="$(readlink -f "$1")"
+    mkdir -p "${TARGET}" || die "Directory creation failed."
     for filename in "output.xml" "log.html" "report.html"; do
     for filename in "output.xml" "log.html" "report.html"; do
-        mv "${ARCHIVE_DIR}/${filename}" "${target}/${filename}" || {
+        mv "${ARCHIVE_DIR}/${filename}" "${TARGET}/${filename}" || {
             die "Attempt to move '${filename}' failed."
         }
     done
             die "Attempt to move '${filename}' failed."
         }
     done
-    parse_bmrr_results "${target}" || {
+}
+
+
+function archive_parse_test_results () {
+
+    set -exuo pipefail
+
+    # Arguments:
+    # - ${1}: Directory to archive to. Required. Parent has to exist.
+    # Variables read:
+    # - TARGET - Target directory.
+    # Functions called:
+    # - die - Print to stderr and exit, defined in common.sh
+    # - archive_test_results - Archiving results.
+    # - parse_bmrr_results - See definition in this file.
+
+    archive_test_results "$1" || die
+    parse_bmrr_results "${TARGET}" || {
         die "The function should have died on error."
     }
 }
         die "The function should have died on error."
     }
 }
index 1f8a1cf..3bda338 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Cisco and/or its affiliates.
+# Copyright (c) 2019 Cisco and/or its affiliates.
 # 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:
 # 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:
@@ -57,7 +57,7 @@ while 1:
     except IOError:
         break
     num_lines = len(parent_lines)
     except IOError:
         break
     num_lines = len(parent_lines)
-    filename = "csit_new/{iter}/results.txt".format(iter=iteration)
+    filename = "csit_current/{iter}/results.txt".format(iter=iteration)
     with open(filename) as new_file:
         new_lines = new_file.readlines()
     if num_lines != len(new_lines):
     with open(filename) as new_file:
         new_lines = new_file.readlines()
     if num_lines != len(new_lines):
@@ -82,7 +82,7 @@ for test_index in range(num_tests):
         new_values.extend(
             json.loads(new_iterations[iteration_index][test_index]))
     print "TRACE pre-hack parent: {p}".format(p=parent_values)
         new_values.extend(
             json.loads(new_iterations[iteration_index][test_index]))
     print "TRACE pre-hack parent: {p}".format(p=parent_values)
-    print "TRACE pre-hack new: {n}".format(n=new_values)
+    print "TRACE pre-hack current: {n}".format(n=new_values)
     parent_values = hack(parent_values)
     new_values = hack(new_values)
     parent_max = BitCountingMetadataFactory.find_max_value(parent_values)
     parent_values = hack(parent_values)
     new_values = hack(new_values)
     parent_max = BitCountingMetadataFactory.find_max_value(parent_values)
@@ -93,9 +93,9 @@ for test_index in range(num_tests):
     new_factory = BitCountingMetadataFactory(val_max, parent_stats.avg)
     new_stats = new_factory.from_data(new_values)
     print "TRACE parent: {p}".format(p=parent_values)
     new_factory = BitCountingMetadataFactory(val_max, parent_stats.avg)
     new_stats = new_factory.from_data(new_values)
     print "TRACE parent: {p}".format(p=parent_values)
-    print "TRACE new: {n}".format(n=new_values)
+    print "TRACE current: {n}".format(n=new_values)
     print "DEBUG parent: {p}".format(p=parent_stats)
     print "DEBUG parent: {p}".format(p=parent_stats)
-    print "DEBUG new: {n}".format(n=new_stats)
+    print "DEBUG current: {n}".format(n=new_stats)
     common_max = max(parent_stats.avg, new_stats.avg)
     difference = (new_stats.avg - parent_stats.avg) / common_max
     print "DEBUG difference: {d}%".format(d=100 * difference)
     common_max = max(parent_stats.avg, new_stats.avg)
     difference = (new_stats.avg - parent_stats.avg) / common_max
     print "DEBUG difference: {d}%".format(d=100 * difference)