Add conformance test
Add simple test that runs conformance tests using pre-built image Requires path to it to be set via E2E_CONFORMANCE_IMAGE env variable Change-Id: I80d82531d8a80912f007b814c287d96e1e286244
This commit is contained in:
parent
5d3db0e0d4
commit
e1c94fbe0e
|
@ -12,13 +12,14 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from operator import attrgetter
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from fuel_ccp_tests import logger
|
|
||||||
from fuel_ccp_tests.helpers import ext
|
from fuel_ccp_tests.helpers import ext
|
||||||
from fuel_ccp_tests import settings
|
from fuel_ccp_tests import logger
|
||||||
from fuel_ccp_tests.managers import k8smanager
|
from fuel_ccp_tests.managers import k8smanager
|
||||||
|
from fuel_ccp_tests import settings
|
||||||
|
|
||||||
LOG = logger.logger
|
LOG = logger.logger
|
||||||
|
|
||||||
|
@ -94,12 +95,17 @@ def check_files_missing(request):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='class')
|
@pytest.fixture(scope='class')
|
||||||
def check_settings_missing(request):
|
def check_settings_missing(request, config):
|
||||||
|
def get_attr(attr, obj):
|
||||||
|
try:
|
||||||
|
return attrgetter(attr)(obj)
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
LOG.info("Required settings: {}".format(request.cls.required_settings))
|
LOG.info("Required settings: {}".format(request.cls.required_settings))
|
||||||
settings_missing = [s for s in request.cls.required_settings
|
missing = [s for s in request.cls.required_settings
|
||||||
if not getattr(settings, s, None)]
|
if not (getattr(settings, s, None) or get_attr(s, config))]
|
||||||
assert len(settings_missing) == 0, \
|
assert len(missing) == 0, \
|
||||||
"Following env variables are not set {}". format(settings_missing)
|
"Following env variables are not set {}". format(missing)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='class')
|
@pytest.fixture(scope='class')
|
||||||
|
|
|
@ -18,12 +18,12 @@ import yaml
|
||||||
|
|
||||||
from devops.helpers import helpers
|
from devops.helpers import helpers
|
||||||
|
|
||||||
from fuel_ccp_tests.helpers import exceptions
|
|
||||||
from fuel_ccp_tests.helpers import _subprocess_runner
|
from fuel_ccp_tests.helpers import _subprocess_runner
|
||||||
|
from fuel_ccp_tests.helpers import exceptions
|
||||||
from fuel_ccp_tests.helpers import post_install_k8s_checks
|
from fuel_ccp_tests.helpers import post_install_k8s_checks
|
||||||
from fuel_ccp_tests import logger
|
from fuel_ccp_tests import logger
|
||||||
from fuel_ccp_tests import settings
|
|
||||||
from fuel_ccp_tests.managers.k8s import cluster
|
from fuel_ccp_tests.managers.k8s import cluster
|
||||||
|
from fuel_ccp_tests import settings
|
||||||
|
|
||||||
LOG = logger.logger
|
LOG = logger.logger
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,10 @@ k8s_deploy_opts = [
|
||||||
help="", default=None),
|
help="", default=None),
|
||||||
ct.Cfg('kube_settings', ct.JSONDict(),
|
ct.Cfg('kube_settings', ct.JSONDict(),
|
||||||
help="", default={}),
|
help="", default={}),
|
||||||
|
ct.Cfg('e2e_conformance_image', ct.String(),
|
||||||
|
help="", default=''),
|
||||||
|
ct.Cfg('e2e_conformance_timeout', ct.Integer(),
|
||||||
|
help="", default=3600),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Access credentials to a ready K8S cluster
|
# Access credentials to a ready K8S cluster
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
# Copyright 2016 Mirantis, Inc.
|
||||||
|
#
|
||||||
|
# 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 pytest
|
||||||
|
|
||||||
|
from fuel_ccp_tests.helpers import _subprocess_runner
|
||||||
|
from fuel_ccp_tests.helpers import exceptions
|
||||||
|
from fuel_ccp_tests import logger
|
||||||
|
|
||||||
|
LOG = logger.logger
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.k8s_conformance
|
||||||
|
@pytest.mark.component_k8s
|
||||||
|
class TestK8sConformance(object):
|
||||||
|
|
||||||
|
required_settings = [
|
||||||
|
'k8s_deploy.e2e_conformance_image',
|
||||||
|
]
|
||||||
|
|
||||||
|
@pytest.mark.fail_snapshot
|
||||||
|
@pytest.mark.dashboard_exists
|
||||||
|
@pytest.mark.usefixtures("check_settings_missing", "k8scluster")
|
||||||
|
def test_k8s_conformance(self, underlay, config):
|
||||||
|
"""Run k8s conformance tests.
|
||||||
|
|
||||||
|
Requires path to the image to be set via environment variable
|
||||||
|
E2E_CONFORMANCE_IMAGE
|
||||||
|
|
||||||
|
Scenario:
|
||||||
|
1. Get or deploy k8s environment.
|
||||||
|
2. Run conformance tests
|
||||||
|
"""
|
||||||
|
LOG.info("Running e2e conformance tests")
|
||||||
|
remote = underlay.remote(host=config.k8s.kube_host)
|
||||||
|
cmd = 'docker run --rm --net=host ' \
|
||||||
|
'-e API_SERVER="http://127.0.0.1:8080" ' \
|
||||||
|
'{image} >> e2e-conformance.log'.format(
|
||||||
|
image=config.k8s_deploy.e2e_conformance_image
|
||||||
|
)
|
||||||
|
result = remote.execute(
|
||||||
|
cmd,
|
||||||
|
timeout=config.k8s_deploy.e2e_conformance_timeout,
|
||||||
|
verbose=True)
|
||||||
|
|
||||||
|
cmd = "mkdir -p logs"
|
||||||
|
|
||||||
|
# FIXME Use Subprocess.execute instead of Subprocess.check_call until
|
||||||
|
# check_call is not fixed (fuel-devops3.0.2)
|
||||||
|
_subprocess_runner.Subprocess.execute(cmd, verbose=True)
|
||||||
|
|
||||||
|
remote.download('/home/vagrant/e2e-conformance.log', 'logs/')
|
||||||
|
|
||||||
|
expected_ec = [0]
|
||||||
|
if result.exit_code not in expected_ec:
|
||||||
|
raise exceptions.UnexpectedExitCode(
|
||||||
|
cmd,
|
||||||
|
result.exit_code,
|
||||||
|
expected_ec,
|
||||||
|
stdout=result.stdout_brief,
|
||||||
|
stderr=result.stdout_brief)
|
Loading…
Reference in New Issue