summaryrefslogtreecommitdiffstats
path: root/scripts/automation/regression/trex.py
blob: 36e204af2d43ac09e9d57544d8864d27b9a542ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/router/bin/python

import os
import sys
import subprocess
import misc_methods
import re
import signal
import time
from CProgressDisp import TimedProgressBar
from stateful_tests.tests_exceptions import TRexInUseError
import datetime
import copy
import outer_packages
import yaml

class CTRexScenario:
    modes            = set() # list of modes of this setup: loopback, virtual etc.
    server_logs      = False
    is_test_list     = False
    is_init          = False
    is_stl_init      = False
    trex_crashed     = False
    configuration    = None
    trex             = None
    stl_trex         = None
    stl_ports_map    = None
    stl_init_error   = None
    router           = None
    router_cfg       = None
    daemon_log_lines = 0
    setup_name       = None
    setup_dir        = None
    router_image     = None
    trex_version     = None
    scripts_path     = None
    benchmark        = None
    report_dir       = 'reports'
    # logger         = None
    test_types       = {'functional_tests': [], 'stateful_tests': [], 'stateless_tests': []}
    pkg_updated      = False
    GAManager        = None
    no_daemon        = False
    debug_image      = False
    test             = None
    json_verbose     = False
    elk              = None
    elk_info         = None
    global_cfg       = None

def copy_elk_info ():
   assert(CTRexScenario.elk_info)
   d = copy.deepcopy(CTRexScenario.elk_info);

   timestamp = datetime.datetime.now() - datetime.timedelta(hours=2); # Jerusalem timeZone, Kibana does not have feature to change timezone 
   d['timestamp']=timestamp.strftime("%Y-%m-%d %H:%M:%S")
   return(d)

global_cfg = 'cfg/global_regression_cfg.yaml'
if not os.path.exists(global_cfg):
    raise Exception('Global configuration file %s is missing' % global_cfg)
with open(global_cfg) as f:
    CTRexScenario.global_cfg = yaml.safe_load(f.read())