Multiple concurrent browser sessions - streaming service

Hello,

Is there a way to test multiple concurrent browser sessions for a streaming service?
Here is an example of my current implementation:

import { browser } from 'k6/experimental/browser';
import { check } from 'k6';

export const options = {
    scenarios: {
      open_model: {
        executor: 'shared-iterations',
        options: {
          browser: {
            type: 'chromium',
          },
        },
      },
    },
  };

export default async function () {
  const context = browser.newContext();
  const page = context.newPage();

  try {
    const res = await page.goto('https://website.com');

    // checks the response code
    check(res, {
        'response code was 200': (res) => res.status() === 200,
    });

    // clicks on the tune in button
    const playAudio =  page.locator('button[aria-label="tuneInButton"]')
    
    // checks tune in button exists
    check(page, {
        'Tune in button present': () => page.locator('button[aria-label="tuneInButton"]').isVisible(),
    });
    
    playAudio.dispatchEvent('click');

    // checks that the button has been clicked
        check(page, {
            'Tune in button clicked': () => page.locator('button[aria-label="tuneInButton"]').isHidden(),
        });
  
  } finally {
    page.close();
  }
}

if i run it with 1 vus and 1 iteration it works but with multiple vus the test fails mainly because the playAudio button is no longer present and/or page was closed .
I’ve read on a recent post that concurrent browser contexts are not allowed.
So i wonder if there’s any workaround to have multiple browser context with 1 vu for a time period where it would allow me to emulate multiple users at the same time listening to the streaming.

Thanks

Hi @sdgsm,

Welcome to the community forum.

So you are trying to test a website that streams some audio, and you are trying to mimic multiple users streaming that same audio file? What is the aim of the test? To find the max concurrent audio streams?

My first question would be, do you need to have multiple browser sessions to do this test? Could you work with scenario where one VU was used to ensure that the frontend was working, and another scenario where you can solely look at streaming a large number (VU count) of audio files?

Coming back to your current requirement, which is to be able to navigate and stream the audio file from multipule chrome instances:

I’ve read on a recent post that concurrent browser contexts are not allowed

Yes, that is the case. In a single VU and single iteration you can only run a single browserContext.

but with multiple vus the test fails mainly because the playAudio button is no longer present and/or page was closed

That is odd, since each VU spins up its own chrome instance which doesn’t share any data with any other instance of chrome, I don’t see why the test is behaving in this way. Could your backend system be limiting the number of concurrent streams to a single IP?

I’d need to be able to test against a publicly accessible website to be able to replicate this issue, do you think you can provide me with one?

Cheers,
Ankur