End to end tests are tests which require a DC/OS cluster to run against. Each test spins up at least one cluster, and has the choice of configuring this cluster as appropriate. For example, a test may require a cluster with a certain number of agents, or certain configuration options.
Tests must be run in a supported environment. See "Test Environment".
To create tests using clusters with custom configurations, first install the harness:
pip install git+https://github.com/adamtheturtle/dcos-e2e.git@masterThen, create a test, such as the following:
import subprocess
from pathlib import Path
from dcos_e2e.backends import DCOS_Docker
from dcos_e2e.cluster import Cluster
class TestExample:
def test_example(self):
with Cluster(
extra_config={'check_time': True},
cluster_backend=DCOS_Docker(),
generate_config_path=Path('/tmp/dcos_generate_config.sh'),
) as cluster:
(master, ) = cluster.masters
result = master.run_as_root(args=['test', '-f', path])
print(result.stdout)
cluster.run_integration_tests(pytest_command=['pytest', '-x', 'test_tls.py'])
try:
master.run_as_root(args=['test', '-f', '/no/file/here'])
except subprocess.CalledProcessError:
print('No file exists')See API.md for details on the API.
See CONTRIBUTING.md for details on how to contribute to this repository.
Tests for this package and tests which use this package must be run on a host which is supported by DC/OS Docker. See the DC/OS Docker README.
With Vagrant and VirtualBox, it is possible to quickly get a test environment running.
Run the following commands to create an environment.
These commands will create a Vagrant VM with access to the files in the
directory from which they are launched.
These files will be at /vagrant in the VM.
# Download files from the DC/OS Docker repository to create a VM.
mkdir -p vagrant
cd vagrant
curl -O https://raw.githubusercontent.com/dcos/dcos-docker/master/vagrant/resize-disk.sh
curl -O https://raw.githubusercontent.com/dcos/dcos-docker/master/vagrant/vbox-network.sh
chmod +x resize-disk.sh
chmod +x vbox-network.sh
cd ..
curl -O https://raw.githubusercontent.com/dcos/dcos-docker/master/Vagrantfile
vagrant/resize-disk.sh 102400Then create a virtual environment:
vagrant ssh -c 'curl https://raw.githubusercontent.com/adamtheturtle/dcos-e2e/master/vagrant_create_env.sh | /bin/bash'
Then, to enter the environment, run the following:
laptop$ vagrant ssh
[root@vagrant]$ pyenv activate dcosThen install the dependencies of the package you want to test.
There is a common issue which causes error messages on old kernels. See moby/moby#5618. Optionally on the VM run the following commands to update the kernel:
sudo yum update -y kernel
rebootTests run with this harness clean up after themselves. However, if a test is interrupted, it can leave behind containers, volumes and files. To remove these, run the following:
docker stop $(docker ps -a -q --filter="name=dcos-e2e")
docker rm --volumes $(docker ps -a -q --filter="name=dcos-e2e")
docker volume prune --forceIf this repository is available, run make clean.
On macOS /tmp is a symlink to /private/tmp.
/tmp is used by the harness.
Docker for Mac must be configured to allow /private to be bind mounted into Docker containers.
This is the default.
See Docker > Preferences > File Sharing.
See "Cleaning up".