Merge "Add tox functional testing for drivers"

This commit is contained in:
Zuul 2018-11-05 14:55:13 +00:00 committed by Gerrit Code Review
commit 6c461c3877
19 changed files with 74 additions and 6 deletions

View File

@ -0,0 +1,23 @@
zookeeper-servers:
- host: {zookeeper_host}
port: {zookeeper_port}
chroot: {zookeeper_chroot}
labels:
- name: kubernetes-namespace
min-ready: 1
- name: pod-fedora
min-ready: 1
providers:
- name: minikube
driver: kubernetes
context: minikube
pools:
- name: main
labels:
- name: kubernetes-namespace
type: namespace
- name: pod-fedora
type: pod
image: docker.io/fedora:28

View File

View File

@ -0,0 +1,40 @@
# Copyright (C) 2018 Red Hat
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from nodepool import tests
class TestKubernetes(tests.DBTestCase):
log = logging.getLogger("nodepool.TestKubernetes")
def setup_config(self, filename):
adjusted_filename = "functional/kubernetes/" + filename
return super().setup_config(adjusted_filename)
def test_basic(self):
configfile = self.setup_config('basic.yaml')
pool = self.useNodepool(configfile, watermark_sleep=1)
pool.start()
# Add something here to test for namespace/pods/whatever
namespace = self.waitForNodes("kubernetes-namespace", 1)
self.assertEqual(1, len(namespace))
self.assertEqual(namespace[0].connection_type, "namespace")
pod = self.waitForNodes("pod-fedora", 1)
self.assertEqual(1, len(pod))
self.assertEqual(pod[0].connection_type, "kubectl")

View File

View File

@ -21,7 +21,8 @@ from nodepool.driver import Drivers
class TestDrivers(tests.DBTestCase):
def setup_config(self, filename):
test_dir = os.path.dirname(__file__)
drivers_dir = os.path.join(os.path.dirname(test_dir), 'driver')
drivers_dir = os.path.join(
os.path.dirname(os.path.dirname(test_dir)), 'driver')
Drivers.load([drivers_dir])
return super().setup_config(filename)

View File

@ -1,7 +1,6 @@
- hosts: all
roles:
- role: bindep
bindep_profile: dev
tasks:
- name: Ensure nodepool services directories

View File

@ -1,5 +1,5 @@
- hosts: all
roles:
- install-nodepool
- install-kubernetes
- nodepool-k8s-functional
- role: tox
tox_envlist: functional_kubernetes

View File

@ -16,7 +16,7 @@ install_command = pip install {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
passenv = NODEPOOL_ZK_HOST
commands = stestr run --no-subunit-trace {posargs}
commands = stestr --test-path ./nodepool/tests/unit run --no-subunit-trace {posargs}
stestr slowest
[testenv:pep8]
@ -38,7 +38,7 @@ setenv =
{[testenv]setenv}
PYTHON=coverage run --source nodepool --parallel-mode
commands =
stestr run --no-subunit-trace {posargs}
stestr --test-path ./nodepool/tests/unit run --no-subunit-trace {posargs}
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
@ -54,6 +54,11 @@ commands =
basepython = python3
commands = {posargs}
[testenv:functional_kubernetes]
basepython = python3
commands = stestr --test-path ./nodepool/tests/functional/kubernetes run --no-subunit-trace {posargs}
stestr slowest
[flake8]
# These are ignored intentionally in openstack-infra projects;
# please don't submit patches that solely correct them or enable them.