Skip to content

Commit 06dc666

Browse files
committed
Fix ephemeral LV name in the tests
1 parent 6def88b commit 06dc666

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

tests/bats/test.bats

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,25 +389,22 @@
389389
}
390390

391391
@test "ephemeral encrypted raw LV is LUKS-formatted" {
392-
# Ephemeral volume ID: csi-<pod-uid>-<volume-handle>
393-
POD_UID=$(kubectl get pod volume-test-inline-encrypted -o jsonpath='{.metadata.uid}')
394392
NODE=$(kubectl get pod volume-test-inline-encrypted -o jsonpath='{.spec.nodeName}')
395393
PLUGIN_POD=$(kubectl get pods -n csi-driver-lvm -l app=csi-driver-lvm --field-selector "spec.nodeName=$NODE" -o jsonpath='{.items[0].metadata.name}')
396394

397-
# Find the ephemeral LV name (starts with csi- and contains the pod UID)
398-
LV_NAME=$(kubectl exec -n csi-driver-lvm "$PLUGIN_POD" -c csi-driver-lvm -- lvs csi-lvm --noheadings -o lv_name | tr -d ' ' | grep "$POD_UID")
395+
# Ephemeral LV names start with "csi-" — find the one currently active
396+
LV_NAME=$(kubectl exec -n csi-driver-lvm "$PLUGIN_POD" -c csi-driver-lvm -- lvs csi-lvm --noheadings -o lv_name | tr -d ' ' | grep '^csi-')
399397
[ -n "$LV_NAME" ]
400398

401399
run kubectl exec -n csi-driver-lvm "$PLUGIN_POD" -c csi-driver-lvm -- cryptsetup isLuks "/dev/csi-lvm/$LV_NAME"
402400
[ "$status" -eq 0 ]
403401
}
404402

405403
@test "ephemeral encrypted plaintext data not readable on raw LV" {
406-
POD_UID=$(kubectl get pod volume-test-inline-encrypted -o jsonpath='{.metadata.uid}')
407404
NODE=$(kubectl get pod volume-test-inline-encrypted -o jsonpath='{.spec.nodeName}')
408405
PLUGIN_POD=$(kubectl get pods -n csi-driver-lvm -l app=csi-driver-lvm --field-selector "spec.nodeName=$NODE" -o jsonpath='{.items[0].metadata.name}')
409406

410-
LV_NAME=$(kubectl exec -n csi-driver-lvm "$PLUGIN_POD" -c csi-driver-lvm -- lvs csi-lvm --noheadings -o lv_name | tr -d ' ' | grep "$POD_UID")
407+
LV_NAME=$(kubectl exec -n csi-driver-lvm "$PLUGIN_POD" -c csi-driver-lvm -- lvs csi-lvm --noheadings -o lv_name | tr -d ' ' | grep '^csi-')
411408
[ -n "$LV_NAME" ]
412409

413410
run kubectl exec -n csi-driver-lvm "$PLUGIN_POD" -c csi-driver-lvm -- strings "/dev/csi-lvm/$LV_NAME"

0 commit comments

Comments
 (0)