performance integration with GA
authorimarom <[email protected]>
Sun, 30 Oct 2016 14:52:36 +0000 (16:52 +0200)
committerimarom <[email protected]>
Sun, 30 Oct 2016 14:52:36 +0000 (16:52 +0200)
Signed-off-by: imarom <[email protected]>
scripts/automation/regression/stateless_tests/stl_performance_test.py
scripts/automation/regression/trex_unit_test.py

index ac39ee6..ef95c86 100644 (file)
@@ -54,12 +54,24 @@ class PerformanceReport(object):
 
         return self.GOLDEN_NORMAL
 
+    def report_to_analytics(self, ga, golden_mpps):
+        print("\n* Reporting to GA *\n")
+        ga.gaAddTestQuery(TestName = self.scenario,
+                          TRexMode = 'stl',
+                          SetupName = self.machine_name,
+                          TestType = 'performance',
+                          Mppspc = self.avg_mpps_per_core,
+                          GoldenMin = golden_mpps['min'],
+                          GoldenMax = golden_mpps['max'])
+
+        ga.emptyAndReportQ()
 
 
 class STLPerformance_Test(CStlGeneral_Test):
     """Tests for stateless client"""
 
     def setUp(self):
+
         CStlGeneral_Test.setUp(self)
 
         self.c = CTRexScenario.stl_trex
@@ -233,7 +245,10 @@ class STLPerformance_Test(CStlGeneral_Test):
             report = self.execute_single_scenario_iteration(scenario_cfg)
             rc = report.check_golden(golden)
 
-            if rc == PerformanceReport.GOLDEN_NORMAL:
+            if (rc == PerformanceReport.GOLDEN_NORMAL) or (rc == PerformanceReport.GOLDEN_BETTER):
+                if self.GAManager:
+                    report.report_to_analytics(self.GAManager, golden)
+
                 return
 
             if rc == PerformanceReport.GOLDEN_BETTER:
@@ -315,7 +330,7 @@ class STLPerformance_Test(CStlGeneral_Test):
         avg_mpps_per_core = avg_mpps * (100.0 / avg_cpu)
 
         report = PerformanceReport(scenario            =  scenario_cfg['name'],
-                                   machine_name        =  os.uname()[1],
+                                   machine_name        =  CTRexScenario.setup_name,
                                    core_count          =  scenario_cfg['core_count'],
                                    avg_cpu             =  avg_cpu,
                                    avg_gbps            =  avg_gbps,
index 7c2e317..1f066fa 100755 (executable)
@@ -39,7 +39,7 @@ from trex import CTRexScenario
 from trex_stf_lib.trex_client import *
 from trex_stf_lib.trex_exceptions import *
 from trex_stl_lib.api import *
-from trex_stl_lib.utils.GAObjClass import GAmanager
+from trex_stl_lib.utils.GAObjClass import GAmanager_Regression
 import trex
 import socket
 from pprint import pprint
@@ -180,12 +180,20 @@ class CTRexTestConfiguringPlugin(Plugin):
         CTRexScenario.test  = options.test
         if self.collect_only or self.functional:
             return
+        
         if CTRexScenario.setup_dir and options.config_path:
             raise Exception('Please either define --cfg or use env. variable SETUP_DIR, not both.')
-        if not options.config_path and CTRexScenario.setup_dir:
-            options.config_path = CTRexScenario.setup_dir
-        if not options.config_path:
+
+        if not CTRexScenario.setup_dir and not options.config_path:
             raise Exception('Please specify path to config.yaml using --cfg parameter or env. variable SETUP_DIR')
+
+        if not options.config_path:
+            options.config_path = CTRexScenario.setup_dir
+        if not CTRexScenario.setup_dir:
+            CTRexScenario.setup_dir = options.config_path
+        
+        CTRexScenario.setup_name = os.path.basename(CTRexScenario.setup_dir)
+
         self.configuration = misc_methods.load_complete_config_file(os.path.join(options.config_path, 'config.yaml'))
         self.configuration.trex['trex_name'] = address_to_ip(self.configuration.trex['trex_name']) # translate hostname to ip
         self.benchmark     = misc_methods.load_benchmark_config_file(os.path.join(options.config_path, 'benchmark.yaml'))
@@ -213,14 +221,14 @@ class CTRexTestConfiguringPlugin(Plugin):
                 print('Could not connect to master daemon')
                 sys.exit(-1)
         if options.ga and CTRexScenario.setup_name:
-            CTRexScenario.GAManager  = GAmanager(GoogleID       = 'UA-75220362-4',
-                                                 UserID         = CTRexScenario.setup_name,
-                                                 QueueSize      = 100,
-                                                 Timeout        = 5, # seconds
-                                                 UserPermission = 1,
-                                                 BlockingMode   = 1,
-                                                 appName        = 'TRex',
-                                                 appVer         = '1.11.232')
+            CTRexScenario.GAManager  = GAmanager_Regression(GoogleID         = 'UA-75220362-3',
+                                                            AnalyticsUserID  = CTRexScenario.setup_name,
+                                                            QueueSize        = 100,
+                                                            Timeout          = 3,  # seconds
+                                                            UserPermission   = 1,
+                                                            BlockingMode     = 0,
+                                                            appName          = 'TRex',
+                                                            appVer           = CTRexScenario.trex_version)
 
 
     def begin (self):
@@ -319,7 +327,6 @@ if __name__ == "__main__":
     if not CTRexScenario.setup_dir:
         CTRexScenario.setup_dir = check_setup_path(os.path.join('setups', setup_dir))
 
-
     nose_argv = ['', '-s', '-v', '--exe', '--rednose', '--detailed-errors']
     test_client_package = False
     if '--test-client-package' in sys.argv: