Skip to content
Snippets Groups Projects
Commit fe548e6e authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Create script to run robot mock server

parent a7d30c85
No related branches found
No related tags found
3 merge requests!43Staging to Main for Release 1,!26Draft: Ocf38 logging new events,!22Resolve "Logging CCF use redis to send event service api invocation"
Pipeline #6016 failed
......@@ -325,47 +325,3 @@ Prueba JMS
Log ${event}
List Should Contain Value ${notification_events_on_mock_server} ${event}
END
*** Keywords ***
Create Events From invocationLogs
[Arguments] ${subscription_id} ${invocation_log}
${events}= Create List
# Now we create the expected events received at notification server according to logs sent to loggin service in order to check if all are present.
${invocation_log_base}= Copy Dictionary ${invocation_log} deepcopy=True
# Store log array because each log will be notified in one Event Notification
${invocation_log_logs}= Copy List ${invocation_log_base['logs']}
# Remove logs array from invocationLog data
Remove From Dictionary ${invocation_log_base} logs
FOR ${log} IN @{invocation_log_logs}
Log Dictionary ${log}
${invocation_logs}= Copy Dictionary ${invocation_log_base} deepcopy=True
# Get Event Enum for this result
${event_enum}= Set Variable
IF ${log['result']} >= 200 and ${log['result']} < 300
${event_enum}= Set Variable SERVICE_API_INVOCATION_SUCCESS
ELSE
${event_enum}= Set Variable SERVICE_API_INVOCATION_FAILURE
END
# Create a log array with only one component
${log_list}= Create List ${log}
# Setup logs array with previously created list
Set To Dictionary ${invocation_logs} logs=${log_list}
# Create event details for each log
${event_details}= Create dictionary invocationLogs=${invocation_logs}
# Create Event with Event Details from invocationLog and also is appended to events array
${event}= Create Dictionary
... subscriptionId=${subscription_id}
... events=${event_enum}
... eventDetail=${event_details}
Check Variable ${event} EventNotification
Append To List ${events} ${event}
END
Log List ${events}
${events_length}= Get Length ${events}
RETURN ${events} ${events_length}
from flask import Flask, request
import logging
from logging.handlers import RotatingFileHandler
import os
app = Flask(__name__)
......@@ -53,4 +53,4 @@ def requests_list():
configure_logging(app)
if __name__ == '__main__':
app.run(host='0.0.0.0',port=9090,debug=True)
app.run(host=os.environ.get("IP",'0.0.0.0'),port=os.environ.get("PORT",9090),debug=True)
#!/bin/bash
help() {
echo "Usage: $1 <options>"
echo " -i : Setup different host ip for mock server (default 0.0.0.0)"
echo " -p : Setup different port for mock server (default 9090)"
echo " -h : show this help"
exit 1
}
IP=0.0.0.0
PORT=9090
# Read params
while getopts ":i:p:h" opt; do
case $opt in
i)
IP="$OPTARG"
;;
p)
PORT=$OPTARG
;;
h)
help
;;
\?)
echo "Not valid option: -$OPTARG" >&2
help
;;
:)
echo "The -$OPTARG option requires an argument." >&2
help
;;
esac
done
echo Robot Framework Mock Server will listen on $IP:$PORT
pip install -r requirements.txt
IP=$IP PORT=$PORT python mock_server.py
......@@ -744,3 +744,46 @@ Create Security Context Between invoker and provider
... username=${register_user_info_invoker['management_cert']}
Check Response Variable Type And Values ${resp} 201 ServiceSecurity
Create Events From invocationLogs
[Arguments] ${subscription_id} ${invocation_log}
${events}= Create List
# Now we create the expected events received at notification server according to logs sent to loggin service in order to check if all are present.
${invocation_log_base}= Copy Dictionary ${invocation_log} deepcopy=True
# Store log array because each log will be notified in one Event Notification
${invocation_log_logs}= Copy List ${invocation_log_base['logs']}
# Remove logs array from invocationLog data
Remove From Dictionary ${invocation_log_base} logs
FOR ${log} IN @{invocation_log_logs}
Log Dictionary ${log}
${invocation_logs}= Copy Dictionary ${invocation_log_base} deepcopy=True
# Get Event Enum for this result
${event_enum}= Set Variable
IF ${log['result']} >= 200 and ${log['result']} < 300
${event_enum}= Set Variable SERVICE_API_INVOCATION_SUCCESS
ELSE
${event_enum}= Set Variable SERVICE_API_INVOCATION_FAILURE
END
# Create a log array with only one component
${log_list}= Create List ${log}
# Setup logs array with previously created list
Set To Dictionary ${invocation_logs} logs=${log_list}
# Create event details for each log
${event_details}= Create dictionary invocationLogs=${invocation_logs}
# Create Event with Event Details from invocationLog and also is appended to events array
${event}= Create Dictionary
... subscriptionId=${subscription_id}
... events=${event_enum}
... eventDetail=${event_details}
Check Variable ${event} EventNotification
Append To List ${events} ${event}
END
Log List ${events}
${events_length}= Get Length ${events}
RETURN ${events} ${events_length}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment