[OOM] Remove disabled components from healtchecks
[testsuite.git] / robot / resources / clamp_interface.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with Microservice Bus.
3 Library           RequestsLibrary
4 Library           Collections
5 Library           String
6 Library           ONAPLibrary.JSON
7 Library           ONAPLibrary.Templating    WITH NAME    Templating
8 Resource          global_properties.robot
9
10 *** Variables ***
11 ${CLAMP_HEALTH_CHECK_PATH}        /restservices/clds/v1/healthcheck
12 ${CLAMP_ENDPOINT}     ${GLOBAL_CLAMP_SERVER_PROTOCOL}://${GLOBAL_INJECTED_CLAMP_IP_ADDR}:${GLOBAL_CLAMP_SERVER_PORT}
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
16
17 ${CLAMP_TEMPLATE_PATH}        clamp
18
19
20 *** Keywords ***
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}
25      Templating.Create Environment    clamp    ${GLOBAL_TEMPLATE_FOLDER}
26      ${data}=   Templating.Apply Template    clamp    ${CLAMP_TEMPLATE_PATH}/create_model.jinja    ${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
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      Templating.Create Environment    clamp    ${GLOBAL_TEMPLATE_FOLDER}
39      ${data}=   Templating.Apply Template    clamp    ${CLAMP_TEMPLATE_PATH}/save_model_vlb.jinja    ${dict}
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
52
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
59 Run CLAMP Get Control Loop
60      [Documentation]   runs CLAMP Open Control Loop based on model name and returns control_loop_id
61      [Arguments]   ${model_name}
62      ${data_path}=   Set Variable   ${CLAMP_BASE_PATH}/clds/model/${model_name}
63      ${resp}=   Run Clamp HTTPS Get Request    ${data_path}
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
68      [Return]      ${control_loop_id[0]}
69
70 Run CLAMP Get Model Names
71      [Documentation]   runs CLAMP Get Model Names and returns the model_id
72      ${data_path}=   Set Variable   ${CLAMP_BASE_PATH}/clds/model-names
73      ${resp}=   Run Clamp HTTPS Get Request    ${data_path}
74      [Return]     ${resp.json()[0]['value']}
75
76 Run CLAMP Health Check
77      [Documentation]    Runs CLAMP Health check
78      ${resp}=    Run CLAMP Get Request    ${CLAMP_HEALTH_CHECK_PATH}
79      Should Be Equal As Integers        ${resp.status_code}     200
80
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
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
99      Log    ${resp.json()}
100      [Return]    ${resp}
101
102 Run CLAMP Get Request
103      [Documentation]    Runs CLAMP Get request
104      [Arguments]    ${data_path}
105      ${session}=    Create Session      session         ${CLAMP_ENDPOINT}
106      ${resp}=   Get Request     session         ${data_path}
107      Should Be Equal As Integers        ${resp.status_code}     200
108      Log    Received response from CLAMP ${resp.text}
109      [Return]    ${resp}