Kailash | 1675831 | 2019-03-18 14:10:39 -0700 | [diff] [blame] | 1 | # XOS Core Test |
| 2 | # |
| 3 | # This test will validate the xos-core's sync steps and model policies using the TestService |
| 4 | # |
| 5 | |
| 6 | *** Settings *** |
| 7 | Documentation Test migration of a Service in the core |
| 8 | Library RequestsLibrary |
| 9 | Library HttpLibrary.HTTP |
| 10 | Library Collections |
| 11 | Library String |
| 12 | Library OperatingSystem |
| 13 | Library DateTime |
| 14 | Library ../../Framework/utils/utils.py |
| 15 | Resource ../../Framework/utils/utils.robot |
| 16 | Library ../../Framework/restApi.py |
| 17 | Variables ../../Properties/RestApiProperties.py |
| 18 | Suite Setup Setup |
| 19 | Suite Teardown Teardown |
| 20 | |
| 21 | *** Variables *** |
| 22 | ${testservice_api} /xosapi/v1/testservice/testserviceservices |
| 23 | ${testservice_si} /xosapi/v1/testservice/testserviceserviceinstances |
| 24 | ${testservice_duplicate_si} /xosapi/v1/testservice/testserviceduplicateserviceinstances |
| 25 | |
| 26 | *** Test Cases *** |
| 27 | Create Test Model with No Duplicate |
| 28 | [Documentation] Create a testservice service instance with no duplicate |
| 29 | [Tags] create |
| 30 | ${model_name}= Generate Random Value string |
| 31 | ${data}= Create Dictionary name=${model_name} create_duplicate=${false} |
| 32 | ${resp}= CORD Post ${testservice_si} ${data} |
| 33 | ${json_content}= To Json ${resp.content} |
| 34 | ${test_serviceinstance_id}= Get From Dictionary ${json_content} id |
| 35 | Set Suite Variable ${test_serviceinstance_id} |
| 36 | Set Suite Variable ${model_name} |
| 37 | Repeat Keyword 10s Validate Duplicate Model false |
| 38 | |
| 39 | Update Model with Duplicate |
| 40 | [Tags] update |
| 41 | CORD Put ${testservice_si} {'create_duplicate': ${true}} ${test_serviceinstance_id} |
| 42 | Wait Until Keyword Succeeds 60s 2s Validate Duplicate Model true |
| 43 | |
| 44 | Revert Model |
| 45 | [Tags] revert notready |
| 46 | CORD Put ${testservice_si} {'create_duplicate': ${false}} ${test_serviceinstance_id} |
| 47 | Wait Until Keyword Succeeds 60s 2s Validate Duplicate Model false |
| 48 | |
| 49 | *** Keywords *** |
| 50 | Setup |
| 51 | ${auth} = Create List ${XOS_USER} ${XOS_PASSWD} |
| 52 | ${HEADERS} Create Dictionary Content-Type=application/json allow_modify_feedback=True |
| 53 | Create Session ${server_ip} http://${server_ip}:${server_port} auth=${AUTH} headers=${HEADERS} |
| 54 | # create test-service |
| 55 | ${data}= Create Dictionary name=xos-core-test-service-test |
| 56 | ${resp}= CORD Post ${testservice_api} ${data} |
| 57 | |
| 58 | Teardown |
| 59 | [Documentation] Delete all https sessions |
| 60 | Clean Up Objects ${testservice_si} |
| 61 | Clean Up Objects ${testservice_duplicate_si} |
| 62 | Clean Up Objects ${testservice_api} |
| 63 | Delete All Sessions |
| 64 | |
| 65 | Validate Duplicate Model |
| 66 | [Documentation] Checks if 'testserviceduplicateserviceinstances' was created or not |
| 67 | [Arguments] ${exists}=false |
| 68 | ${resp}= Wait Until Keyword Succeeds 60s 2s CORD Get ${testservice_duplicate_si} |
| 69 | ${jsondata}= To Json ${resp.content} |
| 70 | Run Keyword If '${exists}' == 'false' Should Be Empty ${jsondata['items']} ELSE Verify Exists ${jsondata} |
| 71 | |
| 72 | Verify Exists |
| 73 | [Arguments] ${data} |
| 74 | ${dict}= Get From List ${data['items']} 0 |
| 75 | Should Be Equal As Strings ${dict['name']} ${model_name} |