Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Initial implementation of smoke tests #124

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

dongsupark
Copy link
Member

@dongsupark dongsupark commented Aug 28, 2017

A simple implementation of smoke tests based on Vagrant.

Fixes #56

@dongsupark dongsupark added this to the 0.2.0 milestone Aug 28, 2017
@dongsupark dongsupark self-assigned this Aug 28, 2017
@dongsupark dongsupark force-pushed the dongsu/smoke-test branch 2 times, most recently from d63d350 to 00a6c1b Compare August 29, 2017 09:40
@dongsupark dongsupark changed the title [WIP] Initial implementation of smoke tests Initial implementation of smoke tests Sep 8, 2017
@dongsupark
Copy link
Member Author

dongsupark commented Sep 8, 2017

This test works well when we run ./scripts/test-smoke.sh on our own. Next step would be to run the script automatically when each PR is made.

Unfortunately at the moment CI services like semaphoreCI or circleCI are based on Ubuntu 14.04, where neither vagrant nor VirtualBox is installed. So I wanted to somehow install vagrant & virtualbox from test-smoke.sh. It didn't work well, as there's no kernel tree inside chroot environment, which prevents vbox kernel modules from getting built. Anyway it's not a good idea at all to build kernel modules every time.

Next attempt was to make use of vagrant-libvirt, instead of virtualbox. Then we don't need to build vbox kernel modules at all. For that, I needed to support libvirt in Vagrantfile of kube-spawn. (See https://github.com/dongsupark/kube-spawn/tree/dongsu/smoke-test )
That works perfectly on most recent distros like Fedora 26, Ubuntu 17.04, but not on Ubuntu 14.04 of SemaphoreCI, where vagrant-libvirt package doesn't exist. Installing the package manually caused the whole dependency chain to be fetched. Not good at all.

So I would rather keep this PR based on virtualbox instead of libvirt. Maybe later when semaphoreCI supported Ubuntu 16.04, we will be able to make test-smoke.sh run integrated with semaphoreCI.

EDIT: Another issue is that /dev/net/tun is not available inside lxc containers provided by semaphoreCI and CircleCI. The result is KVM networking being completely unusable.

Copy link
Contributor

@schu schu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also create a deployment, a service for the deployment and test if the service is up and running?

set -o pipefail

CDIR=$(cd "$(dirname "$0")" && pwd)
cd "$CDIR"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better with pushd:

pushd "$CDIR"
trap 'popd' EXIT


echo "Test result: ${RES}"

vagrant halt fedora
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also go into trap.

@dongsupark
Copy link
Member Author

Updated.

  • added tests for creating deployments, services etc.
  • Fixed a name of Fedora Vagrant image.
  • Used trap for cleaning up.

@schu
Copy link
Contributor

schu commented Sep 25, 2017

As far as I can see, it doesn't test if the pods/services are actually running and reachable over the network endpoints. IMHO we should test this.

Copy link

@nhlfr nhlfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small stylistic nit

Vagrantfile Outdated
@@ -5,7 +5,7 @@ ENV["TERM"] = "xterm-256color"
ENV["LC_ALL"] = "en_US.UTF-8"

Vagrant.configure("2") do |config|
config.vm.box = "jhcook/fedora26" # defaults to fedora
config.vm.box = "fedora/26-cloud-base" # defaults to fedora
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase needed?

trap 'popd' EXIT

if ! vagrant version > /dev/null 2>&1; then
echo "Please install vagrant first"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentaions in this script are inconsistent. Sometimes you are using two spaces, sometimes tabs. Please choose the one pattern - I prefer tabs, but whatever you prefer WFM.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nhlfr Fixed the coding style, and removed "make vendor" from the build command.
It's working, but I'm not sure I'm satisfied with this PR yet.

Another side issue with semaphoreCI still remains: SemaphoreCI limits size of downloaded files for each build instance. ~500MB. As kube-spawn downloads more than that in the end, this script cannot be used for such CI services.

Copy link

@nhlfr nhlfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that only @schu's suggestion about checking network connectivity to pods/services needs to be implemented and after that we can merge this PR.

@dongsupark
Copy link
Member Author

@nhlfr Also I would need to change commands according to the new design of v0.2.
I would also need to try to run this PR on semaphore CI, to check if the total download size still exceeds the limit from the provider.
Also need to try either libvirt or virtualbox, etc.

The script `test-smoke.sh` launches a Vagrant VM based on Fedora 26,
to run smoke tests inside the VM for each build.
A simple implementation of smoke tests based on Vagrant.
It initializes a simple K8s cluster with 2 nodes, deploys an nginx
pod, a service for the deployment, and checks if it's running.

Fixes #56
@dongsupark
Copy link
Member Author

Rebased.
Updated every necessary change according to the redesigned CLI from the current master branch.
Added a connectivity test that exposes a deployment, and checks if the cluster IP is reachable from a node.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants