Commit 4a024b09 authored by Petr.Kalashnikov's avatar Petr.Kalashnikov
Browse files

Merge branch 'botting27' into 'master'

Bottint27: Add stresstesting module

See merge request !58
parents 7f77ef6f 218dfe49
Pipeline #53839 passed with stage
in 2 minutes and 9 seconds
......@@ -168,3 +168,15 @@ Set credentials in `config.yaml` and run
```sh
python -m pytest -m integration
```
### Stresstesting
Set credentials in `config.yaml` and run
```sh
locust -f locust_testing/stresstest.py
```
then open http://127.0.0.1:8089/ and choose the desired parameters of the test, as
well as the base url for the server that is to be tested.
See [locust documentation](https://docs.locust.io/en/stable/)
......@@ -60,3 +60,7 @@ transaction_service:
#wsdl: https://agr-bott-utv02.sfso.no/AgrBOTT_Utv02_WS/service.svc?BatchInputService/BatchInput
# wsdl is file based for now, dfo is not able to deliver via api mannager
wsdl: wsdl/batchinputservice.wsdl
locust_waiting_time:
min_time: 5.1
max_time: 7.5
from locust import HttpUser, TaskSet, task, between
import bios
import logging
logger = logging.getLogger(__name__)
ubw_config = bios.read("config.yaml")
endpoints_list = ubw_config["rest"]["endpoints"]
headers = ubw_config["rest"]["headers"]
min_waiting_time = ubw_config["locust_waiting_time"]["min_time"]
max_waiting_time = ubw_config["locust_waiting_time"]["max_time"]
def get_endpoint(endpoint):
return "/" + endpoints_list[endpoint]["url"] + "/"
class WebsiteTasks(TaskSet):
@task(10) # weights can be adjusted in prod
def check_get_arbeidsordre(self):
self.client.get(get_endpoint("arbeidsordre") + "UB/102454100", headers=headers)
@task(10)
def check_get_anlegg(self):
self.client.get(get_endpoint("anlegg") + "UB", headers=headers)
@task(10)
def check_get_koststed(self):
self.client.get(get_endpoint("koststeder") + "UB", headers=headers)
@task(2)
def check_get_begreper(self):
self.client.get(get_endpoint("begreper") + "UB", headers=headers)
@task(10)
def check_get_begrepsverdier(self):
self.client.get(get_endpoint("begrepsverdier") + "UB/AH", headers=headers)
@task(10)
def check_get_prosjekt(self):
self.client.get(get_endpoint("project") + "UB/100000", headers=headers)
@task(1)
def check_get_firma(self):
self.client.get(get_endpoint("firma") + "UB", headers=headers)
@task(5)
def check_get_brukere(self):
self.client.get(get_endpoint("bruker") + "UB", headers=headers)
@task(10)
def check_get_bruker(self):
self.client.get(get_endpoint("bruker") + "UB/3780B6057255", headers=headers)
@task(10)
def check_get_periode(self):
self.client.get(get_endpoint("periode") + "UB/202001", headers=headers)
@task(2)
def check_get_perioder(self):
self.client.get(
get_endpoint("periode") + "UB?periodType/periodType+eq+GL", headers=headers
)
@task(2)
def check_get_arbeidsordrer(self):
self.client.get(get_endpoint("arbeidsordre") + "UB", headers=headers)
@task(10)
def check_get_specific_anlegg(self):
self.client.get(get_endpoint("anlegg") + "UB/102454100", headers=headers)
@task(10)
def check_get_gl07logs(self):
self.client.get(get_endpoint("gl07logs") + "UB", headers=headers)
@task(5)
def check_get_kontoplan(self):
self.client.get(get_endpoint("kontoplan") + "UB", headers=headers)
@task(10)
def check_get_konto(self):
self.client.get(get_endpoint("kontoplan") + "UB/9466", headers=headers)
@task(5)
def check_get_konteringsregler(self):
self.client.get(get_endpoint("konteringsregler") + "UB", headers=headers)
@task(10)
def check_get_konteringsregel(self):
self.client.get(get_endpoint("konteringsregel") + "UB/30", headers=headers)
@task(10)
def check_get_avgiftskode(self):
self.client.get(get_endpoint("avgiftskoder") + "UB", headers=headers)
@task(5)
def check_get_bilagstyper(self):
self.client.get(get_endpoint("bilagstyper") + "UB", headers=headers)
@task(10)
def check_get_bilagstype(self):
self.client.get(get_endpoint("bilagstyper") + "UB/TT", headers=headers)
@task(5)
def check_get_ressursere(self):
self.client.get(get_endpoint("ressurser") + "UB", headers=headers)
@task(10)
def check_get_ressurs(self):
self.client.get(get_endpoint("ressurser") + "UB/6060620", headers=headers)
class WebsiteUser(HttpUser):
tasks = [WebsiteTasks]
wait_time = between(min_waiting_time, max_waiting_time)
......@@ -5,3 +5,5 @@ pyyaml
coverage
pylint
black
locust
bios
......@@ -18,7 +18,7 @@ commands =
deps =
black
commands =
black --check --diff ubw_client tests setup.py
black --check --diff ubw_client tests setup.py locust_testing
# Linters
[testenv:flake8]
......@@ -32,7 +32,7 @@ deps =
# flake8-import-order
# flake8-docstrings
commands =
flake8 --per-file-ignores="__init__.py:F401" ubw_client
flake8 --per-file-ignores="__init__.py:F401" ubw_client locust_testing
[testenv:bandit]
basepython = python3
......
......@@ -93,11 +93,17 @@ class UbwRestBase(BaseModel):
endpoints: UbwRestEndpoints = UbwRestEndpoints()
class LocustWaitingTime(BaseModel):
min_time: float
max_time: float
class UbwClientConfig(BaseModel):
# Base config for rest endpoints
rest: typing.Optional[UbwRestBase]
import_service: typing.Optional[UbwSoapService]
transaction_service: typing.Optional[UbwSoapService]
locust_waiting_time: typing.Optional[LocustWaitingTime]
class Begrep(BaseModel):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment