mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-02-23 07:24:24 +01:00
ci: Add travis basic testing
Add basic a few tests to be run by travis. Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
15
.ci/run.sh
Executable file
15
.ci/run.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2018 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
export GOPATH="${GOPATH:-/tmp/go}"
|
||||
|
||||
script_dir="$(dirname $(readlink -f $0))"
|
||||
|
||||
sudo -E PATH="$PATH" bats "${script_dir}/../tests/image_creation.bats"
|
||||
20
.ci/setup.sh
Executable file
20
.ci/setup.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2018 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
#Note: If add clearlinux as supported CI use a stateless os-release file
|
||||
source /etc/os-release
|
||||
|
||||
if [ "$ID" == fedora ];then
|
||||
sudo -E dnf -y install automake bats
|
||||
elif [ "$ID" == ubuntu ];then
|
||||
#bats isn't available for Ubuntu trusty, need for travis
|
||||
sudo add-apt-repository -y ppa:duggan/bats
|
||||
sudo apt-get -qq update
|
||||
sudo apt-get install -y -qq automake bats qemu-utils
|
||||
else
|
||||
echo "Linux distribution not supported"
|
||||
fi
|
||||
19
.travis.yml
Normal file
19
.travis.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2018 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
language: bash
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_script:
|
||||
- ".ci/setup.sh"
|
||||
|
||||
script:
|
||||
- ".ci/run.sh"
|
||||
49
tests/image_creation.bats
Normal file
49
tests/image_creation.bats
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bats
|
||||
#
|
||||
# Copyright (c) 2018 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
||||
rootfs_sh="$BATS_TEST_DIRNAME/../rootfs-builder/rootfs.sh"
|
||||
image_builder_sh="$BATS_TEST_DIRNAME/../image-builder/image_builder.sh"
|
||||
readonly tmp_dir=$(mktemp -t -d osbuilder-test.XXXXXXX)
|
||||
#FIXME: Remove image size after https://github.com/kata-containers/osbuilder/issues/25 is fixed
|
||||
readonly image_size=400
|
||||
|
||||
|
||||
setup()
|
||||
{
|
||||
export USE_DOCKER=true
|
||||
}
|
||||
|
||||
teardown(){
|
||||
# Rootfs is own by root change it to remove it
|
||||
sudo rm -rf "${tmp_dir}/rootfs-osbuilder"
|
||||
rm -rf "${tmp_dir}"
|
||||
}
|
||||
|
||||
function build_image()
|
||||
{
|
||||
distro="$1"
|
||||
[ -n "$distro" ]
|
||||
local rootfs="${tmp_dir}/rootfs-osbuilder"
|
||||
sudo -E ${rootfs_sh} -r "${rootfs}" fedora
|
||||
sudo ${image_builder_sh} -s ${image_size} -o "${tmp_dir}/image.img" "${rootfs}"
|
||||
}
|
||||
|
||||
@test "Can create fedora image" {
|
||||
build_image fedora
|
||||
}
|
||||
|
||||
@test "Can create clearlinux image" {
|
||||
build_image clearlinux
|
||||
}
|
||||
|
||||
@test "Can create centos image" {
|
||||
build_image centos
|
||||
}
|
||||
|
||||
@test "Can create euleros image" {
|
||||
build_image euleros
|
||||
}
|
||||
Reference in New Issue
Block a user