Skip to content

Commit

Permalink
Initial testbench support
Browse files Browse the repository at this point in the history
    make testbench-check TELEPRESENCE_REGISTRY=docker.io/lukeshu PYTEST_ARGS="-m 'new and inject_tcp'"

The environments included were just taken verbatim from
testbench-demo.git, then beaten until `-m 'new and inject_tcp'` worked
correctly.
  • Loading branch information
LukeShu committed Dec 4, 2018
1 parent 6144723 commit e97c448
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ docs/.bundle
virtualenv
*/__pycache__
*cache*

environments
mkosi.cache
.mkosi*
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ gcloud-service-key.json
.idea
.vscode

# testbench
/mkosi.cache/
/testbench.html
*.tap
.mkosi*

# --- Docs ---
docs/book.json
docs/_book
Expand Down
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,17 @@ _pytest_env += TELEPRESENCE_VERSION=$(TELEPRESENCE_VERSION)
_pytest_env += SCOUT_DISABLE=1
check: virtualenv $(DOCKER_PUSH) ## Run the test suite (implies 'virtualenv' and '$(DOCKER_PUSH)')
sudo echo -n
$(VIRTUALENV) $(_pytest_env) py.test -v --timeout=360 --timeout-method=thread $(PYTEST_ARGS)
$(VIRTUALENV) $(_pytest_env) py.test -v --timeout=360 --timeout-method=thread $(PYTEST_ARGS) tests
.PHONY: check

_testbench_vars = TELEPRESENCE_REGISTRY=$(TELEPRESENCE_REGISTRY)
_testbench_vars += TELEPRESENCE_VERSION=$(TELEPRESENCE_VERSION)
_testbench_vars += DOCKER_PUSH=''
_testbench_vars += PYTEST_ARGS='$(call escape_squotes,--tap-combined $(PYTEST_ARGS))'
testbench-check: virtualenv $(DOCKER_PUSH) ## Run the test suite in testbench (implies 'virtualenv' and '$(DOCKER_PUSH)')
+testbench CMD='make check $(call escape_squotes,$(_testbench_vars)) >&2; cat testresults.tap'
.PHONY: testbench-check

docker-build: ## Build Docker images
docker build --file local-docker/Dockerfile . -t $(TELEPRESENCE_REGISTRY)/telepresence-local:$(TELEPRESENCE_VERSION)
docker build k8s-proxy -t $(TELEPRESENCE_REGISTRY)/telepresence-k8s:$(TELEPRESENCE_VERSION) --target telepresence-k8s
Expand All @@ -82,7 +90,8 @@ VIRTUALENV = PATH=$$PWD/virtualenv/bin:$$PATH
PIP = $(VIRTUALENV) env -u __PYENV_LAUNCHER__ pip
virtualenv: dev-requirements.txt k8s-proxy/requirements.txt ## Set up Python3 virtual environment for development
rm -rf $@ || true
virtualenv --python=python3 $@
virtualenv --python=python3 --always-copy $@
if [ ! -d virtualenv/lib64 ]; then ln -s lib virtualenv/lib64; fi
$(PIP) install flake8
$(PIP) install -r dev-requirements.txt
$(PIP) install -r k8s-proxy/requirements.txt
Expand Down Expand Up @@ -124,3 +133,8 @@ help: ## Show this message
@echo TARGETS:
@sed -n 's/:.*[#]#/:#/p' ${MAKEFILE_LIST} | column -t -c 2 -s ':#' | sed 's/^/ /'
.PHONY: help

# I put this as the last line in the file because it confuses Emacs
# syntax highlighting and makes the remainder of the file difficult to
# edit.
escape_squotes = $(subst ','\'',$1)
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mypy
pytest
pytest-xdist
pytest-timeout
pytest-tap
pyyaml
yapf
pylint
Expand Down
4 changes: 4 additions & 0 deletions environments/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*.knaut
/*.knaut.claim
/*.mk
/*.osi
27 changes: 27 additions & 0 deletions environments/archlinux.mkosi
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[Distribution]
Distribution=arch

[Output]
Bootable=yes

[Partitions]
RootSize=4G

[Packages]
Packages=
# Base OS
base
base-devel
networkmanager

# For AUR and for tests/utils.py
git

# For Telepresence
conntrack-tools
docker
fuse2
python-setuptools
sshfs
torsocks
WithNetwork=yes
4 changes: 4 additions & 0 deletions environments/archlinux.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
gpasswd -a testbench docker
systemctl enable docker
sudo -u testbench sh -c 'cd ~ && git clone https://aur.archlinux.org/kubectl-bin.git && cd kubectl-bin && makepkg --syncdeps --install --noconfirm --rmdeps'
29 changes: 29 additions & 0 deletions environments/debian.mkosi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[Distribution]
Distribution=debian

[Output]
Bootable=yes

[Partitions]
RootSize=4G

[Packages]
Packages=
# Base OS
ca-certificates
make
network-manager
sudo

# For tests/utils.py
git

# For Telepresence
conntrack
docker.io
kubernetes-client
libpython3.7
python3-setuptools
sshfs
torsocks
WithNetwork=yes
3 changes: 3 additions & 0 deletions environments/debian.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
gpasswd -a testbench docker
systemctl enable NetworkManager
28 changes: 28 additions & 0 deletions environments/fedora.mkosi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[Distribution]
Distribution=fedora

[Output]
Bootable=yes

[Partitions]
RootSize=4G

[Packages]
Packages=
# Base OS
@core
@standard
make

# For tests/utils.py
git

# For Telepresence
conntrack-tools
docker
fuse
kubernetes-client
python3-setuptools
sshfs
torsocks
WithNetwork=yes
5 changes: 5 additions & 0 deletions environments/fedora.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
sudo groupadd docker
gpasswd -a testbench docker
systemctl enable NetworkManager
systemctl enable docker

0 comments on commit e97c448

Please sign in to comment.