Move CSIT to integration/csit repo
[integration/csit.git] / tests / aai / traversal / suite1 / custom_query_1.robot
1 *** Settings ***
2 Library       OperatingSystem
3 Library       RequestsLibrary
4 Library       requests
5 Library       Collections
6
7 *** Variables ***
8 ${GENERICVNFKEYVALUE}  generic-vnf-integration-test1
9 ${PSERVERKEYVALUE}     pserver-integration-test1
10 ${GENERICVNFURL}       https://${HOST_IP}:8443/aai/v11/network/generic-vnfs/generic-vnf/${GENERICVNFKEYVALUE}
11 ${PSERVERURL}          https://${HOST_IP}:8443/aai/v11/cloud-infrastructure/pservers/pserver/${PSERVERKEYVALUE}
12 ${RELATIONSHIPURL}     https://${HOST_IP}:8443/aai/v11/network/generic-vnfs/generic-vnf/${GENERICVNFKEYVALUE}/relationship-list/relationship
13 ${CUSTOMQUERYURL}      https://${HOST_IP}:8443/aai/v11/query?format=simple
14 ${GENERICVNFDATA}  { "vnf-id": "${GENERICVNFKEYVALUE}", "vnf-name": "example-vnf-name-val-51663", "vnf-name2": "example-vnf-name2-val-15450", "vnf-type": "example-vnf-type-val-32726", "service-id": "example-service-id-val-49385", "regional-resource-zone": "example-regional-resource-zone-val-41257", "prov-status": "example-prov-status-val-5666", "operational-status": "example-operational-status-val-95008", "license-key": "example-license-key-val-25823", "equipment-role": "example-equipment-role-val-30138", "orchestration-status": "example-orchestration-status-val-18897", "heat-stack-id": "example-heat-stack-id-val-46807", "mso-catalog-key": "example-mso-catalog-key-val-43833", "management-option": "example-management-option-val-92040", "ipv4-oam-address": "example-ipv4-oam-address-val-85170", "ipv4-loopback0-address": "example-ipv4-loopback0-address-val-88650", "nm-lan-v6-address": "example-nm-lan-v6-address-val-76997", "management-v6-address": "example-management-v6-address-val-10065", "vcpu": 5182376, "vcpu-units": "example-vcpu-units-val-52149", "vmemory": 35401466, "vmemory-units": "example-vmemory-units-val-46534", "vdisk": 74255232, "vdisk-units": "example-vdisk-units-val-83649", "in-maint": true, "is-closed-loop-disabled": true, "summary-status": "example-summary-status-val-99435", "encrypted-access-flag": true, "entitlement-assignment-group-uuid": "example-entitlement-assignment-group-uuid-val-50758", "entitlement-resource-uuid": "example-entitlement-resource-uuid-val-21058", "license-assignment-group-uuid": "example-license-assignment-group-uuid-val-99092", "license-key-uuid": "example-license-key-uuid-val-93512", "nf-naming-code": "example-nf-naming-code-val-89", "selflink": "example-selflink-val-42557", "ipv4-oam-gateway-address": "example-ipv4-oam-gateway-address-val-50012", "ipv4-oam-gateway-address-prefix-length": 92759, "vlan-id-outer": 20604980, "nm-profile-name": "example-nm-profile-name-val-35055" }
15 ${PSERVERDATA}  { "hostname": "${PSERVERKEYVALUE}", "ptnii-equip-name": "example-ptnii-equip-name-val-91724", "number-of-cpus": 56461, "disk-in-gigabytes": 13534, "ram-in-megabytes": 66589, "equip-type": "example-equip-type-val-94149", "equip-vendor": "example-equip-vendor-val-91811", "equip-model": "example-equip-model-val-26157", "fqdn": "example-fqdn-val-19743", "pserver-selflink": "example-pserver-selflink-val-67676", "ipv4-oam-address": "example-ipv4-oam-address-val-12819", "serial-number": "example-serial-number-val-33384", "ipaddress-v4-loopback-0": "example-ipaddress-v4-loopback0-val-63311", "ipaddress-v6-loopback-0": "example-ipaddress-v6-loopback0-val-70485", "ipaddress-v4-aim": "example-ipaddress-v4-aim-val-23497", "ipaddress-v6-aim": "example-ipaddress-v6-aim-val-24473", "ipaddress-v6-oam": "example-ipaddress-v6-oam-val-38196", "inv-status": "example-inv-status-val-10016", "pserver-id": "example-pserver-id-val-90123", "internet-topology": "example-internet-topology-val-17042", "in-maint": true, "pserver-name2": "example-pserver-name2-val-12304", "purpose": "example-purpose-val-86719", "prov-status": "example-prov-status-val-68126", "management-option": "example-management-option-val-86521", "host-profile": "example-host-profile-val-48679" }
16 ${CUSTOMQUERYDATA}  {"gremlin":"g.V().has(\\'hostname\\', \\'${PSERVERKEYVALUE}\\')"}
17 ${PSERVER_GENERIC_VNF_RELATIONSHIPDATA}         {"related-to":"pserver","relationship-data":[{"relationship-key":"pserver.hostname","relationship-value":"${PSERVERKEYVALUE}"}]}
18
19 *** Test Cases ***
20
21 Run AAI Put generic-vnf
22     [Documentation]             Create an generic-vnf object
23     ${resp}=                    PutWithCert              ${GENERICVNFURL}              ${GENERICVNFDATA}
24     log                         ${GENERICVNFURL}
25     log                         ${resp.text}
26     Should Be Equal As Strings  ${resp.status_code}      201
27         
28 Run AAI Put pserver
29     [Documentation]             Create an pserver object
30     ${resp}=                    PutWithCert              ${PSERVERURL}              ${PSERVERDATA}
31     log                         ${PSERVERURL}
32     log                         ${resp.text}
33     Should Be Equal As Strings  ${resp.status_code}      201    
34         
35 Run AAI Put relationship of pserver and generic-vnf
36     [Documentation]             Create relationship of pserver and generic-vnf
37     ${resp}=                    PutWithCert              ${RELATIONSHIPURL}              ${PSERVER_GENERIC_VNF_RELATIONSHIPDATA}
38     log                         ${RELATIONSHIPURL}
39     log                         ${resp.text}
40     Should Be Equal As Strings  ${resp.status_code}      200
41
42 Run AAI Get pserver
43     [Documentation]             Get the pserver object just relationship
44     ${resp}                     GetWithCert              ${PSERVERURL}
45     log                         ${resp}
46     log                         ${resp.json()}
47     Should Be Equal As Strings  ${resp.status_code}      200    
48         
49 Run AAI Get generic-vnf
50     [Documentation]             Get the generic-vnf object just relationship
51     ${resp}                     GetWithCert              ${GENERICVNFURL}
52     log                         ${resp}
53     log                         ${resp.json()}
54     Should Be Equal As Strings  ${resp.status_code}      200    
55         
56 Run AAI Put custom query simple format
57     [Documentation]             custom query simple format
58     log                         ${CUSTOMQUERYDATA}
59     ${resp}=                    PutWithCert              ${CUSTOMQUERYURL}              ${CUSTOMQUERYDATA}
60     log                         ${CUSTOMQUERYURL}
61     log                         ${resp.text}
62         log                         ${resp.json()}
63     Should Be Equal As Strings  ${resp.status_code}      200
64         
65 Run AAI Get generic-vnf to delete
66     [Documentation]             Get the generic-vnf object to delete
67     ${resp}                     GetWithCert              ${GENERICVNFURL}
68     log                         ${resp}
69     log                         ${resp.json()}
70     Should Be Equal As Strings  ${resp.status_code}      200
71     ${resource_version}=        Evaluate                 $resp.json().get('resource-version')
72     Set Global Variable                 ${resource_version}
73
74 Run AAI Delete generic-vnf
75     [Documentation]             Delete the generic-vnf
76     ${resp}=                    DeleteWithCert           ${GENERICVNFURL}?resource-version=${resource_version}
77     log                         ${resp.text}
78     Should Be Equal As Strings  ${resp.status_code}      204
79         
80 Run AAI Get pserver to delete
81     [Documentation]             Get the pserver object to delete
82     ${resp}                     GetWithCert              ${PSERVERURL}
83     log                         ${resp}
84     log                         ${resp.json()}
85     Should Be Equal As Strings  ${resp.status_code}      200
86     ${resource_version}=        Evaluate                 $resp.json().get('resource-version')
87     Set Global Variable                 ${resource_version}
88
89 Run AAI Delete pserver
90     [Documentation]             Delete the pserver
91     ${resp}=                    DeleteWithCert           ${PSERVERURL}?resource-version=${resource_version}
92     log                         ${resp.text}
93     Should Be Equal As Strings  ${resp.status_code}      204    
94
95 *** Keywords ***
96 PutWithCert
97     [Arguments]      ${url}      ${data}
98     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
99     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
100     ${resp}=         Evaluate    requests.put('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
101     [return]         ${resp}
102         
103 PatchWithCert
104     [Arguments]      ${url}      ${data}
105     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/merge-patch+json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
106     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
107     ${resp}=         Evaluate    requests.patch('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
108     [return]         ${resp}    
109
110 PostWithCert
111     [Arguments]      ${url}      ${data}
112     ${auth}=         Create List  AAI AAI
113     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
114     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
115     ${resp}=         Evaluate    requests.post('${url}', data='${data}', headers=${headers}, cert=${certinfo}, verify=False)    requests
116     [return]         ${resp}
117
118 GetWithCert
119     [Arguments]      ${url}
120     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
121     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
122     ${resp}=         Evaluate    requests.get('${url}', headers=${headers}, cert=${certinfo}, verify=False)    requests
123     [return]         ${resp}
124
125 DeleteWithCert
126     [Arguments]      ${url}
127     ${auth}=         Create List  AAI AAI
128     ${headers}=      Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=integration-aai    X-FromAppId=integration-aai   Authorization=Basic QUFJOkFBSQ==
129     ${certinfo}=     Evaluate    ('${CURDIR}/aai.crt', '${CURDIR}/aai.key')
130     ${resp}=         Evaluate    requests.delete('${url}', headers=${headers}, cert=${certinfo}, verify=False)    requests
131     [return]         ${resp}