From 4614ce286b2d070ff83d9809cc5527eab36edb2c Mon Sep 17 00:00:00 2001 From: Airren Date: Tue, 14 Feb 2023 16:19:44 +0800 Subject: [PATCH] add docker test Signed-off-by: Airren --- .gitignore | 1 + coreutils/testcase/tc-docoker.sh | 153 +++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 .gitignore create mode 100755 coreutils/testcase/tc-docoker.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/coreutils/testcase/tc-docoker.sh b/coreutils/testcase/tc-docoker.sh new file mode 100755 index 0000000..53fc070 --- /dev/null +++ b/coreutils/testcase/tc-docoker.sh @@ -0,0 +1,153 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20230106-200139-xxxxxxxxx +# @用例名称: tc-docker +# @用例级别: 3 +# @用例标签: +# @用例类型: 功能 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +############################################################################### + +OS_ARCH='amd64' + +PROXY=${https_proxy} + +DOCKER_VERSION='23.0.1' +BUILDX_VERSION='v0.10.2' +CONTAINERD_VERSION='1.6.16' +RUNC_VERSION='v1.1.4' + +#---------------------------- Install Runc ------------------------------------- +function install_runc() { + wget https://github.com/opencontainers/runc/releases/download/${RUNC_VERSION}/runc.${OS_ARCH} + sudo install -m 755 runc.amd64 /usr/local/sbin/runc +} + +#-------------------------- Install Containerd --------------------------------- +function install_containerd() { + CONTAINERD_FILE=containerd-${CONTAINERD_VERSION}-linux-${OS_ARCH}.tar.gz + wget https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERSION}/${CONTAINERD_FILE} + sudo tar Czxvf /usr/local ./${CONTAINERD_FILE} + + wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service + sudo mv containerd.service /usr/lib/systemd/system/ + sudo systemctl daemon-reload + sudo systemctl enable --now containerd + sudo systemctl status containerd +} + +#---------------------------- Install Docker ----------------------------------- +function install_docker() { + DOCKER_FILE=docker-${DOCKER_VERSION}.tgz + wget https://download.docker.com/linux/static/stable/x86_64/${DOCKER_FILE} + + tar xzvf ./${DOCKER_FILE} + sudo cp docker/* /usr/bin/ + + sudo groupadd docker + sudo usermod -aG docker $USER + + wget https://raw.githubusercontent.com/moby/moby/master/contrib/init/systemd/docker.service + wget https://raw.githubusercontent.com/moby/moby/master/contrib/init/systemd/docker.socket + sudo mv docker.service docker.socket /usr/lib/systemd/system/ + sudo systemctl daemon-reload + sudo systemctl enable --now docker + sudo systemctl status docker + sleep 10s + +} + +function install_buildx() { + BUILDX_FILE=buildx-${BUILDX_VERSION}.linux-${OS_ARCH} + wget https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/${BUILDX_FILE} + + sudo mv ./${BUILDX_FILE} /usr/bin/buildx +} + +function set_proxy_for_docker() { + echo ">>>>>>>>>>>>>>>>>>>>>>> Set Proxy for Docker <<<<<<<<<<<<<<<<<<<<<<<<" + sudo mkdir -p /etc/systemd/system/docker.service.d + cat <Dockerfile + + assert_true docker build -t registry.cn-shanghai.aliyuncs.com/aaron-share/ubuntu-server:latest . + popd + + # docker run -i --rm \ + # --name testng-in-docker -v "$(pwd)":/usr/src/mymaven -v ~/.m2:/root/.m2 -w /usr/src/mymaven maven:latest + # mvn clean test + + return 0 +} + +tc_teardown() { + msg "clean the download file" + rm -rfv "$g_tmpdir" || return 1 + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### -- Gitee