From f083f360455f15fcfca9075bf23282fe48210474 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 8 Nov 2019 16:01:53 +0900 Subject: [PATCH] .travis.yml: add cgroup v2 Vagrant box Signed-off-by: Akihiro Suda --- .travis.yml | 18 ++++++++++++++++++ paths_test.go | 3 +++ testutil_test.go | 30 ++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 testutil_test.go diff --git a/.travis.yml b/.travis.yml index 4f0fdc2a..cbab7de3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,27 @@ +dist: bionic language: go go: - 1.11.x - 1.12.x - 1.13.x +matrix: + include: + - env: + - VIRTUALBOX_VERSION=6.0 + - VAGRANT_VERSION=2.2.6 + - FEDORA_VERSION=31 + before_install: + - cat /proc/cpuinfo + - wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - && sudo sh -c "echo deb https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib >> /etc/apt/sources.list" && sudo apt-get update && sudo apt-get install -yq build-essential gcc make linux-headers-$(uname -r) virtualbox-${VIRTUALBOX_VERSION} && sudo usermod -aG vboxusers $(whoami) + - wget https://releases.hashicorp.com/vagrant/${VAGRANT_VERSION}/vagrant_${VAGRANT_VERSION}_$(uname -m).deb && sudo dpkg -i vagrant_${VAGRANT_VERSION}_$(uname -m).deb + - vagrant init bento/fedora-${FEDORA_VERSION} && vagrant up && mkdir -p ~/.ssh && vagrant ssh-config >> ~/.ssh/config + - ssh default sudo dnf install -y golang + script: + - ssh default sudo mkdir -p /go/src/github.com/containerd/cgroups + - cd $GOPATH/src/github.com/containerd/cgroups && tar c . | ssh default sudo tar Cx /go/src/github.com/containerd/cgroups + - ssh default sudo GOPATH=/go sh -c "cd /go/src/github.com/containerd/cgroups && go test -v ./..." + go_import_path: github.com/containerd/cgroups install: diff --git a/paths_test.go b/paths_test.go index affca0e6..6860dee0 100644 --- a/paths_test.go +++ b/paths_test.go @@ -114,6 +114,9 @@ func TestEmptySubsystem(t *testing.T) { } func TestSystemd240(t *testing.T) { + if isUnified { + t.Skipf("requires the system to be running in legacy mode") + } const data = `8:net_cls:/ 7:memory:/system.slice/docker.service 6:freezer:/ diff --git a/testutil_test.go b/testutil_test.go new file mode 100644 index 00000000..e78396e0 --- /dev/null +++ b/testutil_test.go @@ -0,0 +1,30 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package cgroups + +import ( + "golang.org/x/sys/unix" +) + +var isUnified bool + +func init() { + var st unix.Statfs_t + if err := unix.Statfs("/sys/fs/cgroup", &st); err == nil { + isUnified = st.Type == unix.CGROUP2_SUPER_MAGIC + } +}