forked from farcop/rules_docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
container_repro_test rule to test for container reproducibility (baze…
…lbuild#955) * container_repro_test rule to test for container reproducibility * buildifier and disable tests on buildkite * test * test * buildifier * address some comments * test * test with buildkite * enable testing toolchain_container targets * test without remote cache * address comments * buildifier * test * test * address comments and use migrated base_image_docker rules * fix test script * address comments
- Loading branch information
1 parent
00a517f
commit 63fd7c1
Showing
10 changed files
with
416 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2017 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Testing script consumed by the container_repro_test rule that compares | ||
# two images. | ||
# Two images are considered to be identical when they both have the same | ||
# digest and ID. On a mismatch of one of those values, the test fails | ||
# and produces the summary of the images' differences. | ||
|
||
set -e | ||
|
||
imgs_differ=false | ||
|
||
function cmp_sha_files() { | ||
local file1="${1}" | ||
local file2="${2}" | ||
local content_type="${3}" | ||
|
||
local diff_ret=0 | ||
diff $file1 $file2 || diff_ret=$? | ||
echo === Comparing image "${content_type}"s === | ||
if [ $diff_ret = 0 ]; then | ||
echo Both images have the same SHA256 "${content_type}": "$(<$file1)" | ||
else | ||
echo Images have different SHA256 "${content_type}"s | ||
echo First image "${content_type}": "$(<$file1)" | ||
echo Reproduced image "${content_type}": "$(<$file2)" | ||
imgs_differ=true | ||
fi | ||
} | ||
|
||
# Compare image digests. | ||
img1_digest_file=%{img1_path}/%{img_name}.digest | ||
img2_digest_file=%{img2_path}/%{img_name}.digest | ||
cmp_sha_files $img1_digest_file $img2_digest_file "digest" | ||
|
||
# Compare image IDs | ||
img1_id_file="$(readlink -f %{img1_path}/%{img_name}.id)" | ||
img2_id_file="$(readlink -f %{img2_path}/%{img_name}.id)" | ||
cmp_sha_files "$img1_id_file" "$img2_id_file" "ID" | ||
|
||
# Run the container_diff tool if images differ. | ||
if [ "$imgs_differ" = true ]; then | ||
echo === Images are different. Running container_diff tool === | ||
img1_tar=%{img1_path}/%{img_name}.tar | ||
img2_tar=%{img2_path}/%{img_name}.tar | ||
%{container_diff_tool} diff $img1_tar $img2_tar %{container_diff_args} | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
Oops, something went wrong.