Commit 6eee358b authored by piscione's avatar piscione
Browse files

TCs for MEC045 for QkD Measurement subscription

parent 2f6fbfd3
Loading
Loading
Loading
Loading
Loading
+263 −0
Original line number Diff line number Diff line
Y''[Documentation]   robot --outputdir ../../../outputs ./QoSMeasurementSubNot.robot
...    Test Suite to validate QoSMeasurementSubNot Service API operations.

*** Settings ***
Resource    environment/variables.txt
Resource    ../../../../pics.txt
Resource    ../../../../GenericKeywords.robot
Library     REST    ${SCHEMA}://${HOST}:${PORT}    ssl_verify=false
Library     OperatingSystem
Library     libraries/Server.py
Library     libraries/StressGenerator.py
Library     JSONLibrary
Library     String    
Library     Collections
Library     DateTime 

*** Test Cases ***
TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_OK_01
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_OK_01
    ...    Check that the IUT acknowledges the creation of QoS measurement subscription request when commanded by a MEC Application
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 6.4.2,
    ...    ETSI GS MEC 045 Clause 7.3.3.4
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Create QoS Event Subscription    QoSMeasureSubscription
    ${SUB_TYPE}   Get value entry from JSON file    QoSMeasureSubscription  subscriptionType
    
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is  QoSEventSubscription
    Should Be Equal As Strings    ${response['body']['subscriptionType']}       ${SUB_TYPE}

TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_OK_02
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_OK_02
    ...    Check that the IUT acknowledges the creation of QoS measurement subscription request when commanded by a MEC Application - with reportingInterval
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 6.4.2,
    ...    ETSI GS MEC 045 Clause 7.3.3.4
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Create QoS Event Subscription    QoSMeasureSubscriptionWithRepInterval
    ${SUB_TYPE}   Get value entry from JSON file    QoSMeasureSubscriptionWithRepInterval  subscriptionType
    
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is  QoSEventSubscription
    Should Be Equal As Strings    ${response['body']['subscriptionType']}       ${SUB_TYPE}


TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_OK_03
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_OK_03
    ...    Check that the IUT acknowledges the creation of QoS measurement subscription request when commanded by a MEC Application - with numberOfReports
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 6.4.2,
    ...    ETSI GS MEC 045 Clause 7.3.3.4
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Create QoS Event Subscription    QoSMeasureSubscriptionWithNumOfReports
    ${SUB_TYPE}   Get value entry from JSON file    QoSMeasureSubscriptionWithNumOfReports  subscriptionType
    
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is  QoSEventSubscription
    Should Be Equal As Strings    ${response['body']['subscriptionType']}       ${SUB_TYPE}


TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_01
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_01
    ...    Check that the IUT responds with an error when a request with incorrect parameters is sent 
    ...    by a MEC Application - Invalid subscriptionType
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.3.3.4
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Create QoS Event Subscription    QoSSubscriptionBR
    Check HTTP Response Status Code Is    400


TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_02
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_02
    ...    Check that the IUT responds with an error when a request with incorrect parameters is sent 
    ...    by a MEC Application - Neither callbackReference nor websockNotifConfig provided
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.3.3.4
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Create QoS Event Subscription    QoSSubscriptionBR2
    Check HTTP Response Status Code Is    400
    

TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_03
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_03
    ...    Check that the IUT responds with an error when a request with incorrect parameters is sent 
    ...    by a MEC Application - Both callbackReference and websockNotifConfig provided
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.3.3.4
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Create QoS Event Subscription    QoSSubscriptionBR3
    Check HTTP Response Status Code Is    400  
    

TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_04
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_04
    ...    Check that the IUT responds with an error when a request with incorrect parameters is sent 
    ...    by a MEC Application - users not present (Note 2)
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.3.3.4
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Create QoS Event Subscription    QoSSubscriptionBR4
    Check HTTP Response Status Code Is    400


TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_05
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_05
    ...    Check that the IUT responds with an error when a request with incorrect parameters is sent 
    ...    by a MEC Application - flowInfo not present (Note 2)
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.3.3.4
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Create QoS Event Subscription    QoSSubscriptionBR5
    Check HTTP Response Status Code Is    400


TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_06
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_06
    ...    Check that the IUT responds with an error when a request with incorrect parameters is sent 
    ...    by a MEC Application - Invalid flowFilter
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.3.3.4
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Create QoS Event Subscription    QoSSubscriptionBR6
    Check HTTP Response Status Code Is    400


TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_07
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_07
    ...    Check that the IUT responds with an error when a request with incorrect parameters is sent 
    ...    by a MEC Application - Invalid condition on reportingInterval/measuringPeriod
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.3.3.4
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Create QoS Event Subscription    QoSSubscriptionBR7
    Check HTTP Response Status Code Is    400  
    
TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_08
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_001_BR_08
    ...    Check that the IUT responds with an error when a request with incorrect parameters is sent 
    ...    by a MEC Application - Invalid condition on measuringArea
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.3.3.4
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Create QoS Event Subscription    QoSSubscriptionBR8
    Check HTTP Response Status Code Is    400  


TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_002_OK
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_002_OK
    ...    Check that the IUT acknowledges the changes of an existing QoS measurement subscription request when commanded by a MEC Application
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.4.3.2
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Update QoS Event Subscription    QoSEventSubscriptionUpdate   ${SUBSCRIPTION_ID}
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is  QoSEventSubscription


TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_002_NF
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_002_NF
    ...    Check that the IUT responds with an error when a request for an URI that cannot be mapped to a valid resource URI is sent by a MEC Application
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.4.3.2
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Update QoS Event Subscription    QoSEventSubscriptionUpdate   ${UNKNOWN_SUBSCRIPTION_ID}
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is  QoSEventSubscription


TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_003_OK
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_003_OK
    ...    Check that the IUT acknowledges the cancellation of QoS measurement subscription when commanded by a MEC Application
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.4.3.5
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Delete QoS Event Subscription   ${SUBSCRIPTION_ID}
    Check HTTP Response Status Code Is    204    
    

TC_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_003_NF
    [Documentation]    TP_MEC_MEC045_SRV_QOS_MEAS_SUB_NOT_003_NF
    ...    Check that the IUT responds with an error when a request for an URI that cannot be mapped to a valid resource URI is sent by a MEC Application
    ...    ETSI GS MEC 045 Clause 5.2.2,
    ...    ETSI GS MEC 045 Clause 6.3.2,
    ...    ETSI GS MEC 045 Clause 7.4.3.5
    [Tags]    PIC_MEC_PLAT     PIC_SERVICES
    Delete QoS Event Subscription   ${UNKNOWN_SUBSCRIPTION_ID}
    Check HTTP Response Status Code Is    404     
    

*** Keywords ***
Spawn Expiry Notification Server
    Log    Starting notification server on ${NOTIFICATION_SERVER_IP}:${NOTIFICATION_SERVER_PORT} for expiry notification
    ${notification}=    Spawn Web Server  ${NOTIFICATION_SERVER_IP}  ${NOTIFICATION_SERVER_PORT}  ${NOTIFICATION_SERVER_TIMEOUT}  ${NOTIFICATION_SERVER_HTTP_METHOD}  ${NOTIFICATION_SERVER_URI}  ResourceUsageSubscription
    [Return]    ${notification}

Spawn Resource Notification Server
    Log    Starting notification server on ${NOTIFICATION_SERVER_IP}:${NOTIFICATION_SERVER_PORT}
    ${notification}=    Spawn Web Server  ${NOTIFICATION_SERVER_IP}  ${NOTIFICATION_SERVER_PORT}  ${NOTIFICATION_SERVER_TIMEOUT}  ${NOTIFICATION_SERVER_HTTP_METHOD}  ${NOTIFICATION_SERVER_URI}  ResourceUsageSubscription
    [Return]    ${notification}

Spawn Notification Server
    Log    Starting notification server on ${NOTIFICATION_SERVER_IP}:${NOTIFICATION_SERVER_PORT}
    ${notification}=    Spawn Web Server  ${NOTIFICATION_SERVER_IP}  ${NOTIFICATION_SERVER_PORT}  ${NOTIFICATION_SERVER_TIMEOUT}  ${NOTIFICATION_SERVER_HTTP_METHOD}  ${NOTIFICATION_SERVER_URI}  SiteResourceUsageSubscription
    [Return]    ${notification}

Create QoS Event Subscription
    [Arguments]    ${content}
    Should Be True    ${PIC_MEC_PLAT} == 1
    Should Be True    ${PIC_SERVICES} == 1
    Set Headers    {"Accept":"application/json"}
    Set Headers    {"Content-Type":"application/json"}
    Set Headers    {"Authorization":"${TOKEN}"}
    ${file}=    Catenate    SEPARATOR=    jsons/    ${content}    .json
    ${body}=    Get File    ${file}
    
    POST    ${apiRoot}/${apiName}/${apiVersion}/subscriptions    ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}


