Day array to vu for scenario

How can I convert my array into a list that take one vu for each day in the days array

export default function () {
    let days = [];
    const first = dayjs();
    const last = first.clone().add(3, 'month');

    for(let d=first.clone(); d<last; d=d.add(1, 'day') ) {
        days.push(d);
    }
    for(let d of days) {
        <run my test scenario>
    }

How can I take one line from the days array so I can run it as a vu?

The solution I’m testing is independent on day.

Test is all fine, it is the report that only show one vu.

I have it fixed using a single redis key since ‘INCR’ is atomic,
But the first scenario firstruns twice, even if it is vu:1, iteration:1
and is it possible to just let them run after each other without adding the delayed startTime: '1s'

import dayjs from '../tools/dayjs.min.js';
import utc from '../tools/dayjs-plugin-utc.min.js';
// inject utc plugin to dayjs
dayjs.extend(utc);
import redis from 'k6/x/redis';
const redisClient = new redis.Client(
    // URL in the form of redis[s]://[[username][:password]@][host][:port][/db-number
    __ENV.REDIS_URL || "redis://127.0.0.1:6379",
);
const redisKey = 'hvdc-k6-date-vu-pos';

let days = [];
const first = dayjs();
const last = first.clone().add(1, 'month');
for(let d=first.clone(); d<last; d=d.add(1, 'day') ) {
    days.push(d.format('YYYY-MM-DD'));
}

export const options = {
    scenarios: {
        first: {
            executor: 'shared-iterations',
            vus: 1,
            iterations: 1,
            exec: 'setup',
        },
        test: {
            executor: 'shared-iterations',
            vus: 10,
            iterations: 30,
            exec: 'default',
            startTime: '1s'
        },
    },
};

export async function setup() {
    await redisClient.set(redisKey, 0);
    console.log(`initialize key '${redisKey}'`);
};

export default async function() {
    let myday = undefined;
    const exists = await redisClient.exists(redisKey);
    if (exists === false) {
        throw new Error(`${redisKey} should exist`);
    }
    let r = parseInt(await redisClient.incr(redisKey));
    if(typeof(r)!== 'undefined' && r+1<=days.length) {
        myday = days[r-1];
        console.log(`doing ${myday}`);
    }
};

Why first scenario twice?

$ k6 -q run test/test-scenario.js
INFO[0000] initialize key ‘hvdc-k6-date-vu-pos’ source=console
INFO[0000] initialize key ‘hvdc-k6-date-vu-pos’ source=console
INFO[0001] doing 2025-11-28 source=console
INFO[0001] doing 2025-11-27 source=console
INFO[0001] doing 2025-11-29 source=console
INFO[0001] doing 2025-11-30 source=console
INFO[0001] doing 2025-12-01 source=console
INFO[0001] doing 2025-12-04 source=console
INFO[0001] doing 2025-12-02 source=console
INFO[0001] doing 2025-12-05 source=console
INFO[0001] doing 2025-12-03 source=console
INFO[0001] doing 2025-12-06 source=console
INFO[0001] doing 2025-12-10 source=console
INFO[0001] doing 2025-12-09 source=console
INFO[0001] doing 2025-12-12 source=console
INFO[0001] doing 2025-12-07 source=console
INFO[0001] doing 2025-12-15 source=console
INFO[0001] doing 2025-12-08 source=console
INFO[0001] doing 2025-12-14 source=console
INFO[0001] doing 2025-12-13 source=console
INFO[0001] doing 2025-12-11 source=console
INFO[0001] doing 2025-12-17 source=console
INFO[0001] doing 2025-12-18 source=console
INFO[0001] doing 2025-12-19 source=console
INFO[0001] doing 2025-12-16 source=console
INFO[0001] doing 2025-12-25 source=console
INFO[0001] doing 2025-12-21 source=console
INFO[0001] doing 2025-12-23 source=console
INFO[0001] doing 2025-12-22 source=console
INFO[0001] doing 2025-12-20 source=console
INFO[0001] doing 2025-12-24 source=console
INFO[0001] doing undefined source=console

I found the issue with the first scenario running twice, because it is called setup()
if there is a setup() it is always ran before the scenarios starts. So I just rename it.

So now it is perfect I can set VUS=60 and it will pick unique days. and each only once.