Suchitra Vemuri | c2eb5f1 | 2018-03-27 18:26:08 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test suite for Instance creation for multiple subscribers with same "s_tag" - Chameleon APIs |
| 3 | Suite Setup Read InputFile |
| 4 | Library Collections |
| 5 | Library String |
| 6 | Library OperatingSystem |
| 7 | Library XML |
| 8 | Library RequestsLibrary |
| 9 | Library HttpLibrary.HTTP |
| 10 | Library ../Framework/utils/utils.py |
| 11 | Library ../Framework/restApi.py |
| 12 | |
| 13 | *** Variables *** |
Suchitra Vemuri | c2eb5f1 | 2018-03-27 18:26:08 -0700 | [diff] [blame] | 14 | ${PATHFILE} ${CURDIR}/data/Soak_ScaleVCPE.json |
| 15 | ${SCALE_COUNT} 1 |
| 16 | |
| 17 | *** Test Cases *** |
| 18 | Test 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} + 0 |
| 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} |
Suchitra Vemuri | b6280fb | 2018-04-09 18:36:53 -0700 | [diff] [blame] | 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 |
Suchitra Vemuri | c2eb5f1 | 2018-03-27 18:26:08 -0700 | [diff] [blame] | 80 | Log ${c_tag} |
| 81 | Log ${service_specific_id} |
| 82 | |
| 83 | *** Keywords *** |
| 84 | Read InputFile |
| 85 | ${inputDict}= utils.readFile ${PATHFILE} |
| 86 | Log To Console \n ${inputDict} |
| 87 | ${service_specific_id}= Get Json Value ${inputDict} /service_specific_id |
| 88 | Log \n ${service_specific_id} |
| 89 | ${s_tag} = Get Json Value ${inputDict} /s_tag |
| 90 | Log \n ${s_tag} |
| 91 | ${c_tag} = Get Json Value ${inputDict} /c_tag |
| 92 | Log \n ${c_tag} |
| 93 | Set Suite Variable ${service_specific_id} |
| 94 | Set Suite Variable ${s_tag} |
| 95 | Set Suite Variable ${c_tag} |
| 96 | @{instanceList}= Create List |
| 97 | Set Suite Variable @{instanceList} |