github.com/OpenFlowLabs/storage@v1.12.13/tests/import-layer-ostree.bats (about) 1 #!/usr/bin/env bats 2 3 load helpers 4 5 @test "import-layer-ostree" { 6 case "$STORAGE_DRIVER" in 7 overlay*|vfs) 8 ;; 9 *) 10 skip "not supported by driver $STORAGE_DRIVER" 11 ;; 12 esac 13 14 # The checkdiffs function needs "tar". 15 if test -z "$(which tar 2> /dev/null)" ; then 16 skip "need tar" 17 fi 18 if test -z "$(which ostree 2> /dev/null)" ; then 19 skip "need ostree" 20 fi 21 22 OSTREE_REPO=${TESTDIR}/ostree 23 mkdir -p $OSTREE_REPO 24 25 # Create and populate three interesting layers. 26 populate 27 28 OPTS="--storage-opt=.ostree_repo=$OSTREE_REPO,.skip_mount_home=true" 29 30 # Extract the layers. 31 storage diff $OPTS -u -f $TESTDIR/lower.tar $lowerlayer 32 storage diff $OPTS -c -f $TESTDIR/middle.tar $midlayer 33 storage diff $OPTS -u -f $TESTDIR/upper.tar $upperlayer 34 35 # Delete the layers. 36 storage delete-layer $OPTS $upperlayer 37 storage delete-layer $OPTS $midlayer 38 storage delete-layer $OPTS $lowerlayer 39 40 # Import new layers using the layer diffs and mark them read-only. Only read-only layers are deduplicated with OSTree. 41 run storage --debug=false import-layer $OPTS -r -f $TESTDIR/lower.tar 42 [ "$status" -eq 0 ] 43 [ "$output" != "" ] 44 lowerlayer="$output" 45 46 run storage --debug=false import-layer $OPTS -r -f $TESTDIR/middle.tar "$lowerlayer" 47 [ "$status" -eq 0 ] 48 [ "$output" != "" ] 49 midlayer="$output" 50 51 run storage --debug=false import-layer $OPTS -r -f $TESTDIR/upper.tar "$midlayer" 52 [ "$status" -eq 0 ] 53 [ "$output" != "" ] 54 upperlayer="$output" 55 56 # The contents of these new layers should match what the old ones had. 57 checkchanges 58 checkdiffs 59 }