|
89 | 89 | ################################################################################ |
90 | 90 | # functions for tests |
91 | 91 |
|
| 92 | +upload_target_file_from_stdin() { |
| 93 | + # same trickery as in `upload_file_from_stdin` (see comments over there), but |
| 94 | + # for a target container |
| 95 | + sed 's/^ //' > "${TEST_FILENAME}" |
| 96 | + local CONTAINER_NAME="${CONTAINER_BASE}-$1" |
| 97 | + local OBJECT_NAME="$2" |
| 98 | + shift 2 |
| 99 | + swift upload "${CONTAINER_NAME}" "${TEST_FILENAME}" --object-name "${OBJECT_NAME}" "$@" |
| 100 | +} |
| 101 | + |
92 | 102 | mirror() { |
93 | 103 | # config file comes from stdin |
94 | 104 | ./build/swift-http-import /dev/fd/0 |
|
494 | 504 |
|
495 | 505 | fi # end of: if [ "$1" = http ] |
496 | 506 |
|
| 507 | +################################################################################ |
| 508 | +step 'Test 10: Cleanup on target side' |
| 509 | + |
| 510 | +upload_target_file_from_stdin test10 ignored.txt <<-EOF |
| 511 | + This file does not get cleaned up because it's not below object_prefix. |
| 512 | +EOF |
| 513 | +upload_target_file_from_stdin test10 target/cleanup-please.txt <<-EOF |
| 514 | + This file gets cleaned up because it's below object_prefix. |
| 515 | +EOF |
| 516 | +# This file will get cleaned up even though it exists on the source side |
| 517 | +# because it's excluded from transfer by a filter. |
| 518 | +upload_target_file_from_stdin test10 target/just/some/files/2.txt <<-EOF |
| 519 | + Hello Second World. |
| 520 | +EOF |
| 521 | +sleep 10 # wait for container listing to get updated |
| 522 | + |
| 523 | +mirror <<-EOF |
| 524 | + swift: { $AUTH_PARAMS } |
| 525 | + jobs: |
| 526 | + - from: ${SOURCE_SPEC} |
| 527 | + to: |
| 528 | + container: ${CONTAINER_BASE}-test10 |
| 529 | + object_prefix: target/ |
| 530 | + only: '/$|1\\.txt$' |
| 531 | +EOF |
| 532 | + |
| 533 | +# This first pass does not have cleanup enabled (to compare against the second |
| 534 | +# pass down below), so we're still seeing the files that need to be cleaned up. |
| 535 | +expect test10 <<-EOF |
| 536 | +>> ignored.txt |
| 537 | +This file does not get cleaned up because it's not below object_prefix. |
| 538 | +>> target/cleanup-please.txt |
| 539 | +This file gets cleaned up because it's below object_prefix. |
| 540 | +>> target/just/some/files/1.txt |
| 541 | +Hello World. |
| 542 | +>> target/just/some/files/2.txt |
| 543 | +Hello Second World. |
| 544 | +EOF |
| 545 | + |
| 546 | +mirror <<-EOF |
| 547 | + swift: { $AUTH_PARAMS } |
| 548 | + jobs: |
| 549 | + - from: ${SOURCE_SPEC} |
| 550 | + to: |
| 551 | + container: ${CONTAINER_BASE}-test10 |
| 552 | + object_prefix: target/ |
| 553 | + only: '/$|1\\.txt$' |
| 554 | + cleanup: |
| 555 | + strategy: delete |
| 556 | +EOF |
| 557 | + |
| 558 | +expect test10 <<-EOF |
| 559 | +>> ignored.txt |
| 560 | +This file does not get cleaned up because it's not below object_prefix. |
| 561 | +>> target/just/some/files/1.txt |
| 562 | +Hello World. |
| 563 | +EOF |
| 564 | + |
497 | 565 | ################################################################################ |
498 | 566 | # cleanup before exiting |
499 | 567 |
|
|
0 commit comments