Skip to content

Commit 4bf0863

Browse files
committed
cover new feature with e2e tests
Signed-off-by: solidDoWant <fred.heinecke@yahoo.com>
1 parent 0d4e072 commit 4bf0863

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

e2e/dr/config/dummy/instance/backend.values.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ controllers:
8686
printf 'bucket2-seed' > /tmp/obj && \
8787
mc cp /tmp/obj sw/dummy-bucket2/seed.txt
8888
env: *s3Env
89-
# --- Source data PVC seed (writes a known file into the files-source PVC) ---
89+
# --- Source data PVC seed (writes known files into the files-source PVC) ---
90+
# Alongside the kept files (hello.txt, sub/keep.txt) it writes files the backup config's filter should
91+
# exclude: *.tmp at any depth (skip.tmp, sub/also.tmp) and everything under the top-level cache/ dir.
9092
dummy-data-seed:
9193
type: job
9294
containers:
@@ -98,7 +100,7 @@ controllers:
98100
- /bin/sh
99101
- -c
100102
args:
101-
- printf 'files-seed' > /data/hello.txt
103+
- mkdir -p /data/sub /data/cache && printf 'files-seed' > /data/hello.txt && printf 'nested-keep' > /data/sub/keep.txt && printf 'tmp' > /data/sub/also.tmp && printf 'tmp' > /data/skip.tmp && printf 'cache' > /data/cache/inner.txt
102104
persistence:
103105
data-vol:
104106
suffix: data-vol # PVC name: dummy-backend-data-vol
@@ -162,7 +164,8 @@ rawResources:
162164
- /bin/sh
163165
- -c
164166
args:
165-
- printf 'shard-a-seed' > /a/d.txt && printf 'shard-b-seed' > /b/d.txt
167+
# d.txt is the kept payload; skip.log in each shard is what the fileGroups filter excludes.
168+
- printf 'shard-a-seed' > /a/d.txt && printf 'shard-b-seed' > /b/d.txt && printf 'log' > /a/skip.log && printf 'log' > /b/skip.log
166169
volumeMounts:
167170
- name: a
168171
mountPath: /a

e2e/dr/config/dummy/tests/backup.values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,20 @@ jobConfig:
3333
files:
3434
- name: files # => DR subdir "files"
3535
pvc: dummy-backend-data-vol
36+
# Whitelist/blacklist which files are captured. "**" crosses any depth; a bare name is anchored at
37+
# the PVC root, and excluding a directory prunes its whole subtree.
38+
exclude:
39+
- glob: "**/*.tmp" # any .tmp file, at any depth
40+
- glob: cache # the top-level cache/ dir and everything under it
3641
fileGroups:
3742
- name: shards # => DR subtree "fileGroups/shards/<pvc>"
3843
snapshotClass: csi-hostpath-groupsnapclass
3944
selector:
4045
matchLabels:
4146
app: dummy-fileshard
47+
# Applied identically to every member PVC of the group.
48+
exclude:
49+
- glob: "**/*.log"
4250
s3:
4351
- name: bucket1 # => DR subdir "bucket1"
4452
path: s3://dummy-bucket1/

e2e/dr/dummy_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,25 @@ func TestDummy(t *testing.T) {
303303
assertSeedFile(t, filepath.Join(mountpoint, "bucket1", "seed.txt"), "bucket1-seed")
304304
assertSeedFile(t, filepath.Join(mountpoint, "bucket2", "seed.txt"), "bucket2-seed")
305305

306+
// The files source's include/exclude filter (exclude **/*.tmp and the top-level cache/ dir) is
307+
// applied per entry end to end: a nested non-excluded file survives, while the .tmp files (at any
308+
// depth) and the entire cache/ subtree are absent from the capture.
309+
assertSeedFile(t, filepath.Join(mountpoint, "files", "sub", "keep.txt"), "nested-keep")
310+
assert.NoFileExists(t, filepath.Join(mountpoint, "files", "skip.tmp"))
311+
assert.NoFileExists(t, filepath.Join(mountpoint, "files", "sub", "also.tmp"))
312+
assert.NoDirExists(t, filepath.Join(mountpoint, "files", "cache"))
313+
306314
// The fileGroups source captured both label-selected shard PVCs as one VolumeGroupSnapshot into
307315
// fileGroups/<group>/<pvc>/. Both member subdirs present with their seeded content confirms the
308316
// group was frozen and synced atomically (one subdir per member PVC, keyed by source PVC name).
309317
assertSeedFile(t, filepath.Join(mountpoint, "fileGroups", "shards", "dummy-shard-a", "d.txt"), "shard-a-seed")
310318
assertSeedFile(t, filepath.Join(mountpoint, "fileGroups", "shards", "dummy-shard-b", "d.txt"), "shard-b-seed")
311319

320+
// The group-wide filter (exclude **/*.log) applied to every member: the .log file seeded into each
321+
// shard is dropped, while the kept payload (d.txt, asserted above) and the member subdir remain.
322+
assert.NoFileExists(t, filepath.Join(mountpoint, "fileGroups", "shards", "dummy-shard-a", "skip.log"))
323+
assert.NoFileExists(t, filepath.Join(mountpoint, "fileGroups", "shards", "dummy-shard-b", "skip.log"))
324+
312325
return ctx
313326
}).
314327
Assess("file-group shards are corrupted before restore", corruptShardData(namespace)).

0 commit comments

Comments
 (0)