grafana / xk6-kubernetes

Client extension for interacting with Kubernetes clusters from your k6 tests.
Apache License 2.0
62 stars 20 forks source link

Add wait option to Pod Create #44

Closed pablochacin closed 2 years ago

pablochacin commented 2 years ago

Add option for waiting until the Pod is running to pod Create. if the pod is not running after a given timeout, an error is returned.

Closes #43

ppcano commented 2 years ago

Given the example:

kubernetes.pods.create({
    namespace: namespace,
    name: podName,
    image: image,
    command: command
  })

const options = {
    namespace: namespace,
    name: podName,
    status: "Succeeded",
    timeout: "10s"
}
if (kubernetes.pods.wait(options)) {
    console.log(podName + " pod completed successfully")
} else {
    throw podName + " is not completed"
}

I suggest adding the timeout option to the creation command. It could be something like:

const resultExecution = kubernetes.pods.createAndWait({
    namespace: namespace,
    name: podName,
    image: image,
    command: command,
    timeout: "10s"
})

or any other alternative:

pablochacin commented 2 years ago

I suggest adding the timeout option to the creation command. It could be something like:

@ppcano this is already done. I just also made possible to wait after the pod is created. This is useful for waiting for the pod to complete.