IMPLEMENTS: RICPLT-2062, XApp LCM tests 89/889/11
authordave kormann <dk3239@att.com>
Wed, 4 Sep 2019 16:38:06 +0000 (12:38 -0400)
committerd k <davek@research.att.com>
Mon, 9 Sep 2019 14:12:15 +0000 (14:12 +0000)
This change updates the appmgr robot library and adds positive and negative tests
for app deployment via the XApp manager.

The required tests are documented here:
https://rancodev.atlassian.net/wiki/spaces/IT/pages/113705032/xApp+LCM+Test+Manual

This change will break any code that relied on the previously implemented
appmgr_interface.robot resource.

Signed-off-by: dave kormann <dk3239@att.com>
Change-Id: I2e8290d9759a756affaf8427262194601708347b

ric_robot_suite/docker/nanobot/Dockerfile
ric_robot_suite/helm/nanobot/configmap-src/testsuites/ete.robot
ric_robot_suite/robot/assets/templates/appmgr_create_xapp.template [deleted file]
ric_robot_suite/robot/resources/appmgr/appmgr_interface.robot
ric_robot_suite/robot/resources/appmgr/negative_appmgr_tests.robot [new file with mode: 0644]
ric_robot_suite/robot/testsuites/ete.robot

index 1bf7757..fb202d0 100644 (file)
@@ -61,7 +61,6 @@ COPY robot/resources/global_properties.robot /robot/resources
 
 RUN mkdir -p /robot/assets/templates
 COPY robot/assets/templates/e2mgr_setup_nodeb.template /robot/assets/templates
-COPY robot/assets/templates/appmgr_create_xapp.template /robot/assets/templates
 
 RUN pip install UUID
 RUN pip install kubernetes
index adf459a..cd86164 100644 (file)
@@ -2,32 +2,69 @@
 Documentation    Executes the End To End Test cases
 ...
 Library   Collections
-#Library    HTTPUtils
+Library   OperatingSystem
+
 Resource         ../resources/appmgr/appmgr_interface.robot
+Resource         ../resources/appmgr/negative_appmgr_tests.robot
 Resource         ../resources/e2mgr/e2mgr_interface.robot
+Resource         ../resources/dashboard/dashboard_interface.robot
 
 *** Variables ***
-${TEST_XAPPNAME}       DemoXapp1
-${TEST_XAPPID}    101
-${TEST_NODE_B_NAME}     nodeB1
+${TEST_XAPPNAME}      xapp-std
+${TEST_XAPPID}        101
+${TEST_NODE_B_NAME}   AAAA456789
 ${TEST_NODE_B_IP}     10.0.0.3
-${TEST_NODE_B_PORT}   879
+${TEST_NODE_B_PORT}   36422
 
 
 *** Test Cases ***
