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