Adding new PCC delegation test cases 31/91631/13
authorBhuvanaVignesh <bvignesh@luminanetworks.com>
Fri, 24 Jul 2020 14:03:48 +0000 (19:33 +0530)
committerVenkatrangan Govindarajan <vgovindarajan@luminanetworks.com>
Thu, 6 Aug 2020 04:49:03 +0000 (04:49 +0000)
 - This patch contains the test case which revoke the pcc delegation in LSP updates

JIRA: INTTEST-120
Signed-off-by: BhuvanaVignesh <bvignesh@luminanetworks.com>
Change-Id: I16eb170586d6e7e1eb7736a4e09ed01a9c68570a

csit/suites/bgpcep/throughpcep/cases.robot
tools/pcep_updater/updater.py

index a236195746853fa7ea5e01dd5a646de34b810336..c92c16b595225d85abc72a89a13645f1fba9a5d1 100644 (file)
@@ -340,6 +340,13 @@ Verify_10
     [Tags]    critical
     Verify    10
 
+Updater_with delegate
+    [Documentation]    Run updater tool to revoke the delegate for the given hop, using 1 blocking http thread.
+    [Tags]    critical
+    Updater    10    1    127.1.0.0    ${PCCS}    ${LSPS}    True    false    127.1.0.1    2
+    Verify    10
+    [Teardown]    Do_Not_Start_Failing_If_This_Failed
+
 Stop_Pcc_Mock
     [Documentation]    Send ctrl+c to pcc-mock, see prompt again within timeout.
     [Setup]    Run_Even_When_Failing_Fast
@@ -467,7 +474,7 @@ Set_Hop
     BuiltIn.Log    ${hop}
 
 Updater
-    [Arguments]    ${iteration}    ${workers}    ${mock-ip}=${FIRST_PCC_IP}    ${pccs}=${PCCS}    ${lsps}=${LSPS}    ${parallel}=False
+    [Arguments]    ${iteration}    ${workers}    ${mock-ip}=${FIRST_PCC_IP}    ${pccs}=${PCCS}    ${lsps}=${LSPS}    ${parallel}=False    ${delegate}=true    ${pccip}=${none}    ${tunnel_no}=${none}
     [Documentation]    Compute number of workers, call updater.py, assert its response.
     SSHLibrary.Switch_Connection    pccmock
     # In some systems, inactive SSH sessions get severed.
@@ -476,7 +483,7 @@ Updater
     # The previous line relies on a fact that Execute_Command spawns separate shels, so running pcc-mock is not affected.
     Set_Hop    ${iteration}
     SSHLibrary.Switch_Connection    updater
-    ${response} =    SSHLibrary.Execute_Command    bash -c "cd ${UPDATERVM_WORKSPACE}; taskset 0x00000001 python updater.py --workers '${workers}' --odladdress '${UPDATER_ODLADDRESS}' --user '${RESTCONF_USER}' --password '${RESTCONF_PASSWORD}' --scope '${RESTCONF_SCOPE}' --pccaddress '${mock-ip}' --pccs '${pccs}' --lsps '${lsps}' --hop '${hop}' --timeout '${UPDATER_TIMEOUT}' --refresh '${UPDATER_REFRESH}' --reuse '${RESTCONF_REUSE}' 2>&1"
+    ${response} =    SSHLibrary.Execute_Command    bash -c "cd ${UPDATERVM_WORKSPACE}; taskset 0x00000001 python updater.py --workers '${workers}' --odladdress '${UPDATER_ODLADDRESS}' --user '${RESTCONF_USER}' --password '${RESTCONF_PASSWORD}' --scope '${RESTCONF_SCOPE}' --pccaddress '${mock-ip}' --pccs '${pccs}' --lsps '${lsps}' --hop '${hop}' --timeout '${UPDATER_TIMEOUT}' --refresh '${UPDATER_REFRESH}' --reuse '${RESTCONF_REUSE}' --delegate '${delegate}' --pccip '${pccip}' --tunnelnumber '${tunnel_no}' 2>&1"
     Check Updater response    ${response}    ${parallel}
 
 Check Updater response
index 159398fae08f902fb0bbf03be0494ec7a9bd5844..3b2d32254a773da0ef46f564ba85dc0d1e48c54c 100644 (file)
@@ -80,10 +80,49 @@ parser.add_argument('--scope', default='sdn',
                     help='Scope for restconf authentication')
 parser.add_argument('--reuse', default='True', type=str2bool,
                     help='Should single requests session be re-used')
+parser.add_argument('--delegate', default='true',
+                    help='should delegate the lsp or set "false" if lsp not be delegated')
+parser.add_argument('--pccip', default=None,
+                    help='IP address of the simulated PCC')
+parser.add_argument('--tunnelnumber', default=None,
+                    help='Tunnel Number for the simulated PCC')
 args = parser.parse_args()  # arguments are read
 
 expected = '''{"output":{}}'''
 
