Cherry pick: vfwclosedloop for new vFW 89/88989/5
authorBrian Freeman <bf1936@att.com>
Fri, 31 May 2019 03:35:30 +0000 (22:35 -0500)
committerBrian Freeman <bf1936@att.com>
Fri, 31 May 2019 15:09:53 +0000 (10:09 -0500)
Manual cherry pick from dublin

Issue-ID: INT-838
Change-Id: I19f619f6e5b1c0a788e0f6014d79c07c88e3eecd
Signed-off-by: Brian Freeman <bf1936@att.com>
robot/assets/templates/vfw_pg_streams_v2.template [new file with mode: 0644]
robot/resources/stack_validation/packet_generator_interface.robot
robot/resources/test_templates/closedloop_test_template.robot
robot/testsuites/closed-loop.robot

diff --git a/robot/assets/templates/vfw_pg_streams_v2.template b/robot/assets/templates/vfw_pg_streams_v2.template
new file mode 100644 (file)
index 0000000..8162614
--- /dev/null
@@ -0,0 +1,5 @@
+{
+        "streams": {
+            "active-streams": ${number_streams}
+        }
+}
index c75e61b..62ac91d 100644 (file)
 Documentation     The main interface for interacting with A&AI. It handles low level stuff like managing the http request library and A&AI required fields
 Library              RequestsLibrary
 Library           StringTemplater
-Library                  UUID      
-Library                  OperatingSystem      
+Library                  UUID
+Library                  OperatingSystem
 Resource          ../global_properties.robot
 Resource          ../json_templater.robot
 
 *** Variables ***
 ${PGN_URL_TEMPLATE}     http://\${host}:\${port}
 ${PGN_PATH}    /restconf/config/sample-plugin:sample-plugin
+${PGN_PATH_V2}    /restconf/config/stream-count:stream-count
 ${PGN_ENABLE_STREAM_TEMPLATE}    robot/assets/templates/vfw_pg_stream_enable.template
 ${PGN_ENABLE_STREAMS_TEMPLATE}    robot/assets/templates/vfw_pg_streams_enable.template
+${PGN_ENABLE_STREAMS_V2_TEMPLATE}    robot/assets/templates/vfw_pg_streams_v2.template
 
 *** Keywords ***
 Connect To Packet Generator
     [Documentation]    Enables packet generator for the passed stream on the passed host
     [Arguments]    ${host}    ${alias}=pgn
-    ${map}=  Create Dictionary     host=${host}    port=${GLOBAL_PACKET_GENERATOR_PORT}    path=${PGN_PATH}   
-    ${url}=    Template String    ${PGN_URL_TEMPLATE}    ${map}        
-    ${auth}=  Create List     ${GLOBAL_PACKET_GENERATOR_USERNAME}    ${GLOBAL_PACKET_GENERATOR_PASSWORD} 
+    ${map}=  Create Dictionary     host=${host}    port=${GLOBAL_PACKET_GENERATOR_PORT}    path=${PGN_PATH}
+    ${url}=    Template String    ${PGN_URL_TEMPLATE}    ${map}
+    ${auth}=  Create List     ${GLOBAL_PACKET_GENERATOR_USERNAME}    ${GLOBAL_PACKET_GENERATOR_PASSWORD}
     ${session}=    Create Session      ${alias}        ${url}    auth=${auth}
-    [Return]     ${session}    
+    [Return]     ${session}
 
 Enable Stream
-    [Documentation]    Enable a single stream on the passed packet generator host IP  
+    [Documentation]    Enable a single stream on the passed packet generator host IP
     [Arguments]    ${host}    ${stream}=udp1    ${alias}=pgn
     Connect To Packet Generator    ${host}    alias=${alias}
     ${headers}=  Create Headers
-    ${data_path}=    Catenate    ${PGN_PATH}/pg-streams    
+    ${data_path}=    Catenate    ${PGN_PATH}/pg-streams
     ${map}=    Create Dictionary    stream=${stream}
     ${streams}=   Fill JSON Template File    ${PGN_ENABLE_STREAM_TEMPLATE}    ${map}
     ${streams}=    evaluate    json.dumps(${streams})    json
     ${map}=    Create Dictionary    pgstreams=${streams}
-    ${data}=   Fill JSON Template File    ${PGN_ENABLE_STREAMS_TEMPLATE}    ${map} 
+    ${data}=   Fill JSON Template File    ${PGN_ENABLE_STREAMS_TEMPLATE}    ${map}
     ${resp}=   Put Request     ${alias}        ${data_path}     data=${data}     headers=${headers}
     Should Be Equal As Strings    ${resp.status_code}    200
     [Return]    ${resp}
 
 Enable Streams
