Skip to content

Commit d2eda1a

Browse files
bauderh-atomic-bot
authored andcommitted
Enhancements to papr tests
The PR contains several enhancements to our CI testing. - enable lint testing on Fedora - add Centos Atomic as test platform - integration tests on run on the OS natively (uncontainerized) - builds are done in containers - inclusion of Vagrant file for local testing Signed-off-by: baude <[email protected]> Closes: containers#18 Approved by: mheon
1 parent bf8b9a3 commit d2eda1a

38 files changed

+441
-338
lines changed

Diff for: .papr.sh

+91-27
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,101 @@
11
#!/bin/bash
22
set -xeuo pipefail
33

4-
export GOPATH=$HOME/gopath
4+
DIST=$(cat /etc/redhat-release | awk '{print $1}')
5+
IMAGE=registry.fedoraproject.org/fedora:26
6+
PACKAGER=dnf
7+
if [[ ${DIST} != "Fedora" ]]; then
8+
PACKAGER=yum
9+
IMAGE=registry.centos.org/centos/centos:7
10+
fi
11+
12+
if test -z "${INSIDE_CONTAINER:-}"; then
13+
if [ -f /run/ostree-booted ]; then
14+
15+
# by default, the root LV on AH is only 3G, but we need a
16+
# bit more for our tests
17+
lvresize -r -L +4G atomicos/root
18+
19+
if [ ! -e /var/tmp/ostree-unlock-ovl.* ]; then
20+
ostree admin unlock
21+
fi
22+
fi
23+
# Restarting docker helps with permissions related to above.
24+
systemctl restart docker
25+
26+
# somewhat mimic the spec conditional
27+
source /etc/os-release
28+
if [ "$ID" == fedora ]; then
29+
PYTHON=python3
30+
else
31+
PYTHON=python
32+
fi
33+
docker run --rm \
34+
--privileged \
35+
-v $PWD:/go/src/github.com/projectatomic/libpod \
36+
-v /etc/yum.repos.d:/etc/yum.repos.d.host:ro \
37+
-v /:/host \
38+
--workdir /go/src/github.com/projectatomic/libpod \
39+
-e INSIDE_CONTAINER=1 \
40+
-e PYTHON=$PYTHON \
41+
${IMAGE} /go/src/github.com/projectatomic/libpod/.papr.sh
42+
systemd-detect-virt
43+
./test/test_runner.sh
44+
exit 0
45+
fi
46+
47+
export GOPATH=/go
548
export PATH=$HOME/gopath/bin:$PATH
6-
export GOSRC=$HOME/gopath/src/github.com/projectatomic/libpod
7-
8-
(mkdir -p $GOSRC && cd /code && cp -r . $GOSRC)
9-
10-
dnf install -y \
11-
bats \
12-
btrfs-progs-devel \
13-
bzip2 \
14-
device-mapper-devel \
15-
findutils \
16-
git \
17-
glib2-devel \
18-
gnupg \
19-
golang \
20-
gpgme-devel \
21-
libassuan-devel \
22-
libseccomp-devel \
23-
libselinux-devel \
24-
skopeo-containers \
25-
runc \
26-
make \
27-
ostree-devel \
28-
python \
29-
which
49+
export GOSRC=/$GOPATH/src/github.com/projectatomic/libpod
50+
51+
${PACKAGER} install -y \
52+
bats \
53+
btrfs-progs-devel \
54+
bzip2 \
55+
device-mapper-devel \
56+
findutils \
57+
git \
58+
glib2-devel \
59+
gnupg \
60+
golang \
61+
gpgme-devel \
62+
libassuan-devel \
63+
libseccomp-devel \
64+
libselinux-devel \
65+
skopeo-containers \
66+
runc \
67+
make \
68+
ostree-devel \
69+
python \
70+
which\
71+
golang-github-cpuguy83-go-md2man
72+
3073

