Add initial set of gbp-sxp test cases
[integration/test.git] / csit / libraries / BierResource.robot
1 *** Settings ***
2 Documentation     Robot keyword library (Resource) for BIER information configuration and verification Python utilities.
3 ...
4 ...               Copyright (c) 2016-2017 Zte, Inc. and others. All rights reserved.
5 ...
6 ...               This resource contains some keywords which complete four main functions:
7 ...               Send corresponding request to datastore,
8 ...               Construct BIER information,
9 ...               Verity Configuration success or not and its result,
10 ...               Delete BIER configuration and close all session.
11 Library           Collections
12 Library           RequestsLibrary
13 Library           json
14
15 *** Keywords ***
16 Send_Request_To_Query_Topology_Id
17     [Arguments]    ${module}    ${oper}
18     [Documentation]    Send request to controller to query topologyid through REST-API using POST method, ${module} represents yang module and ${oper} represents rpc operation
19     ${resp}    Post Request    session    /restconf/operations/${module}:${oper}
20     BuiltIn.Log    ${resp.content}
21     [Return]    ${resp}
22
23 Send_Request_Operation_Besides_QueryTopology_Id
24     [Arguments]    ${module}    ${oper}    ${input}
25     [Documentation]    Send other request to controller besides query topologyid, for example configures domain, subdomain, node and so on. ${input} represents the request body
26     ${pkg}    Create Dictionary    input=${input}
27     ${data}    Dumps    ${pkg}
28     ${resp}    Post Request    session    /restconf/operations/${module}:${oper}    data=${data}
29     BuiltIn.Log    ${resp.content}
30     [Return]    ${resp}
31
32 Construct_Af
33     [Arguments]    ${ipv4_bsl}    ${ipv6_bsl}    ${bier_ipv4_mlslab_base}    ${bier_ipv6_mlslab_base}    ${bier_mlslab_range_size}
34     [Documentation]    Construct container af inside single subdomain by given details ${ipv4_bsl}, ${ipv6_bsl}, ${bier_mlslab_base} and ${bier_mlslab_range_size}
35     ${ipv4}    Create Dictionary    bitstringlength=${ipv4_bsl}    bier-mpls-label-base=${bier_ipv4_mlslab_base}    bier-mpls-label-range-size=${bier_mlslab_range_size}
36     ${ipv6}    Create Dictionary    bitstringlength=${ipv6_bsl}    bier-mpls-label-base=${bier_ipv6_mlslab_base}    bier-mpls-label-range-size=${bier_mlslab_range_size}
37     ${ipv4_list}    Create List    ${ipv4}
38     ${ipv6_list}    Create List    ${ipv6}
39     ${af}    Create Dictionary    ipv4=${ipv4_list}    ipv6=${ipv6_list}
40     [Return]    ${af}
41
42 Construct_Subdomain
43     [Arguments]    ${subdomain_id}    ${igp_type}    ${mt_id}    ${bfr_id}    ${bit_string_length}    ${af}
44     [Documentation]    Construct subdomain list in a domain by given details ${subdomain_id}, ${igp_type}, ${mt_id}, ${bfr_id}, ${bit_string_length}, ${af}
45     ${subdomain}    Create Dictionary    sub-domain-id=${subdomain_id}    igp-type=${igp_type}    mt-id=${mt_id}    bfr-id=${bfr_id}    bitstringlength=${bit_string_length}
46     ...    af=${af}
47     [Return]    ${subdomain}
48
49 Construct_Bier_Global
50     [Arguments]    ${encapsulation_type}    ${bit_string_length}    ${bfr_id}    ${ipv4_bfr_prefix}    ${ipv6_bfr_prefix}    ${subdomain_list}
51     [Documentation]    Construct bier global in a domain by given details ${encapsulation_type}, ${bit_string_length}, ${bfr_id}, ${ipv4_bfr_prefix}, ${ipv6_bfr_prefix}, ${subdomain_list}
52     ${bier_global}    Create Dictionary    encapsulation-type=${encapsulation_type}    bitstringlength=${bit_string_length}    bfr-id=${bfr_id}    ipv4-bfr-prefix=${ipv4_bfr_prefix}    ipv6-bfr-prefix=${ipv6_bfr_prefix}
53     ...    sub-domain=${subdomain_list}
54     [Return]    ${bier_global}
55
56 Construct_Domain
57     [Arguments]    ${domain_id}    ${bier_global}
58     [Documentation]    Construct domain by given details ${domain_id}, ${bier_global}
59     ${domain}    Create Dictionary    domain-id=${domain_id}    bier-global=${bier_global}
60     [Return]    ${domain}
61
62 Add_Subdomain
63     [Arguments]    ${subdomain_bfr_id_value}    ${subdomain_list}
64     [Documentation]    Construct ${af} to contruct new subdomain and add it to the ${subdomain_list}
65     ${af}    Construct_Af    ${BSL_OF_IPV4_AND_IPV6[2]}    ${BSL_OF_IPV4_AND_IPV6[0]}    9    13    4
66     ${subdomain}    Construct_Subdomain    ${SUBDOMAIN_ID_LIST[1]}    ${IGP_TYPE_LIST[1]}    ${MT_ID_LIST[0]}    ${subdomain_bfr_id_value}    ${BITSTRINGLENGTH_LIST[0]}
67     ...    ${af}
68     Append To List    ${subdomain_list}    ${subdomain}
69     BuiltIn.Log    ${subdomain_list}
70     [Return]    ${subdomain_list}
71
72 Add_Or_Modify_Ipv4
73     [Arguments]    ${ipv4_bsl}    ${ipv6_bsl}    ${bier_ipv4_mlslab_base}    ${bier_new_ipv4_mlslab_base}    ${bier_ipv6_mlslab_base}    ${bier_mlslab_range_size}
74     [Documentation]    Add or modify ipv4 inside af by given details ${ipv4_bsl}, ${ipv6_bsl}, ${bier_mlslab_base}, ${bier_mlslab_range_size}
75     ${ipv4_one}    Create Dictionary    bitstringlength=${ipv4_bsl}    bier-mpls-label-base=${bier_ipv4_mlslab_base}    bier-mpls-label-range-size=${bier_mlslab_range_size}
76     ${ipv4_two}    Create Dictionary    bitstringlength=${ipv6_bsl}    bier-mpls-label-base=${bier_new_ipv4_mlslab_base}    bier-mpls-label-range-size=${bier_mlslab_range_size}
77     ${ipv6}    Create Dictionary    bitstringlength=${ipv6_bsl}    bier-mpls-label-base=${bier_ipv6_mlslab_base}    bier-mpls-label-range-size=${bier_mlslab_range_size}
78     ${ipv4_list}    Create List    ${ipv4_one}    ${ipv4_two}
79     ${ipv6_list}    Create List    ${ipv6}
80     ${af}    Create Dictionary    ipv4=${ipv4_list}    ipv6=${ipv6_list}
81     [Return]    ${af}
82
83 Verify_Configuration_Success_Or_Not
84     [Arguments]    ${resp}
85     [Documentation]    Verify the return value ${resp} of request to controller success or not
86     BuiltIn.Should_Be_Equal    ${resp.status_code}    ${200}
87     ${root}    To Json    ${resp.content}
88     ${output}    Get From Dictionary    ${root}    output
89     ${configure_result}    Get From Dictionary    ${output}    configure-result
90     ${result}    Get From Dictionary    ${configure_result}    result
91     BuiltIn.Should_Be_Equal    ${result}    SUCCESS
92
93 Extract_NodeConfig_Output_And_Verify_Value
94     [Arguments]    ${resp}    ${subdomain_index}    ${ipv4_list_index}    ${node_id_value}    ${domain_id_value}    ${ipv4_value}
95     ...    ${ipv6_value}    ${bit_string_length_value}    ${bfr_id_value}    ${subdomain_id_value}    ${igp_type_value}    ${subdomain_bit_string_length_value}
96     ...    ${subdomain_bfr_id_value}    ${mt_id_value}    ${ipv4_bit_string_length_value}    ${ipv4_bier_mpls_label_base_value}    ${ipv4_bier_mpls_label_range_size_value}    ${ipv6_bit_string_length_value}
97     ...    ${ipv6_bier_mpls_label_base_value}    ${ipv6_bier_mpls_label_range_size_value}
98     [Documentation]    Extract the output of node configuration request and verify its value
99     ${root}    To Json    ${resp.content}
100     ${out_put}    Get From Dictionary    ${root}    output
101     ${node_list}    Get From Dictionary    ${out_put}    node
102     ${node}    Get From List    ${node_list}    0
103     ${node_id}    Get From Dictionary    ${node}    node-id
104     ${bier_node_params}    Get From Dictionary    ${node}    bier-node-params
105     ${domain_list}    Get From Dictionary    ${bier_node_params}    domain
106     ${domain}    Get From List    ${domain_list}    0
107     ${domain_id}    Get From Dictionary    ${domain}    domain-id
108     ${bier_global}    Get From Dictionary    ${domain}    bier-global
109     ${ipv4_bfr_prefix}    Get From Dictionary    ${bier_global}    ipv4-bfr-prefix
110     ${ipv6_bfr_prefix}    Get From Dictionary    ${bier_global}    ipv6-bfr-prefix
111     ${encapsulation_type}    Get From Dictionary    ${bier_global}    encapsulation-type
112     ${bit_string_length}    Get From Dictionary    ${bier_global}    bitstringlength
113     ${bfr_id}    Get From Dictionary    ${bier_global}    bfr-id
114     ${subdomain_list}    Get From Dictionary    ${bier_global}    sub-domain
115     ${subdomain}    Get From List    ${subdomain_list}    ${subdomain_index}
116     ${subdomain_id}    Get From Dictionary    ${subdomain}    sub-domain-id
117     ${igp_type}    Get From Dictionary    ${subdomain}    igp-type
118     ${subdomain_bit_string_length}    Get From Dictionary    ${subdomain}    bitstringlength
119     ${subdomain_bfr_id}    Get From Dictionary    ${subdomain}    bfr-id
120     ${mt_id}    Get From Dictionary    ${subdomain}    mt-id
121     ${af}    Get From Dictionary    ${subdomain}    af
122     ${ipv4_list}    Get From Dictionary    ${af}    ipv4
123     ${ipv6_list}    Get From Dictionary    ${af}    ipv6
124     ${ipv4}    Get From List    ${ipv4_list}    ${ipv4_list_index}
125     ${ipv6}    Get From List    ${ipv6_list}    0
126     ${ipv4_bit_string_length}    Get From Dictionary    ${ipv4}    bitstringlength
127     ${ipv4_bier_mpls_label_base}    Get From Dictionary    ${ipv4}    bier-mpls-label-base
128     ${ipv4_bier_mpls_label_range_size}    Get From Dictionary    ${ipv4}    bier-mpls-label-range-size
129     ${ipv6_bit_string_length}    Get From Dictionary    ${ipv6}    bitstringlength
130     ${ipv6_bier_mpls_label_base}    Get From Dictionary    ${ipv6}    bier-mpls-label-base
131     ${ipv6_bier_mpls_label_range_size}    Get From Dictionary    ${ipv6}    bier-mpls-label-range-size
132     BuiltIn.Should_Be_Equal_As_strings    ${node_id}    ${node_id_value}
133     BuiltIn.Should_Be_Equal    ${domain_id}    ${domain_id_value}
134     BuiltIn.Should_Be_Equal    ${ipv4_bfr_prefix}    ${ipv4_value}
135     BuiltIn.Should_Be_Equal    ${ipv6_bfr_prefix}    ${ipv6_value}
136     BuiltIn.Should_Be_Equal    ${bit_string_length}    ${bit_string_length_value}
137     BuiltIn.Should_Be_Equal    ${bfr_id}    ${bfr_id_value}
138     BuiltIn.Should_Be_Equal    ${subdomain_id}    ${subdomain_id_value}
139     BuiltIn.Should_Be_Equal    ${igp_type}    ${igp_type_value}
140     BuiltIn.Should_Be_Equal    ${subdomain_bit_string_length}    ${subdomain_bit_string_length_value}
141     BuiltIn.Should_Be_Equal    ${subdomain_bfr_id}    ${subdomain_bfr_id_value}
142     BuiltIn.Should_Be_Equal    ${mt_id}    ${mt_id_value}
143     BuiltIn.Should_Be_Equal    ${ipv4_bit_string_length}    ${ipv4_bit_string_length_value}
144     BuiltIn.Should_Be_Equal    ${ipv4_bier_mpls_label_base}    ${ipv4_bier_mpls_label_base_value}
145     BuiltIn.Should_Be_Equal    ${ipv4_bier_mpls_label_range_size}    ${ipv4_bier_mpls_label_range_size_value}
146     BuiltIn.Should_Be_Equal    ${ipv6_bit_string_length}    ${ipv6_bit_string_length_value}
147     BuiltIn.Should_Be_Equal    ${ipv6_bier_mpls_label_base}    ${ipv6_bier_mpls_label_base_value}
148     BuiltIn.Should_Be_Equal    ${ipv6_bier_mpls_label_range_size}    ${ipv6_bier_mpls_label_range_size_value}
149
150 Extract_Channel_Output_And_Verify_Value
151     [Arguments]    ${resp}    ${name}    ${src_ip_value}    ${dst_group_value}    ${domain_id_value}    ${subdomain_id_value}
152     ...    ${source_wildcard_value}    ${group_wildcard_value}
153     [Documentation]    Extract the output of channel configuration request and verify its value
154     ${root}    To Json    ${resp.content}
155     ${out_put}    Get From Dictionary    ${root}    output
156     ${channel_list}    Get From Dictionary    ${out_put}    channel
157     ${channel}    Get From List    ${channel_list}    0
158     ${channel_name}    Get From Dictionary    ${channel}    name
159     ${src_ip}    Get From Dictionary    ${channel}    src-ip
160     ${subdomain_id}    Get From Dictionary    ${channel}    sub-domain-id
161     ${source_wildcard}    Get From Dictionary    ${channel}    source-wildcard
162     ${dst_group}    Get From Dictionary    ${channel}    dst-group
163     ${domain_id}    Get From Dictionary    ${channel}    domain-id
164     ${group_wildcard}    Get From Dictionary    ${channel}    group-wildcard
165     BuiltIn.Should_Be_Equal    ${channel_name}    ${name}
166     BuiltIn.Should_Be_Equal    ${src_ip}    ${src_ip_value}
167     BuiltIn.Should_Be_Equal    ${dst_group}    ${dst_group_value}
168     BuiltIn.Should_Be_Equal    ${domain_id}    ${domain_id_value}
169     BuiltIn.Should_Be_Equal    ${subdomain_id}    ${subdomain_id_value}
170     BuiltIn.Should_Be_Equal    ${source_wildcard}    ${source_wildcard_value}
171     BuiltIn.Should_Be_Equal    ${group_wildcard}    ${group_wildcard_value}
172     [Return]    ${channel}
173
174 Extract_Channel_Ingress_And_Egress_Node_Output_And_Verify_Value
175     [Arguments]    ${channel}    ${ingress_node_value}    ${egress_node1_value}    ${egress_node2_value}
176     [Documentation]    Extract the ingress and egress node of deployed channel and verify its value
177     ${ingress_node}    Get From Dictionary    ${channel}    ingress-node
178     ${egress_node_list}    Get From Dictionary    ${channel}    egress-node
179     ${egress_node1}    Get From List    ${egress_node_list}    0
180     ${egress_node2}    Get From List    ${egress_node_list}    1
181     ${node_id1}    Get From Dictionary    ${egress_node1}    node-id
182     ${node_id2}    Get From Dictionary    ${egress_node2}    node-id
183     BuiltIn.Should_Be_Equal    ${ingress_node}    ${ingress_node_value}
184     BuiltIn.Should_Be_Equal    ${node_id1}    ${egress_node1_value}
185     BuiltIn.Should_Be_Equal    ${node_id2}    ${egress_node2_value}
186
187 Delete_All
188     [Documentation]    Delete domain and subdomain which were configured previous and close restconf session
189     : FOR    ${i}    IN RANGE    3
190     \    ${input1}    Create Dictionary    topology-id    ${TOPOLOGY_ID}    domain-id    ${DOMAIN_ID}
191     \    ...    sub-domain-id    ${i+1}
192     \    ${resp1}    Send_Request_Operation_Besides_QueryTopology_Id    bier-topology-api    delete-subdomain    ${input1}
193     \    Verify_Configuration_Success_Or_Not    ${resp1}
194     ${input2}    Create Dictionary    topology-id    ${TOPOLOGY_ID}    domain-id    ${DOMAIN_ID}
195     ${resp2}    Send_Request_Operation_Besides_QueryTopology_Id    bier-topology-api    delete-domain    ${input2}
196     Verify_Configuration_Success_Or_Not    ${resp2}
197     RequestsLibrary.Delete_All_Sessions