Update PRH tests to use file based conifg
[integration/csit.git] / tests / dcaegen2 / prh-testcases / resources / prh_config_library.robot
1 *** Settings ***
2 Documentation     Keywords related to checking and updating PRH app config based on CBS config
3 Library           RequestsLibrary
4 Library           OperatingSystem
5 Library           Collections
6 Library           yaml
7
8 *** Variables ***
9 ${CONFIGS_DIR}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/resources/prh_configs/
10 ${PRH_CONFIG_FILE}    ${CONFIGS_DIR}/prh_config_volume/application_config.yaml
11 *** Keywords ***
12
13 Put key-value to config
14     [Arguments]    ${key}    ${value}
15     ${prh_config}=    Get PRH config
16     set to dictionary    ${prh_config}    ${key}    ${value}
17     Set PRH config     ${prh_config}
18
19 Get PRH config
20     [Arguments]    ${logMessage}=prh config
21     ${prh_config_file_content}=    Get File    ${PRH_CONFIG_FILE}
22     ${prh_config}=    yaml.Safe Load    ${prh_config_file_content}
23     log    ${logMessage}: ${prh_config}
24     [Return]    ${prh_config}
25
26 Set PRH config
27     [Arguments]  ${prh_config}
28     ${prh_config_output}=  yaml.Safe Dump  ${prh_config}
29     Create File  ${PRH_CONFIG_FILE}  ${prh_config_output}
30
31 Set PRH config from file
32     [Arguments]     ${config_file_name}
33     Copy File    ${config_file_name}    ${PRH_CONFIG_FILE}
34     Force PRH config refresh
35
36 Set default PRH config
37     Set PRH config from file    ${CONFIGS_DIR}/prh-config.yaml
38
39 Force PRH config refresh
40     ${refresh_response}=    post request    prh_session    /actuator/refresh
41     should be equal as integers    ${refresh_response.status_code}    200
42
43 Check key-value in PRH app environment
44     [Arguments]    ${key}    ${expected_value}
45     ${env_response}=    get request    prh_session    /actuator/env/${key}
46     should be equal as integers    ${env_response.status_code}    200
47     log    ${env_response.content}
48     should be equal    ${env_response.json()["property"]["value"]}    ${expected_value}
49
50 Set scheduled config updates interval
51     [Arguments]    ${cbs_updates_interval}
52     Put key-value to config    cbs.updates-interval    ${cbs_updates_interval}
53     Force PRH config refresh
54
55 Set logging level in config
56     [Arguments]    ${logger}   ${level}
57     Put key-value to config    logging.level.${logger}    ${level}
58
59 Generate random value
60     ${some_random_value}     evaluate    random.randint(sys.maxint/10, sys.maxint)    modules=random,sys
61     [Return]    ${some_random_value}