#!/bin/bash
#
# Copyright 2023 Nordix Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -o errexit  # Exit on most errors
set -o nounset  # Disallow expansion of unset variables
set -o pipefail # Use last non-zero exit code in a pipeline
#set -o xtrace   # Uncomment for debugging

GRAB_METRICS=true
DOCKER_COMPOSE_FILE=../docker-compose/docker-compose.yml
CREATE_REQUEST=/tmp/cmhandles-create-req.txt
REMOVE_REQUEST=/tmp/cmhandles-remove-req.txt
REPORT_FILE=metrics-reports/deregister-summary-$(date --iso-8601=seconds).tsv

stop_docker() {
    docker-compose -f $DOCKER_COMPOSE_FILE down >/dev/null
    docker container prune -f >/dev/null
    docker volume prune -f >/dev/null
}

restart_docker() {
    stop_docker
    docker-compose -f $DOCKER_COMPOSE_FILE --profile dmi-stub --profile monitoring up -d >/dev/null
}

wait_for_cps_to_start() {
    docker logs cps-and-ncmp -f | grep -m 1 'Started Application' >/dev/null || true
}

get_number_of_handles_ready() {
    PGPASSWORD=cps psql -h localhost -p 5432 cpsdb cps -c \
        "SELECT count(*) FROM public.fragment where attributes @> '{\"cm-handle-state\": \"READY\"}';" \
        | sed '3!d' | sed 's/ *//'
}

wait_for_handles_to_be_ready() {
    local TOTAL_HANDLES=$1
    while
        sleep 30
        HANDLES_READY=$(get_number_of_handles_ready)
        echo "There are $HANDLES_READY CM handles in READY state."
        [ $HANDLES_READY -ne $TOTAL_HANDLES ]
    do true; done
}

create_handles() {
    curl --fail --silent --show-error \
        --location 'http://localhost:8883/ncmpInventory/v1/ch' \
        --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' \
        --header 'Content-Type: application/json' \
        --data @$CREATE_REQUEST
}

remove_handles_and_record_time() {
    curl --fail --silent --show-error --output /dev/null --write-out '%{time_total}\n' \
        --location 'http://localhost:8883/ncmpInventory/v1/ch' \
        --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' \
        --header 'Content-Type: application/json' \
        --data @$REMOVE_REQUEST >> $REPORT_FILE
}

create_request_bodies() {
    local CREATE_SIZE=$1
    local REMOVE_SIZE=$2
    echo -n '{"dmiPlugin": "http://ncmp-dmi-plugin-stub:8080","createdCmHandles":[' > $CREATE_REQUEST
    echo -n '{"dmiPlugin": "http://ncmp-dmi-plugin-stub:8080","removedCmHandles":[' > $REMOVE_REQUEST
    for i in $(seq 1 $CREATE_SIZE); do
        local CMHANDLE=$(uuidgen | tr -d '-')
        echo -n "{\"cmHandle\": \"$CMHANDLE\",\"cmHandleProperties\":{\"neType\":\"RadioNode\"}}" \
            >> $CREATE_REQUEST
        if [ $i -lt $CREATE_SIZE ]; then
            echo -n "," >> $CREATE_REQUEST
        fi
        if [ $i -le $REMOVE_SIZE ]; then
            echo -n "\"$CMHANDLE\"" >> $REMOVE_REQUEST
        fi
        if [ $i -lt $REMOVE_SIZE ]; then
            echo -n "," >> $REMOVE_REQUEST
        fi
    done
    echo ']}' >> $CREATE_REQUEST
    echo ']}' >> $REMOVE_REQUEST
}

test_deregistration() {
    local REMOVE_SIZE=$1
    local CREATE_SIZE=$2

    echo "Testing deregistration of $REMOVE_SIZE out of $CREATE_SIZE CM handles"

    echo "Restarting docker"
    restart_docker
    echo "Waiting for CPS to start"
    wait_for_cps_to_start

    echo "Creating request bodies"
    create_request_bodies $CREATE_SIZE $REMOVE_SIZE

    echo "[$(date --iso-8601=seconds)] Creating CM handles"
    create_handles
    echo "Waiting for CM handles to be in READY state"
    wait_for_handles_to_be_ready $CREATE_SIZE

    if [ "$GRAB_METRICS" = "true" ]; then
        echo "Grabbing metrics before deregistration"
        METRICS_BEFORE=$(./generate-metrics-report.sh)
    fi

    echo "[$(date --iso-8601=seconds)] Removing CM handles"
    echo -e -n "$REMOVE_SIZE\t$CREATE_SIZE\t" >> $REPORT_FILE
    remove_handles_and_record_time
    echo "There are $(get_number_of_handles_ready) CM handles still in READY state."

    if [ "$GRAB_METRICS" = "true" ]; then
        echo "Grabbing metrics after deregistration"
        METRICS_AFTER=$(./generate-metrics-report.sh)
        echo "Generating metrics report"
        ./subtract-metrics-reports.py -a $METRICS_AFTER -b $METRICS_BEFORE \
            -o metrics-reports/deregister-$(date --iso-8601=seconds)-$REMOVE_SIZE-$CREATE_SIZE.tsv
        rm $METRICS_BEFORE $METRICS_AFTER
    fi

    echo
}

cleanup() {
    rm -f "$CREATE_REQUEST" "$REMOVE_REQUEST"
    stop_docker
    popd
}
trap cleanup EXIT

pushd -- "$(dirname -- "${BASH_SOURCE[0]}")"

mkdir -p $(dirname $REPORT_FILE)
echo -e "Removed\tTotal\tTime" > $REPORT_FILE

for number_to_delete in 100 500 1000 5000 10000 20000; do
    test_deregistration $number_to_delete $number_to_delete
done

