Skip to content
Snippets Groups Projects
Commit 15b7f104 authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

use median to check slo

parent e9e2bbd2
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!137Allow multiple repititions of an experiment,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
...@@ -5,6 +5,7 @@ import os ...@@ -5,6 +5,7 @@ import os
import pandas as pd import pandas as pd
import json import json
import sys import sys
from statistics import median
app = FastAPI() app = FastAPI()
...@@ -20,7 +21,7 @@ elif os.getenv('LOG_LEVEL') == 'WARNING': ...@@ -20,7 +21,7 @@ elif os.getenv('LOG_LEVEL') == 'WARNING':
elif os.getenv('LOG_LEVEL') == 'DEBUG': elif os.getenv('LOG_LEVEL') == 'DEBUG':
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)
def execute(results, threshold, warmup): def calculate_slope_trend(results, warmup):
d = [] d = []
for result in results: for result in results:
group = result['metric']['group'] group = result['metric']['group']
...@@ -39,14 +40,16 @@ def execute(results, threshold, warmup): ...@@ -39,14 +40,16 @@ def execute(results, threshold, warmup):
logger.error('Mark this subexperiment as not successful and continue benchmark.') logger.error('Mark this subexperiment as not successful and continue benchmark.')
return False return False
result = trend_slope < threshold logger.info("Computed lag trend slope is '%s'", trend_slope)
logger.info("Computed lag trend slope is '%s'. Result is: %s", trend_slope, result) return trend_slope
return result
def check_service_level_objective(results, threshold):
return median(results) < threshold
@app.post("/evaluate-slope",response_model=bool) @app.post("/evaluate-slope",response_model=bool)
async def evaluate_slope(request: Request): async def evaluate_slope(request: Request):
data = json.loads(await request.body()) data = json.loads(await request.body())
results = [execute(total_lag, data['threshold'], data['warmup']) for total_lag in data['total_lags']] results = [calculate_slope_trend(total_lag, data['warmup']) for total_lag in data['total_lags']]
return all(results) return check_service_level_objective(results=results, threshold=data["threshold"])
logger.info("SLO evaluator is online") logger.info("SLO evaluator is online")
\ No newline at end of file
import unittest
from main import app, check_service_level_objective
import json
from fastapi.testclient import TestClient
class TestSloEvaluation(unittest.TestCase):
client = TestClient(app)
def test_1_rep(self):
with open('../resources/test-1-rep-success.json') as json_file:
data = json.load(json_file)
response = self.client.post("/evaluate-slope", json=data)
self.assertEquals(response.json(), True)
def test_3_rep(self):
with open('../resources/test-3-rep-success.json') as json_file:
data = json.load(json_file)
response = self.client.post("/evaluate-slope", json=data)
self.assertEquals(response.json(), True)
def test_check_service_level_objective(self):
list = [1,2,3,4]
self.assertEquals(check_service_level_objective(list, 2), False)
self.assertEquals(check_service_level_objective(list, 3), True)
list = [1,2,3,4,5]
self.assertEquals(check_service_level_objective(list, 2), False)
self.assertEquals(check_service_level_objective(list, 4), True)
if __name__ == '__main__':
unittest.main()
\ No newline at end of file
{
"total_lags": [
[
{
"metric": {
"group": "theodolite-uc1-application-0.0.1"
},
"values": [
[
1.621008960827E9,
"234"
],
[
1.621008965827E9,
"234"
],
[
1.621008970827E9,
"234"
],
[
1.621008975827E9,
"719"
],
[
1.621008980827E9,
"719"
],
[
1.621008985827E9,
"719"
],
[
1.621008990827E9,
"1026"
],
[
1.621008995827E9,
"1026"
],
[
1.621009000827E9,
"1026"
],
[
1.621009005827E9,
"534"
],
[
1.621009010827E9,
"534"
],
[
1.621009015827E9,
"534"
],
[
1.621009020827E9,
"943"
],
[
1.621009025827E9,
"943"
],
[
1.621009030827E9,
"943"
],
[
1.621009035827E9,
"66"
],
[
1.621009040827E9,
"66"
],
[
1.621009045827E9,
"66"
],
[
1.621009050827E9,
"841"
],
[
1.621009055827E9,
"841"
],
[
1.621009060827E9,
"841"
],
[
1.621009065827E9,
"405"
],
[
1.621009070827E9,
"405"
],
[
1.621009075827E9,
"405"
],
[
1.621009080827E9,
"201"
],
[
1.621009085827E9,
"201"
],
[
1.621009090827E9,
"201"
],
[
1.621009095827E9,
"227"
],
[
1.621009100827E9,
"227"
],
[
1.621009105827E9,
"227"
],
[
1.621009110827E9,
"943"
]
]
}
]
],
"threshold": 2000,
"warmup": 0
}
\ No newline at end of file
{
"total_lags": [
[
{
"metric": {
"group": "theodolite-uc1-application-0.0.1"
},
"values": [
[
1.621012384232E9,
"6073"
],
[
1.621012389232E9,
"6073"
],
[
1.621012394232E9,
"6073"
],
[
1.621012399232E9,
"227"
],
[
1.621012404232E9,
"227"
],
[
1.621012409232E9,
"227"
],
[
1.621012414232E9,
"987"
],
[
1.621012419232E9,
"987"
],
[
1.621012424232E9,
"987"
],
[
1.621012429232E9,
"100"
],
[
1.621012434232E9,
"100"
],
[
1.621012439232E9,
"100"
],
[
1.621012444232E9,
"959"
],
[
1.621012449232E9,
"959"
],
[
1.621012454232E9,
"959"
],
[
1.621012459232E9,
"625"
],
[
1.621012464232E9,
"625"
],
[
1.621012469232E9,
"625"
],
[
1.621012474232E9,
"683"
],
[
1.621012479232E9,
"683"
],
[
1.621012484232E9,
"683"
],
[
1.621012489232E9,
"156"
]
]
}
],
[
{
"metric": {
"group": "theodolite-uc1-application-0.0.1"
},
"values": [
[
1.621012545211E9,
"446"
],
[
1.621012550211E9,
"446"
],
[
1.621012555211E9,
"446"
],
[
1.621012560211E9,
"801"
],
[
1.621012565211E9,
"801"
],
[
1.621012570211E9,
"801"
],
[
1.621012575211E9,
"773"
],
[
1.621012580211E9,
"773"
],
[
1.621012585211E9,
"773"
],
[
1.621012590211E9,
"509"
],
[
1.621012595211E9,
"509"
],
[
1.621012600211E9,
"509"
],
[
1.621012605211E9,
"736"
],
[
1.621012610211E9,
"736"
],
[
1.621012615211E9,
"736"
],
[
1.621012620211E9,
"903"
],
[
1.621012625211E9,
"903"
],
[
1.621012630211E9,
"903"
],
[
1.621012635211E9,
"512"
],
[
1.621012640211E9,
"512"
],
[
1.621012645211E9,
"512"
]
]
}
],
[
{
"metric": {
"group": "theodolite-uc1-application-0.0.1"
},
"values": [
[
1.621012700748E9,
"6484"
],
[
1.621012705748E9,
"6484"
],
[
1.621012710748E9,
"6484"
],
[
1.621012715748E9,
"505"
],
[
1.621012720748E9,
"505"
],
[
1.621012725748E9,
"505"
],
[
1.621012730748E9,
"103"
],
[
1.621012735748E9,
"103"
],
[
1.621012740748E9,
"103"
],
[
1.621012745748E9,
"201"
],
[
1.621012750748E9,
"201"
],
[
1.621012755748E9,
"201"
],
[
1.621012760748E9,
"965"
],
[
1.621012765748E9,
"965"
],
[
1.621012770748E9,
"965"
],
[
1.621012775748E9,
"876"
],
[
1.621012780748E9,
"876"
],
[
1.621012785748E9,
"876"
],
[
1.621012790748E9,
"380"
],
[
1.621012795748E9,
"380"
],
[
1.621012800748E9,
"380"
]
]
}
]
],
"threshold": 2000,
"warmup": 0
}
\ No newline at end of file
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