Update PRH tests to use file based conifg
[integration/csit.git] / tests / dcaegen2 / prh-testcases / resources / prh_config_library.robot
index 78b4782..1e7c69a 100644 (file)
@@ -3,38 +3,38 @@ Documentation     Keywords related to checking and updating PRH app config based
 Library           RequestsLibrary
 Library           OperatingSystem
 Library           Collections
+Library           yaml
 
 *** Variables ***
 ${CONFIGS_DIR}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/resources/prh_configs/
-
+${PRH_CONFIG_FILE}    ${CONFIGS_DIR}/prh_config_volume/application_config.yaml
 *** Keywords ***
 
-Put key-value to consul
+Put key-value to config
     [Arguments]    ${key}    ${value}
-    ${prh_config}=    Get PRH config from consul
+    ${prh_config}=    Get PRH config
     set to dictionary    ${prh_config}    ${key}    ${value}
-    Set PRH config in consul  ${prh_config}
+    Set PRH config     ${prh_config}
 
-Get PRH config from consul
-    [Arguments]    ${logMessage}=prh config in consul
-    ${phr_config_response}=    get request    consul_session    /v1/kv/dcae-prh?raw
-    log    ${logMessage}: ${phr_config_response.content}
-    [Return]    ${phr_config_response.json()}
+Get PRH config
+    [Arguments]    ${logMessage}=prh config
+    ${prh_config_file_content}=    Get File    ${PRH_CONFIG_FILE}
+    ${prh_config}=    yaml.Safe Load    ${prh_config_file_content}
+    log    ${logMessage}: ${prh_config}
+    [Return]    ${prh_config}
 
-Set PRH config in consul
+Set PRH config
     [Arguments]  ${prh_config}
-    put request    consul_session    /v1/kv/dcae-prh    json=${prh_config}
-    Get PRH config from consul    prh config in consul after update
+    ${prh_config_output}=  yaml.Safe Dump  ${prh_config}
+    Create File  ${PRH_CONFIG_FILE}  ${prh_config_output}
 
-Set PRH CBS config from file
+Set PRH config from file
     [Arguments]     ${config_file_name}
-    ${config_file_content}=    get file    ${config_file_name}
-    ${config_json}=    to json    ${config_file_content}
-    Set PRH config in consul    ${config_json}
+    Copy File    ${config_file_name}    ${PRH_CONFIG_FILE}
     Force PRH config refresh
 
-Set default PRH CBS config
-    Set PRH CBS config from file    ${CONFIGS_DIR}/prh-config.json
+Set default PRH config
+    Set PRH config from file    ${CONFIGS_DIR}/prh-config.yaml
 
 Force PRH config refresh
     ${refresh_response}=    post request    prh_session    /actuator/refresh
@@ -47,14 +47,14 @@ Check key-value in PRH app environment
     log    ${env_response.content}
     should be equal    ${env_response.json()["property"]["value"]}    ${expected_value}
 
-Set scheduled CBS updates interval
+Set scheduled config updates interval
     [Arguments]    ${cbs_updates_interval}
-    Put key-value to consul    cbs.updates-interval    ${cbs_updates_interval}
+    Put key-value to config    cbs.updates-interval    ${cbs_updates_interval}
     Force PRH config refresh
 
-Set logging level in CBS
+Set logging level in config
     [Arguments]    ${logger}   ${level}
-    Put key-value to consul    logging.level.${logger}    ${level}
+    Put key-value to config    logging.level.${logger}    ${level}
 
 Generate random value
     ${some_random_value}     evaluate    random.randint(sys.maxint/10, sys.maxint)    modules=random,sys