1*** Settings ***
2Documentation    Module to test network stability.
3...              By default running HTX mdt.bu profile for stress test.
4
5Resource         ../syslib/utils_os.robot
6Library          ../syslib/utils_keywords.py
7
8Test Setup      Pre Test Case Execution
9Test Teardown   Post Test Case Execution
10
11*** Variables ****
12
13${stack_mode}        skip
14
15# Default duration and interval of HTX exerciser to run.
16${HTX_DURATION}     2 hours
17${HTX_INTERVAL}     15 min
18
19# Default iteration HTX exerciser to run.
20${HTX_LOOP}         4
21
22*** Test Cases ***
23
24Network Stability Test
25    [Documentation]  Execute network stress in loop.
26    [Tags]  Network_Stability_Test
27
28    # Run the network stress test HTX_LOOP times in loop.
29    Repeat Keyword  ${HTX_LOOP} times  Execute Network Test
30
31
32*** Keywords ***
33
34Execute Network Test
35    [Documentation]  Execute network stress test.
36    # Test Flow:
37    #              - Power on
38    #              - Establish SSH connection session
39    #              - Create HTX mdt profile
40    #              - Run HTX exerciser
41    #              - Inject network activity on BMC
42    #              - Check HTX status for errors
43    #              - Shutdown HTX if no error when timer expires
44
45    Boot To OS
46
47    # Post Power off and on, the OS SSH session needs to be established.
48    Login To OS
49
50    Rprint Timen  Create HTX mdt profile.
51    ${profile}=  Execute Command On OS  htxcmdline -createmdt
52    Rprint Timen  ${profile}
53    Should Contain  ${profile}  mdts are created successfully
54
55    Rprint Timen  Start HTX mdt profile execution.
56    ${htx_run}=  Execute Command On OS  htxcmdline -run -mdt mdt.bu
57    Rprint Timen  ${htx_run}
58    Should Contain  ${htx_run}  Activated
59
60    # HTX is running, inject network traffic and check every HTX_INTERVAL
61    ${status}=  Run Until Keyword Fails  ${HTX_DURATION}  ${HTX_INTERVAL}
62    ...  Start Network Test
63
64    Run Keyword If  '${status}' == '{False}'
65    ...  Fail  Network is unstable. Please check for errors.
66
67    Shutdown HTX Exerciser
68
69    Rprint Timen  HTX Test ran for: ${HTX_DURATION}
70
71
72Start Network Test
73    [Documentation]  Start network stress test.
74    BMC Network Payload
75    Check HTX Run Status
76
77
78BMC Network Payload
79    [Documentation]  Start creating network activity over BMC network.
80
81    # REST GET enumerate call.
82    OpenBMC Get Request  /xyz/openbmc_project/enumerate  quiet=${1}
83
84    # Upload 32 MB data via REST to BMC.
85    REST Upload File To BMC
86
87
88Check HTX Run Status
89    [Documentation]  Get HTX exerciser status and check for error.
90
91    Rprint Timen  Check HTX mdt Status and error.
92    ${status}=  Execute Command On OS  htxcmdline -status -mdt mdt.bu
93    Log  ${status}
94    Rprint Timen  ${status}
95
96    ${errlog}=  Execute Command On OS  htxcmdline -geterrlog
97    Log  ${errlog}
98    Rprint Timen  ${errlog}
99
100    Should Contain  ${errlog}  file </tmp/htxerr> is empty
101
102
103Shutdown HTX Exerciser
104    [Documentation]  Shut down HTX exerciser run.
105
106    Rprint Timen  Shutdown HTX Run.
107    ${shutdown}=  Execute Command On OS  htxcmdline -shutdown -mdt mdt.bu
108    Rprint Timen  ${shutdown}
109    Should Contain  ${shutdown}  shutdown successfully
110
111
112Pre Test Case Execution
113    [Documentation]  Do the initial test setup.
114    # 1. Check if HTX tool exist.
115    # 2. Power on
116
117    Boot To OS
118    Tool Exist  htxcmdline
119
120
121Post Test Case Execution
122    [Documentation]  Do the post test teardown.
123    # 1. Shut down HTX exerciser if test Failed.
124    # 2. Capture FFDC on test failure.
125    # 3. Close all open SSH connections.
126
127    Run Keyword If  '${TEST_STATUS}' == 'FAIL'
128    ...  Shutdown HTX Exerciser
129
130    FFDC On Test Case Fail
131    Close All Connections
132
133