Problem with localFile options in k6 resource yamls

It is supposed to create 4 runner pods, but it is creating an initializer pod and not moving forward.


apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
name: k6-sample
spec:
parallelism: 4
script:
localFile: /app/script.js
runner:
image: Google Cloud console

Could you check and suggest?

It is working with

parallelism: 1

But we must run with parallelism: 4, We can not use configMaps in our case as we are trying to run a file from the framework.

@bandorko Could you advise on it?

I have followed these references k6-operator/config/samples/k6_v1alpha1_k6_with_localfile.yaml at main · grafana/k6-operator · GitHub

Hi @mouliveera , welcome to the community forum!

You should see the logs of the initializer pod. There should be an error message. Usually this happens if you want to split 1 VU into multiple pods which is not possible.

@bandorko Below are the logs; I see the max Vus = 1. How can we resolve these issues to get parallelism work?

kubectl logs run-k6-test-cases-initializer-45pmj -f
{
“paused”: null,
“vus”: null,
“duration”: null,
“iterations”: null,
“stages”: null,
“scenarios”: {
“browser”: {
“executor”: “shared-iterations”,
“startTime”: null,
“gracefulStop”: null,
“env”: null,
“exec”: null,
“tags”: null,
“options”: {
“browser”: {
“type”: “chromium”
}
},
“vus”: null,
“iterations”: null,
“maxDuration”: null
}
},
“executionSegment”: null,
“executionSegmentSequence”: null,
“noSetup”: null,
“setupTimeout”: null,
“noTeardown”: null,
“teardownTimeout”: null,
“rps”: null,
“dns”: {
“ttl”: null,
“select”: null,
“policy”: null
},
“maxRedirects”: null,
“userAgent”: null,
“batch”: null,
“batchPerHost”: null,
“httpDebug”: null,
“insecureSkipTLSVerify”: null,
“tlsCipherSuites”: null,
“tlsVersion”: null,
“tlsAuth”: null,
“throw”: null,
“thresholds”: {},
“blacklistIPs”: null,
“blockHostnames”: null,
“hosts”: null,
“noConnectionReuse”: null,
“noVUConnectionReuse”: null,
“minIterationDuration”: null,
“ext”: null,
“summaryTrendStats”: [
“avg”,
“min”,
“med”,
“max”,
“p(90)”,
“p(95)”
],
“summaryTimeUnit”: null,
“systemTags”: [
“check”,
“error”,
“error_code”,
“expected_response”,
“group”,
“method”,
“name”,
“proto”,
“scenario”,
“service”,
“status”,
“subproto”,
“tls_version”,
“url”
],
“tags”: null,
“metricSamplesBufferSize”: null,
“noCookiesReset”: null,
“discardResponseBodies”: null,
“totalDuration”: “10m30s”,
“maxVUs”: 1
}%

As mentioned in our previous post; our script file could not fit with configmaps, we have multiple dependencies on the script.js file. So we had to mount a folder and run the script on the container.

Reference script js:

import { browser } from ‘k6/experimental/browser’;
import exec from ‘k6/execution’;
import { expect } from ‘https://jslib.k6.io/k6chaijs/4.3.4.3/index.js’;
import * as k6BrowserUtils from ‘…/…/…/yyyyy/k6.browser.utils.js’;
import * as utils from ‘…/…/…/yyyyy/bigquery.utils.js’
import { LoginPage } from ‘…/xxxxx/login.page.js’;
import { DashboardPage } from ‘…/xxxxx/dashboard.page.js’;
import { ReportsPage } from ‘…/xxxxx/reports.page.js’;

Reference k6 resource yaml:

apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
name: k6-sample
spec:
parallelism: 4
cleanup: post
separate: true
script:
localFile: /app/script.js
arguments: -e ENV_X=$ENV_X -e TENANT_ID=$TENANT_ID -e USER_ID=$USER_ID
runner:
image: Google Cloud console
securityContext:
runAsUser: 1001
runAsGroup: 1001
runAsNonRoot: true
resources:
limits:
cpu: 200m
memory: 1000Mi
requests:
cpu: 100m
memory: 500Mi

@mouliveera : can you show me the options?

@bandorko We have not explicitly used any options here to create k6-resource.yaml.

Followed k6_v1alpha1_k6_with_localfile.yaml

This is yaml we used to deploy: Link

If you could share a sample yaml which works for localFile and parallelism, that would be helpful.

Options set:

export const options = {
scenarios: {
browser: {
executor: ‘shared-iterations’,
options: {
browser: {
type: ‘chromium’,
},
},
},
},
// thresholds: {
// checks: [“rate==1.0”]
// }
thresholds: {
// ‘browser_web_vital_lcp’: [‘p(90) < 1000’],
},
}

@bandorko could you please update on this issue if there’s any fix?

@mouliveera

The default vu count for shared-iterations executor is 1. You should set it to at least 4 for parallelism: 4

So please try with this options:

export const options = {
  scenarios: {
    browser: {
      executor: ‘shared-iterations’,
      vus: 4,
      iterations: 4,
      options: {
        browser: {
          type: ‘chromium’,
         },
      },
    },
  },
}
1 Like

@bandorko Thanks for the input. Suggested options helped to adjust our script file.