Add TemplatedRequests.robot Resource
[integration/test.git] / csit / suites / controller / OneNode_Datastore / carpeople_library_test.robot
1 *** Settings ***
2 Documentation     Basic library verification suite, handling cars/people in 1-node setup.
3 ...
4 ...               Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
5 ...
6 ...               This program and the accompanying materials are made available under the
7 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...               This is a lightweight and stripped-down functional analogue of performance suite.
11 ...               Intention is to use this as a verify suite for changes in TemplatedRequests resource.
12 Suite Setup       Start_Suite
13 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
14 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
15 Variables         ${CURDIR}/../../../variables/Variables.py
16 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
17 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
18
19 *** Variables ***
20 ${VAR_BASE}       ${CURDIR}/../../../variables/carpeople/libtest
21 ${BULK_SIZE}      2
22 ${TIMEOUT_BUG_4220}    60s
23
24 *** Test Cases ***
25 Wait_For_Rpcs
26     [Documentation]    Issue (invalid) RPC requests until 501 goes away (or timeout expires).
27     ...    See https://bugs.opendaylight.org/show_bug.cgi?id=4220
28     BuiltIn.Wait_Until_Keyword_Succeeds    ${TIMEOUT_BUG_4220}    5s    Check_Rpc_Readiness
29
30 Add_And_Verify_Person
31     [Documentation]    Add a person entry, verify it is seen in the datastore.
32     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/person
33     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_BASE}/person    verify=True
34
35 Add_And_Verify_Car
36     [Documentation]    Add a car entry, verify it is seen in the datastore.
37     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/car
38     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_BASE}/car    verify=True
39
40 Purchase_And_Verify_Car
41     [Documentation]    Post RPC to buy a car.
42     TemplatedRequests.Post_As_Json_Templated    folder=${VAR_BASE}/purchase
43     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_BASE}/car_person    verify=True
44
45 Delete_CarPerson
46     [Documentation]    Remove the car-people entry from the datastore.
47     TemplatedRequests.Delete_Templated    folder=${VAR_BASE}/car_person
48     # TODO: Add specific error check on Get attempt.
49
50 Delete_Car
51     [Documentation]    Remove the car entry from the datastore.
52     TemplatedRequests.Delete_Templated    folder=${VAR_BASE}/car
53     # TODO: Add specific error check on Get attempt.
54
55 Delete_Person
56     [Documentation]    Remove the person entry from the datastore.
57     TemplatedRequests.Delete_Templated    folder=${VAR_BASE}/person
58     # TODO: Add specific error check on Get attempt.
59
60 Add_And_Verify_People
61     [Documentation]    Create container with several people, verify it is seen in the datastore..
62     TemplatedRequests.Post_As_Json_Templated    folder=${VAR_BASE}/people    iterations=${BULK_SIZE}
63     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_BASE}/people    verify=True    iterations=${BULK_SIZE}
64
65 Add_And_Verify_Cars
66     [Documentation]    Create container with several cars, verify it is seen in the datastore.
67     TemplatedRequests.Post_As_Json_Templated    folder=${VAR_BASE}/cars    iterations=${BULK_SIZE}
68     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_BASE}/cars    verify=True    iterations=${BULK_SIZE}
69     # TODO: Add cases with purchase loop.
70
71 Delete_CarsPeople
72     [Documentation]    Remove cars-people container from the datastore.
73     TemplatedRequests.Delete_Templated    folder=${VAR_BASE}/cars_people
74     # TODO: Add specific error check on Get attempt.
75
76 Delete_Cars
77     [Documentation]    Remove cars container from the datastore.
78     TemplatedRequests.Delete_Templated    folder=${VAR_BASE}/cars
79     # TODO: Add specific error check on Get attempt.
80
81 Delete_People
82     [Documentation]    Remove people container from the datastore.
83     TemplatedRequests.Delete_Templated    folder=${VAR_BASE}/people
84     # TODO: Add specific error check on Get attempt.
85
86 *** Keywords ***
87 Start_Suite
88     [Documentation]    Suite setup keyword
89     SetupUtils.Setup_Utils_For_Setup_And_Teardown
90     TemplatedRequests.Create_Default_Session
91
92 Check_Rpc_Readiness
93     [Documentation]    Issue invalid RPC requests and assert appropriate http status code
94     # So far only buy-car is checked, but other RPCs such as add-car may be added later.
95     ${status}    ${message} =    BuiltIn.Run_Keyword_And_Ignore_Error    TemplatedRequests.Post_As_Json_To_Uri    uri=restconf/operations/car-purchase:buy-car    data={"input":{}}
96     # TODO: Create template directory for this?
97     BuiltIn.Should_Not_Contain    ${message}    '50