diff --git a/Dockerfile b/Dockerfile index 177e104..6c0ac26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ FROM alpine:3.14 -ARG KUBECTL_VERSION=v1.21.2 -ARG HELM_VERSION=v3.6.1 -ARG BATS_VERSION=1.3.0 +ARG KUBECTL_VERSION=v1.29.2 +ARG HELM_VERSION=v3.14.2 +ARG BATS_VERSION=1.10.0 # Add packages RUN apk --no-cache add \ diff --git a/README.md b/README.md index d725826..91f1a20 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,8 @@ DETIK_CLIENT_NAMESPACE="my-specific-namespace" # Verify the number of PODS and services verify "there are 2 pods named 'nginx'" verify "there is 1 service named 'nginx'" +verify "there are less than 3 pods named 'nginx'" +verify "there are more than 1 pods named 'nginx'" # Verify assertions on resources verify "'status' is 'running' for pods named 'nginx'" @@ -157,6 +159,8 @@ verify "'.spec.ports[*].targetPort' is '8484' for services named 'nginx'" # You can also specify a number of attempts try "at most 5 times every 30s to get pods named 'nginx' and verify that 'status' is 'running'" try "at most 5 times every 30s to get svc named 'nginx' and verify that '.spec.ports[*].targetPort' is '8484'" +try "at most 5 times every 30s to get deployment named 'nginx' and verify that 'status.currentReplicas' is more than '2'" +try "at most 5 times every 30s to get deployment named 'nginx' and verify that 'status.currentReplicas' is less than '4'" # Long assertions can also be split over several lines try "at most 5 times every 30s " \ @@ -283,8 +287,14 @@ Verify there are N resources of this type with this name pattern. # Expecting 0 or 1 instance verify "there is <0 or 1> named ''" -# Expecting more than 1 instance +# Expecting instances verify "there are named ''" + +# Expecting more than instances +verify "there are more than named ''" + +# Expecting less than instances +verify "there are less than named ''" ``` *resource-type* is one of the K8s ones (e.g. `pods`, `po`, `services`, `svc`...). diff --git a/examples/bats/test_kubectl_and_oc.sh b/examples/bats/test_kubectl_and_oc.sh index b740e79..9fa5300 100644 --- a/examples/bats/test_kubectl_and_oc.sh +++ b/examples/bats/test_kubectl_and_oc.sh @@ -17,6 +17,8 @@ DETIK_CLIENT_NAME="kubectl" # Basic examples verify "there are 1 service named 'nginx'" verify "there are 4 pods named 'nginx'" +verify "there are more than 2 pods named 'nginx'" +verify "there are less than 5 pods named 'nginx'" # The same thing (it is case insensitive) verify "There are 4 pods naMed 'nginx'" @@ -62,6 +64,10 @@ try "at most 5 times every 5s to get pods named 'nginx' and verify that 'status' # The same thing (it is case insensitive) try "at most 5 times every 15s to GET pods named 'nginx' and verify that 'status' is 'RUNNING'" +# Basic examples with more/less than +try "at most 5 times every 5s to get deploy named 'nginx' and verify that 'status.currentReplicas' is more than '1'" +try "at most 5 times every 5s to get deploy named 'nginx' and verify that 'status.currentReplicas' is less than '3'" + # Use short names for resources ('po' instead of 'pods') # See https://kubernetes.io/docs/reference/kubectl/overview/#resource-types try "at most 5 times every 5s to get po named 'nginx' and verify that 'status' is 'running'"