Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 4671491

Browse files
authored
Merge pull request #18 from jumpstarter-dev/env
2 parents 5839fd8 + 1b4421e commit 4671491

File tree

2 files changed

+168
-93
lines changed

2 files changed

+168
-93
lines changed

action.yml

Lines changed: 7 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ runs:
1515
shell: bash
1616
run: |
1717
uv python install 3.12
18+
- name: Install bats
19+
shell: bash
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install -y bats bats-support bats-assert
1823
- name: Checkout jumpstarter controller
1924
uses: actions/checkout@v4
2025
with:
@@ -77,7 +82,7 @@ runs:
7782
- name: Run jumpstarter
7883
shell: bash
7984
run: |
80-
ENDPOINT=$(helm get values jumpstarter --output json | jq -r '."jumpstarter-controller".grpc.endpoint')
85+
export ENDPOINT=$(helm get values jumpstarter --output json | jq -r '."jumpstarter-controller".grpc.endpoint')
8186
8287
sudo mkdir -p /etc/jumpstarter/exporters
8388
sudo chown $USER /etc/jumpstarter/exporters
@@ -89,95 +94,4 @@ runs:
8994
kubectl create -n default sa test-client-sa
9095
kubectl create -n default sa test-exporter-sa
9196
92-
jmp admin create client test-client-oidc --unsafe --out /dev/null \
93-
--oidc-username dex:test-client-oidc
94-
jmp admin create client test-client-sa --unsafe --out /dev/null \
95-
--oidc-username dex:system:serviceaccount:default:test-client-sa
96-
jmp admin create client test-client-legacy --unsafe --save
97-
98-
jmp admin create exporter test-exporter-oidc --out /dev/null \
99-
--oidc-username dex:test-exporter-oidc \
100-
--label example.com/board=oidc
101-
jmp admin create exporter test-exporter-sa --out /dev/null \
102-
--oidc-username dex:system:serviceaccount:default:test-exporter-sa \
103-
--label example.com/board=sa
104-
jmp admin create exporter test-exporter-legacy --save \
105-
--label example.com/board=legacy
106-
107-
jmp config client list
108-
jmp config exporter list
109-
110-
jmp login --client test-client-oidc \
111-
--endpoint "$ENDPOINT" --namespace default --name test-client-oidc \
112-
--issuer https://dex.dex.svc.cluster.local:5556 \
113-
--username test-client-oidc@example.com --password password --unsafe
114-
115-
jmp login --client test-client-sa \
116-
--endpoint "$ENDPOINT" --namespace default --name test-client-sa \
117-
--issuer https://dex.dex.svc.cluster.local:5556 \
118-
--connector-id kubernetes \
119-
--token $(kubectl create -n default token test-client-sa) --unsafe
120-
121-
jmp login --exporter test-exporter-oidc \
122-
--endpoint "$ENDPOINT" --namespace default --name test-exporter-oidc \
123-
--issuer https://dex.dex.svc.cluster.local:5556 \
124-
--username test-exporter-oidc@example.com --password password
125-
126-
jmp login --exporter test-exporter-sa \
127-
--endpoint "$ENDPOINT" --namespace default --name test-exporter-sa \
128-
--issuer https://dex.dex.svc.cluster.local:5556 \
129-
--connector-id kubernetes \
130-
--token $(kubectl create -n default token test-exporter-sa)
131-
132-
go run github.com/mikefarah/yq/v4@latest -i ". * load(\"$GITHUB_ACTION_PATH/exporter.yaml\")" \
133-
/etc/jumpstarter/exporters/test-exporter-oidc.yaml
134-
go run github.com/mikefarah/yq/v4@latest -i ". * load(\"$GITHUB_ACTION_PATH/exporter.yaml\")" \
135-
/etc/jumpstarter/exporters/test-exporter-sa.yaml
136-
go run github.com/mikefarah/yq/v4@latest -i ". * load(\"$GITHUB_ACTION_PATH/exporter.yaml\")" \
137-
/etc/jumpstarter/exporters/test-exporter-legacy.yaml
138-
139-
jmp config client list
140-
jmp config exporter list
141-
142-
jmp run --exporter test-exporter-oidc &
143-
jmp run --exporter test-exporter-sa &
144-
jmp run --exporter test-exporter-legacy &
145-
146-
kubectl -n default wait --for=condition=Online --for=condition=Registered exporters.jumpstarter.dev/test-exporter-oidc
147-
kubectl -n default wait --for=condition=Online --for=condition=Registered exporters.jumpstarter.dev/test-exporter-sa
148-
kubectl -n default wait --for=condition=Online --for=condition=Registered exporters.jumpstarter.dev/test-exporter-legacy
149-
150-
jmp config client use test-client-oidc
151-
152-
jmp create lease --selector example.com/board=oidc --duration 1d
153-
jmp get leases
154-
jmp get exporters
155-
jmp delete leases --all
156-
157-
jmp admin get client
158-
jmp admin get exporter
159-
jmp admin get lease
160-
161-
jmp run --exporter test-exporter-oidc &
162-
kubectl -n default wait --for=condition=Online --for=condition=Registered exporters.jumpstarter.dev/test-exporter-oidc
163-
164-
jmp shell --client test-client-oidc --selector example.com/board=oidc <<EOF
165-
j power on
166-
EOF
167-
168-
jmp shell --client test-client-sa --selector example.com/board=sa <<EOF
169-
j power on
170-
EOF
171-
172-
jmp shell --client test-client-legacy --selector example.com/board=legacy <<EOF
173-
j power on
174-
EOF
175-
176-
kubectl -n default get secret test-client-oidc-client
177-
kubectl -n default get secret test-exporter-oidc-exporter
178-
179-
jmp admin delete client test-client-oidc -d
180-
jmp admin delete exporter test-exporter-oidc -d
181-
182-
! kubectl -n default get secret test-client-oidc-client
183-
! kubectl -n default get secret test-exporter-oidc-exporter
97+
bats --show-output-of-passing-tests --verbose-run "$GITHUB_ACTION_PATH"/tests.bats

