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 |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 7 | Library ONAPLibrary.Templating WITH NAME Templating |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 8 | Resource global_properties.robot |
| 9 | |
| 10 | *** Variables *** |
Brian Freeman | d089b94 | 2018-09-07 07:30:06 -0500 | [diff] [blame] | 11 | ${CLAMP_HEALTH_CHECK_PATH} /restservices/clds/v1/healthcheck |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 12 | ${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] | 13 | ${CLAMP_BASE_PATH} /restservices/clds/v1 |
| 14 | ${CLAMP_CLIENT_KEY} robot/assets/keys/org.onap.clamp.key.clear.pem |
| 15 | ${CLAMP_CLIENT_CERT} robot/assets/keys/org.onap.clamp.cert.pem |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 16 | |
DR695H | 369e515 | 2019-06-19 21:16:58 -0400 | [diff] [blame] | 17 | ${CLAMP_TEMPLATE_PATH} clamp |
Brian Freeman | 893c12a | 2019-01-17 13:48:16 -0500 | [diff] [blame] | 18 | |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 19 | |
| 20 | *** Keywords *** |
Brian Freeman | 893c12a | 2019-01-17 13:48:16 -0500 | [diff] [blame] | 21 | Run CLAMP Create Model |
| 22 | [Documentation] Create a new CLAMP Model |
| 23 | [Arguments] ${model_name} ${template_name} |
| 24 | ${dict}= Create Dictionary MODEL_NAME=${model_name} TEMPLATE_NAME=${template_name} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 25 | Templating.Create Environment clamp ${GLOBAL_TEMPLATE_FOLDER} |
| 26 | ${data}= Templating.Apply Template clamp ${CLAMP_TEMPLATE_PATH}/create_model.jinja ${dict} |
Brian Freeman | 893c12a | 2019-01-17 13:48:16 -0500 | [diff] [blame] | 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=$ |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 38 | Templating.Create Environment clamp ${GLOBAL_TEMPLATE_FOLDER} |
| 39 | ${data}= Templating.Apply Template clamp ${CLAMP_TEMPLATE_PATH}/save_model_vlb.jinja ${dict} |
Brian Freeman | 75f5ad1 | 2019-01-17 17:37:59 -0500 | [diff] [blame] | 40 | ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/model/${model_name} |
| 41 | ${resp}= Run CLAMP HTTPS Put Request ${data_path} ${data} |
| 42 | Should Be Equal As Strings ${resp.status_code} 200 |
| 43 | Run CLAMP Validation Test ${model_name} ${data} |
| 44 | |
| 45 | Run CLAMP Validation Test |
| 46 | [Documentation] Validate CLAMP Control Loop CLAMP Model |
| 47 | [Arguments] ${model_name} ${model_data} |
| 48 | ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/action/submit/${model_name}?test=true |
| 49 | ${resp}= Run CLAMP HTTPS Put Request ${data_path} ${model_data} |
| 50 | Should Be Equal As Strings ${resp.status_code} 200 |
| 51 | |
Brian Freeman | 893c12a | 2019-01-17 13:48:16 -0500 | [diff] [blame] | 52 | |
Brian Freeman | cc84e48 | 2019-01-16 09:38:46 -0500 | [diff] [blame] | 53 | Run CLAMP Get Properties |
| 54 | [Documentation] get CLAMP Control Loop properties |
| 55 | [Arguments] ${property_id} |
| 56 | ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/properties/${property_id} |
| 57 | ${resp}= Run Clamp HTTPS Get Request ${data_path} |
| 58 | |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 59 | Run CLAMP Get Control Loop |
Brian Freeman | 22d7f74 | 2019-01-17 11:57:59 -0500 | [diff] [blame] | 60 | [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] | 61 | [Arguments] ${model_name} |
Brian Freeman | cc84e48 | 2019-01-16 09:38:46 -0500 | [diff] [blame] | 62 | ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/model/${model_name} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 63 | ${resp}= Run Clamp HTTPS Get Request ${data_path} |
Brian Freeman | 22d7f74 | 2019-01-17 11:57:59 -0500 | [diff] [blame] | 64 | # propText value is a string |
| 65 | # propText': u '{"global":[{"name":"service","value":["5fcdb3b7-5a5b-45da-83f6-14cce29181c8"]} |
| 66 | Log ${resp.json()['propText']} |
| 67 | ${control_loop_id}= Get Regexp Matches ${resp.json()['propText']} \\"service\\",\\"value\\":\\[\\"([0-9a-f\-]{36})\\" 1 |
Brian Freeman | 22d7f74 | 2019-01-17 11:57:59 -0500 | [diff] [blame] | 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 | [Return] ${resp.json()[0]['value']} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 75 | |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 76 | Run CLAMP Health Check |
| 77 | [Documentation] Runs CLAMP Health check |
| 78 | ${resp}= Run CLAMP Get Request ${CLAMP_HEALTH_CHECK_PATH} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 79 | Should Be Equal As Integers ${resp.status_code} 200 |
| 80 | |
Brian Freeman | 893c12a | 2019-01-17 13:48:16 -0500 | [diff] [blame] | 81 | Run CLAMP HTTPS Put Request |
| 82 | [Documentation] Runs CLAMP HTTPS Put request |
| 83 | [Arguments] ${data_path} ${data} |
| 84 | @{client_certs}= Create List ${CLAMP_CLIENT_CERT} ${CLAMP_CLIENT_KEY} |
| 85 | ${session}= Create Client Cert Session session ${CLAMP_ENDPOINT} client_certs=@{client_certs} |
| 86 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 87 | ${resp}= Put Request session ${data_path} data=${data} headers=${headers} |
| 88 | Should Be Equal As Integers ${resp.status_code} 200 |
| 89 | Log ${resp.json()} |
| 90 | [Return] ${resp} |
| 91 | |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 92 | Run CLAMP HTTPS Get Request |
| 93 | [Documentation] Runs CLAMP HTTPS Get request |
| 94 | [Arguments] ${data_path} |
| 95 | @{client_certs}= Create List ${CLAMP_CLIENT_CERT} ${CLAMP_CLIENT_KEY} |
| 96 | ${session}= Create Client Cert Session session ${CLAMP_ENDPOINT} client_certs=@{client_certs} |
| 97 | ${resp}= Get Request session ${data_path} |
| 98 | Should Be Equal As Integers ${resp.status_code} 200 |
Brian Freeman | cc84e48 | 2019-01-16 09:38:46 -0500 | [diff] [blame] | 99 | Log ${resp.json()} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 100 | [Return] ${resp} |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 101 | |
| 102 | Run CLAMP Get Request |
| 103 | [Documentation] Runs CLAMP Get request |
| 104 | [Arguments] ${data_path} |
Brian Freeman | 86805fe | 2019-01-16 09:03:42 -0500 | [diff] [blame] | 105 | ${session}= Create Session session ${CLAMP_ENDPOINT} |
| 106 | ${resp}= Get Request session ${data_path} |
| 107 | Should Be Equal As Integers ${resp.status_code} 200 |
Gary Wu | ba8f94d | 2017-10-23 09:51:13 -0700 | [diff] [blame] | 108 | Log Received response from CLAMP ${resp.text} |
| 109 | [Return] ${resp} |