grafana / xk6-kubernetes

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

Reimplement apply #81

Closed pablochacin closed 1 year ago

pablochacin commented 1 year ago

Closes #79 #77

Note to reviewers Due to limitations in the fake client (see https://github.com/kubernetes/client-go/issues/1184 and https://github.com/kubernetes/client-go/issues/970), unit tests for the apply method fail. The way to test this change set is running the following script:

test script for creating and updating pod (click to display code) ```js import { Kubernetes } from 'k6/x/kubernetes'; const manifest = ` apiVersion: v1 kind: Pod metadata: name: busybox namespace: default spec: containers: - name: busybox image: busybox:1.23 command: ["sleep", "300"] ` const update = ` apiVersion: v1 kind: Pod metadata: name: busybox namespace: default spec: containers: - name: busybox image: busybox:1.24 command: ["sleep", "300"] ` export default function () { const kubernetes = new Kubernetes(); kubernetes.apply(manifest) const created = kubernetes.get("Pod", "busybox", "default"); console.log(created.spec.containers[0].image) kubernetes.apply(update) const updated = kubernetes.get("Pod", "busybox", "default"); console.log(updated.spec.containers[0].image) if (created.spec.containers[0].image == updated.spec.containers[0].image) { throw "image not updated" } } ```