Merge "Add tox functional testing for drivers"
This commit is contained in:
commit
6c461c3877
23
nodepool/tests/fixtures/functional/kubernetes/basic.yaml
vendored
Normal file
23
nodepool/tests/fixtures/functional/kubernetes/basic.yaml
vendored
Normal 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
|
0
nodepool/tests/functional/__init__.py
Normal file
0
nodepool/tests/functional/__init__.py
Normal file
0
nodepool/tests/functional/kubernetes/__init__.py
Normal file
0
nodepool/tests/functional/kubernetes/__init__.py
Normal file
40
nodepool/tests/functional/kubernetes/test_kubernetes.py
Normal file
40
nodepool/tests/functional/kubernetes/test_kubernetes.py
Normal 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")
|
0
nodepool/tests/unit/__init__.py
Normal file
0
nodepool/tests/unit/__init__.py
Normal file
@ -21,7 +21,8 @@ from nodepool.driver import Drivers
|
|||||||
class TestDrivers(tests.DBTestCase):
|
class TestDrivers(tests.DBTestCase):
|
||||||
def setup_config(self, filename):
|
def setup_config(self, filename):
|
||||||
test_dir = os.path.dirname(__file__)
|
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])
|
Drivers.load([drivers_dir])
|
||||||
return super().setup_config(filename)
|
return super().setup_config(filename)
|
||||||
|
|
@ -1,7 +1,6 @@
|
|||||||
- hosts: all
|
- hosts: all
|
||||||
roles:
|
roles:
|
||||||
- role: bindep
|
- role: bindep
|
||||||
bindep_profile: dev
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Ensure nodepool services directories
|
- name: Ensure nodepool services directories
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
- hosts: all
|
- hosts: all
|
||||||
roles:
|
roles:
|
||||||
- install-nodepool
|
|
||||||
- install-kubernetes
|
- install-kubernetes
|
||||||
- nodepool-k8s-functional
|
- role: tox
|
||||||
|
tox_envlist: functional_kubernetes
|
||||||
|
9
tox.ini
9
tox.ini
@ -16,7 +16,7 @@ install_command = pip install {opts} {packages}
|
|||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
passenv = NODEPOOL_ZK_HOST
|
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
|
stestr slowest
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
@ -38,7 +38,7 @@ setenv =
|
|||||||
{[testenv]setenv}
|
{[testenv]setenv}
|
||||||
PYTHON=coverage run --source nodepool --parallel-mode
|
PYTHON=coverage run --source nodepool --parallel-mode
|
||||||
commands =
|
commands =
|
||||||
stestr run --no-subunit-trace {posargs}
|
stestr --test-path ./nodepool/tests/unit run --no-subunit-trace {posargs}
|
||||||
coverage combine
|
coverage combine
|
||||||
coverage html -d cover
|
coverage html -d cover
|
||||||
coverage xml -o cover/coverage.xml
|
coverage xml -o cover/coverage.xml
|
||||||
@ -54,6 +54,11 @@ commands =
|
|||||||
basepython = python3
|
basepython = python3
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
|
[testenv:functional_kubernetes]
|
||||||
|
basepython = python3
|
||||||
|
commands = stestr --test-path ./nodepool/tests/functional/kubernetes run --no-subunit-trace {posargs}
|
||||||
|
stestr slowest
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# These are ignored intentionally in openstack-infra projects;
|
# These are ignored intentionally in openstack-infra projects;
|
||||||
# please don't submit patches that solely correct them or enable them.
|
# please don't submit patches that solely correct them or enable them.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user