Resource variables and common HTX keywords

Resolves  openbmc/openbmc-test-automation#633

Change-Id: I1d79c74d34f4ac3ee9c81d4e270486df1cfa34f0
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/systest/htx_hardbootme_test.robot b/systest/htx_hardbootme_test.robot
index 38c60a1..db9d25c 100644
--- a/systest/htx_hardbootme_test.robot
+++ b/systest/htx_hardbootme_test.robot
@@ -2,7 +2,6 @@
 Documentation    Stress the system using HTX exerciser.
 
 Resource         ../syslib/utils_os.robot
-Library          ../lib/gen_robot_print.py
 
 Test Setup      Pre Test Case Execution
 Test Teardown   Post Test Case Execution
@@ -11,21 +10,6 @@
 
 ${stack_mode}        skip
 
-# Default duration and interval of HTX exerciser to run.
-${HTX_DURATION}      2 hours
-${HTX_INTERVAL}      15 min
-
-# Default hardbootme loop times HTX exerciser to run.
-${HTX_LOOP}          4
-
-# User-defined halt on error.
-${HTX_KEEP_RUNNING}  ${0}
-
-# User-defined MDT profile.
-# There are a few stanzas in the HTX test exerciser that need to be removed
-# temporarily and manually built and executed.
-${HTX_MDT_PROFILE}  mdt.bu
-
 *** Test Cases ***
 
 Hard Bootme Test
@@ -77,69 +61,6 @@
     ...  AND  Sleep  ${HTX_INTERVAL}
 
 
-Check HTX Run Status
-    [Documentation]  Get HTX exerciser status and check for error.
-
-    Rprint Timen  Collect HTX status and error log files.
-    Run Key U  Collect HTX Log Files
-
-    Rprint Timen  Check HTX mdt Status and error.
-    ${status}=  Execute Command On OS
-    ...  htxcmdline -status -mdt ${HTX_MDT_PROFILE}
-    Log  ${status}
-    Rprint Timen  ${status}
-
-    ${errlog}=  Execute Command On OS  htxcmdline -geterrlog
-    Log  ${errlog}
-    Rprint Timen  ${errlog}
-
-    Should Contain  ${errlog}  file </tmp/htxerr> is empty
-
-
-Create Default MDT Profile
-    [Documentation]  Create default mdt.bu profile and run.
-
-    Rprint Timen  Create HTX mdt profile.
-
-    ${profile}=  Execute Command On OS  htxcmdline -createmdt
-    Rprint Timen  ${profile}
-    Should Contain  ${profile}  mdts are created successfully
-
-
-Run MDT Profile
-    [Documentation]  Load user pre-defined MDT profile.
-
-    Rprint Timen  Start HTX mdt profile execution.
-    ${htx_run}=  Execute Command On OS
-    ...  htxcmdline -run -mdt ${HTX_MDT_PROFILE}
-    Rprint Timen  ${htx_run}
-    Should Contain  ${htx_run}  Activated
-
-
-Shutdown HTX Exerciser
-    [Documentation]  Shut down HTX exerciser run.
-
-    Rprint Timen  Shutdown HTX Run
-    ${shutdown}=  Execute Command On OS
-    ...  htxcmdline -shutdown -mdt ${HTX_MDT_PROFILE}
-    Rprint Timen  ${shutdown}
-    Should Contain  ${shutdown}  shutdown successfully
-
-
-Pre Test Case Execution
-    [Documentation]  Do the initial test setup.
-    # 1. Check if HTX tool exist.
-    # 2. Power on
-
-    Boot To OS
-    Tool Exist  htxcmdline
-
-    # Shutdown if HTX is running.
-    ${status}=  Run Keyword And Return Status  Is HTX Running
-    Run Keyword If  '${status}' == 'True'
-    ...  Shutdown HTX Exerciser
-
-
 Post Test Case Execution
     [Documentation]  Do the post test teardown.
     # 1. Shut down HTX exerciser if test Failed.
diff --git a/systest/network_stability_test.robot b/systest/network_stability_test.robot
index d2edbfd..cfc0119 100644
--- a/systest/network_stability_test.robot
+++ b/systest/network_stability_test.robot
@@ -12,13 +12,6 @@
 
 ${stack_mode}        skip
 
-# Default duration and interval of HTX exerciser to run.
-${HTX_DURATION}     2 hours
-${HTX_INTERVAL}     15 min
-
-# Default iteration HTX exerciser to run.
-${HTX_LOOP}         4
-
 *** Test Cases ***
 
 Network Stability Test
@@ -47,15 +40,10 @@
     # Post Power off and on, the OS SSH session needs to be established.
     Login To OS
 
-    Rprint Timen  Create HTX mdt profile.
-    ${profile}=  Execute Command On OS  htxcmdline -createmdt
-    Rprint Timen  ${profile}
-    Should Contain  ${profile}  mdts are created successfully
+    Run Keyword If  '${HTX_MDT_PROFILE}' == 'mdt.bu'
+    ...  Create Default MDT Profile
 
-    Rprint Timen  Start HTX mdt profile execution.
-    ${htx_run}=  Execute Command On OS  htxcmdline -run -mdt mdt.bu
-    Rprint Timen  ${htx_run}
-    Should Contain  ${htx_run}  Activated
+    Run MDT Profile
 
     # HTX is running, inject network traffic and check every HTX_INTERVAL
     ${status}=  Run Until Keyword Fails  ${HTX_DURATION}  ${HTX_INTERVAL}
@@ -85,48 +73,15 @@
     REST Upload File To BMC
 
 
-Check HTX Run Status
-    [Documentation]  Get HTX exerciser status and check for error.
-
-    Rprint Timen  Check HTX mdt Status and error.
-    ${status}=  Execute Command On OS  htxcmdline -status -mdt mdt.bu
-    Log  ${status}
-    Rprint Timen  ${status}
-
-    ${errlog}=  Execute Command On OS  htxcmdline -geterrlog
-    Log  ${errlog}
-    Rprint Timen  ${errlog}
-
-    Should Contain  ${errlog}  file </tmp/htxerr> is empty
-
-
-Shutdown HTX Exerciser
-    [Documentation]  Shut down HTX exerciser run.
-
-    Rprint Timen  Shutdown HTX Run.
-    ${shutdown}=  Execute Command On OS  htxcmdline -shutdown -mdt mdt.bu
-    Rprint Timen  ${shutdown}
-    Should Contain  ${shutdown}  shutdown successfully
-
-
-Pre Test Case Execution
-    [Documentation]  Do the initial test setup.
-    # 1. Check if HTX tool exist.
-    # 2. Power on
-
-    Boot To OS
-    Tool Exist  htxcmdline
-
-
 Post Test Case Execution
     [Documentation]  Do the post test teardown.
     # 1. Shut down HTX exerciser if test Failed.
     # 2. Capture FFDC on test failure.
     # 3. Close all open SSH connections.
 
-    Run Keyword If  '${TEST_STATUS}' == 'FAIL'
+    # Keep HTX running if user set HTX_KEEP_RUNNING to 1.
+    Run Keyword If  '${TEST_STATUS}' == 'FAIL' and ${HTX_KEEP_RUNNING} == ${0}
     ...  Shutdown HTX Exerciser
 
     FFDC On Test Case Fail
     Close All Connections
-