Fix for bug 1669 -- SA02 robot test fails as threshold not reached
[osm/tests.git] / robot-systest / lib / vim_lib.robot
index a54448a..8e622c9 100644 (file)
@@ -24,8 +24,10 @@ Resource   %{ROBOT_DEVOPS_FOLDER}/lib/prometheus_lib.robot
 ${success_return_code}   0
 ${delete_max_wait_time}   1min
 ${delete_pol_time}   15sec
-${vim_status_max_wait_time}   2min
+${vim_status_max_wait_time}   3min
 ${vim_status_pol_time}   15sec
+${vim_opstate_max_wait_time}   40sec
+${vim_opstate_pol_time}   10sec
 
 
 *** Keywords ***
@@ -70,6 +72,13 @@ Check for VIM Target
     Should Not Be Equal As Strings  ${stdout}  ${vim_name}
 
 
+Check for VIM Target Metric
+    [Arguments]  ${vim_name}  ${prometheus_host}  ${prometheus_port}
+
+    ${vim_account_id}=  Get VIM Target ID  ${vim_name}
+    Wait Until Keyword Succeeds  ${vim_status_max_wait_time}  ${vim_status_pol_time}  Check If VIM Target Has Metric  ${vim_account_id}  ${prometheus_host}  ${prometheus_port}
+
+
 Check for VIM Target Status
     [Arguments]  ${vim_name}  ${prometheus_host}  ${prometheus_port}
 
@@ -86,8 +95,29 @@ Get VIM Target ID
     [Return]  ${stdout}
 
 
+Check VIM Target Operational State
+    [Arguments]  ${vim_name}
+
+    Wait Until Keyword Succeeds  ${vim_opstate_max_wait_time}  ${vim_opstate_pol_time}  Check If VIM Target Is Enabled  ${vim_name}
+
+
+Check If VIM Target Is Enabled
+    [Arguments]  ${vim_name}
+
+    ${rc}  ${stdout}=  Run and Return RC and Output  osm vim-list | grep " ${vim_name} " | awk '{print $6}'
+    Should Be Equal As Integers  ${rc}  ${success_return_code}
+    Should Be Equal As Strings  ${stdout}  ENABLED  msg=VIM Target '${vim_name}' is not enabled  values=false
+
+
 Check If VIM Target Is Available
     [Arguments]  ${vim_account_id}  ${prometheus_host}  ${prometheus_port}
 
     ${metric}=  Get Metric  ${prometheus_host}  ${prometheus_port}  osm_vim_status  vim_account_id=${vim_account_id}
     Should Be Equal As Integers  ${metric}  1  msg=VIM Target '${vim_account_id}' is not active  values=false
+
+
+Check If VIM Target Has Metric
+    [Arguments]  ${vim_account_id}  ${prometheus_host}  ${prometheus_port}
+
+    ${metric}=  Get Metric  ${prometheus_host}  ${prometheus_port}  osm_vim_status  vim_account_id=${vim_account_id}
+    Should Be True   ${metric} <2   msg=VIM Target '${vim_account_id}' has no metric