3174
# PAPR adds a merge commit, for testing, which fails the
3275
# short-commit-subject validation test, so tell git-validate.sh to only check
3376
# up to, but not including, the merge commit.
3477
export GITVALIDATE_TIP=$(cd $GOSRC; git log -2 --pretty='%H' | tail -n 1)
3578
export TAGS="seccomp $($GOSRC/hack/btrfs_tag.sh) $($GOSRC/hack/libdm_tag.sh) $($GOSRC/hack/btrfs_installed_tag.sh) $($GOSRC/hack/ostree_tag.sh) $($GOSRC/hack/selinux_tag.sh)"
36-
make -C $GOSRC binaries install.tools all gofmt localintegration testunit TAGS="${TAGS}"
37-
#make -C $GOSRC lint
79+
80+
make gofmt TAGS="${TAGS}"
81+
make testunit TAGS="${TAGS}"
82+
make install.tools TAGS="${TAGS}"
83+
84+
# Only check lint and gitvalidation on more recent
85+
# distros with updated git and tooling
86+
if [[ ${PACKAGER} != "yum" ]]; then
87+
HEAD=$GITVALIDATE_TIP make -C $GOSRC .gitvalidation TAGS="${TAGS}"
88+
make lint
89+
dnf install -y --installroot /host bats
90+
fi
91+
92+
make TAGS="${TAGS}"
93+
make TAGS="${TAGS}" install PREFIX=/host/usr
94+
make TAGS="${TAGS}" test-binaries
95+
96+
if [[ ${PACKAGER} == "yum" ]]; then
97+
# Install EPEL to get Bats
98+
${PACKAGER} -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
99+
${PACKAGER} install --downloadonly --downloaddir=/tmp bats
100+
cd /host && rpm2cpio /tmp/bats*.rpm | cpio -ivd
101+
fi

Diff for: .papr.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ required: true
1313
timeout: 45m
1414

1515
tests:
16-
# mount yum repos to inherit injected mirrors from PAPR
17-
- docker run --net=host --privileged -v /etc/yum.repos.d:/etc/yum.repos.d.host:ro
18-
-v /tmp:/tmp -v /var/tmp:/var/tmp
19-
-v $PWD:/code registry.fedoraproject.org/fedora:26 sh -c
20-
"cp -fv /etc/yum.repos.d{.host/*.repo,} && /code/.papr.sh"
16+
- CRIO_ROOT=/var/tmp/checkout KPOD_BINARY=/usr/bin/kpod CONMON_BINARY=/usr/libexec/crio/conmon PAPR=1 sh .papr.sh
17+
18+
---
19+
20+
inherit: true
21+
host:
22+
distro: centos/7/atomic/alpha
23+
specs:
24+
ram: 8192
25+
26+
context: centos/7/atomic/alpha

Diff for: .tool/lint

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ if [ ! -f ${LINTER} ]; then
1313
exit 1
1414
fi
1515

16-
PKGS=$(find . -type d -not -path . -a -not -iwholename '*.git*' -a -not -iname '.tool' -a -not -iwholename '*vendor*' -a -not -iname 'hack' -a -not -iwholename '*.artifacts*' -a -not -iwholename '*contrib*' -a -not -iwholename '*test*' -a -not -iwholename '*logo*' -a -not -iwholename '*conmon*' -a -not -iwholename '*completions*' -a -not -iwholename '*docs*' -a -not -iwholename '*pause*')
16+
PKGS=$(find . -type d -not -path . -a -not -iwholename '*.git*' -a -not -iname '.tool' -a -not -iwholename '*vendor*' -a -not -iname 'hack' -a -not -iwholename '*.artifacts*' -a -not -iwholename '*contrib*' -a -not -iwholename '*test*' -a -not -iwholename '*logo*' -a -not -iwholename '*conmon*' -a -not -iwholename '*completions*' -a -not -iwholename '*docs*' -a -not -iwholename '*pause*' -a -not -iwholename './_output*')
17+
18+
echo $PKGS
1719

1820
# Execute the linter
1921
${LINTER} \
@@ -40,5 +42,6 @@ ${LINTER} \
4042
--exclude='duplicate of.*_test.go.*\(dupl\)$'\
4143
--exclude='cmd\/client\/.*\.go.*\(dupl\)$'\
4244
--exclude='vendor\/.*'\
45+
--exclude='kpod\/.*'\
4346
--exclude='server\/seccomp\/.*\.go.*$'\
4447
${PKGS[@]}

