From 17784f35bfc79cb8daa7d645388ab5077859641b Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Mon, 13 Nov 2023 13:46:24 -0800 Subject: [PATCH] test: replace import with imports, add one explicit legacy import test This just changes all the existing tests to test 'imports' rather than 'import'. Then it adds one test for 'import' explicitly and within the same stacker file. Test test/cache.bats test "can read previous version's cache" is skipped as the old version can't build a stacker file in the test because it uses 'imports'. Signed-off-by: Scott Moser --- test/basic.bats | 6 +-- test/broken-link.bats | 2 +- test/build-only.bats | 8 ++-- test/caching.bats | 15 +++--- test/cp-not-required.bats | 2 +- test/dependency-order.bats | 4 +- test/docker-base.bats | 2 +- test/import-http.bats | 4 +- test/import.bats | 93 ++++++++++++++++++++++++-------------- test/invalid.bats | 2 +- test/multi-arch.bats | 4 +- test/overlay-dirs.bats | 2 +- test/prerequisites.bats | 4 +- test/publish.bats | 4 +- test/squashfs.bats | 8 ++-- test/unprivileged.bats | 8 ++-- 16 files changed, 98 insertions(+), 70 deletions(-) diff --git a/test/basic.bats b/test/basic.bats index dbf496e7..3995b5bc 100644 --- a/test/basic.bats +++ b/test/basic.bats @@ -14,7 +14,7 @@ centos: from: type: oci url: $CENTOS_OCI - import: import + imports: import EOF echo 1 > import stacker build @@ -32,7 +32,7 @@ centos: from: type: tar url: .stacker/layer-bases/centos.tar - import: + imports: - ./stacker.yaml - https://www.cisco.com/favicon.ico - ./executable @@ -198,7 +198,7 @@ centos: from: type: tar url: .stacker/layer-bases/centos.tar - import: + imports: - ./stacker.yaml - https://www.cisco.com/favicon.ico - ./executable diff --git a/test/broken-link.bats b/test/broken-link.bats index ce776e9f..8213bede 100644 --- a/test/broken-link.bats +++ b/test/broken-link.bats @@ -15,7 +15,7 @@ broken_link: from: type: oci url: $CENTOS_OCI - import: + imports: - dir run: cp -a /stacker/imports/dir/testln /testln EOF diff --git a/test/build-only.bats b/test/build-only.bats index b3d0f1c7..b7bfe729 100644 --- a/test/build-only.bats +++ b/test/build-only.bats @@ -83,7 +83,7 @@ centos: from: type: oci url: $CENTOS_OCI - import: https://www.cisco.com/favicon.ico + imports: https://www.cisco.com/favicon.ico run: | cp /stacker/imports/favicon.ico /favicon.ico build_only: true @@ -91,7 +91,7 @@ layer1: from: type: built tag: centos - import: + imports: - stacker://centos/favicon.ico run: - cp /stacker/imports/favicon.ico /favicon2.ico @@ -108,7 +108,7 @@ centos: from: type: oci url: $CENTOS_OCI - import: https://www.cisco.com/favicon.ico + imports: https://www.cisco.com/favicon.ico run: | cp /stacker/imports/favicon.ico /favicon.ico build_only: true @@ -116,7 +116,7 @@ layer1: from: type: built tag: centos - import: + imports: - stacker://centos/favicon.ico run: - cp /stacker/imports/favicon.ico /favicon2.ico diff --git a/test/caching.bats b/test/caching.bats index 8681ed79..538dd3ea 100644 --- a/test/caching.bats +++ b/test/caching.bats @@ -52,7 +52,7 @@ base: from: type: built tag: build-base - import: + imports: - foo run: | cp /stacker/imports/foo /foo @@ -71,7 +71,7 @@ import-cache: from: type: oci url: $CENTOS_OCI - import: + imports: - link/foo run: cp /stacker/imports/foo/zomg /zomg EOF @@ -95,7 +95,7 @@ a: from: type: oci url: $CENTOS_OCI - import: + imports: - foo run: | [ -f /stacker/imports/foo/bar ] @@ -111,7 +111,7 @@ a: from: type: oci url: $CENTOS_OCI - import: + imports: - foo run: | [ ! -f /stacker/imports/foo/bar ] @@ -126,7 +126,7 @@ bind-test: from: type: oci url: ${{CENTOS_OCI}} - import: + imports: - tree1/foo/zomg binds: - ${{bind_path}} -> /root/tree2/foo @@ -169,7 +169,7 @@ mode-test: from: type: oci url: $CENTOS_OCI - import: + imports: - executable run: cp /stacker/imports/executable /executable EOF @@ -185,6 +185,7 @@ EOF } @test "can read previous version's cache" { + skip "old version does not support imports (plural) directive" # some additional testing that the cache can be read by older versions of # stacker (cache_test.go has the full test for the type, this just checks # the mechanics of filepaths and such) @@ -204,7 +205,7 @@ test: from: type: oci url: $CENTOS_OCI - import: + imports: - foo run: cp /stacker/imports/foo /foo EOF diff --git a/test/cp-not-required.bats b/test/cp-not-required.bats index 137f9689..ad935dc5 100644 --- a/test/cp-not-required.bats +++ b/test/cp-not-required.bats @@ -27,7 +27,7 @@ contents2: from: type: built tag: build - import: + imports: - stacker://contents/first - stacker://contents/second run: | diff --git a/test/dependency-order.bats b/test/dependency-order.bats index 7240d62e..133a0cca 100644 --- a/test/dependency-order.bats +++ b/test/dependency-order.bats @@ -27,7 +27,7 @@ test: from: type: oci tag: $CENTOS_OCI - import: + imports: - stacker://foo/bar - stacker://baz/foo EOF @@ -74,7 +74,7 @@ installer-iso-build: type: built tag: minbase1 build_only: true - import: + imports: - stacker://installer-initrd/output/installer-initrd-base.cpio - stacker://installer-initrd-modules/output/installer-initrd-modules.cpio run: | diff --git a/test/docker-base.bats b/test/docker-base.bats index 92ff3613..26b7aacc 100644 --- a/test/docker-base.bats +++ b/test/docker-base.bats @@ -14,7 +14,7 @@ centos: from: type: docker url: oci:${CENTOS_OCI} - import: + imports: - https://www.cisco.com/favicon.ico run: | cp /stacker/imports/favicon.ico /favicon.ico diff --git a/test/import-http.bats b/test/import-http.bats index 1541821e..a0cdc404 100644 --- a/test/import-http.bats +++ b/test/import-http.bats @@ -23,7 +23,7 @@ img: from: type: oci url: $(pwd)/oci:centos_base - import: + imports: - http://network-test.debian.org/nm run: | cp /stacker/imports/nm /root/nm @@ -79,7 +79,7 @@ centos_base: from: type: oci url: $CENTOS_OCI - import: + imports: - path: https://www.cisco.com/favicon.ico dest: /dest/icon run: | diff --git a/test/import.bats b/test/import.bats index f8b77c6a..f161dda4 100644 --- a/test/import.bats +++ b/test/import.bats @@ -15,7 +15,7 @@ thing: from: type: oci url: $CENTOS_OCI - import: + imports: - https://bing.com/favicon.ico EOF stacker build @@ -35,7 +35,7 @@ centos: from: type: oci url: $CENTOS_OCI - import: + imports: - recursive run: | [ -d /stacker/imports/recursive ] @@ -53,7 +53,7 @@ first: from: type: oci url: $CENTOS_OCI - import: + imports: - recursive run: | [ -d /stacker/imports/recursive ] @@ -63,7 +63,7 @@ second: from: type: oci url: $CENTOS_OCI - import: + imports: - stacker://first/recursive run: | [ -d /stacker/imports/recursive ] @@ -82,7 +82,7 @@ first: from: type: oci url: $CENTOS_OCI - import: + imports: - path: test_file hash: $test_file_sha - test_file2 @@ -96,7 +96,7 @@ second: from: type: built tag: first - import: + imports: - path: stacker://first/test_file hash: $test_file_sha run: | @@ -113,7 +113,7 @@ centos: from: type: oci url: $CENTOS_OCI - import: + imports: - path: test_file hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b856 EOF @@ -128,7 +128,7 @@ centos: from: type: oci url: $CENTOS_OCI - import: + imports: - path: test_file hash: 1234abcdef EOF @@ -145,7 +145,7 @@ first: from: type: oci url: $CENTOS_OCI - import: + imports: - path: test_file hash: $test_file_sha run: | @@ -155,7 +155,7 @@ second: from: type: built tag: first - import: + imports: - path: stacker://first/test_file hash: $test_file_sha_upper run: | @@ -173,7 +173,7 @@ thing: from: type: oci url: $CENTOS_OCI - import: + imports: - path: https://www.google.com/favicon.ico hash: $google_sha run: | @@ -190,7 +190,7 @@ thing: from: type: oci url: $CENTOS_OCI - import: + imports: - path: https://www.google.com/favicon.ico hash: 0d4856785d1d3c3aad3e5311e654c70c19d335f927c24ebb89dfcd52b2d988cb EOF @@ -209,7 +209,7 @@ thing: from: type: oci url: $CENTOS_OCI - import: + imports: - path: https://www.google.com/favicon.ico hash: $google_sha - path: test_file @@ -232,7 +232,7 @@ thing: from: type: oci url: $CENTOS_OCI - import: + imports: - path: https://www.google.com/favicon.ico - path: test_file hash: $test_file_sha @@ -250,7 +250,7 @@ thing: from: type: oci url: $CENTOS_OCI - import: + imports: - path: https://www.google.com/favicon.ico hash: $google_sha - path: test_file @@ -265,7 +265,7 @@ centos: from: type: oci url: $CENTOS_OCI - import: + imports: - "zomg" - - "one" - "two" @@ -279,7 +279,7 @@ centos: from: type: oci url: $CENTOS_OCI - import: + imports: - dir run: | find /stacker @@ -307,7 +307,7 @@ first: from: type: oci url: $CENTOS_OCI - import: + imports: - path: test_file hash: $test_file_sha - test_file2 @@ -321,7 +321,7 @@ second: from: type: built tag: first - import: + imports: - path: stacker://first/test_file perms: 0777 hash: $test_file_sha @@ -330,7 +330,7 @@ second: third: from: type: scratch - import: + imports: - path: stacker://first/test_file mode: 0777 hash: $test_file_sha @@ -338,7 +338,7 @@ third: fourth: from: type: scratch - import: + imports: - path: test_file hash: $test_file_sha mode: 0777 @@ -348,7 +348,7 @@ fourth: fifth: from: type: scratch - import: + imports: - path: test_file dest: /files/ - path: test_file2 @@ -357,7 +357,7 @@ sixth: from: type: docker url: oci:${UBUNTU_OCI} - import: + imports: - stacker://fifth/files/test_file - stacker://fifth/file2 run: | @@ -365,7 +365,7 @@ sixth: seventh: from: type: scratch - import: + imports: - path: test_file dest: /files/ - path: test_file2 @@ -376,7 +376,7 @@ eigth: from: type: docker url: oci:${UBUNTU_OCI} - import: + imports: - path: test_file dest: /dir/files/ - path: test_file2 @@ -403,7 +403,7 @@ first: from: type: oci url: $CENTOS_OCI - import: + imports: - path: folder1/ dest: /folder1/ run: | @@ -422,7 +422,7 @@ third: from: type: oci url: $CENTOS_OCI - import: + imports: - path: stacker://second/folder1/ dest: /folder1/ run: | @@ -433,7 +433,7 @@ fourth: from: type: oci url: $CENTOS_OCI - import: + imports: - path: folder1/ dest: / run: | @@ -446,7 +446,7 @@ fifth: from: type: oci url: $CENTOS_OCI - import: + imports: - path: folder1/subfolder2/ dest: /folder3/ - path: folder1/subfolder2 @@ -477,7 +477,7 @@ src_folder_dest_non_existent_folder_case1: from: type: docker url: oci:${UBUNTU_OCI} - import: + imports: - path: folder1 dest: /folder2 run: | @@ -487,7 +487,7 @@ src_folder_dest_non_existent_folder_case2: from: type: docker url: oci:${UBUNTU_OCI} - import: + imports: - path: folder1/ dest: /folder2 run: | @@ -497,7 +497,7 @@ src_folder_dest_non_existent_folder_case3: from: type: docker url: oci:${UBUNTU_OCI} - import: + imports: - path: folder1 dest: /folder2/ run: | @@ -509,7 +509,7 @@ src_folder_dest_non_existent_folder_case4: from: type: docker url: oci:${UBUNTU_OCI} - import: + imports: - path: folder1/ dest: /folder2/ run: | @@ -517,3 +517,30 @@ src_folder_dest_non_existent_folder_case4: EOF stacker build } + +@test "legacy imports" { + echo "file1-content" > file1.txt + cat > stacker.yaml < stacker.yaml <