K6 Tool is being used for our testing needs. For the sample snippet below when run with K6, we see that the change occurred in default function for data passed from setup is not affected and visible in tear down stage. Is there any other possible way to have this available so that we could utilize it for Test Data Management purposes during Load Tests?
import http from "k6/http";
import { group, check, sleep, fail } from "k6";
import papaparse from 'https://jslib.k6.io/papaparse/5.1.1/index.js';
import { textSummary } from "https://jslib.k6.io/k6-summary/0.0.1/index.js";
const SLEEP_DURATION = 1;
// Global variables should be initialized.
var csvData = [{"Id":"P976O6RP8NSFN076RKLBSGK1Q8NZT7WA"},{"Id":"D4YJZFQJUPJTZWPLP2VB5M839SZBNNSO"}];
function removeId(arr, value) {
arr = arr.filter(function(item) {
return item.Id !== value
});
return arr;
}
export function setup() {
return JSON.parse(JSON.stringify(csvData));
}
export default function(data) {
let Id = csvData[0].Id;
data = removeId(data, Id);
console.log('ID deleted is: '+Id+' \nJson<data> in default :: '+JSON.stringify(data));
}
export function handleSummary(data) {
return {
//stdout: JSON.stringify(data),
};
}
export function teardown(data) {
//Teardown does not have modified data object updated in default function
console.log('\nJson<data> in teardown :: '+JSON.stringify(data));
}