tests.bats

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
setup() {
2+
bats_load_library bats-support
3+
bats_load_library bats-assert
4+
}
5+
6+
@test "can create clients with admin cli" {
7+
jmp admin create client test-client-oidc --unsafe --out /dev/null \
8+
--oidc-username dex:test-client-oidc
9+
jmp admin create client test-client-sa --unsafe --out /dev/null \
10+
--oidc-username dex:system:serviceaccount:default:test-client-sa
11+
jmp admin create client test-client-legacy --unsafe --save
12+
}
13+
14+
@test "can create exporters with admin cli" {
15+
jmp admin create exporter test-exporter-oidc --out /dev/null \
16+
--oidc-username dex:test-exporter-oidc \
17+
--label example.com/board=oidc
18+
jmp admin create exporter test-exporter-sa --out /dev/null \
19+
--oidc-username dex:system:serviceaccount:default:test-exporter-sa \
20+
--label example.com/board=sa
21+
jmp admin create exporter test-exporter-legacy --save \
22+
--label example.com/board=legacy
23+
}
24+
25+
@test "can login with oidc" {
26+
jmp config client list
27+
jmp config exporter list
28+
29+
jmp login --client test-client-oidc \
30+
--endpoint "$ENDPOINT" --namespace default --name test-client-oidc \
31+
--issuer https://dex.dex.svc.cluster.local:5556 \
32+
--username test-client-oidc@example.com --password password --unsafe
33+
34+
jmp login --client test-client-sa \
35+
--endpoint "$ENDPOINT" --namespace default --name test-client-sa \
36+
--issuer https://dex.dex.svc.cluster.local:5556 \
37+
--connector-id kubernetes \
38+
--token $(kubectl create -n default token test-client-sa) --unsafe
39+
40+
jmp login --exporter test-exporter-oidc \
41+
--endpoint "$ENDPOINT" --namespace default --name test-exporter-oidc \
42+
--issuer https://dex.dex.svc.cluster.local:5556 \
43+
--username test-exporter-oidc@example.com --password password
44+
45+
jmp login --exporter test-exporter-sa \
46+
--endpoint "$ENDPOINT" --namespace default --name test-exporter-sa \
47+
--issuer https://dex.dex.svc.cluster.local:5556 \
48+
--connector-id kubernetes \
49+
--token $(kubectl create -n default token test-exporter-sa)
50+
51+
go run github.com/mikefarah/yq/v4@latest -i ". * load(\"$GITHUB_ACTION_PATH/exporter.yaml\")" \
52+
/etc/jumpstarter/exporters/test-exporter-oidc.yaml
53+
go run github.com/mikefarah/yq/v4@latest -i ". * load(\"$GITHUB_ACTION_PATH/exporter.yaml\")" \
54+
/etc/jumpstarter/exporters/test-exporter-sa.yaml
55+
go run github.com/mikefarah/yq/v4@latest -i ". * load(\"$GITHUB_ACTION_PATH/exporter.yaml\")" \
56+
/etc/jumpstarter/exporters/test-exporter-legacy.yaml
57+
58+
jmp config client list
59+
jmp config exporter list
60+
}
61+
62+
@test "can run exporters" {
63+
cat <<EOF | bash 3>&- &
64+
while true; do
65+
jmp run --exporter test-exporter-oidc
66+
done
67+
EOF
68+
69+
cat <<EOF | bash 3>&- &
70+
while true; do
71+
jmp run --exporter test-exporter-sa
72+
done
73+
EOF
74+
75+
cat <<EOF | bash 3>&- &
76+
while true; do
77+
jmp run --exporter test-exporter-legacy
78+
done
79+
EOF
80+
81+
kubectl -n default wait --for=condition=Online --for=condition=Registered \
82+
exporters.jumpstarter.dev/test-exporter-oidc
83+
kubectl -n default wait --for=condition=Online --for=condition=Registered \
84+
exporters.jumpstarter.dev/test-exporter-sa
85+
kubectl -n default wait --for=condition=Online --for=condition=Registered \
86+
exporters.jumpstarter.dev/test-exporter-legacy
87+
}
88+
89+
@test "can specify client config only using environment variables" {
90+
kubectl -n default wait --for=condition=Online --for=condition=Registered \
91+
exporters.jumpstarter.dev/test-exporter-oidc
92+
93+
JMP_NAMEPSACE=default \
94+
JMP_NAME=test-exporter-legacy \
95+
JMP_ENDPOINT=$(kubectl get clients.jumpstarter.dev -n default test-client-legacy -o 'jsonpath={.status.endpoint}') \
96+
JMP_TOKEN=$(kubectl get secrets -n default test-client-legacy-client -o 'jsonpath={.data.token}' | base64 -d) \
97+
jmp shell --selector example.com/board=oidc j power on
98+
}
99+
100+
@test "can operate on leases" {
101+
kubectl -n default wait --for=condition=Online --for=condition=Registered \
102+
exporters.jumpstarter.dev/test-exporter-oidc
103+
104+
jmp config client use test-client-oidc
105+
106+
jmp create lease --selector example.com/board=oidc --duration 1d
107+
jmp get leases
108+
jmp get exporters
109+
jmp delete leases --all
110+
}
111+
112+
@test "can lease and connect to exporters" {
113+
kubectl -n default wait --for=condition=Online --for=condition=Registered \
114+
exporters.jumpstarter.dev/test-exporter-oidc
115+
kubectl -n default wait --for=condition=Online --for=condition=Registered \
116+
exporters.jumpstarter.dev/test-exporter-sa
117+
kubectl -n default wait --for=condition=Online --for=condition=Registered \
118+
exporters.jumpstarter.dev/test-exporter-legacy
119+
120+
jmp shell --client test-client-oidc --selector example.com/board=oidc j power on
121+
jmp shell --client test-client-sa --selector example.com/board=sa j power on
122+
jmp shell --client test-client-legacy --selector example.com/board=legacy j power on
123+
}
124+
125+
@test "can get crds with admin cli" {
126+
jmp admin get client
127+
jmp admin get exporter
128+
jmp admin get lease
129+
}
130+
131+
@test "can delete clients with admin cli" {
132+
kubectl -n default get secret test-client-oidc-client
133+
kubectl -n default get clients.jumpstarter.dev/test-client-oidc
134+
kubectl -n default get clients.jumpstarter.dev/test-client-sa
135+
kubectl -n default get clients.jumpstarter.dev/test-client-legacy
136+
137+
jmp admin delete client test-client-oidc --delete
138+
jmp admin delete client test-client-sa --delete
139+
jmp admin delete client test-client-legacy --delete
140+
141+
run ! kubectl -n default get secret test-client-oidc-client
142+
run ! kubectl -n default get clients.jumpstarter.dev/test-client-oidc
143+
run ! kubectl -n default get clients.jumpstarter.dev/test-client-sa
144+
run ! kubectl -n default get clients.jumpstarter.dev/test-client-legacy
145+
}
146+
147+
@test "can delete exporters with admin cli" {
148+
kubectl -n default get secret test-exporter-oidc-exporter
149+
kubectl -n default get exporters.jumpstarter.dev/test-exporter-oidc
150+
kubectl -n default get exporters.jumpstarter.dev/test-exporter-sa
151+
kubectl -n default get exporters.jumpstarter.dev/test-exporter-legacy
152+
153+
jmp admin delete exporter test-exporter-oidc --delete
154+
jmp admin delete exporter test-exporter-sa --delete
155+
jmp admin delete exporter test-exporter-legacy --delete
156+
157+
run ! kubectl -n default get secret test-exporter-oidc-exporter
158+
run ! kubectl -n default get exporters.jumpstarter.dev/test-exporter-oidc
159+
run ! kubectl -n default get exporters.jumpstarter.dev/test-exporter-sa
160+
run ! kubectl -n default get exporters.jumpstarter.dev/test-exporter-legacy
161+
}

0 commit comments

Comments
 (0)