blob: fe592329b02547ea4ba2e2676c0353bdd4d63708 [file] [log] [blame]
Gary Wuba8f94d2017-10-23 09:51:13 -07001*** Settings ***
2Documentation The main interface for interacting with Microservice Bus.
3Library RequestsLibrary
Brian Freeman22d7f742019-01-17 11:57:59 -05004Library Collections
5Library String
DR695H7aca1a42019-06-03 17:08:34 -04006Library ONAPLibrary.JSON
DR695Hd9794652019-07-19 18:20:40 -04007Library ONAPLibrary.Templating WITH NAME Templating
Gary Wuba8f94d2017-10-23 09:51:13 -07008Resource global_properties.robot
9
10*** Variables ***
Brian Freemand089b942018-09-07 07:30:06 -050011${CLAMP_HEALTH_CHECK_PATH} /restservices/clds/v1/healthcheck
Gary Wuba8f94d2017-10-23 09:51:13 -070012${CLAMP_ENDPOINT} ${GLOBAL_CLAMP_SERVER_PROTOCOL}://${GLOBAL_INJECTED_CLAMP_IP_ADDR}:${GLOBAL_CLAMP_SERVER_PORT}
Brian Freeman86805fe2019-01-16 09:03:42 -050013${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 Wuba8f94d2017-10-23 09:51:13 -070016
DR695H369e5152019-06-19 21:16:58 -040017${CLAMP_TEMPLATE_PATH} clamp
Brian Freeman893c12a2019-01-17 13:48:16 -050018
Gary Wuba8f94d2017-10-23 09:51:13 -070019
20*** Keywords ***
Brian Freeman893c12a2019-01-17 13:48:16 -050021Run 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}
DR695Hd9794652019-07-19 18:20:40 -040025 Templating.Create Environment clamp ${GLOBAL_TEMPLATE_FOLDER}
26 ${data}= Templating.Apply Template clamp ${CLAMP_TEMPLATE_PATH}/create_model.jinja ${dict}
Brian Freeman893c12a2019-01-17 13:48:16 -050027 ${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 Freeman75f5ad12019-01-17 17:37:59 -050030 ${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
34Run 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=$
DR695Hd9794652019-07-19 18:20:40 -040038 Templating.Create Environment clamp ${GLOBAL_TEMPLATE_FOLDER}
39 ${data}= Templating.Apply Template clamp ${CLAMP_TEMPLATE_PATH}/save_model_vlb.jinja ${dict}
Brian Freeman75f5ad12019-01-17 17:37:59 -050040 ${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
45Run 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 Freeman893c12a2019-01-17 13:48:16 -050052
Brian Freemancc84e482019-01-16 09:38:46 -050053Run 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 Freeman86805fe2019-01-16 09:03:42 -050059Run CLAMP Get Control Loop
Brian Freeman22d7f742019-01-17 11:57:59 -050060 [Documentation] runs CLAMP Open Control Loop based on model name and returns control_loop_id
Brian Freeman86805fe2019-01-16 09:03:42 -050061 [Arguments] ${model_name}
Brian Freemancc84e482019-01-16 09:38:46 -050062 ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/model/${model_name}
Brian Freeman86805fe2019-01-16 09:03:42 -050063 ${resp}= Run Clamp HTTPS Get Request ${data_path}
Brian Freeman22d7f742019-01-17 11:57:59 -050064 # 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 Freeman22d7f742019-01-17 11:57:59 -050068 [Return] ${control_loop_id[0]}
Brian Freeman86805fe2019-01-16 09:03:42 -050069
70Run CLAMP Get Model Names
Brian Freeman22d7f742019-01-17 11:57:59 -050071 [Documentation] runs CLAMP Get Model Names and returns the model_id
Brian Freeman86805fe2019-01-16 09:03:42 -050072 ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/model-names
73 ${resp}= Run Clamp HTTPS Get Request ${data_path}
Brian Freeman22d7f742019-01-17 11:57:59 -050074 [Return] ${resp.json()[0]['value']}
Brian Freeman86805fe2019-01-16 09:03:42 -050075
Gary Wuba8f94d2017-10-23 09:51:13 -070076Run CLAMP Health Check
77 [Documentation] Runs CLAMP Health check
78 ${resp}= Run CLAMP Get Request ${CLAMP_HEALTH_CHECK_PATH}
Brian Freeman86805fe2019-01-16 09:03:42 -050079 Should Be Equal As Integers ${resp.status_code} 200
80
Brian Freeman893c12a2019-01-17 13:48:16 -050081Run 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 Freeman86805fe2019-01-16 09:03:42 -050092Run 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 Freemancc84e482019-01-16 09:38:46 -050099 Log ${resp.json()}
Brian Freeman86805fe2019-01-16 09:03:42 -0500100 [Return] ${resp}
Gary Wuba8f94d2017-10-23 09:51:13 -0700101
102Run CLAMP Get Request
103 [Documentation] Runs CLAMP Get request
104 [Arguments] ${data_path}
Brian Freeman86805fe2019-01-16 09:03:42 -0500105 ${session}= Create Session session ${CLAMP_ENDPOINT}
106 ${resp}= Get Request session ${data_path}
107 Should Be Equal As Integers ${resp.status_code} 200
Gary Wuba8f94d2017-10-23 09:51:13 -0700108 Log Received response from CLAMP ${resp.text}
109 [Return] ${resp}