containers-bsi/test/02-from_image_ref.bats
Vincent Batts 8e438c7a6d BuildSourceImage: expose "unpack" as subcommand
This may be a pattern we can do for some of the more useful functions.
But for now, folks can build, push, etc. and once they skopeo copy an
image to their host, they can

```bash
./BuildSourceImage unpack <src> <dest>
```

and it will be nicely exposed in the container build too

Also included, exporting the defaults into the bats test for easier
direct running. Perhaps we can move the srpm caching into bats too, so
the Makefile target isn't strictly required.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2019-10-15 15:26:02 +00:00

30 lines
1 KiB
Bash

#!/usr/bin/env bats -t
load helpers
@test "Build from image reference" {
#skip "this takes like 20min ..."
local d
d=$(mktemp -d)
echo "temporary directory: ${d}"
ref="registry.fedoraproject.org/fedora-minimal"
run_ctr --mount type=bind,source=${d},destination=/output $CTR_IMAGE -i "${ref}" -o /output
[ "$status" -eq 0 ]
#echo ${lines[@]}
[[ ${lines[0]} =~ "Getting image source signatures" ]]
[[ ${lines[1]} =~ "Copying blob " ]]
[[ ${lines[5]} =~ "[SrcImg][INFO] [unpacking] layer sha256:" ]]
[[ ${lines[6]} =~ "[SrcImg][INFO] inspecting image reference ${ref}:" ]]
[[ ${lines[7]} =~ "[SrcImg][INFO] calling source collection drivers" ]]
# get the number of the last line
n=$(expr ${#lines[@]} - 1)
[[ ${lines[${n}]} =~ "[SrcImg][INFO] copied to oci:/output:latest-source" ]]
echo "${d}"
[ -f "${d}/index.json" ]
[ -f "${d}/oci-layout" ]
[ "$(du -b ${d}/index.json | awk '{ print $1 }')" -gt 0 ]
[ "$(du -b ${d}/oci-layout | awk '{ print $1 }')" -gt 0 ]
[ "$(find ${d} -type f | wc -l)" -gt 5 ]
}