save and restore gdt variables in gdt-kube tests#23
Merged
a-hilaly merged 1 commit intogdt-dev:mainfrom Sep 12, 2025
Merged
Conversation
Adds the gdt variable system functionality to the gdt-kube plugin,
allowing test authors to define variables that should be populated from
inspecting the results of the kube.get output and extracting an element
using a JSONPath expression.
You can mix and match gdt test specs and the gdt variable system to pass
values between test specs, allowing for a really extensible testing
framework, like this example shows:
```
name: curl-pod-ip
description: scenario showing how to create two NGinx Pods and test connectivity to internal Pod IP addresses
fixtures:
- kind
defaults:
kube:
namespace: curl-pod-ip
tests:
- name: create-server
kube:
create: testdata/manifests/nginx-server.yaml
- name: get-server-pod-ip
kube:
get: pods/server
assert:
conditions:
ready:
status: true
var:
SERVER_IP:
from: $.status.podIP
- name: create-connect-tester
kube:
create: testdata/manifests/nginx-connect-test.yaml
- name: wait-connect-test-ready
kube:
get: pods/connect-test
assert:
conditions:
ready:
status: true
- name: curl-server-from-connect-tester
exec: kubectl exec -n curl-pod-ip pods/connect-test -- curl -s -I -v $$SERVER_IP
timeout: 2s
assert:
out:
contains: "200 OK"
# curl -v causes output to be sent to stderr that looks like this:
# * Connected to 10.244.0.17 (10.244.0.17) port 80 (#0)
# > GET / HTTP/1.1
# > Host: 10.244.0.17
# > User-Agent: curl/7.88.1
# > Accept: */*
# >
# < HTTP/1.1 200 OK
err:
contains: "Host: $$SERVER_IP"
- name: delete-connect-tester
kube:
delete: pods/connect-test
- name: delete-server
kube:
delete: pods/server
```
Issue gdt-dev/gdt#51
Signed-off-by: Jay Pipes <jaypipes@gmail.com>
4d63df7 to
2f16879
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the gdt variable system functionality to the gdt-kube plugin, allowing test authors to define variables that should be populated from inspecting the results of the kube.get output and extracting an element using a JSONPath expression.
You can mix and match gdt test specs and the gdt variable system to pass values between test specs, allowing for a really extensible testing framework, like this example shows:
Issue gdt-dev/gdt#51