-    [Documentation]    Enable <stream_count> number of streams on the passed packet generator host IP  
+    [Documentation]    Enable <stream_count> number of streams on the passed packet generator host IP
     [Arguments]    ${host}    ${stream_count}=5    ${alias}=pgn    ${prefix}=fw_udp
     Connect To Packet Generator    ${host}    alias=${alias}
     ${headers}=  Create Headers
     ${data_path}=    Catenate    ${PGN_PATH}/pg-streams
     ${streams}=    Set Variable
     ${comma}=      Set Variable
-    ${stream_count}=    Evaluate    ${stream_count}+1        
+    ${stream_count}=    Evaluate    ${stream_count}+1
     :FOR    ${i}    IN RANGE     1    ${stream_count}
     \    ${name}=    Catenate    ${prefix}${i}
     \    ${map}=    Create Dictionary    stream=${name}
     \    ${one}=   Fill JSON Template File    ${PGN_ENABLE_STREAM_TEMPLATE}    ${map}
-    \    ${one}=    evaluate    json.dumps(${one})    json     
+    \    ${one}=    evaluate    json.dumps(${one})    json
     \    ${streams}=    Set Variable    ${streams}${comma}${one}
-    \    ${comma}=      Set Variable    , 
+    \    ${comma}=      Set Variable    ,
     ${map}=    Create Dictionary    pgstreams=${streams}
-    ${data}=   Fill JSON Template File    ${PGN_ENABLE_STREAMS_TEMPLATE}    ${map} 
+    ${data}=   Fill JSON Template File    ${PGN_ENABLE_STREAMS_TEMPLATE}    ${map}
     ${resp}=   Put Request     ${alias}        ${data_path}     data=${data}     headers=${headers}
     Should Be Equal As Strings    ${resp.status_code}    200
     [Return]    ${resp}
 
+
+Enable Streams V2
+    [Documentation]    V2 is for new honeycomb steams interface
+    ...  Enable <stream_count> number of streams on the passed packet generator host IP
+    [Arguments]    ${host}    ${stream_count}=5    ${alias}=pgn    ${prefix}=fw_udp
+    Connect To Packet Generator    ${host}    alias=${alias}
+    ${headers}=  Create Headers
+    ${data_path}=    Catenate    ${PGN_PATH_V2}/streams
+    ${map}=    Create Dictionary    number_streams=${stream_count}
+    ${data}=   Fill JSON Template File    ${PGN_ENABLE_STREAMS_V2_TEMPLATE}    ${map}
+    ${resp}=   Put Request     ${alias}        ${data_path}     data=${data}     headers=${headers}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+
 Disable All Streams
     [Documentation]    Disable all streams on the passed packet generator host IP
     [Arguments]    ${host}    ${stream}=udp1    ${alias}=pgn
     Connect To Packet Generator    ${host}    alias=${alias}
     ${headers}=  Create Headers
-    ${data_path}=    Catenate    ${PGN_PATH}/pg-streams  
+    ${data_path}=    Catenate    ${PGN_PATH}/pg-streams
     ${data}=   Catenate    {"pg-streams":{"pg-stream": []}}
     ${resp}=   Put Request     ${alias}        ${data_path}     data=${data}     headers=${headers}
     Should Be Equal As Strings    ${resp.status_code}    200
     [Return]    ${resp}
 
  Disable Stream
-    [Documentation]    Disables packet generator for the passed stream 
+    [Documentation]    Disables packet generator for the passed stream
     [Arguments]    ${host}    ${stream}=udp1    ${alias}=pgn
     ${session}=    Connect To Packet Generator    ${host}    alias=${alias}
     ${headers}=  Create Headers
-    ${data_path}=    Catenate    ${PGN_PATH}/pg-streams/pg-stream/${stream}        
+    ${data_path}=    Catenate    ${PGN_PATH}/pg-streams/pg-stream/${stream}
     ${resp}=   Delete Request  ${alias}        ${data_path}     headers=${headers}
     Should Be Equal As Strings    ${resp.status_code}    200
     [Return]    ${resp}
-    
+
 Get List Of Enabled Streams
-    [Documentation]     Get a list of streams on the passed packet generator host IP    
+    [Documentation]     Get a list of streams on the passed packet generator host IP
     [Arguments]    ${host}    ${alias}=pgn
     ${session}=    Connect To Packet Generator    ${host}    alias=${alias}
     ${headers}=  Create Headers
-    ${data_path}=    Catenate    /        
+    ${data_path}=    Catenate    /
     ${resp}=   Get Request     ${alias}        ${PGN_PATH}     headers=${headers}
     Should Be Equal As Strings    ${resp.status_code}    200
     [Return]    ${resp.json()}
