Extracting config related tests to separate suit since they do not share common setup and teardown.
Small improvements in existing test for ad-hoc logging level change using rest endpoint.
Change-Id: I0b81680cc68cd210aad01b87f84856200cb4b88b
Issue-ID: DCAEGEN2-1544
Signed-off-by: grabinsk <maciej.grabinski@nokia.com>
--- /dev/null
+*** Settings ***
+Documentation Tests related to updating PRH app config based on CBS config
+Suite Setup Run keywords Create sessions
+Resource resources/prh_sessions.robot
+Resource resources/prh_config_library.robot
+Resource resources/prh_library.robot
+Test Timeout 15 seconds
+
+*** Test Cases ***
+CBS configuration forced refresh
+ [Documentation] It should be possible to force refresh PRH configuration from CBS
+ [Tags] PRH coniguration
+ ${some_random_value}= Generate random value
+ Put key-value to consul foo_${some_random_value} bar_${some_random_value}
+ Force PRH config refresh
+ Check key-value in PRH app environment foo_${some_random_value} bar_${some_random_value}
+
+CBS configuration scheduled refresh
+ [Documentation] PRH should pull for CBS configuration updates according to schedule
+ [Tags] PRH coniguration
+ Set scheduled CBS updates interval 1s
+ ${some_random_value}= Generate random value
+ Put key-value to consul spam_${some_random_value} ham_${some_random_value}
+ wait until keyword succeeds 20x 500ms
+ ... Check key-value in PRH app environment spam_${some_random_value} ham_${some_random_value}
+ [Teardown] Set scheduled CBS updates interval 0
+
+PRH log level change based on CBS config
+ [Documentation] It should be possible to change logging levels in PRH based on entries in CBS
+ [Tags] PRH coniguration logging
+ Set logging level in CBS org.onap.dcaegen2.services.prh.foo WARN
+ Force PRH config refresh
+ Verify logging level org.onap.dcaegen2.services.prh.foo WARN
\ No newline at end of file
Library resources/PrhLibrary.py
Resource resources/prh_sessions.robot
Resource resources/prh_library.robot
-Resource resources/prh_config_tests.robot
*** Variables ***
${TEST_CASES_DIR} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets
-${DMAAP_SIMULATOR_SETUP_URL} http://${DMAAP_SIMULATOR_SETUP}
-${AAI_SIMULATOR_SETUP_URL} http://${AAI_SIMULATOR_SETUP}
-${CONSUL_SETUP_URL} http://${CONSUL_SETUP}
-${PRH_SETUP_URL} http://${PRH_SETUP}
-${TRACE_LOG_LEVEL_CONF} {"configuredLevel":"TRACE","effectiveLevel":"TRACE"}
-${WARN_LOG_LEVEL_CONF} {"configuredLevel":"WARN","effectiveLevel":"WARN"}
-
*** Test Cases ***
BBS case event - attachment point
[Documentation] PRH get from DMaaP valid event with valid attachment point
${TEST_CASES_DIR}/re-registration
PRH logging level change
- [Documentation] PRH logging level change from WARN to TRACE
+ [Documentation] ad-hoc PRH logging level change using rest endpoint
[Tags] PRH logging level
Verify change logging level
-
-CBS configuration forced refresh
- [Documentation] It should be possible to force refresh PRH configuration from CBS
- [Tags] PRH coniguration
- Verify PRH configuration forced refresh
-
-CBS configuration scheduled refresh
- [Documentation] PRH should pull for CBS configuration updates according to schedule
- [Tags] PRH coniguration
- Verify scheduled CBS config updates
\ No newline at end of file
"cbs.updates-interval": 0,
"logging.level.org.onap.dcaegen2.services.prh": "debug",
"logging.level.org.onap.dcaegen2.services.sdk": "debug",
+ "logging.level.org.onap.dcaegen2.services.prh.controllers.AppInfoController": "off",
"dmaap.dmaapConsumerConfiguration.dmaapUserName":"admin",
"dmaap.dmaapConsumerConfiguration.dmaapUserPassword":"admin",
"dmaap.dmaapConsumerConfiguration.dmaapContentType": "application/json",
*** Settings ***
-Documentation Tests and keywords related to updating PRH app config based on CBS config
+Documentation Keywords related to checking and updating PRH app config based on CBS config
Library RequestsLibrary
Library Collections
*** Keywords ***
-Verify PRH configuration forced refresh
- ${some_random_value}= Generate random value
- Put key-value to consul foo_${some_random_value} bar_${some_random_value}
- Force PRH config refresh
- Check key-value in PRH app environment foo_${some_random_value} bar_${some_random_value}
-
Put key-value to consul
[Arguments] ${key} ${value}
${prh_config}= Get PRH config from consul
log ${env_response.content}
should be equal ${env_response.json()["property"]["value"]} ${expected_value}
-Verify scheduled CBS config updates
- Set scheduled CBS updates interval 1s
- ${some_random_value}= Generate random value
- Put key-value to consul spam_${some_random_value} ham_${some_random_value}
- wait until keyword succeeds 20x 500ms
- ... Check key-value in PRH app environment spam_${some_random_value} ham_${some_random_value}
- [Teardown] Set scheduled CBS updates interval 0
-
Set scheduled CBS updates interval
[Arguments] ${cbs_updates_interval}
Put key-value to consul cbs.updates-interval ${cbs_updates_interval}
Force PRH config refresh
+Set logging level in CBS
+ [Arguments] ${logger} ${level}
+ Put key-value to consul logging.level.${logger} ${level}
+
Generate random value
${some_random_value} evaluate random.randint(sys.maxint/10, sys.maxint) modules=random,sys
[Return] ${some_random_value}
\ No newline at end of file
Library RequestsLibrary
Library Collections
Library PrhLibrary.py
-Library OperatingSystem
Resource ../../../common.robot
*** Keywords ***
Verify change logging level
- Change logging level TRACE
+ ${logger}= Set Variable org.onap.dcaegen2.services.prh.controllers.AppInfoController
+ Change logging level ${logger} TRACE
+ Verify logging level ${logger} TRACE
Verify logs with heartbeat
- Change logging level INFO
+ [Teardown] Change logging level ${logger} INFO
Change logging level
- [Arguments] ${expected_log_level}
- Run curl -i -X POST -H 'Content-Type: application/json' -d '{"configuredLevel": "${expected_log_level}"}' http://localhost:8100/actuator/loggers/org.onap.dcaegen2.services.prh
+ [Arguments] ${logger} ${log_level}
+ ${request_body}= Create Dictionary configuredLevel=${log_level}
+ ${resp}= Post Request prh_session /actuator/loggers/${logger} json=${request_body}
+ Should Be Equal As Integers ${resp.status_code} 204
Verify logging level
- [Arguments] ${expected_log_level}
- ${resp}= Get Request prh_session /actuator/loggers/org.onap.dcaegen2.services.prh
- Should Be Equal As JSON ${resp.content} ${expected_log_level}
+ [Arguments] ${logger} ${expected_log_level}
+ ${resp}= Get Request prh_session /actuator/loggers/${logger}
+ Should Be Equal As Integers ${resp.status_code} 200
+ Log ${resp.content}
+ Should Be Equal As Strings ${resp.json()["configuredLevel"]} ${expected_log_level} ignore_case=true
Verify logs with heartbeat
- Verify logging level ${TRACE_LOG_LEVEL_CONF}
Get Request prh_session /heartbeat
Check PRH log Heartbeat request received
\ No newline at end of file
Library RequestsLibrary
Library Collections
+*** Variables ***
+${DMAAP_SIMULATOR_SETUP_URL} http://${DMAAP_SIMULATOR_SETUP}
+${AAI_SIMULATOR_SETUP_URL} http://${AAI_SIMULATOR_SETUP}
+${CONSUL_SETUP_URL} http://${CONSUL_SETUP}
+${PRH_SETUP_URL} http://${PRH_SETUP}
+
*** Keywords ***
Create sessions
Create Session dmaap_session ${DMAAP_SIMULATOR_SETUP_URL}