Setting up a PersistentVolume to run test

Hi,

I would like to Setting up a PersistentVolume to run test. I am geting the following error:

level=error msg="The moduleSpecifier "/test/test.js" couldn’t be found on local disk. Make sure that you’ve specified the right path to the file. If you’re ru │
│ Stream closed EOF for k6-operator-system/run-k6-with-vars-initializer-vwccf (k6)

Below is my YAMLs. I am not sure what this means in the doc " When using a PersistentVolume , the operator will expect all test scripts to be contained within a directory named /test/" ? Can I please get some guidance here?

apiVersion: v1
kind: PersistentVolume
metadata:
  name: k6-volume
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /mnt/data/k6-test-scripts

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: k6-volume-claim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
  name: run-k6-with-vars
spec:
  parallelism: 3
  script:
    volumeClaim:
      name: k6-volume-claim
      file: test.js
  runner:
    env:
      - name: USERS
        value: '5'
  # cleanup: "post"

Hi @thescoredevservices, it looks like you’re using a local cluster: there may be differences in how local clusters can access a folder on your disk.

It makes sense to check what is actually available on that volume. I’d suggest to create an inspector pod with mounted volume manually, kubectl exec into it and double-check if k6 scripts are present where expected. If they are not, the next step is to figure out why your local cluster is not locating that folder with the scripts.

Hope that helps!

can you provide me example for Pv and pvc yamls please?

@thescoredevservices, your yamls for PV and PVC look fine, AFAIS. But depending on specifics of your cluster setup, they might not be mounting your folder. For example, you’re using hostPath: it makes sense to double-check the docs. Volumes need to be debugged, to confirm that the scripts can be accessed. I’d do that by exec to any long-running pod with volume attached.