+payload_list_data = [
+    '{',
+    '   "input":{',
+    '       "node":"pcc://', '', '",',
+    '       "name":"pcc_', '', '_tunnel_', '', '",',
+    '       "network-topology-ref":"/network-topology:network-topology/network-topology:topology',
+    '[network-topology:topology-id=\\\"pcep-topology\\\"]",',
+    '       "arguments":{',
+    '           "lsp":{',
+    '           "delegate":', '',
+    '           ,"administrative":true',
+    '},',
+    '"ero":{',
+    '   "subobject":[',
+    '       {',
+    '           "loose":false,',
+    '           "ip-prefix":{',
+    '                "ip-prefix":', '"', '', '"',
+    '           }',
+    '       },',
+    '       {',
+    '           "loose":false,',
+    '           "ip-prefix":{',
+    '                "ip-prefix":"1.1.1.1/32"',
+    '            }',
+    '        }',
+    '        ]',
+    '       }',
+    '   }',
+    ' }',
+    '}'
+]
+
 
 class CounterDown(object):
     """Counter which also knows how many items are left to be added."""
@@ -97,35 +136,55 @@ class CounterDown(object):
         self.opened -= 1
 
 
-def iterable_msg(pccs, lsps, workers, hop):
+def iterable_msg(pccs, lsps, workers, hop, delegate):
     """Generator yielding tuple of worker number and kwargs to post."""
     first_pcc_int = int(ipaddr.IPv4Address(args.pccaddress))
     # Headers are constant, but it is easier to add them to kwargs in this generator.
     headers = {'Content-Type': 'application/json'}
     # TODO: Perhaps external text file with Template? May affect performance.
-    list_data = [
-        '{"input":{"node":"pcc://', '', '",',
-        '"name":"pcc_', '', '_tunnel_', '', '","network-topology-ref":',
-        '"/network-topology:network-topology/network-topology:topology',
-        '[network-topology:topology-id=\\\"pcep-topology\\\"]",',
-        '"arguments":{"lsp":{"delegate":true,"administrative":true},',
-        '"ero":{"subobject":[{"loose":false,"ip-prefix":{"ip-prefix":',
-        '"', hop, '"}},{"loose":false,"ip-prefix":{"ip-prefix":',
-        '"1.1.1.1/32"}}]}}}}'
-    ]
+    list_data = payload_list_data
     for lsp in range(1, lsps + 1):
         str_lsp = str(lsp)
-        list_data[6] = str_lsp  # Replaces with new pointer.
+        list_data[8] = str_lsp  # Replaces with new pointer.
         for pcc in range(pccs):
             pcc_ip = str(ipaddr.IPv4Address(first_pcc_int + pcc))
-            list_data[1] = pcc_ip
-            list_data[4] = pcc_ip
+            list_data[3] = pcc_ip
+            list_data[6] = pcc_ip
+            list_data[15] = delegate
+            list_data[25] = hop
             whole_data = ''.join(list_data)
             worker = (lsp * pccs + pcc) % workers
             post_kwargs = {"data": whole_data, "headers": headers}
             yield worker, post_kwargs
 
 
+def generate_payload_for_single_pcc(hop, delegate, pccip, tunnel_no):
+    """Generator yielding single kwargs to post."""
+    first_pcc_int = int(ipaddr.IPv4Address(args.pccaddress))
+    # Headers are constant, but it is easier to add them to kwargs in this generator.
+    headers = {'Content-Type': 'application/json'}
+    # TODO: Perhaps external text file with Template? May affect performance.
+    list_data = payload_list_data
+    if tunnel_no == "None":
+        str_lsp = str(1)
+    else:
+        str_lsp = str(tunnel_no)
+    list_data[8] = str_lsp  # Replaces with new pointer.
+    if pccip == "None":
+        pcc_ip = str(ipaddr.IPv4Address(first_pcc_int))
+    else:
+        pcc_ip = pccip
+    list_data[3] = pcc_ip
+    list_data[6] = pcc_ip
+    list_data[15] = delegate
+    list_data[25] = hop
+    whole_data = ''.join(list_data)
+    worker = 0
+    post_kwargs = {"data": whole_data, "headers": headers}
+    print(post_kwargs)
+    yield worker, post_kwargs
+
+
 def queued_send(session, queue_messages, queue_responses):
     """Pop from queue, Post and append result; repeat until empty."""
     uri = 'operations/network-topology-pcep:update-lsp'
@@ -158,8 +217,12 @@ def classify(resp_tuple):
 
 # Main.
 list_q_msg = [collections.deque() for _ in range(args.workers)]
-for worker, post_kwargs in iterable_msg(args.pccs, args.lsps, args.workers, args.hop):
-    list_q_msg[worker].append(post_kwargs)
+if args.pccip == "None":
+    for worker, post_kwargs in iterable_msg(args.pccs, args.lsps, args.workers, args.hop, args.delegate):
+        list_q_msg[worker].append(post_kwargs)
+else:
+    for worker, post_kwargs in generate_payload_for_single_pcc(args.hop, args.delegate, args.pccip, args.tunnelnumber):
+        list_q_msg[worker].append(post_kwargs)
 queue_responses = collections.deque()  # thread safe
 threads = []
 for worker in range(args.workers):