-    
-   
+
+Get List Of Enabled Streams V2
+    [Documentation]     V2 Get a list of streams on the passed packet generator host IP
+    [Arguments]    ${host}    ${alias}=pgn
+    ${session}=    Connect To Packet Generator    ${host}    alias=${alias}
+    ${headers}=  Create Headers
+    ${data_path}=    Catenate    /
+    ${resp}=   Get Request     ${alias}        ${PGN_PATH_V2}     headers=${headers}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    [Return]    ${resp.json()}
+
 Create Headers
     ${uuid}=    Generate UUID
     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
-    [Return]    ${headers}     
\ No newline at end of file
+    [Return]    ${headers}
index dcbb7e6..f5c0e35 100644 (file)
@@ -80,7 +80,7 @@ Get Configs VFW Policy
     ${configpolicy_name}=    Create Dictionary    config_policy_name=${getconfigpolicy}
     ${output} =     Fill JSON Template File     ${GECONFIG_VFW_TEMPLATE}    ${configpolicy_name}
     ${get_resp} =    Run Policy Get Configs Request    ${RESOURCE_PATH_GET_CONFIG}   ${output}
-       Should Be Equal As Strings      ${get_resp.status_code}         200
+    Should Be Equal As Strings          ${get_resp.status_code}  200
     ${config}=    Catenate    ${get_resp.json()[0]["config"]}
     ${thresholds}=    Get Variable Value      ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"]}
 
@@ -100,7 +100,7 @@ Get Configs VDNS Policy
     ${configpolicy_name}=    Create Dictionary    config_policy_name=${getconfigpolicy}
     ${output} =     Fill JSON Template File     ${GECONFIG_VFW_TEMPLATE}    ${configpolicy_name}
     ${get_resp} =    Run Policy Get Configs Request    ${RESOURCE_PATH_GET_CONFIG}   ${output}
-       Should Be Equal As Strings      ${get_resp.status_code}         200
+    Should Be Equal As Strings  ${get_resp.status_code}  200
     ${config}=    Catenate    ${get_resp.json()[0]["config"]}
     ${thresholds}=    Get Variable Value      ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"]}
 
@@ -196,12 +196,12 @@ Orchestrate VNF vFW closedloop
 VFWCL High Test
        [Documentation]    Test Control Loop for High Traffic
         [Arguments]    ${pkg_host}
-       Enable Streams    ${pkg_host}   10
+       Enable Streams V2    ${pkg_host}   10
         Log To Console   Set number of streams to 10
        :FOR    ${i}    IN RANGE    12
        \   Sleep  15s
-       \   ${resp}=   Get List Of Enabled Streams   ${pkg_host}
-        \   ${stream_count}=   Evaluate  len(${resp['sample-plugin']['pg-streams']['pg-stream']})
+       \   ${resp}=   Get List Of Enabled Streams V2   ${pkg_host}
+        \   ${stream_count}=   Set Variable   ${resp['stream-count']['streams']['active-streams']}
         \   Log To Console   Number of streams: ${stream_count}
         \   Exit For Loop If   '${stream_count}'=='5'
         Should Be Equal As Integers  ${stream_count}   5
@@ -209,13 +209,12 @@ VFWCL High Test
 VFWCL Low Test
        [Documentation]    Test Control Loop for Low Traffic
         [Arguments]    ${pkg_host}
-       Enable Streams    ${pkg_host}   1
+       Enable Streams V2     ${pkg_host}   1
         Log To Console   Set number of streams to 1
-       Get List Of Enabled Streams   ${pkg_host}
        :FOR    ${i}    IN RANGE    12
        \   Sleep  15s
-       \   ${resp}=   Get List Of Enabled Streams   ${pkg_host}
-        \   ${stream_count}=   Evaluate  len(${resp['sample-plugin']['pg-streams']['pg-stream']})
+       \   ${resp}=   Get List Of Enabled Streams V2   ${pkg_host}
+        \   ${stream_count}=   Set Variable   ${resp['stream-count']['streams']['active-streams']}
         \   Log To Console   Number of streams: ${stream_count}
         \   Exit For Loop If   '${stream_count}'=='5'
         Should Be Equal As Integers  ${stream_count}   5
index b598627..5fba93f 100644 (file)
@@ -15,5 +15,6 @@ VDNS Closed Loop Test
     VDNS Policy
 VFWCL Closed Loop Test
     [TAGS]    vfwclosedloop
+    Log To Console    ${EMPTY}
     VFWCL High Test   ${pkg_host}
     VFWCL Low Test   ${pkg_host}