From bb90f81e10097ed9756d1237102fab06924668bc Mon Sep 17 00:00:00 2001 From: TomSweeneyRedHat Date: Wed, 16 Oct 2019 19:54:05 -0400 Subject: [PATCH] Re-Add file check to cacheing algorithm Regardless, I've added a test as part of this PR to catch this issue going forward. Fixes: #1906 Signed-off-by: TomSweeneyRedHat --- tests/bud.bats | 26 ++++++++++++++++++++++++++ tests/bud/copy-archive/Containerfile | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 tests/bud/copy-archive/Containerfile diff --git a/tests/bud.bats b/tests/bud.bats index f3a7021bdf3..fc80ad9d139 100644 --- a/tests/bud.bats +++ b/tests/bud.bats @@ -1818,3 +1818,29 @@ load helpers run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} git://github.com/containers/BuildSourceImage#master run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} git://github.com/containers/BuildSourceImage } + +@test "bud containerfile with tar archive in copy" { + # First check to verify cache is uses if the tar file does not change + target=copy-archive + date>bud/${target}/test; tar cJf - bud/${target}/test > bud/${target}/test.tar.xz + run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} ${TESTSDIR}/bud/${target} + expect_output --substring "COMMIT copy-archive" + + run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} ${TESTSDIR}/bud/${target} + expect_output --substring " Using cache" + expect_output --substring "COMMIT copy-archive" + + # Now test that we do NOT use cache if the tar file changes + date>bud/${target}/test; tar cJf - bud/${target}/test > bud/${target}/test.tar.xz + run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} ${TESTSDIR}/bud/${target} + expect_output --substring "COMMIT copy-archive" + + date>bud/${target}/test; tar cJf - bud/${target}/test > bud/${target}/test.tar.xz + run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} ${TESTSDIR}/bud/${target} + if [[ "$output" =~ " Using cache" ]]; then + is "$output" "[no instance of 'Using cache']" "no cache used" + fi + expect_output --substring "COMMIT copy-archive" + + rm bud/${target}/test* +} diff --git a/tests/bud/copy-archive/Containerfile b/tests/bud/copy-archive/Containerfile new file mode 100644 index 00000000000..68ab9c8c1cb --- /dev/null +++ b/tests/bud/copy-archive/Containerfile @@ -0,0 +1,2 @@ +FROM docker.io/busybox +ADD test.tar.xz /