Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSVDataSet With nested data types #121

Open
SmeshMike opened this issue Mar 14, 2024 · 1 comment
Open

CSVDataSet With nested data types #121

SmeshMike opened this issue Mar 14, 2024 · 1 comment

Comments

@SmeshMike
Copy link

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
Copy link

yioyoiyioys222 commented May 27, 2024

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

Correct Usage:
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants