index 000000000..b77b890a9 --- /dev/null +++ b/tests/openeuler_docker @@ -0,0 +1,139 @@ +#!/bin/sh +# - dockerfile_url
+# exit 1 if openEuler failed +# exit 0 if +# - no centos support +# - centos failed
+. $LKP_SRC/lib/debug.sh +. $LKP_SRC/lib/log.sh
+[ -n "$dockerfile_url" ] || die "dockerfile_url is empty"
+cd $BENCHMARK_ROOT
+centos_one_ok=false
+fit_repo() +{
- yum reinstall -y git
- git clone "$dockerfile_url" || exit 0
- file_dir=$(find ./ -type f -name "*Dockerfile*" | xargs grep -HE '^FROM centos:(centos|)[78]')
you can just use: $(grep -rn -E '^FROM centos:(centos|)[78]')
- [ -n "$file_dir" ] || {
echo "current-repo not support centos"
exit 0
- }
+}
+openeuler_ready() +{
- docker load < $BENCHMARK_ROOT/openeuler_docker/openeuler-20.03-lts-v1.tar
+}
+centos_docker() +{
- flag=0
- i=1
- for file in $(find ./ -type f -name "*Dockerfile*" | xargs grep -HE '^FROM centos:(centos|)[78]' | awk -F: '{print $1}')
ditto
Thanks, Luan Shengde
- do
file_dir=${file%/*}
image=$(echo "$file" | awk -F '/' '{print $3}' | tr 'A-Z' 'a-z')
[ -n "$image" ] || image=${file#*/}_$i
if [ -f "$file_dir/build.sh" ] && [ -x "$file_dir/build.sh" ]; then
"$file_dir/build.sh" > /dev/null 2> /dev/null && {
centos_one_ok=true
handle_dockerfile
}
else
docker_build > /dev/null 2> /dev/null && {
centos_one_ok=true
handle_dockerfile
}
fi
let i++
- done
- [ "$centos_one_ok" == "false" ] && {
echo "centos all failed"
exit 0
- }
+}
+handle_FROM() +{
- sed -i "s/^FROM .*/FROM openeuler-20.03-lts:v1/g" "$file"
+}
+handle_epel() +{
- grep -qw "epel-release" "$file" && {
sed -i "s/epel-release/bash/g" "$file"
- }
+}
+handle_epelrpm() +{
- grep -qw "https://.*epel-release.*rpm" "$file" && {
sed -i "s|https://.*epel-release.*rpm|bash|g" "$file"
- }
+}
+handle_groupadd() +{
- grep -qw "groupadd*" "$file" && {
sed -i '/groupadd*/i\ yum -y install shadow && \\' "$file"
- }
+}
+handle_epel_repo() +{
- grep -qwE '.* wget .*(epel|CentOS-Base).repo' "$file" && {
sed 's|^|#|g' "$file"
- }
+}
+handle_dockerfile() +{
- flag=1
- handle_FROM
- handle_epel
- handle_groupadd
- docker_build "-openeuler"
- [ $? -ne 0 ] || docker_run "-openeuler"
+}
+docker_build() +{
- docker build -f "$file" -t "${image}$1" .
- [ $? -ne 0 ] && {
[ "$flag" == "1" ] && echo "${image}$1.build.fail: 1"
return 1
- }
- [ "$flag" == "1" ] && echo "${image}$1.build.success: 1"
- flag=0
+}
+docker_run() +{
- docker run -d --name "${image}" "${image}$1"
- docker_stats=$(docker inspect ${image} | grep Running | awk -F ' ' '{print $2}' | tr -d ',')
- [ $docker_stats == false ] && {
echo "${image}.run.fail: 1"
return 1
- }
- echo "${image}.run.success: 1"
+}
+docker_test() +{
- fit_repo
- openeuler_ready
- centos_docker
+}
+docker_test
2.23.0