Commit a6398d35 authored by Giacomo Bernini's avatar Giacomo Bernini
Browse files

[test-upd][SOL005][NSD-MGMT][v5.3.1][NFVSOL(26)000019r3][5.3.1.9.x Test-IDs]...

[test-upd][SOL005][NSD-MGMT][v5.3.1][NFVSOL(26)000019r3][5.3.1.9.x Test-IDs] implemented support for notification validation as per item 17-2
parent 08f3c8e5
Loading
Loading
Loading
Loading
+250 −4
Original line number Diff line number Diff line
*** Setting ***
Resource	environment/variables.txt
Suite Setup    Create Sessions
Suite Teardown    Terminate All Processes    kill=true
Suite Teardown    Terminate All Processes    kill=trueLibrary           REST    ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}    ssl_verify=false
Library           REST    ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}    ssl_verify=false
Library    MockServerLibrary
Library    Process
Library    OperatingSystem
@@ -22,6 +23,7 @@ NSD Onboarding Notification
    Trigger the completion of NSD Onboarding (external action) 
    Check NSD Onboarding Notification Http Request Body Json Schema Is    NsdOnboardingNotification
    Check NSD Onboarding Notification Http Request Body notificationType attribute Is    NsdOnboardingNotification
    Check NSD Onboarding Notification Validation
    
NSD Onboarding Failure Notification
    [Documentation]    Test ID: 5.3.1.9.2
@@ -35,6 +37,8 @@ NSD Onboarding Failure Notification
    Trigger the failure of NSD Onboarding (external action) 
    Check NSD Onboarding Failure Notification Http Request Body Json Schema Is    NsdOnboardingFailureNotification
    Check NSD Onboarding Failure Notification Http Request Body notificationType attribute Is    NsdOnboardingFailureNotification
    Check NSD Onboarding Failure Notification Validation


NSD Operational State Change Notification
    [Documentation]    Test ID: 5.3.1.9.3
@@ -48,6 +52,7 @@ NSD Operational State Change Notification
    Trigger the change of NSD Operational State (external action) 
    Check NSD Operational State Change Notification Http Request Body Json Schema Is    NsdChangeNotification
    Check NSD Operational State Change Notification Http Request Body notificationType attribute Is    NsdChangeNotification
    Check NSD Operational State Change Notification Validation

NSD Deletion Notification
    [Documentation]    Test ID: 5.3.1.9.4
@@ -61,6 +66,7 @@ NSD Deletion Notification
    Trigger the deletion of NSD (external action) 
    Check NSD Deletion Notification Http Request Body Json Schema Is    NsdDeletionNotification
    Check NSD Deletion Notification Http Request Body notificationType attribute Is    NsdDeletionNotification
    Check NSD Deletion Notification Validation

PNFD Onboarding Notification
    [Documentation]    Test ID: 5.3.1.9.5
@@ -74,6 +80,7 @@ PNFD Onboarding Notification
    Trigger the completion of PNFD Onboarding (external action) 
    Check PNFD Onboarding Notification Http Request Body Json Schema Is    PnfdOnboardingNotification
    Check PNFD Onboarding Notification Http Request Body notificationType attribute Is    PnfdOnboardingNotification
    Check PNFD Onboarding Notification Validation
  
PNFD Onboarding Failure Notification
    [Documentation]    Test ID: 5.3.1.9.6
@@ -87,6 +94,7 @@ PNFD Onboarding Failure Notification
    Trigger the failure of PNFD Onboarding (external action) 
    Check PNFD Onboarding Failure Notification Http Request Body Json Schema Is    PnfdOnboardingFailureNotification
    Check PNFD Onboarding Failure Notification Http Request Body notificationType attribute Is    PndfOnboardingFailureNotification
    Check PNFD Onboarding Failure Notification Validation

PNFD Deletion Notification
    [Documentation]    Test ID: 5.3.1.9.7
@@ -100,7 +108,7 @@ PNFD Deletion Notification
    Trigger the deletion of PNFD (external action) 
    Check PNFD Deletion Notification Http Request Body Json Schema Is    PnfdDeletionNotification
    Check PNFD Deletion Notification Http Request Body notificationType attribute Is    PnfdDeletionNotification

    Check PNFD Deletion Notification Validation

*** Keywords ***
Trigger the completion of NSD Onboarding (external action) 
@@ -300,6 +308,244 @@ Configure Notification Forward
    &{notification_fwd}=  Create Mock Http Forward	${endpoint_fwd}
    Create Mock Expectation With Http Forward  ${notification_tmp}  ${notification_fwd}

