Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation The main interface for interacting with Microservice Bus. |
| 3 | Library RequestsLibrary |
Brian Freeman | 22d7f74 | 2019-01-17 11:57:59 -0500 | [diff] [blame] | 4 | Library Collections |
| 5 | Library String |
DR695H | 7aca1a4 | 2019-06-03 17:08:34 -0400 | [diff] [blame] | 6 | Library ONAPLibrary.JSON |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 7 | |
| 8 | Resource global_properties.robot |
Brian Freeman | 893c12a | 2019-01-17 13:48:16 -0500 | [diff] [blame] | 9 | Resource json_templater.robot |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 10 | |
| 11 | *** Variables *** |
Brian Freeman | d089b94 | 2018-09-07 07:30:06 -0500 | [diff] [blame] | 12 | ${CLAMP_HEALTH_CHECK_PATH} /restservices/clds/v1/healthcheck |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 13 | ${CLAMP_ENDPOINT} ${GLOBAL_CLAMP_SERVER_PROTOCOL}://${GLOBAL_INJECTED_CLAMP_IP_ADDR}:${GLOBAL_CLAMP_SERVER_PORT} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 14 | ${CLAMP_BASE_PATH} /restservices/clds/v1 |
| 15 | ${CLAMP_CLIENT_KEY} robot/assets/keys/org.onap.clamp.key.clear.pem |
| 16 | ${CLAMP_CLIENT_CERT} robot/assets/keys/org.onap.clamp.cert.pem |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 17 | |
Brian Freeman | 893c12a | 2019-01-17 13:48:16 -0500 | [diff] [blame] | 18 | ${CLAMP_TEMPLATE_PATH} robot/assets/templates/clamp |
| 19 | |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 20 | |
| 21 | *** Keywords *** |
Brian Freeman | 893c12a | 2019-01-17 13:48:16 -0500 | [diff] [blame] | 22 | Run CLAMP Create Model |
| 23 | [Documentation] Create a new CLAMP Model |
| 24 | [Arguments] ${model_name} ${template_name} |
| 25 | ${dict}= Create Dictionary MODEL_NAME=${model_name} TEMPLATE_NAME=${template_name} |
| 26 | ${data}= Fill JSON Template File ${CLAMP_TEMPLATE_PATH}/create_model.template ${dict} |
| 27 | ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/model/${model_name} |
| 28 | ${resp}= Run CLAMP HTTPS Put Request ${data_path} ${data} |
| 29 | Should Be Equal As Strings ${resp.status_code} 200 |
Brian Freeman | 75f5ad1 | 2019-01-17 17:37:59 -0500 | [diff] [blame] | 30 | ${random}= Generate Random String 4 [LOWER][NUMBERS] |
| 31 | ${policy_name}= Catenate PolicyTest ${random} |
| 32 | Run CLAMP Save vLB Model ${model_name} ${template_name} ${policy_name} |
| 33 | |
| 34 | Run CLAMP Save vLB Model |
| 35 | [Documentation] Save CLAMP Model |
| 36 | [Arguments] ${model_name} ${template_name} ${policy_name} |
| 37 | ${dict}= Create Dictionary MODEL_NAME=${model_name} TEMPLATE_NAME=${template_name} POLICY_NAME=${policy_name} DOLLAR_SIGN=$ |
| 38 | ${data}= Fill JSON Template File ${CLAMP_TEMPLATE_PATH}/save_model_vlb.template ${dict} |
| 39 | ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/model/${model_name} |
| 40 | ${resp}= Run CLAMP HTTPS Put Request ${data_path} ${data} |
| 41 | Should Be Equal As Strings ${resp.status_code} 200 |
| 42 | Run CLAMP Validation Test ${model_name} ${data} |
| 43 | |
| 44 | Run CLAMP Validation Test |
| 45 | [Documentation] Validate CLAMP Control Loop CLAMP Model |
| 46 | [Arguments] ${model_name} ${model_data} |
| 47 | ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/action/submit/${model_name}?test=true |
| 48 | ${resp}= Run CLAMP HTTPS Put Request ${data_path} ${model_data} |
| 49 | Should Be Equal As Strings ${resp.status_code} 200 |
| 50 | |
Brian Freeman | 893c12a | 2019-01-17 13:48:16 -0500 | [diff] [blame] | 51 | |
Brian Freeman | cc84e48 | 2019-01-16 09:38:46 -0500 | [diff] [blame] | 52 | Run CLAMP Get Properties |
| 53 | [Documentation] get CLAMP Control Loop properties |
| 54 | [Arguments] ${property_id} |
| 55 | ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/properties/${property_id} |
| 56 | ${resp}= Run Clamp HTTPS Get Request ${data_path} |
| 57 | |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 58 | Run CLAMP Get Control Loop |
Brian Freeman | 22d7f74 | 2019-01-17 11:57:59 -0500 | [diff] [blame] | 59 | [Documentation] runs CLAMP Open Control Loop based on model name and returns control_loop_id |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 60 | [Arguments] ${model_name} |
Brian Freeman | cc84e48 | 2019-01-16 09:38:46 -0500 | [diff] [blame] | 61 | ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/model/${model_name} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 62 | ${resp}= Run Clamp HTTPS Get Request ${data_path} |
Brian Freeman | 22d7f74 | 2019-01-17 11:57:59 -0500 | [diff] [blame] | 63 | # propText value is a string |
| 64 | # propText': u '{"global":[{"name":"service","value":["5fcdb3b7-5a5b-45da-83f6-14cce29181c8"]} |
| 65 | Log ${resp.json()['propText']} |
| 66 | ${control_loop_id}= Get Regexp Matches ${resp.json()['propText']} \\"service\\",\\"value\\":\\[\\"([0-9a-f\-]{36})\\" 1 |
| 67 | #Set Suite Variable ${CURRENT_CONTROL_LOOP_ID} ${control_loop_id[0]} |
| 68 | [Return] ${control_loop_id[0]} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 69 | |
| 70 | Run CLAMP Get Model Names |
Brian Freeman | 22d7f74 | 2019-01-17 11:57:59 -0500 | [diff] [blame] | 71 | [Documentation] runs CLAMP Get Model Names and returns the model_id |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 72 | ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/model-names |
| 73 | ${resp}= Run Clamp HTTPS Get Request ${data_path} |
Brian Freeman | 22d7f74 | 2019-01-17 11:57:59 -0500 | [diff] [blame] | 74 | #Set Suite Variable ${CURRENT_MODEL_ID} ${resp.json()[0]['value']} |
| 75 | [Return] ${resp.json()[0]['value']} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 76 | |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 77 | Run CLAMP Health Check |
| 78 | [Documentation] Runs CLAMP Health check |
| 79 | ${resp}= Run CLAMP Get Request ${CLAMP_HEALTH_CHECK_PATH} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 80 | Should Be Equal As Integers ${resp.status_code} 200 |
| 81 | |
Brian Freeman | 893c12a | 2019-01-17 13:48:16 -0500 | [diff] [blame] | 82 | Run CLAMP HTTPS Put Request |
| 83 | [Documentation] Runs CLAMP HTTPS Put request |
| 84 | [Arguments] ${data_path} ${data} |
| 85 | @{client_certs}= Create List ${CLAMP_CLIENT_CERT} ${CLAMP_CLIENT_KEY} |
| 86 | ${session}= Create Client Cert Session session ${CLAMP_ENDPOINT} client_certs=@{client_certs} |
| 87 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 88 | ${resp}= Put Request session ${data_path} data=${data} headers=${headers} |
| 89 | Should Be Equal As Integers ${resp.status_code} 200 |
| 90 | Log ${resp.json()} |
| 91 | [Return] ${resp} |
| 92 | |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 93 | Run CLAMP HTTPS Get Request |
| 94 | [Documentation] Runs CLAMP HTTPS Get request |
| 95 | [Arguments] ${data_path} |
| 96 | @{client_certs}= Create List ${CLAMP_CLIENT_CERT} ${CLAMP_CLIENT_KEY} |
| 97 | ${session}= Create Client Cert Session session ${CLAMP_ENDPOINT} client_certs=@{client_certs} |
| 98 | ${resp}= Get Request session ${data_path} |
| 99 | Should Be Equal As Integers ${resp.status_code} 200 |
Brian Freeman | cc84e48 | 2019-01-16 09:38:46 -0500 | [diff] [blame] | 100 | Log ${resp.json()} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 101 | [Return] ${resp} |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 102 | |
| 103 | Run CLAMP Get Request |
| 104 | [Documentation] Runs CLAMP Get request |
| 105 | [Arguments] ${data_path} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 106 | ${session}= Create Session session ${CLAMP_ENDPOINT} |
| 107 | ${resp}= Get Request session ${data_path} |
| 108 | Should Be Equal As Integers ${resp.status_code} 200 |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 109 | Log Received response from CLAMP ${resp.text} |
| 110 | [Return] ${resp} |