Basically my use case is:
run setup → run test → run teardown → Use handlesummary to write a CSV file → Upload that CSV file to a remote server.
The last step is the one I am struggling with. My handleSummary is just:
export async function handleSummary(data: any) {
return {
'summary.csv': await CsvSummary(data),
'stdout': textSummary(data, { indent: '→', enableColors: true })
};
}
I am not sure how I can do something with the summary.csv file after its written. Is this possible currently? Or a workaround if its not directly supported?
Hi @jackvanier
Welcome to the community forum 
Do you want to generate the CSV and, from the k6 script, send it to a remote server once generated? How do you need to send it, is it an AWS S3 bucket, or how can files be sent to that remote server (and how, SCP/FTP, …)? Can you further describe the case?
If this is the requirement, I would expect sharing the file system of the remote server with the k6 executor system is the path of least resistance, but you can’t do that.
I can ask if there is a way to achieve this, though I’d like to ensure I understand the request.
Thanks in advance for the additional information.
Cheers!
Do you want to generate the CSV and, from the k6 script, send it to a remote server once generated.
Correct. Generate the CSV using handleSummary() and then send the CSV to the remote server. It is just an API call to send to the remote server. The code to send the CSV to the remote server is easy to write no issues there. I just need to know where to put that code because AFAICT handleSummary is the absolute last thing that gets called in a K6 run so as soon as we return from handleSummary the test is over and no more code gets executed.
1 Like
@jackvanier Why don’t you send the CSV from the handleSummary(), if you have the CSV data and the code to send the CSV?
Is there a strong constraint for the CSV upload to happen specifically after the handleSummary
function @jackvanier ?
Otherwise, you could probably do something along those lines:
export async function handleSummary(data: any) {
// Produce the CSV summary
const csvSummary = await CsvSummary(data)
// Upload the summary (here I assume HTTP)
await http.asyncRequest('POST', 'myurl', csvSummary, {})
// Return normally from the function
return {
'summary.csv': csvSummary,
'stdout': textSummary(data, { indent: '→', enableColors: true })
};
}