blob: 3a3e0b8268cf43bfc4702b8eff79304e84075e71 [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
Brian Freeman893c12a2019-01-17 13:48:16 -05006Library JSONUtils
Gary Wuba8f94d2017-10-23 09:51:13 -07007
8Resource global_properties.robot
Brian Freeman893c12a2019-01-17 13:48:16 -05009Resource json_templater.robot
Gary Wuba8f94d2017-10-23 09:51:13 -070010
11*** Variables ***
Brian Freemand089b942018-09-07 07:30:06 -050012${CLAMP_HEALTH_CHECK_PATH} /restservices/clds/v1/healthcheck
Gary Wuba8f94d2017-10-23 09:51:13 -070013${CLAMP_ENDPOINT} ${GLOBAL_CLAMP_SERVER_PROTOCOL}://${GLOBAL_INJECTED_CLAMP_IP_ADDR}:${GLOBAL_CLAMP_SERVER_PORT}
Brian Freeman86805fe2019-01-16 09:03:42 -050014${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 Wuba8f94d2017-10-23 09:51:13 -070017
Brian Freeman893c12a2019-01-17 13:48:16 -050018${CLAMP_TEMPLATE_PATH} robot/assets/templates/clamp
19
Gary Wuba8f94d2017-10-23 09:51:13 -070020
21*** Keywords ***
Brian Freeman893c12a2019-01-17 13:48:16 -050022Run 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 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=$
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
44Run 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 Freeman893c12a2019-01-17 13:48:16 -050051
Brian Freemancc84e482019-01-16 09:38:46 -050052Run 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 Freeman86805fe2019-01-16 09:03:42 -050058Run CLAMP Get Control Loop
Brian Freeman22d7f742019-01-17 11:57:59 -050059 [Documentation] runs CLAMP Open Control Loop based on model name and returns control_loop_id
Brian Freeman86805fe2019-01-16 09:03:42 -050060 [Arguments] ${model_name}
Brian Freemancc84e482019-01-16 09:38:46 -050061 ${data_path}= Set Variable ${CLAMP_BASE_PATH}/clds/model/${model_name}
Brian Freeman86805fe2019-01-16 09:03:42 -050062 ${resp}= Run Clamp HTTPS Get Request ${data_path}
Brian Freeman22d7f742019-01-17 11:57:59 -050063 # 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 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 #Set Suite Variable ${CURRENT_MODEL_ID} ${resp.json()[0]['value']}
75 [Return] ${resp.json()[0]['value']}
Brian Freeman86805fe2019-01-16 09:03:42 -050076
Gary Wuba8f94d2017-10-23 09:51:13 -070077Run CLAMP Health Check
78 [Documentation] Runs CLAMP Health check
79 ${resp}= Run CLAMP Get Request ${CLAMP_HEALTH_CHECK_PATH}
Brian Freeman86805fe2019-01-16 09:03:42 -050080 Should Be Equal As Integers ${resp.status_code} 200
81
Brian Freeman893c12a2019-01-17 13:48:16 -050082Run 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 Freeman86805fe2019-01-16 09:03:42 -050093Run 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 Freemancc84e482019-01-16 09:38:46 -0500100 Log ${resp.json()}
Brian Freeman86805fe2019-01-16 09:03:42 -0500101 [Return] ${resp}
Gary Wuba8f94d2017-10-23 09:51:13 -0700102
103Run CLAMP Get Request
104 [Documentation] Runs CLAMP Get request
105 [Arguments] ${data_path}
Brian Freeman86805fe2019-01-16 09:03:42 -0500106 ${session}= Create Session session ${CLAMP_ENDPOINT}
107 ${resp}= Get Request session ${data_path}
108 Should Be Equal As Integers ${resp.status_code} 200
Gary Wuba8f94d2017-10-23 09:51:13 -0700109 Log Received response from CLAMP ${resp.text}
110 [Return] ${resp}