-Get All Xapps 
-    [Tags]   etetests  xapptests
-    Run AppMgr Get All Request
-Create Xapp 
-    [Tags]   etetests  xapptests
-    Run Create Xapp   ${TEST_XAPPNAME}    ${TEST_XAPPID}
-Get Xapp By Name 
-    [Tags]   etetests  xapptests
-    Run AppMgr Get By XappName   ${TEST_XAPPNAME}
-Get Xapp By Name and Id
-    [Tags]   etetests  xapptests
-    Run AppMgr Get By XappName and XappId    ${TEST_XAPPNAME}   ${TEST_XAPPID}
-Setup RAN Via E2 Mgr 
-    [Tags]   etetests  e2mgrtests
-    Run E2Mgr Setup NodeB   ${TEST_NODE_B_NAME}    ${TEST_NODE_B_IP}   ${TEST_NODE_B_PORT}
-
+Test XApp Manager Health
+    [Tags]  etetests  xapptests
+    Run AppMgr Health Check
+Deploy An XApp    
+    [Tags]  etetests  xapptests
+    Deploy XApp       ${TEST_XAPPNAME}
+Retrieve The Deployed XApp
+    [Tags]  etetests  xapptests
+    Get XApp By Name  ${TEST_XAPPNAME}
+Attempt To Deploy A Duplicate XApp
+    [Tags]  etetests  xapptests
+    Deploy Duplicate XApp And Expect Error
+Undeploy The Deployed XApp
+    [Tags]  etetests  xapptests
+    Undeploy XApp     ${TEST_XAPPNAME}
+Attempt To Undeploy An Already Undeployed XApp
+    [Tags]  etetests  xapptests
+    Undeploy Nondeployed XApp And Expect Error
+Attempt To Request A Nonexistent XApp
+    [Tags]  etetests  xapptests
+    Request Nonexistent XApp And Expect Error
+    
+Setup RAN Via E2Mgr X2
+    [Tags]   x2setup
+    Run E2Mgr Setup NodeB X2   ${TEST_NODE_B_NAME}    ${TEST_NODE_B_IP}   ${TEST_NODE_B_PORT}
+    Wait Until Keyword Succeeds   20s   5s   Check NodeB Status    ${TEST_NODE_B_NAME}
+Setup RAN Via E2Mgr Endc
+    [Tags]   e2setup
+    Run E2Mgr Setup NodeB Endc   ${TEST_NODE_B_NAME}    ${TEST_NODE_B_IP}   ${TEST_NODE_B_PORT}
+    Wait Until Keyword Succeeds   20s   5s   Check NodeB Status    ${TEST_NODE_B_NAME}
+Get NodeB via E2Mgr
+    [Tags]   e2setup   x2setup
+    Run E2Mgr Get NodeB Request   ${TEST_NODE_B_NAME}
+Get All NodeBs Via E2Mgr
+    [Tags]   e2mgrtest   etetests   e2setup   x2setup   ci_tests
+    Run E2Mgr Get All NodeBs Request
+Setup RAN Via Dashboard Endc
+    [Tags]   e2setup_dash
+    Run Dashboard Setup NodeB Endc   ${TEST_NODE_B_NAME}    ${TEST_NODE_B_IP}   ${TEST_NODE_B_PORT}
+    Wait Until Keyword Succeeds   20s   5s   Dashboard Check NodeB Status    ${TEST_NODE_B_NAME}
+Setup RAN Via Dashboard X2
+    [Tags]   x2setup_dash
+    Run Dashboard Setup NodeB X2    ${TEST_NODE_B_NAME}    ${TEST_NODE_B_IP}   ${TEST_NODE_B_PORT}
+    Wait Until Keyword Succeeds   20s   5s   Dashboard Check NodeB Status    ${TEST_NODE_B_NAME}
+Get NodeB via Dashboard
+    [Tags]   e2setup_dash   x2setup_dash
+    Run Dashboard Get NodeB Request   ${TEST_NODE_B_NAME}
+Get All NodeBs via Dashboard
+    [Tags]   e2setup_dash   x2setup_dash    ci_tests
+    Run Dashboard Get All NodeBs Request
diff --git a/ric_robot_suite/robot/assets/templates/appmgr_create_xapp.template b/ric_robot_suite/robot/assets/templates/appmgr_create_xapp.template
deleted file mode 100644 (file)
index c06ca7a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-  "xAppName": "${xapp_name}"
-}
index a215eb1..b8b301e 100644 (file)
 *** Settings ***
-Documentation     The main interface for interacting with RIC Applications Manager (AppMgr) . It handles low level stuff like managing the http request library and AppMgr required fields
-Library           RequestsLibrary
-Library           UUID
+Documentation  Keywords for interacting with the XApp Manager, including listing, deploying, and undeploying XApps
 
-Resource          ../global_properties.robot
-Resource          ../json_templater.robot
+Library        RequestsLibrary
 
-*** Variables ***
-${APPMGR_BASE_PATH}        /ric/v1/xapps/   
-${APPMGR_ENDPOINT}     ${GLOBAL_APPMGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPMGR_IP_ADDR}:${GLOBAL_APPMGR_SERVER_PORT}
-${APPMGR_CREATE_XAPP_TEMPLATE}     robot/assets/templates/appmgr_create_xapp.template
+Resource       ../global_properties.robot
 
+*** Variables ***
+${APPMGR_BASE_PATH}  /ric/v1/xapps
+${APPMGR_ENDPOINT}   ${GLOBAL_APPMGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPMGR_IP_ADDR}:${GLOBAL_APPMGR_SERVER_PORT}
 
 *** Keywords ***
 Run AppMgr Health Check
      [Documentation]    Runs AppMgr Health check
-     Run Keyword   Run AppMgr Get All Request
+     Run Keyword        Get Deployed XApps
+
+Get Deployed XApps
+     [Documentation]  Obtain the list of deployed XApps from the Appmgr
+     ${resp} =        Run AppMgr GET Request
+     [Return]         ${resp.json()}
 