Check NSD Onboarding Notification Validation
    [Arguments]    ${expected_notification_type}=NsdOnboardingNotification
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    Log    Request type: ${request_type}

    ${last_request}=    Run Keyword If    "${request_type}" == "<class 'list'>"
    ...    Get From List    ${requests}    -1
    ...    ELSE
    ...    Set Variable    ${requests}

    ${body}=    Get From Dictionary    ${last_request}    body
    ${body_text}=    Get From Dictionary    ${body}    string

    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    Log    Parsed notification: ${notification}

    Should Be Equal As Strings    ${notification['notificationType']}    ${expected_notification_type}

    ${nsdInfoId}=    Get From Dictionary    ${notification}    nsdId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate entity exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${nsdInfoId}
    Integer    response status    200

    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Check NSD Onboarding Failure Notification Validation
    [Arguments]    ${expected_notification_type}=NsdOnboardingNotification
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    Log    Request type: ${request_type}

    ${last_request}=    Run Keyword If    "${request_type}" == "<class 'list'>"
    ...    Get From List    ${requests}    -1
    ...    ELSE
    ...    Set Variable    ${requests}

    ${body}=    Get From Dictionary    ${last_request}    body
    ${body_text}=    Get From Dictionary    ${body}    string

    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    Log    Parsed notification: ${notification}

    Should Be Equal As Strings    ${notification['notificationType']}    ${expected_notification_type}

    ${nsdInfoId}=    Get From Dictionary    ${notification}    nsdId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate entity exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${nsdInfoId}
    Integer    response status    200

    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Check NSD Operational State Change Notification Validation
    [Arguments]    ${expected_notification_type}=NsdOnboardingNotification
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    Log    Request type: ${request_type}

    ${last_request}=    Run Keyword If    "${request_type}" == "<class 'list'>"
    ...    Get From List    ${requests}    -1
    ...    ELSE
    ...    Set Variable    ${requests}

    ${body}=    Get From Dictionary    ${last_request}    body
    ${body_text}=    Get From Dictionary    ${body}    string

    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    Log    Parsed notification: ${notification}

    Should Be Equal As Strings    ${notification['notificationType']}    ${expected_notification_type}

    ${nsdInfoId}=    Get From Dictionary    ${notification}    nsdId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate entity exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${nsdInfoId}
    Integer    response status    200

    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Check NSD Deletion Notification Validation
    [Arguments]    ${expected_notification_type}=NsdOnboardingNotification
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    Log    Request type: ${request_type}

    ${last_request}=    Run Keyword If    "${request_type}" == "<class 'list'>"
    ...    Get From List    ${requests}    -1
    ...    ELSE
    ...    Set Variable    ${requests}

    ${body}=    Get From Dictionary    ${last_request}    body
    ${body_text}=    Get From Dictionary    ${body}    string

    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    Log    Parsed notification: ${notification}

    Should Be Equal As Strings    ${notification['notificationType']}    ${expected_notification_type}

    ${nsdInfoId}=    Get From Dictionary    ${notification}    nsdId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate entity exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${nsdInfoId}
    Integer    response status    200

    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Check PNFD Onboarding Notification Validation
    [Arguments]    ${expected_notification_type}=PnfdOnboardingNotification
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    Log    Request type: ${request_type}

    ${last_request}=    Run Keyword If    "${request_type}" == "<class 'list'>"
    ...    Get From List    ${requests}    -1
    ...    ELSE
    ...    Set Variable    ${requests}

    ${body}=    Get From Dictionary    ${last_request}    body
    ${body_text}=    Get From Dictionary    ${body}    string

    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    Log    Parsed notification: ${notification}

    Should Be Equal As Strings    ${notification['notificationType']}    ${expected_notification_type}

    ${nsdInfoId}=    Get From Dictionary    ${notification}    nsdId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate entity exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${nsdInfoId}
    Integer    response status    200

    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Check PNFD Onboarding Failure Notification Validation
    [Arguments]    ${expected_notification_type}=PnfdOnboardingFailureNotification
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    Log    Request type: ${request_type}

    ${last_request}=    Run Keyword If    "${request_type}" == "<class 'list'>"
    ...    Get From List    ${requests}    -1
    ...    ELSE
    ...    Set Variable    ${requests}

    ${body}=    Get From Dictionary    ${last_request}    body
    ${body_text}=    Get From Dictionary    ${body}    string

    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    Log    Parsed notification: ${notification}

    Should Be Equal As Strings    ${notification['notificationType']}    ${expected_notification_type}

    ${nsdInfoId}=    Get From Dictionary    ${notification}    nsdId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate entity exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${nsdInfoId}
    Integer    response status    200

    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Check PNFD Deletion Notification Validation
    [Arguments]    ${expected_notification_type}=PnfdDeletionNotification
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    Log    Request type: ${request_type}

    ${last_request}=    Run Keyword If    "${request_type}" == "<class 'list'>"
    ...    Get From List    ${requests}    -1
    ...    ELSE
    ...    Set Variable    ${requests}

    ${body}=    Get From Dictionary    ${last_request}    body
    ${body_text}=    Get From Dictionary    ${body}    string

    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    Log    Parsed notification: ${notification}

    Should Be Equal As Strings    ${notification['notificationType']}    ${expected_notification_type}

    ${nsdInfoId}=    Get From Dictionary    ${notification}    nsdId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate entity exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/ns_descriptors/${nsdInfoId}
    Integer    response status    200

    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Create Sessions
    Start Process  java  -jar ${MOCK_SERVER_JAR} -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue