Skip to content

Commit

Permalink
Merge pull request #2175 from Ace-Tang/criu_test
Browse files Browse the repository at this point in the history
test: install criu in ci test
  • Loading branch information
Wei Fu authored Aug 30, 2018
2 parents ef99853 + 14d08eb commit 009dff8
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ package-dependencies: ## install containerd, runc and lxcfs dependencies for pac
hack/install/install_containerd.sh
hack/install/install_lxcfs.sh
hack/install/install_runc.sh
hack/install/install_criu.sh

.PHONY: download-dependencies
download-dependencies: package-dependencies ## install dumb-init, local-persist, nsenter and CI tools dependencies
Expand Down
60 changes: 60 additions & 0 deletions hack/install/install_criu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash

set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")"
source "./check.sh"

# criu::ubuntu::install_dependencies will install dependencies packages.
criu::ubuntu::install_dependencies() {
apt-get install -y -q \
build-essential \
libnet1-dev \
libprotobuf-dev \
libprotobuf-c0-dev \
protobuf-c-compiler \
protobuf-compiler \
python-protobuf \
libnl-3-dev \
libcap-dev \
asciidoc
}

# criu::ubuntu::install will install criu from source.
criu::ubuntu::install() {
local tmpdir tag

tag="v3.10"
tmpdir="$(mktemp -d /tmp/criu-build-XXXXXX)"

git clone https://github.com/checkpoint-restore/criu.git "${tmpdir}/criu"
cd "${tmpdir}/criu"
git checkout "${tag}" -b "${tag}"
make
make install
}

main() {
local os_dist has_installed

has_installed="$(command -v criu || echo false)"
if [[ "${has_installed}" != "false" ]]; then
echo "criu has been installed!"
exit 0
fi

echo ">>>> install criu <<<<"

os_dist="$(detect_os)"
if [[ "${os_dist}" = "Ubuntu" ]]; then
criu::ubuntu::install_dependencies > /dev/null
criu::ubuntu::install > /dev/null
fi

# final check
command -v criu > /dev/null

echo
}

main
2 changes: 1 addition & 1 deletion hack/install/install_runc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -euo pipefail

readonly RUNC_VERSION="1.0.0-rc4-1"
readonly RUNC_VERSION="1.0.0-rc4-2"

# runc::check_version checks the command and the version.
runc::check_version() {
Expand Down
2 changes: 0 additions & 2 deletions hack/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ function install_criu
if grep -qi "ubuntu" /etc/issue ; then
apt-get update
apt-get install -y criu
else
yum install criu
fi
}

Expand Down
10 changes: 7 additions & 3 deletions test/cli_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"bufio"
"encoding/json"
"io/ioutil"
"os"
"os/exec"
"strings"

Expand Down Expand Up @@ -299,7 +301,6 @@ func (suite *PouchStartSuite) TestStartWithPidsLimit(c *check.C) {
command.PouchRun("start", name).Assert(c, icmd.Success)
}

/* comment on this after alibaba/runc project fixed can not restore bug
// TestStartFromCheckpoint tests start a container from a checkpoint
func (suite *PouchStartSuite) TestStartFromCheckpoint(c *check.C) {
SkipIfFalse(c, environment.IsCRIUExist)
Expand All @@ -315,10 +316,13 @@ func (suite *PouchStartSuite) TestStartFromCheckpoint(c *check.C) {

restoredContainer := "restoredContainer"
defer DelContainerForceMultyTime(c, restoredContainer)
command.PouchRun("create", "--name", restoredContainer, busyboxImage).Assert(c, icmd.Success)
// image busybox not have /proc directory, we need to start busybox image and stop it
// make /proc exist, then we can restore successful
command.PouchRun("run", "-d", "--name", restoredContainer, busyboxImage).Assert(c, icmd.Success)
command.PouchRun("stop", restoredContainer).Assert(c, icmd.Success)

command.PouchRun("start", "--checkpoint-dir", tmpDir, "--checkpoint", checkpoint, restoredContainer).Assert(c, icmd.Success)
}
*/

// TestStartMultiContainers tries to start more than one container.
func (suite *PouchStartSuite) TestStartMultiContainers(c *check.C) {
Expand Down

0 comments on commit 009dff8

Please sign in to comment.