eldaduzman / pymeter

Simple JMeter performance tests API for python
https://pymeter.readthedocs.io/en/latest/
Apache License 2.0
135 stars 12 forks source link

CSVDataSet With nested data types #121

Open SmeshMike opened 7 months ago

SmeshMike commented 7 months ago

Hi everyone!

I'm quite a newbie with Jmeter and pymeter. So, I'm trying to pass nested data via CSVDataSet.

What is a problem? I have an application with an endpoint expecting list of string in body:

from typing import List

from pydantic import BaseModel
from fastapi import Request, FastAPI

app = FastAPI()

class Human(BaseModel):
    age: List[int]

# human: Human,
@app.post("/human/update")
async def update_human(human: Human, request: Request):
    a = await request.json()

And I have a pymeter TestPlan for such app:

local_data_schema = {
    "age": "${age}",
}

local_dcsv_data_set = CsvDataset("kek.csv")

http_sampler = (
    HttpSampler("echo_get_request", "http://0.0.0.0:8081/human/update")
    .post(local_data_schema, ContentType.APPLICATION_JSON)
)

thread_group = ThreadGroupSimple(
    1, 1, http_sampler, local_dcsv_data_set
)
test_plan = TestPlan(thread_group)
stats = test_plan.run()

with kek.csv like

,age
0, [1,2,3]

And all data that comes to andpoint is strings. As I see CSVDataSet uses , as delimeter, so even strings that comes to endoint are separated and value that comes first is '[1', so i can get the whole list. I've found the way to pass such nested data like python dict, but there is no option to send list of dicts, so I can't make my load test various.

I will be happy if you help me with that problem

yioyoiyioys222 commented 5 months ago

hi @SmeshMike ,CSVDataSet does not work when the HttpSampler parameter name is not parameterized image image

Correct Usage: image image