-Run AppMgr Get All Request 
-     [Documentation]    Runs AppMgr Get List of Xapps Request
-     ${resp}=    Run Keyword    Run AppMgr Get Request    ${APPMGR_BASE_PATH}
-     Should Be Equal As Strings        ${resp.status_code}     200
+Get Deployable XApps
+     [Documentation]  Obtain the list of deployed XApps from the Appmgr
+     ${resp} =        Run AppMgr GET Request  /search/
+     Should Be True   ${resp}
+     [Return]         ${resp.json()}
+
+Get XApp By Name
+     [Documentation]  Get installed XApp from Appmgr given name
+     [Arguments]      ${xapp_name}
+     ${resp} =        Run AppMgr GET Request  /${xapp_name}
+     Should Be True   ${resp}
+     [Return]         ${resp.json()}
 
-Run AppMgr Get By XappName and XappId
-     [documentation]     Get Xapp data by XappName and XappId
+Get XApp By Name and ID
+     [Documentation]  Get installed XApp from Appmgr by name and ID
      [Arguments]      ${xapp_name}  ${xapp_id}
-     ${data_path}=    Set Variable    ${APPMGR_BASE_PATH}${xapp_name}/${xapp_id}
-     ${resp}=   Run Keyword   Run AppMgr Get Request    ${data_path}
-     Should Be Equal As Strings        ${resp.status_code}     200
+     ${resp}=         Run AppMgr GET Request  /${xapp_name}/${xapp_id}/
+     Should Be True   ${resp}
+     [Return]         ${resp.json()}
 
-Run AppMgr Get By XappName 
-     [documentation]     Get List of Xapp data by XappName
+Deploy XApp
+     [Documentation]  Create Xapp
      [Arguments]      ${xapp_name}
-     ${data_path}=    Set Variable    ${APPMGR_BASE_PATH}${xapp_name}
-     ${resp}=   Run Keyword   Run AppMgr Get Request    ${data_path}
-     Should Be Equal As Strings        ${resp.status_code}     200
-
-Run Create Xapp
-     [documentation]     Create Xapp 
-     [Arguments]      ${xapp_name}   ${xapp_id}  
-     ${data_path}=    Set Variable    ${APPMGR_BASE_PATH}
-     ${dict}=    Create Dictionary    xapp_name=${xapp_name}    xapp_id=${xapp_id}
-     ${data}=   Fill JSON Template File    ${APPMGR_CREATE_XAPP_TEMPLATE}    ${dict}
-     ${auth}=  Create List  ${GLOBAL_INJECTED_APPMGR_USER}    ${GLOBAL_INJECTED_APPMGR_PASSWORD}
-     ${session}=    Create Session      appmgr      ${APPMGR_ENDPOINT}   auth=${auth}
-     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
-     ${resp}=   Post Request     appmgr     ${data_path}     data=${data}   headers=${headers}
-     Log    Received response from AppMgr ${resp.text}
-     Should Be Equal As Strings        ${resp.status_code}     200
-     [Return]    ${resp}
-
-
-Run AppMgr Get Request
-     [Documentation]    Runs AppMgr Get request
-     [Arguments]    ${data_path}
-     ${auth}=  Create List  ${GLOBAL_INJECTED_APPMGR_USER}    ${GLOBAL_INJECTED_APPMGR_PASSWORD}
-     ${session}=    Create Session      appmgr      ${APPMGR_ENDPOINT}   auth=${auth}
-     ${uuid}=    Generate UUID
-     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
-     ${resp}=   Get Request     appmgr     ${data_path}     headers=${headers}
-     Log    Received response from AppMgr ${resp.text}
-     Should Be Equal As Strings        ${resp.status_code}     200
-     [Return]    ${resp}
-
-Run AppMgr Delete Request
-     [documentation]     Delete Xapp data by XappId
-     [Arguments]      ${xapp_id}
-     ${data_path}=    Set Variable    ${APPMGR_BASE_PATH}/${xapp_id}
-     ${auth}=  Create List  ${GLOBAL_INJECTED_APPMGR_USER}    ${GLOBAL_INJECTED_APPMGR_PASSWORD}
-     ${session}=    Create Session      appmgr      ${APPMGR_ENDPOINT}   auth=${auth}
-     ${uuid}=    Generate UUID
-     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
-     ${resp}=   Delete Request     appmgr     ${data_path}     headers=${headers}
-     Log    Received response from AppMgr ${resp.text}
-     Should Be Equal As Strings        ${resp.status_code}     200
+     &{dict} =        Create Dictionary        name=${xapp_name}
+     ${data} =        Evaluate                 json.dumps(&{dict})  json
+     ${resp} =        Run AppMgr POST Request  ${EMPTY}             ${data}
+     Should Be True   ${resp}
+     [Return]         ${resp}
+
+Deploy XApps
+     [Documentation]  Create one or more XApps
+     [Arguments]      @{xapp_names}
+     :FOR             ${xapp}  IN             @{xapp_names}
+     \                Deploy XApp   ${xapp}
+
+Undeploy XApp
+     [Documentation]  Remove a deployed XApp
+     [Arguments]      ${xapp_name}
+     ${resp} =        Run AppMgr DELETE Request  /${xapp_name}
+     Should Be True   ${resp}
+     [Return]         ${resp}
+
+Undeploy XApps
+     [Documentation]  Remove one or more deployed XApps
+     [Arguments]      @{xapp_names}
+     :FOR             ${xapp}  IN     @{xapp_names}
+     \                Undeploy XApp   ${xapp}
+
+Deploy All Available XApps
+     [Documentation]  Attempt to deploy any not-currently-deployed XApp
+     @{d} =          Get Deployed XApps
+     @{deployed} =   Pluck               Name          ${d}
+     @{available} =  Get Deployable XApps
+     @{toDeploy} =   Subtract From List  ${available}  ${deployed}
+     Deploy XApps    @{toDeploy}
+
+Undeploy All Running XApps
+     [Documentation]  Undeploy any deployed XApps
+     @{d} =           Get Deployed XApps
+     @{deployed} =    Pluck  Name  ${d}
+     Run Keyword If   ${deployed}  Undeploy XApps  @{deployed}
+
+Run AppMgr GET Request
+     [Documentation]  Make an HTTP GET request against the XApp manager
+     [Arguments]   ${path}=${EMPTY}
+     ${session} =  Create Session     roboAppmgrGet                   ${APPMGR_ENDPOINT}
+     ${headers} =  Create Dictionary  Accept=application/json         Content-Type=application/json
+     ${resp} =     Get Request        roboAppmgrGet                   ${APPMGR_BASE_PATH}${path}  headers=${headers}
+     [Return]      ${resp}
+
+Run AppMgr POST Request
+     [Documentation]    Make an HTTP POST request against the XApp manager
+     [Arguments]   ${path}=${EMPTY}   ${body}=${EMPTY}
+     ${session} =  Create Session     roboAppmgrPost                  ${APPMGR_ENDPOINT}
+     ${headers} =  Create Dictionary  Accept=application/json         Content-Type=application/json
+     ${resp} =     Post Request       roboAppmgrPost                  ${APPMGR_BASE_PATH}${path}  headers=${headers}  data=${body}
+     [Return]      ${resp}
+
+Run AppMgr DELETE Request
+     [Documentation]  Make an HTTP DELETE request against the XApp manager
+     [Arguments]      ${path}
+     ${session} =     Create Session     roboAppmgrDelete                ${APPMGR_ENDPOINT}
+     ${headers} =     Create Dictionary  Accept=application/json         Content-Type=application/json
+     ${resp} =        Delete Request     roboAppmgrDelete                ${APPMGR_BASE_PATH}${path}  headers=${headers}
+     [Return]         ${resp}
+
+
+# a few useful list routines that should probably live elsewhere
+Pluck
+     [Documentation]  Get the values of a specific key from a list of dictionaries
+     [Arguments]      ${k}      ${l}
+     @{names} =       Evaluate  filter(lambda v: v != None, [i.get(${k}, None) for i in ${l}])
+     [Return]         ${names}
+
+Subtract From List
+     [Documentation]  Remove the elements of the second argument from the first
+     [Arguments]      ${x}  ${y}
+     ${diff} =        Run Keyword If  ${y}
+     ...              Evaluate  filter(lambda v: v not in ${y}, ${x})
+     ...              ELSE
+     ...              Set Variable    ${x}
+     [Return]         ${diff}
diff --git a/ric_robot_suite/robot/resources/appmgr/negative_appmgr_tests.robot b/ric_robot_suite/robot/resources/appmgr/negative_appmgr_tests.robot
new file mode 100644 (file)
index 0000000..4f82d5c
--- /dev/null
@@ -0,0 +1,35 @@
+*** Settings ***
+Documentation     Negative tests for the AppMgr: ensure that AppMgr produces expected errors for a variety of invalid requests
+
+Library           Collections
+Library           UUID
+
+Resource          ../global_properties.robot
+Resource          appmgr_interface.robot
+
+*** Keywords ***
+Deploy Duplicate XApp And Expect Error
+     [Documentation]      Ensure AppMgr produces an appropriate error when an already-running XApp is deployed
+     @{d} =               Get Deployed XApps
+     Should Not Be Empty  ${d}      No XApps currently deployed
+     @{names} =           Pluck     Name  ${d}
+     ${xapp} =            Evaluate  random.choice(${names})  random
+     ${status} =          Run Keyword And Ignore Error  Deploy XApp  ${xapp}
+     Should Be Equal As Strings  ${status}          FAIL
+
+Undeploy Nondeployed XApp And Expect Error
+     [Documentation]      Ensure AppMgr produces an appropriate error when an existing but non-running XApp is deleted
+     @{d} =               Get Deployed XApps
+     @{a} =               Get Deployable XApps
+     Should Not Be Empty  ${a}       No XApps available to deploy
+     @{dNames} =          Pluck      Name     ${d}
+     @{a} =               Subtract From List  ${a}  ${dNames}
+     ${xapp} =            Evaluate            random.choice(${a})  random
+     ${status}  ${u} =    Run Keyword And Ignore Error  Undeploy XApp  ${xapp}
+     Should Be Equal As Strings               ${status}            FAIL
+
+Request Nonexistent XApp And Expect Error
+     [Documentation]    Ensure AppMgr produces an appropriate error when retrieving a nonexistent XApp
+     ${xapp} =          Generate UUID
+     ${status}  ${u} =  Run Keyword And Ignore Error  Get XApp By Name {$xapp}
+     Should Be Equal As Strings  ${status}   FAIL
index 8b51a8d..cd86164 100644 (file)
@@ -3,31 +3,43 @@ Documentation   Executes the End To End Test cases
 ...
 Library   Collections
 Library   OperatingSystem
