<commit_before>#!/bin/bash
printf "\n\n======== Create and Increment KPI counter ========\n\n\n"

# It Creates the counter
resp=$(curl -qSfsw '\n%{http_code}' -H 'Content-Type: application/json' -X PUT -d '{ "metric_type": "counter", "job": "sonata", "instance": "gtkkpi", "name": "example_counter", "docstring": "metric counter test", "base_labels": {"label1": "value1", "label2": "value2"}}' http://sp.int3.sonata-nfv.eu:32001/api/v2/kpis)    
code=$(echo "$resp" | tail -n1)
if [[ $code != 201 ]] ;
	then
    	echo "Error: Response error $code"
    	exit -1
fi
resp=$(curl -H 'Content-Type: application/json' -X GET http://sp.int3.sonata-nfv.eu:32001/api/v2/kpis?name=example_counter&base_labels[label1]=value1&base_labels[label2]=value2)
echo $resp
first_value=$(echo $resp | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["value"]')
echo "Counter example_counter created/updated with value $first_value"

# It increments the counter (+3)
index=1
while [  $index -lt 3 ]; do
	resp=$(curl -qSfsw '\n%{http_code}' -H 'Content-Type: application/json' -X PUT -d '{ "metric_type": "counter", "job": "sonata", "instance": "gtkkpi", "name": "example_counter", "docstring": "metric counter test", "base_labels": {"label1": "value1", "label2": "value2"}}' http://sp.int3.sonata-nfv.eu:32001/api/v2/kpis)    
    code=$(echo "$resp" | tail -n1)
    if [[ $code != 201 ]] ;
  		then
    		echo "Error: Response error $code"
    		exit -1
	fi
done

# Get the couter value
resp=$(curl -H 'Content-Type: application/json' -X GET http://sp.int3.sonata-nfv.eu:32001/api/v2/kpis?name=example_counter&base_labels[label1]=value1&base_labels[label2]=value2)
counter_value=$(echo $resp | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["value"]')
echo "Counter example_counter incremented. New value: $counter_value"

if [[$counter_value -ne $first_value+3]] ;
	then
		echo "Error: Counter did not be incremented"
		exit -1
fi<commit_msg>son-gtkkpi - prometheus integration tests<commit_after>#!/bin/bash
printf "\n\n======== Create and Increment KPI counter ========\n\n\n"

# It Creates the counter
resp=$(curl -qSfsw '\n%{http_code}' -H 'Content-Type: application/json' -X PUT -d '{ "metric_type": "counter", "job": "sonata", "instance": "gtkkpi", "name": "example_counter", "docstring": "metric counter test", "base_labels": {"label1": "value1", "label2": "value2"}}' http://sp.int3.sonata-nfv.eu:32001/api/v2/kpis)    
echo $resp
code=$(echo "$resp" | tail -n1)
echo $code
if [[ $code != 201 ]] ;
	then
    	echo "Error: Response error $code"
    	exit -1
fi
resp=$(curl -H 'Content-Type: application/json' -X GET http://sp.int3.sonata-nfv.eu:32001/api/v2/kpis?name=example_counter&base_labels[label1]=value1&base_labels[label2]=value2)
echo $resp
first_value=$(echo $resp | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["value"]')
echo "Counter example_counter created/updated with value $first_value"

# It increments the counter (+3)
index=1
while [  $index -lt 3 ]; do
	resp=$(curl -qSfsw '\n%{http_code}' -H 'Content-Type: application/json' -X PUT -d '{ "metric_type": "counter", "job": "sonata", "instance": "gtkkpi", "name": "example_counter", "docstring": "metric counter test", "base_labels": {"label1": "value1", "label2": "value2"}}' http://sp.int3.sonata-nfv.eu:32001/api/v2/kpis)    
    code=$(echo "$resp" | tail -n1)
    if [[ $code != 201 ]] ;
  		then
    		echo "Error: Response error $code"
    		exit -1
	fi
done

# Get the couter value
resp=$(curl -H 'Content-Type: application/json' -X GET http://sp.int3.sonata-nfv.eu:32001/api/v2/kpis?name=example_counter&base_labels[label1]=value1&base_labels[label2]=value2)
counter_value=$(echo $resp | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["value"]')
echo "Counter example_counter incremented. New value: $counter_value"

if [[$counter_value -ne $first_value+3]] ;
	then
		echo "Error: Counter did not be incremented"
		exit -1
fi
{'fraction_non_alphanumeric': 0.1908860759493671, 'fraction_numerical': 0.029873417721518986, 'mean_word_length': 4.923538230884557, 'pattern_counts': {'":': 32, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6251393', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1449, 'n_words': 354}