blob: ca7b3fd0d26421075411ee121d8cfb21ed115ae9 [file] [log] [blame]
Suchitra Vemurib86b86d2018-04-11 15:07:19 -07001*** Settings ***
2Documentation Test suite for Instance creation for multiple subscribers with same "s_tag" - Chameleon APIs
3Suite Setup Read InputFile
4Library Collections
5Library String
6Library OperatingSystem
7Library XML
8Library RequestsLibrary
9Library HttpLibrary.HTTP
10Library ../Framework/utils/utils.py
11Library ../Framework/restApi.py
12
13*** Variables ***
14${PATHFILE} ${CURDIR}/data/Soak_ScaleVSG.json
15${SCALE_COUNT} 1
16
17*** Test Cases ***
18Test Post Subscriber Create
19 [Documentation] Tests creates subscribers based on the count
20 ${service_specific_id}= utils.convertStringToInt ${service_specific_id}
21 :FOR ${i} IN RANGE ${SCALE_COUNT}
22 \ ${service_specific_id}= Evaluate ${service_specific_id} + 1
23 \ ${service_specific_id}= utils.convertToString ${service_specific_id}
24 \ &{subscriberDict}= Create Dictionary service_specific_id ${service_specific_id}
25 \ ${api_result}= restApi.ApiPost VOLT_SUBSCRIBER ${subscriberDict}
26 \ Should Be True ${api_result}
27 # Volt Tenant Creation
28 \ ${json_result}= restApi.ApiGet VOLT_SUBSCRIBER
29 \ Log ${json_result}
30 \ ${json_result_list}= Get From Dictionary ${json_result} items
31 \ ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} service_specific_id ${service_specific_id}
32 \ ${Subscriber_Id}= utils.getFieldValueFromDict ${getJsonDict} id
33 \ Log ${Subscriber_Id}
34 \ ${s_tag}= Evaluate ${s_tag} + 1
35 \ ${c_tag}= Evaluate ${c_tag} + 1
36 \ &{voltDict}= Create Dictionary s_tag ${s_tag} c_tag ${c_tag}
37 \ Log ${voltDict}
38 \ ${postResult}= restApi.ApiPost VOLT_TENANT ${voltDict}
39 \ Sleep 30
40 # Verifying GET operation after POST
41 \ ${get_result}= restApi.ApiGet VOLT_TENANT
42 \ ${get_result_list}= Get From Dictionary ${get_result} items
43 \ ${getJsonDict}= utils.getDictFromListofDict ${get_result_list} c_tag ${c_tag}
44 \ Log ${getJsonDict}
45 \ #${test_result}= utils.compare_dict ${voltDict} ${getJsonDict}
46 \ #Should Be True ${test_result}
47 \ ${Volt_Id}= Get From Dictionary ${getJsonDict} id
48 \ ${provided_links_ids_list}= utils.getFieldValueFromDict ${getJsonDict} provided_links_ids
49 \ Log ${provided_links_ids_list}
50 \ ${provided_links_ids}= Get From List ${provided_links_ids_list} 0
51 \ Log ${provided_links_ids}
52 # Get subscribed_links_ids from volttenant
53 \ ${subscribed_links_ids_list}= utils.getFieldValueFromDict ${getJsonDict} subscribed_links_ids
54 \ ${subscribed_links_ids}= Get From List ${subscribed_links_ids_list} 0
55 # Retrieve service links using provided links ID
56 \ ${getServiceLink}= restApi.ApiChameleonGet CH_CORE_SERVICELINK ${provided_links_ids}
57 \ ${provider_service_instance_id}= Get From Dictionary ${getServiceLink} provider_service_instance_id
58 # Update the subscriber_service_instance_id to the required subscriber_id to establish desired link
59 \ ${serviceDict}= Create Dictionary subscriber_service_instance_id=${Subscriber_Id}
60 \ ${result}= restApi.ApiChameleonPut CH_CORE_SERVICELINK ${serviceDict} ${provided_links_ids}
61 \ Sleep 30
62 \ Should Be True ${result}
63 # Validation of Instances
64 \ Log ${instanceList}
65 \ ${serviceLinkDict}= restApi.ApiChameleonGet CH_CORE_SERVICELINK ${subscribed_links_ids}
66 \ Log ${serviceLinkDict}
67 \ ${VSGTenant}= Get From Dictionary ${serviceLinkDict} provider_service_instance_id
68 # Retrieve VSGTenant to retrieve instance_id
69 \ ${getVSG_result}= restApi.ApiChameleonGet VSG_TENANT ${VSGTenant}
70 \ ${instance_id}= Get From Dictionary ${getVSG_result} instance_id
71 \ Append To List ${instanceList} ${instance_id}
72 # Wait for container to be created
73 \ Sleep 420
74 # Verify container creation within the VSG
75 \ ${nova_id}= Run . /opt/cord_profile/admin-openrc.sh; nova list --all-tenants | grep mysite_vsg-${instance_id} | awk '{print $2}'
76 \ ${compute_node}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep :host | awk '{print $4}'
77 \ ${vsg_ip}= Run . /opt/cord_profile/admin-openrc.sh; nova show ${nova_id} | grep management | awk '{print $5}'
78 \ ${docker_container}= Run ssh -o ProxyCommand="ssh -W %h:%p -l ubuntu ${compute_node}" ubuntu@${vsg_ip} sudo docker ps | grep vsg-${s_tag}-${c_tag} | wc -l
79 \ Should Not Contain ${docker_container} 0
80 Log ${c_tag}
81 Log ${s_tag}
82 Log ${service_specific_id}
83
84*** Keywords ***
85Read InputFile
86 ${inputDict}= utils.readFile ${PATHFILE}
87 Log To Console \n ${inputDict}
88 ${service_specific_id}= Get Json Value ${inputDict} /service_specific_id
89 Log \n ${service_specific_id}
90 ${s_tag} = Get Json Value ${inputDict} /s_tag
91 Log \n ${s_tag}
92 ${c_tag} = Get Json Value ${inputDict} /c_tag
93 Log \n ${c_tag}
94 Set Suite Variable ${service_specific_id}
95 Set Suite Variable ${s_tag}
96 Set Suite Variable ${c_tag}
97 @{instanceList}= Create List
98 Set Suite Variable @{instanceList}