1823b8294SYaroslav Brustinov#!/router/bin/python
2823b8294SYaroslav Brustinov
3823b8294SYaroslav Brustinovimport os
4823b8294SYaroslav Brustinovimport sys
5823b8294SYaroslav Brustinovimport subprocess
6823b8294SYaroslav Brustinovimport misc_methods
7823b8294SYaroslav Brustinovimport re
8823b8294SYaroslav Brustinovimport signal
9823b8294SYaroslav Brustinovimport time
10823b8294SYaroslav Brustinovfrom CProgressDisp import TimedProgressBar
11afefddfaSYaroslav Brustinovfrom stateful_tests.tests_exceptions import TRexInUseError
12823b8294SYaroslav Brustinovimport datetime
13420216e5SHanoh Haimimport copy
14ce9cf273SYaroslav Brustinovimport outer_packages
15ce9cf273SYaroslav Brustinovimport yaml
16823b8294SYaroslav Brustinov
17afefddfaSYaroslav Brustinovclass CTRexScenario:
18afefddfaSYaroslav Brustinov    modes            = set() # list of modes of this setup: loopback, virtual etc.
19afefddfaSYaroslav Brustinov    server_logs      = False
20afefddfaSYaroslav Brustinov    is_test_list     = False
21afefddfaSYaroslav Brustinov    is_init          = False
22afefddfaSYaroslav Brustinov    is_stl_init      = False
23afefddfaSYaroslav Brustinov    trex_crashed     = False
24afefddfaSYaroslav Brustinov    configuration    = None
25afefddfaSYaroslav Brustinov    trex             = None
26afefddfaSYaroslav Brustinov    stl_trex         = None
273f747bcfSYaroslav Brustinov    stl_ports_map    = None
283f747bcfSYaroslav Brustinov    stl_init_error   = None
29afefddfaSYaroslav Brustinov    router           = None
30afefddfaSYaroslav Brustinov    router_cfg       = None
31afefddfaSYaroslav Brustinov    daemon_log_lines = 0
32afefddfaSYaroslav Brustinov    setup_name       = None
33afefddfaSYaroslav Brustinov    setup_dir        = None
34afefddfaSYaroslav Brustinov    router_image     = None
35afefddfaSYaroslav Brustinov    trex_version     = None
36afefddfaSYaroslav Brustinov    scripts_path     = None
37afefddfaSYaroslav Brustinov    benchmark        = None
38afefddfaSYaroslav Brustinov    report_dir       = 'reports'
39afefddfaSYaroslav Brustinov    # logger         = None
40afefddfaSYaroslav Brustinov    test_types       = {'functional_tests': [], 'stateful_tests': [], 'stateless_tests': []}
412ef9113cSYaroslav Brustinov    pkg_updated      = False
42e831a539SYaroslav Brustinov    GAManager        = None
43fad99b60SYaroslav Brustinov    no_daemon        = False
44e058f6e0SYaroslav Brustinov    debug_image      = False
45a76479bcSYaroslav Brustinov    test             = None
460d42a434SYaroslav Brustinov    json_verbose     = False
47420216e5SHanoh Haim    elk              = None
48420216e5SHanoh Haim    elk_info         = None
49ce9cf273SYaroslav Brustinov    global_cfg       = None
50420216e5SHanoh Haim
51420216e5SHanoh Haimdef copy_elk_info ():
52420216e5SHanoh Haim   assert(CTRexScenario.elk_info)
53420216e5SHanoh Haim   d = copy.deepcopy(CTRexScenario.elk_info);
54420216e5SHanoh Haim
558df11b2eSHanoh Haim   timestamp = datetime.datetime.now() - datetime.timedelta(hours=2); # Jerusalem timeZone, Kibana does not have feature to change timezone
56420216e5SHanoh Haim   d['timestamp']=timestamp.strftime("%Y-%m-%d %H:%M:%S")
57420216e5SHanoh Haim   return(d)
58420216e5SHanoh Haim
59ce9cf273SYaroslav Brustinovglobal_cfg = 'cfg/global_regression_cfg.yaml'
60ce9cf273SYaroslav Brustinovif not os.path.exists(global_cfg):
61ce9cf273SYaroslav Brustinov    raise Exception('Global configuration file %s is missing' % global_cfg)
62ce9cf273SYaroslav Brustinovwith open(global_cfg) as f:
63ce9cf273SYaroslav Brustinov    CTRexScenario.global_cfg = yaml.safe_load(f.read())
64420216e5SHanoh Haim
65420216e5SHanoh Haim
66afefddfaSYaroslav Brustinov
67823b8294SYaroslav Brustinov
68