- 1. Install KAWA’s Python client
- 2. Generate test data (optional)
- 3. Load test based on existing views and users
- 3.a) Configuring your views
- 3.b) Running the benchmark
- 3.c) Visualising and analysing the results
The Python library embeds a load testing tool to measure the performances of the system under stress.
Requirements:
KAWA v19 or above (October 25th 2023)
Python client 0.13.0
or above (October 25th 2023)
1. Install KAWA’s Python client
In order to install KAWA’s Python client, you need python 3.8 at least. It is advised to run this installation into a dedicated venv.
Run the following command to install KAWA Client:
pip install kywy --upgrade --extra-index-url https://kawa:Br2zFU2Y5EGBWr4khYzh@gitlab.com/api/v4/projects/31007056/packages/pypi/simple
2. Generate test data (optional)
In order to generate test data, use the DataGenerator
. It will let you inject big volumes of dummy data quickly. You can then create views on the generated sheet in order to prepare for the actual load test.
from kywy.client.kawa_client import KawaClient
from kywy.client.data_generator import DataGenerator
kawa = KawaClient(kawa_api_url='http(s)://<YOUR URL>')
kawa.set_api_key(api_key_file='kawa.key')
kawa.set_active_workspace_id(workspace_id=3)
generator = DataGenerator(
kawa_client=kawa,
number_of_rows=20 * 1000 * 1000,
number_of_measures=1,
number_of_dimensions=1,
sheet_and_datasource_name='test'
)
# A new datasource and a new sheet will be generated
# the will bot be named: 'test'
generator.generate_data()
The following script will generate a sample dataset of 20M rows - feed it into the ‘test’ datasource and the ‘test’ sheet.
A link to the created sheet will be shown in the standard output.
3. Load test based on existing views and users
This methodology of tests allows to test KAWA under real life scenarios by computing existing views for existing users. It requires a KAWA administrator account to run.
3.a) Configuring your views
Before running the actual benchmark, create a couple of views on which you want to run the benchmark on the KAWA GUI.
3.b) Running the benchmark
Here is a sample script to run computations on two views: 952 and 956.
from kywy.client.kawa_clientimportKawaClient
from kywy.client.benchmarkimportKawaBenchmark
kawa = KawaClient(kawa_api_url='http(s)://<YOUR URL>')
kawa.set_api_key(api_key_file='kawa.key')
kawa.set_active_workspace_id(workspace_id=3)
b = KawaBenchmark(
kawa_client=kawa,
# This is the name that will appear in the logs and the output file
benchmark_name='Benchmark 1',
# Outputs the benchmark metrics in this csv file
metrics_output_file='/tmp/logs.csv',
# Compute those two views
view_ids=[952, 956],
# Put a list of user profiles. Those users will be picked randomly
# to perform the computations. This is intersting if you are testing
# various row level security settings.
user_ids=['setup-admin@kawa.io'],
# We will simulate a pool of 100 users making one compute
# every 10 seconds
num_users=100,
num_seconds_between_two_computations=10,
# The test will stop after 30 seconds
test_duration_in_seconds=30
)
b.run()
3.c) Visualising and analysing the results
In order to visualise the result, upload the output CSV file into KAWA as a new datasource. It is recommended to set the TIME as a primary key.
The benchmark tool will output the following metrics:
CPU usage in % Mem usage in % Number of disk reads and writes Number of bytes read and written to disk Number of executed tests during the interval Min/Max/Average execution time of tests during this interval