upgrade to python3 libraries
[testsuite.git] / robot / resources / appc_interface.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with APP-C. It handles low level stuff like managing the http request library and APP-C required fields
3 Library               RequestsLibrary
4 Library           UUID
5 Library           OperatingSystem
6 Library           SeleniumLibrary
7 Library           StringTemplater
8 Resource          global_properties.robot
9 Resource          browser_setup.robot
10
11 *** Variables ***
12 ${APPC_INDEX_PATH}    /restconf
13 ${APPC_HEALTHCHECK_OPERATION_PATH}  /operations/SLI-API:healthcheck
14 ${APPC_CREATE_MOUNTPOINT_PATH}  /config/network-topology:network-topology/topology/topology-netconf/node/
15 ${APPC_MOUNT_XML}    robot/assets/templates/appc/vnf_mount.template
16 ${APPC_ENDPOINT}    ${GLOBAL_APPC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPC_IP_ADDR}:${GLOBAL_APPC_SERVER_PORT}
17 ${APPC_CDT_Config_Scaleout}    ${EXECDIR}/robot/assets/templates/appc/template_ConfigScaleOut_vLoadBalancer_vLoadBalancer-test0_0.0.1V_vLB.xml
18 ${APPC_CDT_Config_Scaleout_PD}    ${EXECDIR}/robot/assets/templates/appc/pd_ConfigScaleOut_vLoadBalancer_vLoadBalancer-test0_0.0.1V_vLB.yaml
19 ${APPC_CDT_Config_Scaleout_REF}    ${EXECDIR}/robot/assets/templates/appc/reference_AllAction_vLoadBalancer_vLoadBalancer-test0_0.0.1V.json
20 ${APPC_CDT_Config_Scaleout_REF_name}    reference_AllAction_vLoadBalancer_vLoadBalancer-test0_0.0.1V.json
21 ${APPC_CDT_ENDPOINT}    ${GLOBAL_APPC_CDT_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPC_CDT_IP_ADDR}:${GLOBAL_APPC_CDT_SERVER_PORT}
22 ${APPC_CDT_LOGIN_URL}                ${APPC_CDT_ENDPOINT}/index.html
23
24
25 *** Keywords ***
26 Run APPC Health Check
27     [Documentation]    Runs an APPC healthcheck
28         ${resp}=    Run APPC Post Request     ${APPC_INDEX PATH}${APPC_HEALTHCHECK_OPERATION_PATH}     ${None}
29     Should Be Equal As Strings  ${resp.status_code}     200
30     Should Be Equal As Strings  ${resp.json()['output']['response-code']}       200
31
32 Run APPC Post Request
33     [Documentation]    Runs an APPC post request
34     [Arguments]    ${data_path}    ${data}    ${content}=json
35     ${auth}=  Create List  ${GLOBAL_APPC_USERNAME}    ${GLOBAL_APPC_PASSWORD}
36     Log    Creating session ${APPC_ENDPOINT}
37     ${session}=    Create Session       appc    ${APPC_ENDPOINT}    auth=${auth}
38     ${uuid}=    Generate UUID
39     ${headers}=  Create Dictionary     Accept=application/${content}    Content-Type=application/${content}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
40     ${resp}=    Post Request    appc    ${data_path}     data=${data}    headers=${headers}
41     Log    Received response from appc ${resp.text}
42     [Return]    ${resp}
43
44 Run APPC Put Request
45     [Documentation]    Runs an APPC post request
46     [Arguments]    ${data_path}    ${data}    ${content}=xml
47     ${auth}=  Create List  ${GLOBAL_APPC_USERNAME}    ${GLOBAL_APPC_PASSWORD}
48     Log    Creating session ${APPC_ENDPOINT}
49     ${session}=    Create Session       appc    ${APPC_ENDPOINT}    auth=${auth}
50     ${uuid}=    Generate UUID
51     ${headers}=  Create Dictionary     Accept=application/${content}    Content-Type=application/${content}    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
52     ${resp}=    Put Request     appc    ${data_path}     data=${data}    headers=${headers}
53     Log    Received response from appc ${resp.text}
54     [Return]    ${resp}
55
56 Create Mount Point In APPC
57     [Documentation]     Go tell APPC about the PGN we just spun up...
58     [Arguments]    ${nodeid}    ${host}    ${port}=${GLOBAL_PGN_PORT}    ${username}=admin    ${password}=admin
59     ${dict}=    Create Dictionary    nodeid=${nodeid}    host=${host}    port=${port}    username=${username}    password=${password}
60     ${template}=    OperatingSystem.Get File    ${APPC_MOUNT_XML}
61     ${data}=    Template String    ${template}    ${dict}
62     ${resp}=    Run APPC Put Request     ${APPC_INDEX PATH}${APPC_CREATE_MOUNTPOINT_PATH}${nodeid}     ${data}
63     Should Be True      200    <= ${resp.status_code} < 300
64     [Return]     ${resp}
65
66 Preload APPC CDT GUI
67     [Documentation]   APPC CDT GUI Preload
68     [Arguments]    ${username}=${GLOBAL_APPC_CDT_USERNAME}   ${reference_file_name}=${APPC_CDT_Config_Scaleout_REF_name}   ${reference_file}=${APPC_CDT_Config_Scaleout_REF}   ${template_file}=${APPC_CDT_Config_Scaleout}   ${parameterdefinition_file}=${APPC_CDT_Config_Scaleout_PD}
69     # Setup Browser Now being managed by test case
70     ##Setup Browser
71     Go To   ${APPC_CDT_LOGIN_URL}#/home
72     Set Selenium Speed   ${GLOBAL_SELENIUM_DELAY}
73     Set Browser Implicit Wait    ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
74     Log   Logging in to ${APPC_CDT_ENDPOINT}
75     Handle Proxy Warning
76     Wait Until Page Contains   WELCOME   ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
77     Go To    ${APPC_CDT_LOGIN_URL}#/vnfs
78     Wait Until Element Is Visible   id=userId   ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
79     Input Text   id=userId   ${username}
80     Click Button   Submit
81     Page Should Contain   ${username}
82     Wait Until Page Contains Element   xpath=(//*[@class='mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary'])   ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
83     Click Button   Create New VNF Type or VNFC Type
84     Page Should Contain   Enter VNF type and VNFC to proceed
85     Click Button   Proceed anyway
86     Click Button   Upload Reference File
87     Choose File   id=inputFile   ${reference_file}
88     Select From List By Value   name=templateIdentifier   vLB
89     Sleep   ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
90     Click Link   Template
91     Click Button   Upload Template File
92     Choose File   id=inputFile   ${template_file}
93     Sleep   ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
94     Click Link   Parameter Definition
95     Click Button   UPLOAD PD FILE
96     Choose File   id=inputFile1   ${parameterdefinition_file}
97     Sleep   ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
98     Click Link   Reference Data
99     Select From List By Value   name=templateIdentifier   vLB
100     Click Button   saveToAppc
101     Go To    ${APPC_CDT_LOGIN_URL}#/vnfs
102     Wait Until Page Contains   ${reference_file_name}   ${GLOBAL_SELENIUM_BROWSER_WAIT_TIMEOUT}
103     Log   Logged in to ${APPC_CDT_ENDPOINT}