Skip to content

Commit a699d9f

Browse files
committed
add test for propagation of X-Delete-At to segments
1 parent d3f8ccc commit a699d9f

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

tests.sh

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ step 'Test 7: Object expiration'
367367
upload_file_from_stdin expires.txt -H 'X-Delete-At: 2000000000' <<-EOF
368368
This will expire soon.
369369
EOF
370+
upload_file_from_stdin expires-with-segments.txt -H 'X-Delete-At: 2000000000' <<-EOF
371+
This will expire soon.
372+
This will expire soon.
373+
EOF
370374

371375
if [ "$1" = http ]; then
372376
echo ">> Test skipped (works only with Swift source)."
@@ -377,21 +381,42 @@ mirror <<-EOF
377381
jobs:
378382
- from: ${SOURCE_SPEC}
379383
to: { container: ${CONTAINER_BASE}-test7 }
380-
only: 'expires.txt'
384+
only: 'expires.*txt'
381385
expiration:
382386
delay_seconds: 42
387+
segmenting:
388+
container: ${CONTAINER_BASE}-test7-segments
389+
min_bytes: 30
390+
segment_bytes: 30
383391
EOF
384392

385393
expect test7 <<-EOF
394+
>> expires-with-segments.txt
395+
This will expire soon.
396+
This will expire soon.
386397
>> expires.txt
387398
This will expire soon.
388399
EOF
389400

390-
EXPIRY_TIMESTAMP="$(swift stat ${CONTAINER_BASE}-test7 expires.txt | awk '/X-Delete-At:/ { print $2 }')"
391-
if [ "${EXPIRY_TIMESTAMP}" != 2000000042 ]; then
392-
echo -e "\e[1;31m>>\e[0;31m Expected file to expire at timestamp 2000000042, but expires at timestamp '${EXPIRY_TIMESTAMP}' instead.\e[0m"
401+
for OBJECT_NAME in expires.txt expires-with-segments.txt; do
402+
EXPIRY_TIMESTAMP="$(swift stat ${CONTAINER_BASE}-test7 ${OBJECT_NAME} | awk '/X-Delete-At:/ { print $2 }')"
403+
if [ "${EXPIRY_TIMESTAMP}" != 2000000042 ]; then
404+
echo -e "\e[1;31m>>\e[0;31m Expected file \"${OBJECT_NAME}\" to expire at timestamp 2000000042, but expires at timestamp '${EXPIRY_TIMESTAMP}' instead.\e[0m"
405+
exit 1
406+
fi
407+
done
408+
409+
# also check that expiration dates are applied to the segments as well
410+
swift list ${CONTAINER_BASE}-test7-segments | while read OBJECT_NAME; do
411+
EXPIRY_TIMESTAMP="$(swift stat ${CONTAINER_BASE}-test7-segments ${OBJECT_NAME} | awk '/X-Delete-At:/ { print $2 }')"
412+
if [ "${EXPIRY_TIMESTAMP}" != 2000000042 ]; then
413+
echo -e "\e[1;31m>>\e[0;31m Expected segment '${OBJECT_NAME}' to expire at timestamp 2000000042, but expires at timestamp '${EXPIRY_TIMESTAMP}' instead.\e[0m"
414+
exit 1
415+
fi
416+
done || (
417+
echo -e "\e[1;31m>>\e[0;31m Expected object 'expires-with-segments.txt' to be an SLO, but it's not segmented.\e[0m"
393418
exit 1
394-
fi
419+
)
395420

396421
fi # end of: if [ "$1" = http ]
397422

@@ -415,6 +440,7 @@ mirror <<-EOF
415440
segment_bytes: 20 # less than job.segmenting.min_bytes, but also more
416441
# than the smallest files (to exercise all code paths)
417442
to: { container: ${CONTAINER_BASE}-test8 }
443+
except: 'expires-with-segments.txt'
418444
segmenting:
419445
container: ${CONTAINER_BASE}-test8-segments
420446
min_bytes: 30

0 commit comments

Comments
 (0)