From 147443441dd3b5dd503502d435dfb13b0368ad08 Mon Sep 17 00:00:00 2001 From: Giacomo Bernini <g.bernini@nextworks.it> Date: Fri, 22 Oct 2021 11:49:23 +0200 Subject: [PATCH] updated SOL005 NS PM threshold creeation and update with mandatory test notification endpoint --- .../NSPerformanceManagementKeywords.robot | 63 ++++++++++++++----- .../environment/variables.txt | 3 + .../jsons/CreatePmJobRequest.json | 2 +- .../jsons/CreateThresholdRequest.json | 7 ++- 4 files changed, 56 insertions(+), 19 deletions(-) diff --git a/SOL005/NSPerformanceManagement-API/NSPerformanceManagementKeywords.robot b/SOL005/NSPerformanceManagement-API/NSPerformanceManagementKeywords.robot index 29e0c562..15bd3116 100644 --- a/SOL005/NSPerformanceManagement-API/NSPerformanceManagementKeywords.robot +++ b/SOL005/NSPerformanceManagement-API/NSPerformanceManagementKeywords.robot @@ -92,7 +92,7 @@ Send Post Request Create new NS Performance Monitoring Job Set Headers {"Content-Type": "${CONTENT_TYPE_JSON}"} Run Keyword If ${AUTH_USAGE} == 1 Set Headers {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"} ${template}= Get File jsons/CreatePmJobRequest.json - ${body}= Format String ${template} pmJobId=${pmJobId} callbackUri=${callback_uri} callbackEndpoint=${callback_endpoint} callbackPort=${callback_port} performanceMetric=${performanceMetric} collectionPeriod=${collectionPeriod} reportingPeriod=${reportingPeriod} + ${body}= Format String ${template} pmJobObjectInstanceId=${pmJobObjectInstanceId} callbackUri=${callback_uri} callbackEndpoint=${callback_endpoint} callbackPort=${callback_port} performanceMetric=${performanceMetric} collectionPeriod=${collectionPeriod} reportingPeriod=${reportingPeriod} Log Creating mock request and response to handle GET operation on notification endpoint &{notification_request}= Create Mock Request Matcher GET ${callback_endpoint} &{notification_response}= Create Mock Response status_code=204 @@ -112,18 +112,10 @@ Send POST request for NS Performance Monitoring Job with unprocessable entity Set Headers {"Content-Type": "${CONTENT_TYPE_JSON}"} Run Keyword If ${AUTH_USAGE} == 1 Set Headers {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"} ${template}= Get File jsons/CreatePmJobRequest.json - ${body}= Format String ${template} pmJobId=${pmJobId} callbackUri=${callback_uri} callbackEndpoint=${unreachable_callback_uri} callbackPort=${callback_port} performanceMetric=${performanceMetric} collectionPeriod=${collectionPeriod} reportingPeriod=${reportingPeriod} - Log Creating mock request and response to handle GET operation on notification endpoint - &{notification_request}= Create Mock Request Matcher GET ${callback_endpoint} - &{notification_response}= Create Mock Response status_code=204 - Log Issue the request - Create Mock Expectation ${notification_request} ${notification_response} + ${body}= Format String ${template} pmJobObjectInstanceId=${pmJobObjectInstanceId} callbackUri=${callback_uri} callbackEndpoint=${unreachable_callback_uri} callbackPort=${callback_port} performanceMetric=${performanceMetric} collectionPeriod=${collectionPeriod} reportingPeriod=${reportingPeriod} POST ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs ${body} ${output}= Output response Set Suite Variable ${response} ${output} - Log Verify producer tested the notification endpoint - Verify Mock Expectation ${notification_request} - Clear Requests ${callback_endpoint} Send PUT Request for all NS Performance Monitoring Jobs Log Trying to perform a PUT. This method should not be implemented @@ -289,9 +281,17 @@ Send Patch request for individual NS Performance Job - Etag mismatch Run Keyword If ${AUTH_USAGE} == 1 Set Headers {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"} ${template}= Get File jsons/PmJobModifications.json ${body}= Format String ${template} callbackUri=${callback_uri} callbackEndpoint=${callback_endpoint} callbackPort=${callback_port} + Log Creating mock request and response to handle GET operation on notification endpoint + &{notification_request}= Create Mock Request Matcher GET ${callback_endpoint} + &{notification_response}= Create Mock Response status_code=204 + Log Issue the request + Create Mock Expectation ${notification_request} ${notification_response} PATCH ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${pmJobId} ${body} ${output}= Output response Set Suite Variable ${response} ${output} + Log Verify producer tested the notification endpoint + Verify Mock Expectation ${notification_request} + Clear Requests ${callback_endpoint} Send Patch request for individual NS Performance Job with unprocessable entity @@ -420,10 +420,18 @@ Send Post Request Create new Performance Threshold Set Headers {"Accept": "${ACCEPT_JSON}"} Set Headers {"Content-Type": "${CONTENT_TYPE_JSON}"} ${template}= Get File jsons/CreateThresholdRequest.json - ${body}= Format String ${template} pmJobId=${pmJobId} + ${body}= Format String ${template} thresholdObjectInstanceId=${thresholdObjectInstanceId} callbackUri=${callback_uri} callbackEndpoint=${callback_endpoint} + ... callbackPort=${callback_port} performanceMetric=${performanceMetric} thresholdType=${thresholdType} thresholdValue=${thresholdValue} hysteresis=${hysteresis} + Log Creating mock request and response to handle GET operation on notification endpoint + &{notification_request}= Create Mock Request Matcher GET ${callback_endpoint} + &{notification_response}= Create Mock Response status_code=204 + Log Issue the request + Create Mock Expectation ${notification_request} ${notification_response} POST ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds ${body} ${output}= Output response - Set Suite Variable ${response} ${output} + Set Suite Variable ${response} ${output}ndpoint + Verify Mock Expectation ${notification_request} + Clear Requests ${callback_endpoint} Send POST request for Performance threshold with unprocessable entity Log Creating a new Threshold @@ -431,10 +439,18 @@ Send POST request for Performance threshold with unprocessable entity Set Headers {"Accept": "${ACCEPT_JSON}"} Set Headers {"Content-Type": "${CONTENT_TYPE_JSON}"} ${template}= Get File jsons/CreateThresholdRequest.json - ${body}= Format String ${template} callback_uri=${unreachable_callback_uri}:${callback_port} + ${body}= Format String ${template} thresholdObjectInstanceId=${thresholdObjectInstanceId} callbackUri=${callback_uri} callbackEndpoint=${unreachable_callback_uri} + ... callbackPort=${callback_port} performanceMetric=${performanceMetric} thresholdType=${thresholdType} thresholdValue=${thresholdValue} hysteresis=${hysteresis} + Log Creating mock request and response to handle GET operation on notification endpoint + &{notification_request}= Create Mock Request Matcher GET ${callback_endpoint} + &{notification_response}= Create Mock Response status_code=204 + Log Issue the request + Create Mock Expectation ${notification_request} ${notification_response} POST ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds ${body} ${output}= Output response - Set Suite Variable ${response} ${output} + Set Suite Variable ${response} ${output}ndpoint + Verify Mock Expectation ${notification_request} + Clear Requests ${callback_endpoint} Send PUT Request for all Performance Thresholds Log PUT THresholds @@ -530,10 +546,19 @@ Send Patch request for individual NS performance Threshold Set Headers {"Accept": "${ACCEPT_JSON}"} Set Headers {"Content-Type": "${CONTENT_TYPE_PATCH}"} Run Keyword If ${AUTH_USAGE} == 1 Set Headers {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"} - ${body}= Get File jsons/ThresholdModifications.json + ${body}= Get File jsons/ThresholdModifications.json + ${body}= Format String ${body} callbackUri=${callback_uri} callbackEndpoint=${callback_endpoint} callbackPort=${callback_port} + Log Creating mock request and response to handle GET operation on notification endpoint + &{notification_request}= Create Mock Request Matcher GET ${callback_endpoint} + &{notification_response}= Create Mock Response status_code=204 + Log Issue the request + Create Mock Expectation ${notification_request} ${notification_response} PATCH ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId} ${body} ${output}= Output response Set Suite Variable ${response} ${output} + Log Verify producer tested the notification endpoint + Verify Mock Expectation ${notification_request} + Clear Requests ${callback_endpoint} Send Patch request for individual NS performance Threshold - Etag mismatch Log Trying to PUT threshold @@ -543,9 +568,17 @@ Send Patch request for individual NS performance Threshold - Etag mismatch Run Keyword If ${AUTH_USAGE} == 1 Set Headers {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"} ${template}= Get File jsons/ThresholdModifications.json ${body}= Format String ${template} callbackUri=${callback_uri} callbackEndpoint=${callback_endpoint} callbackPort=${callback_port} + Log Creating mock request and response to handle GET operation on notification endpoint + &{notification_request}= Create Mock Request Matcher GET ${callback_endpoint} + &{notification_response}= Create Mock Response status_code=204 + Log Issue the request + Create Mock Expectation ${notification_request} ${notification_response} PATCH ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId} ${body} ${output}= Output response Set Suite Variable ${response} ${output} + Log Verify producer tested the notification endpoint + Verify Mock Expectation ${notification_request} + Clear Requests ${callback_endpoint} Send Patch request for Individual Threshold with unprocessable entity Set Headers {"Accept":"${ACCEPT_JSON}"} diff --git a/SOL005/NSPerformanceManagement-API/environment/variables.txt b/SOL005/NSPerformanceManagement-API/environment/variables.txt index 647fed25..e8b303c0 100644 --- a/SOL005/NSPerformanceManagement-API/environment/variables.txt +++ b/SOL005/NSPerformanceManagement-API/environment/variables.txt @@ -29,6 +29,9 @@ ${invalid_etag} invalid etag ${total_polling_time} 2 min ${polling_interval} 10 sec +${objectType} my_type +${pmJobObjectInstanceId} my_id +${thresholdObjectInstanceId} my_id ${performanceMetric} cpu_util ${thresholdType} SIMPLE ${thresholdValue} 10 diff --git a/SOL005/NSPerformanceManagement-API/jsons/CreatePmJobRequest.json b/SOL005/NSPerformanceManagement-API/jsons/CreatePmJobRequest.json index 2f55c065..c0fb7de3 100644 --- a/SOL005/NSPerformanceManagement-API/jsons/CreatePmJobRequest.json +++ b/SOL005/NSPerformanceManagement-API/jsons/CreatePmJobRequest.json @@ -1,5 +1,5 @@ {{ - "objectInstanceIds": ["{pmJobId}"], + "objectInstanceIds": ["{pmJobObjectInstanceId} "], "criteria": {{ "performanceMetric": "{performanceMetric}", "performanceMetricGroup": [], diff --git a/SOL005/NSPerformanceManagement-API/jsons/CreateThresholdRequest.json b/SOL005/NSPerformanceManagement-API/jsons/CreateThresholdRequest.json index 145f2d68..5572d846 100644 --- a/SOL005/NSPerformanceManagement-API/jsons/CreateThresholdRequest.json +++ b/SOL005/NSPerformanceManagement-API/jsons/CreateThresholdRequest.json @@ -1,11 +1,12 @@ {{ - "objectInstanceIds" : "{pmJobId}", + "objectType": "{objectType}", + "objectInstanceId" : "{thresholdObjectInstanceId}", "criteria" : {{ "performanceMetric": "{performanceMetric}", "thresholdType": "{thresholdType}", "simpleThresholdDetails": {{ - "thresholdValue": {thresholdValue}, - "hysteresis": {hysteresis} + "thresholdValue": "{thresholdValue}", + "hysteresis": "{hysteresis}" }} }}, "callbackUri": "{callbackUri}:{callbackPort}{callbackEndpoint}" -- GitLab