Diff for: .travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ before_script:
2525
- export PATH=$HOME/gopath/bin:$PATH
2626
- export LD_LIBRARY_PATH=/usr/local/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
2727

28+
env:
29+
global:
30+
- TRAVIS=1
31+
2832
jobs:
2933
include:
3034
- stage: Build and Verify

Diff for: Makefile

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
GO ?= go
2-
EPOCH_TEST_COMMIT ?= 2b74391
2+
EPOCH_TEST_COMMIT ?= 5cfd7a3
3+
HEAD ?= HEAD
34
PROJECT := github.com/projectatomic/libpod
45
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
56
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
@@ -41,6 +42,8 @@ KPOD_LDFLAGS := -X main.kpodVersion=${KPOD_VERSION}
4142
LDFLAGS := -ldflags '${BASE_LDFLAGS}'
4243
LDFLAGS_KPOD := -ldflags '${BASE_LDFLAGS} ${KPOD_LDFLAGS}'
4344

45+
BOX="fedora_atomic"
46+
4447
all: binaries docs
4548

4649
default: help
@@ -114,6 +117,9 @@ testunit:
114117
localintegration: test-binaries
115118
bash -i ./test/test_runner.sh ${TESTFLAGS}
116119

120+
vagrant-check:
121+
BOX=$(BOX) sh ./vagrant.sh
122+
117123
binaries: conmon kpod
118124

119125
test-binaries: test/bin2img/bin2img test/copyimg/copyimg test/checkseccomp/checkseccomp
@@ -151,13 +157,8 @@ uninstall:
151157
done
152158

153159
.PHONY: .gitvalidation
154-
# When this is running in travis, it will only check the travis commit range
155160
.gitvalidation: .gopathok
156-
ifeq ($(TRAVIS),true)
157-
GIT_CHECK_EXCLUDE="./vendor" $(GOPATH)/bin/git-validation -q -run DCO,short-subject,dangling-whitespace
158-
else
159-
GIT_CHECK_EXCLUDE="./vendor" $(GOPATH)/bin/git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD
160-
endif
161+
GIT_CHECK_EXCLUDE="./vendor" $(GOPATH)/bin/git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..$(HEAD)
161162

162163
.PHONY: install.tools
163164

Diff for: Vagrantfile

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# All Vagrant configuration is done below. The "2" in Vagrant.configure
5+
# configures the configuration version (we support older styles for
6+
# backwards compatibility). Please don't change it unless you know what
7+
# you're doing.
8+
Vagrant.configure(2) do |config|
9+
config.vm.provider "libvirt" do |libvirt, override|
10+
libvirt.memory = 3096
11+
libvirt.cpus = 3
12+
libvirt.storage :file,
13+
:type => 'qcow2'
14+
end
15+
config.vm.synced_folder ".", "/home/vagrant/sync", disabled: true
16+
config.vm.synced_folder ".", "/home/vagrant/libpod", type: "rsync", rsync__exclude: ["_output"]
17+
18+
# The most common configuration options are documented and commented below.
19+
# For a complete reference, please see the online documentation at
20+
# https://docs.vagrantup.com.
21+
22+
# Every Vagrant development environment requires a box. You can search for
23+
# boxes at https://atlas.hashicorp.com/search.
24+
config.vm.define "fedora_atomic" do |fedora_atomic|
25+
fedora_atomic.vm.box = "fedora_atomic"
26+
fedora_atomic.vm.box_url = "https://getfedora.org/atomic_vagrant_libvirt_latest"
27+
end
28+
config.vm.define "centos_atomic" do |centos_atomic|
29+
centos_atomic.vm.box = "centos_atomic"
30+
centos_atomic.vm.box_url = "https://ci.centos.org/artifacts/sig-atomic/centos-continuous/images/cloud/latest/images/centos-atomic-host-7-vagrant-libvirt.box"
31+
end
32+
config.vm.define "fedora_cloud" do |fedora_cloud|
33+
fedora_cloud.vm.box = "fedora/26-cloud-base"
34+
end
35+
end

Diff for: libpod/container.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,17 @@ func (c *Container) Attach(noStdin bool, keys string, attached chan<- bool) erro
411411
resize := make(chan remotecommand.TerminalSize)
412412
defer close(resize)
413413
err = c.attachContainerSocket(resize, noStdin, detachKeys, attached)
414-
if err != nil {
415-
return err
416-
}
414+
415+
return err
416+
417417
// TODO
418418
// Re-enable this when mheon is done wth it
419+
//if err != nil {
420+
// return err
421+
//}
419422
//c.ContainerStateToDisk(c)
420423

421-
return nil
424+
//return err
422425
}
423426

424427
// Mount mounts a container's filesystem on the host

Diff for: libpod/diff.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (r *Runtime) getLayerID(id string) (string, error) {
4444
return toLayer, nil
4545
}
4646

47-
func (r *Runtime) getLayerParent(layerID string) (string, error) {
47+
func (r *Runtime) getLayerParent(layerID string) (string, error) { //nolint
4848
layer, err := r.store.Layer(layerID)
4949
if err != nil {
5050
return "", err

Diff for: libpod/oci.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -256,18 +256,18 @@ func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string) error
256256

257257
// updateContainerStatus retrieves the current status of the container from the
258258
// runtime
259-
func (r *OCIRuntime) updateContainerStatus(ctr *Container) error {
259+
// remove nolint when implemented
260+
func (r *OCIRuntime) updateContainerStatus(ctr *Container) error { //nolint
260261
return ErrNotImplemented
261262
}
262263

263264
// startContainer starts the given container
264-
func (r *OCIRuntime) startContainer(ctr *Container) error {
265+
// remove nolint when function is complete
266+
func (r *OCIRuntime) startContainer(ctr *Container) error { //nolint
265267
// TODO: streams should probably *not* be our STDIN/OUT/ERR - redirect to buffers?
266-
if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, r.path, "start", ctr.ID()); err != nil {
267-
return err
268-
}
268+
err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, r.path, "start", ctr.ID())
269269

270270
// TODO record start time in container struct
271271

272-
return nil
272+
return err
273273
}

Diff for: libpod/runtime_ctr.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ func (r *Runtime) removeMultipleContainers(containers []storage.Container) error
223223
}
224224

225225
// ContainerConfigToDisk saves a container's nonvolatile configuration to disk
226-
func (r *Runtime) containerConfigToDisk(ctr *Container) error {
226+
// remove nolint when implemented
227+
func (r *Runtime) containerConfigToDisk(ctr *Container) error { //nolint
227228
return ErrNotImplemented
228229
}

Diff for: libpod/runtime_img.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ type Image struct {
118118
Name string
119119
ID string
120120
fqname string
121-
hasImageLocal bool
121+
hasImageLocal bool //nolint
122122
runtime *Runtime
123123
Registry string
124124
ImageName string
@@ -359,10 +359,7 @@ func (k *Image) HasLatest() (bool, error) {
359359
return false, err
360360
}
361361
_, _, err = pullRef.(types.ImageSource).GetManifest()
362-
if err != nil {
363-
return false, err
364-
}
365-
return false, nil
362+
return false, err
366363
}
367364

368365
// Pull is a wrapper function to pull and image
@@ -1155,7 +1152,8 @@ func ParseImageNames(names []string) (tags, digests []string, err error) {
11551152
return tags, digests, nil
11561153
}
11571154

1158-
func annotations(manifest []byte, manifestType string) map[string]string {
1155+
// Remove nolint when used
1156+
func annotations(manifest []byte, manifestType string) map[string]string { //nolint
11591157
annotations := make(map[string]string)
11601158
switch manifestType {
11611159
case ociv1.MediaTypeImageManifest:

Diff for: pkg/storage/image.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ func GetImageService(store storage.Store, defaultTransport string, insecureRegis
525525
is := &imageService{
526526
store: store,
527527
defaultTransport: defaultTransport,
528-
indexConfigs: make(map[string]*indexInfo, 0),
528+
indexConfigs: make(map[string]*indexInfo),
529529
insecureRegistryCIDRs: make([]*net.IPNet, 0),
530530
registries: cleanRegistries,
531531
}

0 commit comments

Comments
 (0)