[RIC-584] reject update enb when enb type is one of ng types
[ric-plt/e2mgr.git] / Automation / Tests / Resource / Keywords.robot
index 13873a8..192438c 100644 (file)
 *** Settings ***
 Documentation   Keywords file
 Library     ../Scripts/cleanup_db.py
+Library     ../Scripts/k8s_helper.py
 Resource   ../Resource/resource.robot
 Library     OperatingSystem
+Library     Process
+Variables  ../Scripts/variables.py
 
 *** Keywords ***
-Get Request node b gnb
+Get Request nodeb
+    [Arguments]    ${nodeb_name}=${ranName}
     Sleep    1s
-    GET      ${getNodeb}
+    GET      ${getNodeb}/${nodeb_name}
 
-Update Ran request
+Update Gnb request
     Sleep  1s
     PUT    ${update_gnb_url}   ${update_gnb_body}
 
+Add eNb Request
+    [Arguments]    ${request}=${add_enb_request_body}
+    Sleep  1s
+    POST    ${enb_url}   ${request}
+
+Delete eNb Request
+    Sleep  1s
+    DELETE    ${enb_url}/${enb_ran_name}
+
+Update eNb Request
+    [Arguments]    ${request}=${update_enb_request_body}
+    Sleep  1s
+    PUT    ${enb_url}/${enb_ran_name}   ${request}
+
 Set General Configuration request
     Sleep  1s
     PUT    ${set_general_configuration}   ${set_general_configuration_body}
 
-Update Ran request not valid
+Update Gnb request not valid
     Sleep  1s
     PUT    ${update_gnb_url}   ${update_gnb_body_notvalid}
 
@@ -59,11 +77,11 @@ Prepare Enviorment
      Init logs
      Flush And Populate DB    ${set_new_timestamp}
      Run keyword if  ${need_to_restart_pods}==${True}   Restart RM and GNB Simulator
-     Wait until keyword succeeds  1 min    10 sec    Validate Required Dockers
+     Wait until keyword succeeds  2 min    10 sec    Validate Required Dockers
 
 Restart RM and GNB Simulator
     Restart routing manager
-    Wait until keyword succeeds  1 min    10 sec    Validate Required Dockers
+    Wait until keyword succeeds  2 min    10 sec    Validate Required Dockers
     Restart simulator
 
 
@@ -75,7 +93,6 @@ Init logs
     ${Save_sim_log}          Evaluate  "kubectl -n ricplt logs --since-time=${starting_timestamp} $(${gnbe2_sim_pod}) > ${gnb_log_filename}"
     ${Save_e2mgr_log}        Evaluate   "kubectl -n ricplt logs --since-time=${starting_timestamp} $(${e2mgr_pod}) > ${e2mgr_log_filename}"
     ${Save_e2t_log}          Evaluate   "kubectl -n ricplt logs --since-time=${starting_timestamp} $(${e2term_pod}) > ${e2t_log_filename}"
-
     Set Suite Variable  ${e2t_log_filename}
     Set Suite Variable  ${e2mgr_log_filename}
     Set Suite Variable  ${gnb_log_filename}
@@ -122,7 +139,7 @@ Stop Dbass
 Stop Simulator
     log to console  Stopping gnbe2 simulator
     Run And Return Rc And Output    ${stop_simu}
-    Sleep  50s
+    Sleep  90s
 
 Start Simulator
     log to console  Starting gnbe2 simulator
@@ -148,6 +165,21 @@ Restart Routing Manager
     Stop Routing Manager
     Start Routing Manager
 
+Start e2adapter
+     Log to Console  Starting e2adapter
+     Run And Return Rc And Output    ${start_e2adapter}
+     Sleep  5s
+
+Stop e2adapter
+     Log to Console  Stopping e2adapter
+     Run And Return Rc And Output    ${stop_e2adapter}
+     Sleep  5s
+
+Restart e2adapter
+    Log to Console  Restarting e2adapter
+    Stop e2adapter
+    Start e2adapter
+
 Flush And Populate DB
     [Arguments]    ${set_new_timestamp}=${True}
     Log To Console  Flushing and populating DB
@@ -160,4 +192,45 @@ Stop All Pods Except Simulator
     Stop Dbass
     Stop E2
     Stop Routing Manager
-
+    Stop e2adapter
+
+Send eNB Setup Request
+    Log To Console  Sending eNB setup request form e2adapter
+    Restart e2adapter
+    Wait until keyword succeeds  2 min    3 sec    Validate Required Dockers
+    ${e2adapter_pod} =    Run And Return Rc And Output   kubectl get pods -n ricplt | /bin/grep e2adapter | /bin/grep Running | awk '{{print $1}}'
+    ${send_enb_setup}    Evaluate    "kubectl -n ricplt exec -it ${e2adapter_pod[1]} cli send-e2setup-req 10.0.2.15"
+    Run And Return Rc And Output    ${send_enb_setup}
+
+Start Redis Monitor
+    Log To Console  Starting redis monitor log
+    ${redis_monitor_log_filename}      Evaluate      "redis_monitor.${SUITE NAME}.log".replace(" ","-")
+    Set Suite Variable  ${redis_monitor_log_filename}
+    Remove File  ${EXECDIR}/${redis_monitor_log_filename}
+    Start Process    kubectl -n ricplt exec -it statefulset-ricplt-dbaas-server-0 redis-cli MONITOR>${EXECDIR}/${redis_monitor_log_filename}  shell=yes
+
+Stop Redis Monitor
+    Log To Console  Stopping redis monitor log
+    log_scripts.kill_redis_monitor_root_process
+
+
+Redis Monitor Logs - Verify Publish To Manipulation Channel
+    [Arguments]       ${ran_name}    ${event}
+    Log To Console  Verify Publish To Manipulation Channel
+    Sleep    3s
+    ${result}=  log_scripts.verify_redis_monitor_manipulation_message   ${EXECDIR}/${redis_monitor_log_filename}  ${ran_name}    ${event}
+    Should Be Equal As Strings    ${result}      True
+
+Redis Monitor Logs - Verify Publish To Connection Status Channel
+    [Arguments]       ${ran_name}    ${event}
+    Log To Console    Verify Publish To Connection Status Channel
+    Sleep    3s
+    ${result}=  log_scripts.verify_redis_monitor_connection_status_message   ${EXECDIR}/${redis_monitor_log_filename}  ${ran_name}    ${event}
+    Should Be Equal As Strings    ${result}      True
+
+Redis Monitor Logs - Verify NOT Published To Manipulation Channel
+    [Arguments]       ${ran_name}    ${event}
+    Log To Console  Verify NOT Published To Manipulation Channel
+    Sleep    3s
+    ${result}=  log_scripts.verify_redis_monitor_manipulation_message   ${EXECDIR}/${redis_monitor_log_filename}  ${ran_name}    ${event}
+    Should Be Equal As Strings    ${result}      False
\ No newline at end of file