[PATCH v2 lkp-tests 2/2] fix(iso2rootfs): support skipping iso that not used for dailybuild

[Why] Openeuler release two kinds of iso type now, we need to skip the released iso type that not used for dailybuild. [How] 1. Confirm whether the purpose is dailybuild by iso name. 2. Exit 0 while the released iso is not used for dailybuild. Signed-off-by: Yu Chuan <13186087857@163.com> --- tests/iso2rootfs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/iso2rootfs b/tests/iso2rootfs index 89328f2f4a9b..9e891d585681 100755 --- a/tests/iso2rootfs +++ b/tests/iso2rootfs @@ -22,6 +22,12 @@ log_info() echo "[INFO] $*" } +exit_info() +{ + log_info "$@" + exit 0 +} + die() { echo "[ERROR] $*" >&2 @@ -56,6 +62,26 @@ check_yaml_vars() done } +check_iso_name() +{ + local skipped_iso_prefixes + case ${iso_os} in + "openeuler") + skipped_iso_prefixes=("openEuler-2.0-SP8") + ;; + *) + return + ;; + esac + + local prefix + for prefix in "${skipped_iso_prefixes[@]}" + do + [[ ${ISO_NAME} != ${prefix}* ]] || + exit_info "${iso_os} haven't release new iso for openEuler, no need to generate rootfs" + done +} + get_daily_iso_checksum() { ISO_URL="$(curl "${iso_url_file}")" @@ -63,8 +89,10 @@ get_daily_iso_checksum() local pub_ip=$(echo "${iso_url_file}" | grep -oEw "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}") ISO_URL="$(curl "${iso_url_file}" |sed -r "s/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/${pub_ip}/g")" } + ISO_NAME=$(basename "$ISO_URL") ISO_CHECKSUM_URL="${ISO_URL}.sha256sum" + check_iso_name curl -o "${CHECKSUM_FILE_CACHE}.tmp" "${ISO_CHECKSUM_URL}" SHA256SUM_NET=$(awk '{print $1}' "${CHECKSUM_FILE_CACHE}.tmp") @@ -118,9 +146,8 @@ check_sha256sum_update() if [ "$SHA256SUM_CACHE" == "$SHA256SUM_NET" ] then - log_info "${iso_os} haven't release new iso, no need to generate rootfs" rm -f "${CHECKSUM_FILE_CACHE}.tmp" - exit 0 + exit_info "${iso_os} haven't release new iso, no need to generate rootfs" else log_info "${iso_os} release a new iso, start to generate rootfs ..." return -- 2.23.0

On Mon, Oct 19, 2020 at 04:03:36PM +0800, Yu Chuan wrote:
[Why] Openeuler release two kinds of iso type now, we need to skip the released iso type that not used for dailybuild.
[How] 1. Confirm whether the purpose is dailybuild by iso name. 2. Exit 0 while the released iso is not used for dailybuild.
Signed-off-by: Yu Chuan <13186087857@163.com> --- tests/iso2rootfs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/tests/iso2rootfs b/tests/iso2rootfs index 89328f2f4a9b..9e891d585681 100755 --- a/tests/iso2rootfs +++ b/tests/iso2rootfs @@ -22,6 +22,12 @@ log_info() echo "[INFO] $*" }
+exit_info() +{ + log_info "$@" + exit 0 +} + die() { echo "[ERROR] $*" >&2 @@ -56,6 +62,26 @@ check_yaml_vars() done }
+check_iso_name() +{ + local skipped_iso_prefixes + case ${iso_os} in + "openeuler") + skipped_iso_prefixes=("openEuler-2.0-SP8")
感觉这样的测试没抓住问题的本质 -- 想要的是xxx, 测试的却是yyy. 有什么办法直接测试xxx? 这样的测试就有鲁棒性. 上面的列表将来需要更新, 会有长期维护代价. Thanks, Fengguang
+ ;; + *) + return + ;; + esac + + local prefix + for prefix in "${skipped_iso_prefixes[@]}" + do + [[ ${ISO_NAME} != ${prefix}* ]] || + exit_info "${iso_os} haven't release new iso for openEuler, no need to generate rootfs" + done +} + get_daily_iso_checksum() { ISO_URL="$(curl "${iso_url_file}")" @@ -63,8 +89,10 @@ get_daily_iso_checksum() local pub_ip=$(echo "${iso_url_file}" | grep -oEw "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}") ISO_URL="$(curl "${iso_url_file}" |sed -r "s/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/${pub_ip}/g")" } + ISO_NAME=$(basename "$ISO_URL") ISO_CHECKSUM_URL="${ISO_URL}.sha256sum" + check_iso_name
curl -o "${CHECKSUM_FILE_CACHE}.tmp" "${ISO_CHECKSUM_URL}" SHA256SUM_NET=$(awk '{print $1}' "${CHECKSUM_FILE_CACHE}.tmp") @@ -118,9 +146,8 @@ check_sha256sum_update()
if [ "$SHA256SUM_CACHE" == "$SHA256SUM_NET" ] then - log_info "${iso_os} haven't release new iso, no need to generate rootfs" rm -f "${CHECKSUM_FILE_CACHE}.tmp" - exit 0 + exit_info "${iso_os} haven't release new iso, no need to generate rootfs" else log_info "${iso_os} release a new iso, start to generate rootfs ..." return -- 2.23.0

