How to do scenario with Multiple exec functions and different data file for each exec

I created below scenario with two exec functions, each will have its own data file. I dont want to load both the files for each Vuser. I tried using env to load the file but the env is not available in init code. Please suggest

export let options = {

  scenarios: {
    PDP_UI : {
        executor: 'ramping-vus',
        startVUs: 0,
        stages: [
        { duration: '1s', target: 1 },
        { duration: '1s', target: 1 },
      ],
      gracefulRampDown: '0s',
      tags: { test_type: 'PDP_UI',name:"PDPUI" },
      exec: 'pdp_ui',
      env: { appname: 'PDP_UI' },
    },
    PDP_XAPI : {
        executor: 'ramping-vus',
        startVUs: 0,
        stages: [
        { duration: '15m', target: 9000 },
        { duration: '30m', target: 9000 },
      ],
      gracefulRampDown: '0s',
      tags: { test_type: 'PDP_XAPI',name:"PDPXAPI" },
      exec: 'pdp_xapi',
      env: { appname: 'PDP_XAPI' },
      },
}
}

var datafile

if (__ENV.appname == 'PDP_UI')
{
  datafile = papaparse.parse(open('product_ui.csv'), { header: false }).data;
}
else if (__ENV.appname == 'PDP_xapi')
{
    datafile = papaparse.parse(open('product_xapi.csv'), { header: false }).data;
}
export function pdp_ui() {
 let data = datafile[Math.floor(Math.random() * datafile.length)];
  http.get(site+data);
}

export function pdp_xapi() {
    let data = datafile[Math.floor(Math.random() * datafile.length)];
     http.get(site+data);
}

Thanks
Rama

Hi @Rama,

Unfortunately, this is currently, not possible.

The VUs can be reused between executors (not in your specific script, but still), so the ENV defined per scenarios are only available in the one place where it is specific for the scenario - the exec function.

Possible solutions:

  1. run two scripts
  2. load the files twice
  3. load the file through HTTP request in the first iteration.

Hopefully, something planned for this release cycle will actually fix this, but I have not started on it yet, so I can’t promise that it will make it into this release.