Update QoS Event Subscription
    [Arguments]    ${content}        ${SUBSCRIPTION_ID}
    Should Be True    ${PIC_MEC_PLAT} == 1
    Should Be True    ${PIC_SERVICES} == 1
    Set Headers    {"Accept":"application/json"}
    Set Headers    {"Content-Type":"application/json"}
    Set Headers    {"Authorization":"${TOKEN}"}
    ${file}=    Catenate    SEPARATOR=    jsons/    ${content}    .json
    ${body}=    Get File    ${file}
    
    Put    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${SUBSCRIPTION_ID}    ${body}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    


Delete QoS Event Subscription
    [Arguments]    ${SUBSCRIPTION_ID}
    Should Be True    ${PIC_MEC_PLAT} == 1
    Should Be True    ${PIC_SERVICES} == 1
    Set Headers    {"Accept":"application/json"}
    Set Headers    {"Content-Type":"application/json"}
    Set Headers    {"Authorization":"${TOKEN}"}
    
    Delete    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${SUBSCRIPTION_ID}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
+16 −0
Original line number Diff line number Diff line
*** Variables ***
# Generic variables
${SCHEMA}                           http
${HOST}                             127.0.0.1
#${HOST}                            10.192.2.172
${PORT}                             8081
${response}                         {}
${TOKEN}                            Basic YWxhZGRpbjpvcGVuc2VzYW1l
${apiRoot}        
${apiName}                          qms
${apiVersion}                       v1


##Specific
${SUBSCRIPTION_ID}             subscription_id
${UNKNOWN_SUBSCRIPTION_ID}     unknown_sub_id
 No newline at end of file
+52 −0
Original line number Diff line number Diff line
#!/usr/bin/python3
# filepath: c:\Users\Ikram Laptop\ROBOT-Framework\gs032p3-robot-test-suite\MEC048\MEO\CSE\libraries\Server.py

from http.server import BaseHTTPRequestHandler, HTTPServer
import json, os
import logging

# Library version
__version__ = '0.0.1'

class Server(object):
    ROBOT_LIBRARY_VERSION = '0.0.1'

    def spawn_web_server(self, host="127.0.0.1", port=8080, timeout=15, method="POST", endpoint="/callback_url", resp_body=None):
        
        class POST_Server(BaseHTTPRequestHandler):
            def __call__(self, *args, **kwargs):
                """Handle a request."""
                super().__init__(*args, **kwargs)

            def __init__(self, endpoint, resp_body):
                self.resp_body = resp_body
                self.endpoint = endpoint
                self.req_body = None

            def do_POST(self):
                self.send_response(200)
                self.send_header('Content-Type', 'application/json')
                self.end_headers()
                
                content_len = int(self.headers.get('Content-Length'))
                post_body = self.rfile.read(content_len)
                self.req_body = post_body
                logging.info(f"Received notification: {post_body}")

            def get_req_body(self):
                return self.req_body

            def get_resp_body(self):
                return self.resp_body

        self.handler = POST_Server(endpoint, resp_body)
        self.app = HTTPServer((host, int(port)), self.handler)
        self.app.timeout = int(timeout)
        
        logging.info(f"Starting notification server on {host}:{port} with timeout {timeout}")
        self.app.handle_request()
        self.app.server_close()
        
        if self.handler.get_req_body() is not None:
            return json.loads(self.handler.get_req_body().decode("utf-8"))
        return None
 No newline at end of file
+37 −0
Original line number Diff line number Diff line
import multiprocessing
import time

class StressGenerator:
    ROBOT_LIBRARY_VERSION = '0.0.1'
    
    def generate_cpu_load(self, duration=30, cpu_cores=None):
        """
        Generate CPU load by spinning up processes that perform intensive calculations.
        
        Args:
            duration: How long to run the stress test in seconds
            cpu_cores: Number of CPU cores to use. If None, uses all available cores.
        """
        if cpu_cores is None:
            cpu_cores = multiprocessing.cpu_count()
            
        processes = []
        
        def cpu_intensive_task():
            end_time = time.time() + duration
            while time.time() < end_time:
                # Perform CPU-intensive calculations
                for i in range(10000000):
                    _ = i * i
        
        # Create and start processes
        for _ in range(cpu_cores):
            p = multiprocessing.Process(target=cpu_intensive_task)
            p.start()
            processes.append(p)
            
        # Wait for all processes to complete
        for p in processes:
            p.join()
            
        return f"Generated CPU load on {cpu_cores} cores for {duration} seconds"
 No newline at end of file