+
 Resource         ../resources/appmgr/appmgr_interface.robot
+Resource         ../resources/appmgr/negative_appmgr_tests.robot
 Resource         ../resources/e2mgr/e2mgr_interface.robot
 Resource         ../resources/dashboard/dashboard_interface.robot
 
 *** Variables ***
-${TEST_XAPPNAME}       DemoXapp1
-${TEST_XAPPID}    101
-${TEST_NODE_B_NAME}     AAAA456789
+${TEST_XAPPNAME}      xapp-std
+${TEST_XAPPID}        101
+${TEST_NODE_B_NAME}   AAAA456789
 ${TEST_NODE_B_IP}     10.0.0.3
 ${TEST_NODE_B_PORT}   36422
 
 
 *** Test Cases ***
-Get All Xapps
-    [Tags]   etetests  xapptests   ci_tests
-    Run AppMgr Get All Request
-Create Xapp
-    [Tags]   etetests  xapptests   ci_tests
-    Run Create Xapp   ${TEST_XAPPNAME}    ${TEST_XAPPID}
-Get Xapp By Name
-    [Tags]   etetests  xapptests
-    Run AppMgr Get By XappName   ${TEST_XAPPNAME}
-Get Xapp By Name and Id
-    [Tags]   etetests   xapptests
-    Run AppMgr Get By XappName and XappId    ${TEST_XAPPNAME}   ${TEST_XAPPID}
+Test XApp Manager Health
+    [Tags]  etetests  xapptests
+    Run AppMgr Health Check
+Deploy An XApp    
+    [Tags]  etetests  xapptests
+    Deploy XApp       ${TEST_XAPPNAME}
+Retrieve The Deployed XApp
+    [Tags]  etetests  xapptests
+    Get XApp By Name  ${TEST_XAPPNAME}
+Attempt To Deploy A Duplicate XApp
+    [Tags]  etetests  xapptests
+    Deploy Duplicate XApp And Expect Error
+Undeploy The Deployed XApp
+    [Tags]  etetests  xapptests
+    Undeploy XApp     ${TEST_XAPPNAME}
+Attempt To Undeploy An Already Undeployed XApp
+    [Tags]  etetests  xapptests
+    Undeploy Nondeployed XApp And Expect Error
+Attempt To Request A Nonexistent XApp
+    [Tags]  etetests  xapptests
+    Request Nonexistent XApp And Expect Error
+    
 Setup RAN Via E2Mgr X2
     [Tags]   x2setup
     Run E2Mgr Setup NodeB X2   ${TEST_NODE_B_NAME}    ${TEST_NODE_B_IP}   ${TEST_NODE_B_PORT}
@@ -56,4 +68,3 @@ Get NodeB via Dashboard
 Get All NodeBs via Dashboard
     [Tags]   e2setup_dash   x2setup_dash    ci_tests
     Run Dashboard Get All NodeBs Request
-