Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new feature to README and bump Dockerfile #42

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand All @@ -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 " \
Expand Down Expand Up @@ -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> <resource-type> named '<regular-expression>'"

# Expecting more than 1 instance
# Expecting <number> instances
verify "there are <number> <resource-type> named '<regular-expression>'"

# Expecting more than <number> instances
verify "there are more than <number> <resource-type> named '<regular-expression>'"

# Expecting less than <number> instances
verify "there are less than <number> <resource-type> named '<regular-expression>'"
```

*resource-type* is one of the K8s ones (e.g. `pods`, `po`, `services`, `svc`...).
Expand Down
6 changes: 6 additions & 0 deletions examples/bats/test_kubectl_and_oc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down Expand Up @@ -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'"
Expand Down
Loading