+check_iso_name() +{ + local skipped_iso_prefixes + case ${iso_os} in + "openeuler") + skipped_iso_prefixes=("openEuler-2.0-SP8")
感觉这样的测试没抓住问题的本质 -- 想要的是xxx, 测试的却是yyy. 有什么办法直接测试xxx? 这样的测试就有鲁棒性.
我们当前的检测iso更新的策略如下: 监测是不同os(如openeuler)的iso是否有发布更新,目前openeuler 提供的是一个iso的sha256sum文件,该文件会在每次发布新的iso时候被更新。 文件中有如下两个内容: - latest iso url; - latest iso sha256sum; 关于iso url中的iso名称,我咨询了下openeuler的iso版本发布的支持人员, 得到以下答复: - iso名称当前有两种,openEuler-2.0-SP8-xxx.iso,openEuler-20.03-xxx.iso; - 其中openEuler-2.0.SP8-xx.iso不是给我们用的; - 不确定以后是否会有用作新用途的iso加入进来; 所以我这边的策略是准备了一个array,用来填写要跳过的iso names,以后openeuler 若有新增则进行排除。
上面的列表将来需要更新, 会有长期维护代价.
所以说优化的话,限于上面说的背景,我能想到的是把array从记录要跳过的iso名, 换为记录要执行的iso名,但这样我觉得意义不是很大? 由于我这边暂时也没有其他好的思路,所以如果有好的办法来实现,还望不吝赐教~ -------- Thanks Yu Chuan
Thanks, Fengguang
+ ;; + *) + return + ;; + esac + + local prefix + for prefix in "${skipped_iso_prefixes[@]}" + do + [[ ${ISO_NAME} != ${prefix}* ]] || + exit_info "${iso_os} haven't release new iso for openEuler, no need to generate rootfs" + done +} + get_daily_iso_checksum() { ISO_URL="$(curl "${iso_url_file}")" @@ -63,8 +89,10 @@ get_daily_iso_checksum() local pub_ip=$(echo "${iso_url_file}" | grep -oEw "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}") ISO_URL="$(curl "${iso_url_file}" |sed -r "s/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/${pub_ip}/g")" } + ISO_NAME=$(basename "$ISO_URL") ISO_CHECKSUM_URL="${ISO_URL}.sha256sum" + check_iso_name
curl -o "${CHECKSUM_FILE_CACHE}.tmp" "${ISO_CHECKSUM_URL}" SHA256SUM_NET=$(awk '{print $1}' "${CHECKSUM_FILE_CACHE}.tmp") @@ -118,9 +146,8 @@ check_sha256sum_update()
if [ "$SHA256SUM_CACHE" == "$SHA256SUM_NET" ] then - log_info "${iso_os} haven't release new iso, no need to generate rootfs" rm -f "${CHECKSUM_FILE_CACHE}.tmp" - exit 0 + exit_info "${iso_os} haven't release new iso, no need to generate rootfs" else log_info "${iso_os} release a new iso, start to generate rootfs ..." return -- 2.23.0

On Tue, Oct 20, 2020 at 05:20:31PM +0800, Yu Chuan wrote:
+check_iso_name() +{ + local skipped_iso_prefixes
How about skipped_iso_prefixes => iso_prefixes_to_skip
+ case ${iso_os} in + "openeuler") + skipped_iso_prefixes=("openEuler-2.0-SP8")
感觉这样的测试没抓住问题的本质 -- 想要的是xxx, 测试的却是yyy. 有什么办法直接测试xxx? 这样的测试就有鲁棒性.
我们当前的检测iso更新的策略如下: 监测是不同os(如openeuler)的iso是否有发布更新,目前openeuler 提供的是一个iso的sha256sum文件,该文件会在每次发布新的iso时候被更新。 文件中有如下两个内容: - latest iso url; - latest iso sha256sum;
关于iso url中的iso名称,我咨询了下openeuler的iso版本发布的支持人员, 得到以下答复: - iso名称当前有两种,openEuler-2.0-SP8-xxx.iso,openEuler-20.03-xxx.iso; - 其中openEuler-2.0.SP8-xx.iso不是给我们用的; - 不确定以后是否会有用作新用途的iso加入进来;
所以我这边的策略是准备了一个array,用来填写要跳过的iso names,以后openeuler 若有新增则进行排除。
很好的总结! Sorry 我猜错了,还以为是要跟正常的release iso区别开来.. 上面的总结是不是可以写进changelog or comment? 中文的也行。比没有强多了。
上面的列表将来需要更新, 会有长期维护代价.
所以说优化的话,限于上面说的背景,我能想到的是把array从记录要跳过的iso名, 换为记录要执行的iso名,但这样我觉得意义不是很大?
由于我这边暂时也没有其他好的思路,所以如果有好的办法来实现,还望不吝赐教~
没问题. Thanks, Fengguang
+ ;; + *) + return + ;; + esac + + local prefix + for prefix in "${skipped_iso_prefixes[@]}" + do + [[ ${ISO_NAME} != ${prefix}* ]] || + exit_info "${iso_os} haven't release new iso for openEuler, no need to generate rootfs" + done +} + get_daily_iso_checksum() { ISO_URL="$(curl "${iso_url_file}")" @@ -63,8 +89,10 @@ get_daily_iso_checksum() local pub_ip=$(echo "${iso_url_file}" | grep -oEw "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}") ISO_URL="$(curl "${iso_url_file}" |sed -r "s/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/${pub_ip}/g")" } + ISO_NAME=$(basename "$ISO_URL") ISO_CHECKSUM_URL="${ISO_URL}.sha256sum" + check_iso_name
curl -o "${CHECKSUM_FILE_CACHE}.tmp" "${ISO_CHECKSUM_URL}" SHA256SUM_NET=$(awk '{print $1}' "${CHECKSUM_FILE_CACHE}.tmp") @@ -118,9 +146,8 @@ check_sha256sum_update()
if [ "$SHA256SUM_CACHE" == "$SHA256SUM_NET" ] then - log_info "${iso_os} haven't release new iso, no need to generate rootfs" rm -f "${CHECKSUM_FILE_CACHE}.tmp" - exit 0 + exit_info "${iso_os} haven't release new iso, no need to generate rootfs" else log_info "${iso_os} release a new iso, start to generate rootfs ..." return -- 2.23.0

