You were good until here. English is the preferred language here: )
J'ai deux fichiers : un fichier A (contient ID1) et un fichier B (contient
ID2)
J'ai une URL de ce type :
http://…/…/{ID1}/{ID2}/home.html
Sachant que pour chaque ID1, il y a n ID2, j'aimerais boucler sur le
fichier A, puis pour boucler sur le fichier ID2.
In english, the question is: "I have 2 files that I'd like to use as
feeders: one with some records with an id, and a second one whose records
contain a foreign key to the first file records. How do I join?".
I see 2 solutions.
First: you join upstream yourself, so you get one single file, where the
1*n records are merged into a single field.
Then, you can you use first file as a feeder, turn your second file into a
Map, and join into an exec.
You can reuse the utility methods here:
val file1 = csv("file1")
// file 2 is a Map[String, Record[String]]
val file2 =
SeparatedValuesParser.parse(GatlingFiles.feederResource("file2"),
',').groupBy(record => record("foreignKeyColumnName"))
feed(file1)
.exec(session =>
for {
id1 <- session("ID1").validate[String]
val recordsWithId1InFile2 = file2(id1)
val id2s = recordsWithId1InFile2.map(record => record("ID2"))
} yield session.set("concatenatedId2s", id2s.mkString("/"))
)
.exec(http("Catégorie Poney").get("/${ID1}/${concatenatedId2s}"))
Thanks for your work, and please forgive my English. Hope it’s OK to post this as a response.
About feeding multiple records at once, how do you iterate through them? I try, for each of my users, to post the same files to web services, with a csv file containing the name of all files to post, with their respective service:
Thanks for the quick reply.
But I don’t get it. The fact is that I have 636000 XML file names in my CSV feeder, in a particular order, and I need my user to POST each of them in that order.
but the feeder is then a common resource shared between users. With the new feeder(csvFeeder, csvFeederLength), I would like to POST each csv entry, in order, by user. Is the solution to write 636000 POST with csvcolumn1, csvcolumn2 ?
That was exactly the point of the following line in my previous answer to Franck
// copy the record “fields” as session attributes
exec(session => session(“record”).validate[Map[String, String]].map(record => session.setAll(record.toSeq)))