78b47824d8f70427c587e90adbcaaacc44ee14d7
[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
7 *** Variables ***
8 ${CONFIGS_DIR}    %{WORKSPACE}/tests/dcaegen2/prh-testcases/resources/prh_configs/
9
10 *** Keywords ***
11
12 Put key-value to consul
13     [Arguments]    ${key}    ${value}
14     ${prh_config}=    Get PRH config from consul
15     set to dictionary    ${prh_config}    ${key}    ${value}
16     Set PRH config in consul  ${prh_config}
17
18 Get PRH config from consul
19     [Arguments]    ${logMessage}=prh config in consul
20     ${phr_config_response}=    get request    consul_session    /v1/kv/dcae-prh?raw
21     log    ${logMessage}: ${phr_config_response.content}
22     [Return]    ${phr_config_response.json()}
23
24 Set PRH config in consul
25     [Arguments]  ${prh_config}
26     put request    consul_session    /v1/kv/dcae-prh    json=${prh_config}
27     Get PRH config from consul    prh config in consul after update
28
29 Set PRH CBS config from file
30     [Arguments]     ${config_file_name}
31     ${config_file_content}=    get file    ${config_file_name}
32     ${config_json}=    to json    ${config_file_content}
33     Set PRH config in consul    ${config_json}
34     Force PRH config refresh
35
36 Set default PRH CBS config
37     Set PRH CBS config from file    ${CONFIGS_DIR}/prh-config.json
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 CBS updates interval
51     [Arguments]    ${cbs_updates_interval}
52     Put key-value to consul    cbs.updates-interval    ${cbs_updates_interval}
53     Force PRH config refresh
54
55 Set logging level in CBS
56     [Arguments]    ${logger}   ${level}
57     Put key-value to consul    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}