On Tue, Oct 20, 2020 at 07:10:46PM +0800, Wu Fengguang wrote:
On Tue, Oct 20, 2020 at 05:20:31PM +0800, Yu Chuan wrote:
+check_iso_name() +{ + local skipped_iso_prefixes
How about
skipped_iso_prefixes => iso_prefixes_to_skip
Good, looks more clearly.
+ case ${iso_os} in + "openeuler") + skipped_iso_prefixes=("openEuler-2.0-SP8")
感觉这样的测试没抓住问题的本质 -- 想要的是xxx, 测试的却是yyy. 有什么办法直接测试xxx? 这样的测试就有鲁棒性.
我们当前的检测iso更新的策略如下: 监测是不同os(如openeuler)的iso是否有发布更新,目前openeuler 提供的是一个iso的sha256sum文件,该文件会在每次发布新的iso时候被更新。 文件中有如下两个内容: - latest iso url; - latest iso sha256sum;
关于iso url中的iso名称,我咨询了下openeuler的iso版本发布的支持人员, 得到以下答复: - iso名称当前有两种,openEuler-2.0-SP8-xxx.iso,openEuler-20.03-xxx.iso; - 其中openEuler-2.0.SP8-xx.iso不是给我们用的; - 不确定以后是否会有用作新用途的iso加入进来;
所以我这边的策略是准备了一个array,用来填写要跳过的iso names,以后openeuler 若有新增则进行排除。
很好的总结! Sorry 我猜错了,还以为是要跟正常的release iso区别开来.. 上面的总结是不是可以写进changelog or comment? 中文的也行。比没有强多了。
好的,我再改进下change log。 -------- Thanks Yu Chuan
上面的列表将来需要更新, 会有长期维护代价.
所以说优化的话,限于上面说的背景,我能想到的是把array从记录要跳过的iso名, 换为记录要执行的iso名,但这样我觉得意义不是很大?
由于我这边暂时也没有其他好的思路,所以如果有好的办法来实现,还望不吝赐教~
没问题.
Thanks, Fengguang
+ ;; + *) + return + ;; + esac + + local prefix + for prefix in "${skipped_iso_prefixes[@]}" + do + [[ ${ISO_NAME} != ${prefix}* ]] || + exit_info "${iso_os} haven't release new iso for openEuler, no need to generate rootfs" + done +} + get_daily_iso_checksum() { ISO_URL="$(curl "${iso_url_file}")" @@ -63,8 +89,10 @@ get_daily_iso_checksum() local pub_ip=$(echo "${iso_url_file}" | grep -oEw "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}") ISO_URL="$(curl "${iso_url_file}" |sed -r "s/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/${pub_ip}/g")" } + ISO_NAME=$(basename "$ISO_URL") ISO_CHECKSUM_URL="${ISO_URL}.sha256sum" + check_iso_name
curl -o "${CHECKSUM_FILE_CACHE}.tmp" "${ISO_CHECKSUM_URL}" SHA256SUM_NET=$(awk '{print $1}' "${CHECKSUM_FILE_CACHE}.tmp") @@ -118,9 +146,8 @@ check_sha256sum_update()
if [ "$SHA256SUM_CACHE" == "$SHA256SUM_NET" ] then - log_info "${iso_os} haven't release new iso, no need to generate rootfs" rm -f "${CHECKSUM_FILE_CACHE}.tmp" - exit 0 + exit_info "${iso_os} haven't release new iso, no need to generate rootfs" else log_info "${iso_os} release a new iso, start to generate rootfs ..." return -- 2.23.0
participants (2)
-
Wu Fengguang
-
Yu Chuan