9044185dda12baba6bfd2b0b6c8271aa5819f702
[integration/csit.git] / tests / dcaegen2 / prh-testcases / resources / prh_config_tests.robot
1 *** Settings ***
2 Documentation     Tests and keywords related to updating PRH app config based on CBS config
3 Library           RequestsLibrary
4 Library           Collections
5
6 *** Keywords ***
7
8 Verify PRH configuration forced refresh
9     ${some_random_value}=     Generate random value
10     Put key-value to consul    foo_${some_random_value}    bar_${some_random_value}
11     Force PRH config refresh
12     Check key-value in PRH app environment    foo_${some_random_value}    bar_${some_random_value}
13
14 Put key-value to consul
15    [Arguments]    ${key}    ${value}
16    ${prh_config}=    Get PRH config from consul
17    set to dictionary    ${prh_config}    ${key}    ${value}
18    put request    consul_session    /v1/kv/dcae-prh    json=${prh_config}
19    Get PRH config from consul    prh config in consul after update
20
21 Get PRH config from consul
22     [Arguments]    ${logMessage}=prh config in consul
23     ${phr_config_response}=    get request    consul_session    /v1/kv/dcae-prh?raw
24     log    ${logMessage}: ${phr_config_response.content}
25     [Return]    ${phr_config_response.json()}
26
27 Force PRH config refresh
28     ${refresh_response}=    post request    prh_session    /actuator/refresh
29     should be equal as integers    ${refresh_response.status_code}    200
30
31 Check key-value in PRH app environment
32     [Arguments]    ${key}    ${expected_value}
33     ${env_response}=    get request    prh_session    /actuator/env/${key}
34     should be equal as integers    ${env_response.status_code}    200
35     log    ${env_response.content}
36     should be equal    ${env_response.json()["property"]["value"]}    ${expected_value}
37
38 Verify scheduled CBS config updates
39     Set scheduled CBS updates interval   1s
40     ${some_random_value}=     Generate random value
41     Put key-value to consul    spam_${some_random_value}    ham_${some_random_value}
42     wait until keyword succeeds    20x   500ms
43     ...    Check key-value in PRH app environment    spam_${some_random_value}    ham_${some_random_value}
44     [Teardown]    Set scheduled CBS updates interval    0
45
46 Set scheduled CBS updates interval
47     [Arguments]    ${cbs_updates_interval}
48     Put key-value to consul    cbs.updates-interval    ${cbs_updates_interval}
49     Force PRH config refresh
50
51 Generate random value
52     ${some_random_value}     evaluate    random.randint(sys.maxint/10, sys.maxint)    modules=random,sys
53     [Return]    ${some_random_value}