diff --git a/scripts/test/pipeline.sh b/scripts/test/pipeline.sh index 77df5cec45ffbffeefc685e0729d9a28962fd330..6042ce8b917d5c3a75268593b20e2b60a96c1934 100644 --- a/scripts/test/pipeline.sh +++ b/scripts/test/pipeline.sh @@ -1,19 +1,41 @@ #!/bin/bash +#///////////////////////////////////////////////////////////////////////// +#// +#// (c) University of Southampton IT Innovation Centre, 2018 +#// +#// Copyright in this software belongs to University of Southampton +#// IT Innovation Centre of Gamma House, Enterprise Road, +#// Chilworth Science Park, Southampton, SO16 7NS, UK. +#// +#// This software may not be used, sold, licensed, transferred, copied +#// or reproduced in whole or in part in any manner or form or in or +#// on any media by any person other than in accordance with the terms +#// of the Licence Agreement supplied with the software, or otherwise +#// without the prior written consent of the copyright owners. +#// +#// This software is distributed WITHOUT ANY WARRANTY, without even the +#// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +#// PURPOSE, except where stated in the Licence Agreement supplied with +#// the software. +#// +#// Created By : Nikolay Sanchev +#// Created Date : 21/02/2019 +#// Created for Project : FLAME +#// +#///////////////////////////////////////////////////////////////////////// + +set -euo pipefail + +CLMC_IP="localhost" +ues=("ue20" "ue22" "ue23" "ue24") # TODO currently the list of ues is hardcoded + +JSON_CONFIG=$1 # expects the JSON configuration passed to the execute_graph_pipeline API endpoint + +# extract and delete some of the configuration details, which are used by this script +fields=$(echo ${JSON_CONFIG} | jq -r '"\(.query_period) \(.service_function_chain) \(.results_measurement_name)"') +read query_period db_name results_measurement <<< ${fields} +JSON_CONFIG=$(echo ${JSON_CONFIG} | jq 'del(.query_period, .results_measurement_name)') -CLMC_IP="172.40.231.51" - -sfc="fms-sfc" -sfci="fms-sfc-1" -service_function="fms-storage" -measurement="tomcat_connector" -response_time_field="(max(processing_time) - min(processing_time)) / ((count(processing_time) - 1)*1000)" -request_size_field="(max(bytes_received) - min(bytes_received)) / (count(bytes_received) - 1)" -response_size_field="(max(bytes_sent) - min(bytes_sent)) / (count(bytes_sent) - 1)" -rtt_measurement="graph_measurement" -query_period=30 - -ues=("ue20" "ue22" "ue23" "ue24") -endpoints=("fms-storage-endpoint" "fms-storage-second-endpoint") echo "Building network subgraph..." response=$(curl -s -X POST http://${CLMC_IP}/clmc-service/graph/network) @@ -27,23 +49,19 @@ do start=$((${end}-${query_period})) echo "Start - ${start}, End - ${end}" - JSON_STRING=$( jq -n \ - --arg sfc "${sfc}" \ - --arg sfci "${sfci}" \ - --arg sf "${service_function}" \ - --arg measurement "${measurement}"\ - --arg response_time "${response_time_field}"\ - --arg request_size "${request_size_field}"\ - --arg response_size "${response_size_field}"\ - --argjson from ${start}\ - --argjson to ${end}\ - '{from: $from, to: $to, service_function_chain: $sfc, service_function_chain_instance: $sfci, service_functions: {($sf): {measurement_name: $measurement, response_time_field: $response_time, request_size_field: $request_size, response_size_field: $response_size}}}' ) + JSON_STRING=$(echo ${JSON_CONFIG} | jq --argjson from ${start} --argjson to ${end} '. + {from: $from, to: $to}') echo "Sending build request to CLMC" + echo "Request body - ${JSON_STRING}" response=$(curl -s -X POST -d "${JSON_STRING}" http://${CLMC_IP}/clmc-service/graph/temporal) - fields=$(echo ${response} | jq -r '. | "\(.graph.time_range.to) \(.graph.uuid)"') + + fields=$(echo ${response} | jq -r '"\(.graph.time_range.to) \(.graph.uuid)"') read timestamp graph_uuid <<< ${fields} + + endpoints=($(echo ${response} | jq -r '.graph.endpoints | .[]')) # convert the jq array to bash array + echo "Received request uuid ${graph_uuid}" echo "Timestamp to use for measurement ${timestamp}" + echo "Received endpoints: ${endpoints[@]}" for endpoint in ${endpoints[@]}; do for ue in ${ues[@]}; do @@ -64,9 +82,9 @@ do echo "Service delay: ${service_delay}" echo "Network latency ${network_delay}" - measurement_line="${rtt_measurement},${global_tags},${local_tags} round_trip_time=${rtt},service_delay=${service_delay},network_delay=${network_delay} ${timestamp}" + measurement_line="${results_measurement},${global_tags},${local_tags} round_trip_time=${rtt},service_delay=${service_delay},network_delay=${network_delay} ${timestamp}" echo "Measurement line: ${measurement_line}" - response=$(curl -si -X POST "http://${CLMC_IP}/influxdb/write?db=${sfc}" --data-binary "${measurement_line}") + response=$(curl -si -X POST "http://${CLMC_IP}/influxdb/write?db=${db_name}" --data-binary "${measurement_line}") echo "InfluxDB response: ${response}" done @@ -77,6 +95,6 @@ do echo ${response} echo "Sleeping ${query_period} seconds" - sleep ${query_period} + sleep $((${query_period}-1)) done \ No newline at end of file