|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +test_description='Test flux-filemap' |
| 4 | + |
| 5 | +. `dirname $0`/content/content-helper.sh |
| 6 | + |
| 7 | +. `dirname $0`/sharness.sh |
| 8 | + |
| 9 | +LPTEST=${FLUX_BUILD_DIR}/t/shell/lptest |
| 10 | + |
| 11 | +test_under_flux 2 kvs |
| 12 | + |
| 13 | +umask 022 |
| 14 | + |
| 15 | +# Usage: list_mapped_files tag |
| 16 | +list_mapped_files() { |
| 17 | + flux module stats content | jq -r ".mmap.tags[\"$1\"][]" |
| 18 | +} |
| 19 | + |
| 20 | +test_expect_success 'create copy directory' ' |
| 21 | + mkdir -p copydir |
| 22 | +' |
| 23 | +test_expect_success 'create test file' ' |
| 24 | + ${LPTEST} >testfile && |
| 25 | + chmod u=rwx testfile && |
| 26 | + chmod go=r testfile |
| 27 | +' |
| 28 | +test_expect_success 'flux filemap map works' ' |
| 29 | + flux filemap map ./testfile && |
| 30 | + flux kvs get --raw archive.main | jq |
| 31 | +' |
| 32 | +test_expect_success 'content stats show mapped file' ' |
| 33 | + list_mapped_files main >stats.out && |
| 34 | + realpath ./testfile >stats.exp && |
| 35 | + test_cmp stats.exp stats.out |
| 36 | +' |
| 37 | +test_expect_success 'flux filemap list works' ' |
| 38 | + flux filemap list |
| 39 | +' |
| 40 | +test_expect_success 'flux filemap list --long works' ' |
| 41 | + flux filemap list --long |
| 42 | +' |
| 43 | +test_expect_success 'flux filemap get works' ' |
| 44 | + flux filemap get -C copydir |
| 45 | +' |
| 46 | +test_expect_success 'file content is correct' ' |
| 47 | + test_cmp testfile copydir/testfile |
| 48 | +' |
| 49 | +test_expect_success 'flux filemap umap works' ' |
| 50 | + flux filemap unmap |
| 51 | +' |
| 52 | +test_expect_success 'content stats no longer show mapped file' ' |
| 53 | + test_must_fail list_mapped_files archive.main |
| 54 | +' |
| 55 | +test_expect_success 'flux filemap map --disable-mmap -Too works' ' |
| 56 | + flux filemap map --disable-mmap -Tfoo ./testfile && |
| 57 | + flux kvs get --raw archive.foo | jq |
| 58 | +' |
| 59 | +test_expect_success 'flux filemap list -Tfoo works' ' |
| 60 | + flux filemap list -Tfoo |
| 61 | +' |
| 62 | +test_expect_success 'flux filemap get -Tfoo works' ' |
| 63 | + rm -f copydir/* && |
| 64 | + flux filemap get -C copydir -Tfoo 2>warn.err |
| 65 | +' |
| 66 | +test_expect_success 'with warning printed on stderr' ' |
| 67 | + grep deprecated warn.err |
| 68 | +' |
| 69 | +test_expect_success 'file content is correct' ' |
| 70 | + test_cmp testfile copydir/testfile |
| 71 | +' |
| 72 | +test_expect_success 'flux filemap unmap -Tfoo works' ' |
| 73 | + flux filemap unmap -Tfoo |
| 74 | +' |
| 75 | +test_expect_success 'flux filemap list no longer works' ' |
| 76 | + test_must_fail flux filemap list -Tfoo |
| 77 | +' |
| 78 | +test_expect_success 'flux filemap create does not accept -T' ' |
| 79 | + test_must_fail flux archive create -T bar ./testfile |
| 80 | +' |
| 81 | +test_expect_success 'flux filemap create does not accept --disable-mmap' ' |
| 82 | + test_must_fail flux archive create --disable-mmap ./testfile |
| 83 | +' |
| 84 | +test_expect_success 'flux archive create --name=bar works' ' |
| 85 | + flux archive create --name=bar ./testfile |
| 86 | +' |
| 87 | +test_expect_success 'flux filemap extract does not accept -T' ' |
| 88 | + test_must_fail flux archive extract -T bar |
| 89 | +' |
| 90 | +test_expect_success 'flux filemap remove does not accept -T' ' |
| 91 | + test_must_fail flux archive remove -T bar |
| 92 | +' |
| 93 | +test_done |
0 commit comments