Skip to content

Commit

Permalink
ci: uconv reproduce only check layers
Browse files Browse the repository at this point in the history
Signed-off-by: yuchen.cc <[email protected]>
  • Loading branch information
yuchen0cc committed Jan 4, 2024
1 parent f2b4c77 commit d1332e9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ci/uconv_reproduce/ci-uconv-reproduce.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

apt install -y python3

convertor="/opt/overlaybd/snapshotter/convertor"
images=("centos:centos7.9.2009" "ubuntu:22.04" "redis:7.2.3" "wordpress:6.4.2" "nginx:1.25.3")
repo="registry.hub.docker.com/overlaybd"
Expand Down Expand Up @@ -29,7 +31,8 @@ do
for file in ${files[@]}
do
fn="${file}.json"
diff ${tmp_dir}/${fn} ${ci_base}/${img}/${fn}
# diff ${tmp_dir}/${fn} ${ci_base}/${img}/${fn}
python3 compare_layers.py ${file} ${tmp_dir}/${fn} ${ci_base}/${img}/${fn}
ret=$?
if [[ ${ret} -eq 0 ]]; then
echo "${prefix} ${img} ${file} consistent"
Expand Down
67 changes: 67 additions & 0 deletions ci/uconv_reproduce/compare_layers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import os, sys
import json


def compare_manifest(fa_conf, fb_conf):
fa_layers = fa_conf["layers"]
fb_layers = fb_conf["layers"]
if len(fa_layers) != len(fb_layers):
print("layer size diff: %d %d" % (len(fa_layers), len(fb_layers)))
return -1
ret = 0
for idx in range(0, len(fa_layers)):
has_diff = 0
if fa_layers[idx]["digest"] != fb_layers[idx]["digest"]:
print("layer %d digest diff: %s %s" % (idx, fa_layers[idx]["digest"], fb_layers[idx]["digest"]))
has_diff = -1
if fa_layers[idx]["size"] != fb_layers[idx]["size"]:
print("layer %d size diff: %s %s" % (idx, fa_layers[idx]["size"], fb_layers[idx]["size"]))
has_diff = -1
if has_diff == 0:
print("layer %d consistent" % idx)
else:
ret = -1
return ret


def compare_config(fa_conf, fb_conf):
fa_diffs = fa_conf["rootfs"]["diff_ids"]
fb_diffs = fb_conf["rootfs"]["diff_ids"]
if len(fa_diffs) != len(fb_diffs):
print("diff_ids size diff: %d %d" % (len(fa_diffs), len(fb_diffs)))
return -1
ret = 0
for idx in range(0, len(fa_diffs)):
if fa_diffs[idx] != fb_diffs[idx]:
print("diff_ids %d diff: %s %s" % (idx, fa_diffs[idx], fb_diffs[idx]))
ret = -1
else:
print("diff_ids %d consistent" % idx)
return ret


def main():
if len(sys.argv) < 4:
print("Usage: python3 %s <type> <fa> <fb>" % os.path.basename(sys.argv[0]))
ftype = sys.argv[1]
fa = sys.argv[2]
fb = sys.argv[3]
if not os.path.exists(fa):
print("file %s not exist" % fa)
return -1
if not os.path.exists(fb):
print("file %s not exist" % fb)
return -1
fa_conf = json.load(open(fa, 'r'))
fb_conf = json.load(open(fb, 'r'))
if ftype == "manifest":
sys.exit(compare_manifest(fa_conf, fb_conf))
elif ftype == "config":
sys.exit(compare_config(fa_conf, fb_conf))
else:
print("unknown type %s" % ftype)
sys.exit(-1)


if __name__ == '__main__':
main()
5 changes: 3 additions & 2 deletions cmd/ctr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ package main

import (
"fmt"
"math/rand"
"os"
"time"

"github.com/containerd/containerd/cmd/ctr/app"
"github.com/containerd/containerd/pkg/seed"
"github.com/urfave/cli"
)

func init() {
seed.WithTimeAndRand()
rand.Seed(time.Now().UnixNano())
}

var pluginCmds = []cli.Command{
Expand Down

0 comments on commit d1332e9

Please sign in to comment.