Pre commit test for keystone

Change-Id: I0a430e8288b88334ca1de5738c101078a869c04e
This commit is contained in:
Dmitry Tyzhnenko 2016-08-25 15:21:11 +03:00 committed by Dmitry Tyzhnenko
parent 63f703aa58
commit 135bdd34cc
15 changed files with 501 additions and 144 deletions

View File

@ -15,6 +15,7 @@ import pytest
from fuel_ccp_tests.helpers import ext
from fuel_ccp_tests.managers import ccpmanager
from fuel_ccp_tests import settings
@pytest.fixture(scope='function')
@ -62,6 +63,11 @@ def ccpcluster(revert_snapshot, config, hardware,
# Install CCP
if config.ccp.os_host == '0.0.0.0':
ccp_actions.install_ccp()
ccp_actions.put_yaml_config(
settings.CCP_CLI_PARAMS['deploy-config'],
settings.CCP_DEFAULT_GLOBALS)
ccp_actions.default_params = settings.CCP_CLI_PARAMS
ccp_actions.init_default_config()
config.ccp.os_host = config.k8s.kube_host
hardware.create_snapshot(ext.SNAPSHOT.ccp_deployed)

View File

@ -0,0 +1,30 @@
# 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.managers import rallymanager
@pytest.fixture(scope='function')
def rally(underlay):
"""Fixture that provides various actions for K8S
:param config: fixture provides oslo.config
:param underlay: fixture provides underlay manager
:rtype: K8SManager
For use in tests or fixtures to deploy a custom K8S
"""
return rallymanager.RallyManager(underlay, 'master')

View File

@ -11,7 +11,9 @@
# 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 os
import yaml
from devops.error import DevopsCalledProcessError
from fuel_ccp_tests.helpers import exceptions
from fuel_ccp_tests import settings
@ -19,6 +21,11 @@ from fuel_ccp_tests import logger
LOG = logger.logger
CCP_CONF = """
[DEFAULT]
use_stderr = False
"""
class CCPManager(object):
"""docstring for CCPManager"""
@ -31,20 +38,69 @@ class CCPManager(object):
self.__underlay = underlay
super(CCPManager, self).__init__()
def install_ccp(self):
def install_ccp(self, use_defaults=True):
"""Base action to deploy k8s by external deployment script"""
LOG.info("Trying to install fuel-ccp on admin node")
with self.__underlay.remote(
host=self.__config.k8s.kube_host) as remote:
ccp_repo_url = settings.CCP_REPO
cmd = ('pip install --upgrade git+{}'.format(ccp_repo_url))
LOG.info("Fetch ccp from github")
cmd = 'git clone {}'.format(ccp_repo_url)
remote.check_call(cmd, verbose=True)
LOG.info('Install fuel-ccp from local path')
cmd = 'pip install --upgrade fuel-ccp/'
with remote.get_sudo(remote):
LOG.debug("*** Run cmd={0}".format(cmd))
result = remote.check_call(cmd, verbose=True)
LOG.debug("*** Result STDOUT:\n{0}".format(result.stdout_str))
LOG.debug("*** Result STDERR:\n{0}".format(result.stderr_str))
if use_defaults:
LOG.info("Use defaults config from ccp")
cmd = ('cat fuel-ccp/etc/topology-example.yaml '
'>> /tmp/ccp-globals.yaml')
remote.check_call(cmd, verbose=True)
@property
def default_params(self):
if hasattr(self, '_default_params'):
return self._default_params.copy()
return None
@default_params.setter
def default_params(self, v):
self._default_params = v.copy()
def init_default_config(self):
self.put_raw_config('~/ccp.conf', CCP_CONF)
def put_raw_config(self, path, content):
"""Put config content to file on admin node at path
:param path: path to config file
:param config: raw configuration data
"""
cmd = "cat > {path} << EOF\n{content}\nEOF".format(
path=path, content=content)
with self.__underlay.remote(
host=self.__config.k8s.kube_host) as remote:
remote.execute(cmd)
def put_yaml_config(self, path, config):
"""Convert config dict to yaml and put it to admin node at path
:param path: path to config file
:param config: dict with configuration data
"""
content = yaml.dump(config, default_flow_style=False)
cmd = "cat >> {path} << EOF\n{content}\nEOF".format(
path=path, content=content)
with self.__underlay.remote(
host=self.__config.k8s.kube_host) as remote:
remote.execute(cmd)
@classmethod
def build_command(cls, *args, **kwargs):
"""Generate the list of parameters
@ -63,80 +119,91 @@ class CCPManager(object):
'--{0} {1}'.format(key.replace('_', '-'), kwargs[key]))
return ' '.join(command_list)
def do_fetch(self, *args, **kwargs):
cmd = self.build_command(*args, **kwargs) + " fetch"
def __build_param_string(self, params=None):
if params is None:
params = self.default_params
else:
merge = self.default_params.copy()
merge.update(params)
params = merge
return ' '.join(["--{}={}".format(
k, v) if v else "--{}".format(k) for (k, v) in params.items()])
def run(self, cmd, components=None, params=None, suppress_output=False):
params = self.__build_param_string(params)
params = params or ''
if components:
if isinstance(components, str):
components = [components]
components = '-c {}'.format(' '.join(components))
else:
components = ''
if suppress_output:
ccp_out_redirect = ("> >(tee ccp.out.log > /dev/null) "
"2> >(tee ccp.err.log >/dev/null)")
else:
ccp_out_redirect = ""
cmd = "ccp {params} {cmd} {components} {ccp_out_redirect}".format(
params=params, cmd=cmd, components=components,
ccp_out_redirect=ccp_out_redirect)
LOG.info("Running {cmd}".format(cmd=cmd))
with self.__underlay.remote(
host=self.__config.k8s.kube_host) as remote:
remote.execute(cmd)
remote.check_call(cmd)
def do_build(self, *args, **kwargs):
cmd = self.build_command(*args, **kwargs) + " build"
with self.__underlay.remote(
host=self.__config.k8s.kube_host) as remote:
LOG.info(
"Running command '{cmd}' on node {node}".format(
cmd=cmd,
node=remote.hostname
)
)
remote.execute(cmd)
def fetch(self, components=None, params=None):
self.run('fetch',
components=components,
params=params)
def do_deploy(self, *args, **kwargs):
cmd = self.build_command(*args, **kwargs) + " deploy"
with self.__underlay.remote(
host=self.__config.k8s.kube_host) as remote:
LOG.info(
"Running command '{cmd}' on node {node}".format(
cmd=cmd,
node=remote.hostname
)
)
remote.execute(cmd)
def build(self, components=None, params=None, suppress_output=True):
try:
self.run('build',
components=components,
params=params, suppress_output=suppress_output)
except DevopsCalledProcessError as e:
LOG.warning(e)
LOG.info("Retry build command")
self.run('build',
components=components,
params=params, suppress_output=suppress_output)
def update_service(self, service_name):
if not settings.SERVICE_PATH:
def deploy(self, components=None, params=None):
self.run('deploy',
components=components,
params=params)
def dry_deploy(self, export_dir, components=None, params=None):
self.run('deploy --dry-run --export-dir={export_dir}'.format(
export_dir=export_dir),
components=components,
params=params)
def cleanup(self, components=None, params=None):
self.run('cleanup',
components=components,
params=params)
def show_dep(self, components=None, params=None):
self.run('show-dep',
components=components,
params=params)
def update_service(self, service_name, path=None):
if not settings.SERVICE_PATH and not path:
raise exceptions.VariableNotSet('SERVICE_PATH')
path = path or settings.SERVICE_PATH
with self.__underlay.remote(
host=self.__config.k8s.kube_host) as remote:
remote.execute(
'rm -rf ./microservices-repos/fuel-ccp-{}'
.format(service_name))
remote.upload(
settings.SERVICE_PATH,
"./microservices-repos/")
def do_dry_run(self, *args, **kwargs):
"""Create yaml templates, make registry
:param args: passed into build_command()
:param kwargs: passed into build_command()
:param export_dir: taken from kwargs, contains dir for yaml templates
:param: base_command: should be empty for getting 'dry_run'
params without 'ccp'
:return: None
"""
try:
export_dir = kwargs.pop("export_dir")
except KeyError:
raise ValueError("Variable 'export_dir' is not set")
command_list = [
self.build_command(*args, **kwargs),
"deploy",
"--dry-run",
self.build_command(export_dir=export_dir, base_command='')
]
command_list = ' '.join(command_list)
command = [
command_list,
'kubectl create -f {0}/configmaps/ -f {0}'.format(
os.path.join('~/', export_dir))
]
with self.__underlay.remote(
host=self.__config.k8s.kube_host) as remote:
for cmd in command:
LOG.info("Running command '{cmd}' on node {node}".format(
cmd=cmd,
node=remote.hostname)
)
result = remote.execute(cmd)
assert result['exit_code'] == 0
path,
"/home/{user}/microservices-repos/fuel-ccp-{service}".format(
user=settings.SSH_LOGIN,
service=service_name))

View File

@ -26,6 +26,10 @@ class K8sPod(K8sBaseResource):
def name(self):
return self.metadata.name
@property
def phase(self):
return self.status.phase
class K8sPodManager(K8sBaseManager):
"""docstring for ClassName"""

View File

@ -16,6 +16,8 @@ import os
import yaml
from devops.helpers import helpers
from fuel_ccp_tests.helpers import exceptions
from fuel_ccp_tests.helpers import _subprocess_runner
from fuel_ccp_tests import logger
@ -34,6 +36,7 @@ class K8SManager(object):
def __init__(self, config, underlay):
self.__config = config
self.__underlay = underlay
self._api_client = None
super(K8SManager, self).__init__()
def install_k8s(self, custom_yaml=None, env_var=None,
@ -111,14 +114,22 @@ class K8SManager(object):
return result
def get_k8sclient(self, default_namespace=None):
k8sclient = cluster.K8sCluster(
user=self.__config.k8s.kube_admin_user,
password=self.__config.k8s.kube_admin_pass,
host=self.__config.k8s.kube_host)
return k8sclient
@property
def api(self):
if self._api_client is None:
self._api_client = cluster.K8sCluster(
user=self.__config.k8s.kube_admin_user,
password=self.__config.k8s.kube_admin_pass,
host=self.__config.k8s.kube_host,
default_namespace='default')
return self._api_client
def create_registry(self):
"""Create Pod and SErvice for K8S registry
TODO:
Migrate to k8sclient
"""
registry_pod = os.getcwd() + '/fuel_ccp_tests/templates/' \
'registry_templates/registry-pod.yaml'
service_registry = os.getcwd() + '/fuel_ccp_tests/templates/' \
@ -132,9 +143,59 @@ class K8SManager(object):
remote.upload(item, './')
command = [
'kubectl create -f ~/{0}'.format(registry_pod.split('/')[-1]),
'kubectl create'
' -f ~/{0}'.format(service_registry.split('/')[-1]), ]
with remote.get_sudo(remote):
for cmd in command:
result = remote.execute(cmd)
assert result['exit_code'] == 0, "Registry wasn't created"
'kubectl create -f ~/{0}'.format(
service_registry.split('/')[-1]),
]
for cmd in command:
LOG.info(
"Running command '{cmd}' on node {node_name}".format(
cmd=cmd,
node_name=remote.hostname))
result = remote.execute(cmd)
if result['exit_code'] != 0:
raise SystemError(
"Registry wasn't created. "
"Command '{}' returned non-zero exit code({}). Err: "
"{}".format(
cmd, result['exit_code'], result['stderr_str']))
self.wait_pod_phase('registry', 'default', 'Running', timeout=60)
def get_pod_phase(self, pod_name, namespace):
return self.api.pods.get(
name=pod_name, namespace=namespace).phase
def wait_pod_phase(self, pod_name, namespace, phase, timeout=60):
"""Wait phase of pod_name from namespace while timeout
:param str: pod_name
:param str: namespace
:param list or str: phase
:param int: timeout
:rtype: None
"""
if isinstance(phase, str):
phase = [phase]
def check():
return self.get_pod_phase(pod_name, namespace) in phase
helpers.wait(check, timeout=timeout,
timeout_msg='Timeout waiting, pod {pod_name} is not in '
'"{phase}" phase'.format(
pod_name=pod_name, phase=phase))
def create_objects(self, path):
if isinstance(path, str):
path = [path]
params = ' '.join(["-f {}".format(p) for p in path])
cmd = 'kubectl create {params}'.format(params)
with self.__underlay.remote(
host=self.__config.k8s.kube_host) as remote:
LOG.info("Running command '{cmd}' on node {node}".format(
cmd=cmd,
node=remote.hostname)
)
result = remote.check_call(cmd)
LOG.info(result['stdout'])

View File

@ -0,0 +1,118 @@
# 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.
from fuel_ccp_tests import logger
from fuel_ccp_tests import settings
LOG = logger.logger
class RallyManager(object):
"""docstring for RallyManager"""
image_name = 'rallyforge/rally'
image_version = '0.5.0'
def __init__(self, underlay, admin_node_name):
super(RallyManager, self).__init__()
self._admin_node_name = admin_node_name
self._underlay = underlay
def prepare(self):
content = """
sed -i 's|#swift_operator_role = Member|swift_operator_role=SwiftOperator|g' /etc/rally/rally.conf # noqa
source /home/rally/openrc
rally-manage db recreate
rally deployment create --fromenv --name=tempest
rally verify install
rally verify genconfig
rally verify showconfig"""
cmd = "cat > {path} << EOF\n{content}\nEOF".format(
path='/home/{user}/rally/install_tempest.sh'.format(
user=settings.SSH_LOGIN), content=content)
cmd1 = "chmod +x /home/{user}/rally/install_tempest.sh".format(
user=settings.SSH_LOGIN)
cmd2 = "cp /home/{user}/openrc-* /home/{user}/rally/openrc".format(
user=settings.SSH_LOGIN)
with self._underlay.remote(node_name=self._admin_node_name) as remote:
LOG.info("Create rally workdir")
remote.check_call('mkdir -p /home/{user}/rally'.format(
user=settings.SSH_LOGIN))
LOG.info("Create install_tempest.sh")
remote.check_call(cmd)
LOG.info("Chmod +x install_tempest.sh")
remote.check_call(cmd1)
LOG.info("Copy openstackrc")
remote.check_call(cmd2)
def pull_image(self, version=None):
version = version or self.image_version
image = self.image_name
cmd = "docker pull {image}:{version}".format(image=image,
version=version)
with self._underlay.remote(node_name=self._admin_node_name) as remote:
LOG.info("Pull {image}:{version}".format(image=image,
version=version))
remote.check_call(cmd)
with self._underlay.remote(node_name=self._admin_node_name) as remote:
LOG.info("Getting image id")
cmd = "docker images | grep 0.5.0| awk '{print $3}'"
res = remote.check_call(cmd)
self.image_id = res['stdout'][0].strip()
LOG.info("Image ID is {}".format(self.image_id))
def run(self):
with self._underlay.remote(node_name=self._admin_node_name) as remote:
cmd = ("docker run --net host -v /home/{user}/rally:/home/rally "
"-tid -u root {image_id}".format(
user=settings.SSH_LOGIN, image_id=self.image_id))
LOG.info("Run Rally container")
remote.check_call(cmd)
cmd = ("docker ps | grep {image_id} | "
"awk '{{print $1}}'| head -1").format(
image_id=self.image_id)
LOG.info("Getting container id")
res = remote.check_call(cmd)
self.docker_id = res['stdout'][0].strip()
LOG.info("Container ID is {}".format(self.docker_id))
def run_tempest(self, test):
docker_exec = ('source /home/{user}/rally/openrc; '
'docker exec -i {docker_id} bash -c "{cmd}"')
commands = [
docker_exec.format(cmd="./install_tempest.sh",
user=settings.SSH_LOGIN,
docker_id=self.docker_id),
docker_exec.format(
cmd="source /home/rally/openrc && "
"rally verify start {test}".format(test=test),
user=settings.SSH_LOGIN,
docker_id=self.docker_id),
docker_exec.format(
cmd="rally verify results --json --output-file result.json",
user=settings.SSH_LOGIN,
docker_id=self.docker_id),
docker_exec.format(
cmd="rally verify results --html --output-file result.html",
user=settings.SSH_LOGIN,
docker_id=self.docker_id),
]
with self._underlay.remote(node_name=self._admin_node_name) as remote:
LOG.info("Run tempest inside Rally container")
for cmd in commands:
remote.check_call(cmd, verbose=True)

View File

@ -90,8 +90,33 @@ DEFAULT_CUSTOM_YAML = {
BUILD_IMAGES = get_var_as_bool('BUILD_IMAGES', True)
REGISTRY = os.environ.get('REGISTRY', None)
IMAGES_NAMESPACE = os.environ.get('IMAGES_NAMESPACE', 'mcp')
IMAGES_NAMESPACE = os.environ.get('IMAGES_NAMESPACE', 'ccp')
IMAGES_TAG = os.environ.get('IMAGES_TAG', 'latest')
UPSTREAM_DNS = os.environ.get('UPSTREAM_DNS', '8.8.8.8').split(',')
SERVICE_PATH = os.environ.get('SERVICE_PATH')
TEMPEST_SCRIPT_PATH = os.environ.get('TEMPEST_SCRIPT_PATH')
FUEL_CCP_KEYSTONE_LOCAL_REPO = os.environ.get('FUEL_CCP_KEYSTONE_LOCAL_REPO',
None)
CCP_CLI_PARAMS = {
"config-file": "~/ccp.conf",
"debug": "",
"log-file": "ccp.log",
"builder-workers": "1",
"builder-push": "",
"registry-address": REGISTRY or "127.0.0.1:31500",
"kubernetes-namespace": "demo",
"repositories-skip-empty": "",
"deploy-config": "/tmp/ccp-globals.yaml",
"images-namespace": IMAGES_NAMESPACE,
"images-tag": IMAGES_TAG
}
CCP_DEFAULT_GLOBALS = {
"configs": {
"private_interface": "eth0",
"public_interface": "eth1",
"neutron_external_interface": "eth2"
}
}

View File

@ -90,6 +90,10 @@ k8s_opts = [
ccp_deploy_opts = [
ct.Cfg('private_registry', ct.String(),
help="", default=None),
ct.Cfg('ccp_globals', ct.JSONDict(),
help="", default=None),
ct.Cfg('ccp_params', ct.JSONDict(),
help="", default=None)
]
# Access credentials to a ready CCP

View File

@ -19,5 +19,4 @@ expected_namespaces = ('default', 'kube-system')
@pytest.mark.parametrize('ns', expected_namespaces)
def test_exist_namespace(k8scluster, ns):
k8sclient = k8scluster.get_k8sclient()
k8sclient.namespaces.get(name=ns)
k8scluster.api.namespaces.get(name=ns)

View File

@ -19,5 +19,4 @@ expected_services = ('kubernetes',)
@pytest.mark.parametrize('service', expected_services)
def test_exist_service(k8scluster, service):
k8sclient = k8scluster.get_k8sclient()
k8sclient.services.get(name=service)
k8scluster.api.services.get(name=service)

View File

@ -16,4 +16,5 @@ pytest_plugins = ['fuel_ccp_tests.fixtures.common_fixtures',
'fuel_ccp_tests.fixtures.config_fixtures',
'fuel_ccp_tests.fixtures.underlay_fixtures',
'fuel_ccp_tests.fixtures.k8s_fixtures',
'fuel_ccp_tests.fixtures.rally_fixtures',
'fuel_ccp_tests.fixtures.ccp_fixtures']

View File

@ -53,20 +53,18 @@ class TestServiceHorizon(object):
9. Run horizon tests from docker
Duration 60 min
"""
k8sclient = k8scluster.get_k8sclient()
k8sclient = k8scluster.api
remote = underlay.remote(host=config.k8s.kube_host)
ccpcluster.do_fetch()
ccpcluster.fetch()
ccpcluster.update_service('horizon')
k8scluster.create_registry(remote)
ccpcluster.do_build('builder_push',
registry_address=settings.REGISTRY)
k8scluster.create_registry()
ccpcluster.build()
topology_path = os.getcwd() + '/fuel_ccp_tests/templates/' \
'k8s_templates/k8s_topology.yaml'
remote.upload(topology_path, './')
ccpcluster.do_deploy(registry_address=settings.REGISTRY,
deploy_config='~/k8s_topology.yaml')
remote.upload(topology_path, settings.CCP_CLI_PARAMS['deploy-config'])
ccpcluster.deploy()
post_os_deploy_checks.check_jobs_status(k8sclient, timeout=1500,
namespace='ccp')
post_os_deploy_checks.check_pods_status(k8sclient, timeout=1500,

View File

@ -0,0 +1,82 @@
# 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 import settings
from fuel_ccp_tests.helpers import post_os_deploy_checks
from fuel_ccp_tests.helpers import ext
@pytest.fixture(scope='function')
def ccp(ccp_actions, k8scluster):
"""Fixture to install fuel-ccp on k8s environment
:param env_with_k8s: envmanager.EnvironmentManager
"""
ccp_actions.install_ccp()
ccp_globals = settings.CCP_DEFAULT_GLOBALS
ccp_actions.put_yaml_config(settings.CCP_CLI_PARAMS['deploy-config'],
ccp_globals)
ccp_actions.default_params = settings.CCP_CLI_PARAMS
ccp_actions.init_default_config()
return ccp_actions
class TestPreCommitKeystone(object):
"""docstring for TestPreCommitKeystone
Scenario:
1. Install k8s
2. Install fuel-ccp
3. Fetch all repositories
4. Fetch keystone from review
5. Fetch containers from external registry
6. Build keytone container
7. Deploy Openstack
8. Run tempest
"""
@pytest.mark.keystone_test
@pytest.mark.keystone_component
@pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
def test_deploy_os_with_custom_keystone(
self, ccp, k8s_actions, underlay, rally):
"""
Scenario:
1. Install k8s
2. Install fuel-ccp
3. Fetch repos
4. Upload repo with changes
5. Build components
6. Deploy components
7. Run identity tempest suite
TODO:
Migrate from ccp to ccpcluster
"""
k8s_actions.create_registry()
ccp.fetch()
ccp.update_service('keystone',
settings.FUEL_CCP_KEYSTONE_LOCAL_REPO)
ccp.build('base-tools', suppress_output=False)
ccp.build(suppress_output=False)
ccp.deploy()
rally.prepare()
rally.pull_image()
rally.run()
post_os_deploy_checks.check_jobs_status(k8s_actions.api)
rally.run_tempest('identity')

View File

@ -94,7 +94,7 @@ class TestFuelCCPInstaller(base_test.SystemBaseTest,
7. Delete pod.
"""
k8s_actions.install_k8s()
k8sclient = k8s_actions.get_k8sclient()
k8sclient = k8s_actions.api
self.check_number_kube_nodes(underlay, k8sclient)
self.check_list_required_images(
@ -136,7 +136,7 @@ class TestFuelCCPInstaller(base_test.SystemBaseTest,
self.custom_yaml_images)
k8s_actions.install_k8s(custom_yaml=kube_settings)
k8sclient = k8s_actions.get_k8sclient()
k8sclient = k8s_actions.api
self.check_number_kube_nodes(underlay, k8sclient)
self.check_list_required_images(underlay,
@ -178,7 +178,7 @@ class TestFuelCCPInstaller(base_test.SystemBaseTest,
required_images.append(kube_settings['etcd_image_repo'])
k8s_actions.install_k8s(custom_yaml=kube_settings)
k8sclient = k8s_actions.get_k8sclient()
k8sclient = k8s_actions.api
self.check_number_kube_nodes(underlay, k8sclient)
self.check_list_required_images(underlay,
@ -214,7 +214,7 @@ class TestFuelCCPInstaller(base_test.SystemBaseTest,
}
k8s_actions.install_k8s(env_var=add_var)
k8sclient = k8s_actions.get_k8sclient()
k8sclient = k8s_actions.api
self.check_number_kube_nodes(underlay, k8sclient)
self.check_list_required_images(

View File

@ -13,7 +13,6 @@
# under the License.
import os
import pytest
import yaml
import base_test
from fuel_ccp_tests import logger
@ -81,38 +80,18 @@ class TestDeployOpenstack(base_test.SystemBaseTest):
Duration 35 min
"""
k8sclient = k8scluster.get_k8sclient()
k8sclient = k8scluster.api
remote = underlay.remote(host=config.k8s.kube_host)
self.pre_build_deploy_step(remote)
yaml_path = os.path.join(
os.getcwd(),
'fuel_ccp_tests/templates/k8s_templates/build-deploy_cluster.yaml')
with open(yaml_path, 'r') as yaml_path:
data = yaml_path.read()
data = data.format(registry_address='127.0.0.1:31500'
if settings.BUILD_IMAGES else settings.REGISTRY,
images_namespace=settings.IMAGES_NAMESPACE,
images_tag=settings.IMAGES_TAG,
deploy_config='~/k8s_topology.yaml')
data_params = yaml.load(data)['ccp-microservices-options']
if settings.BUILD_IMAGES:
k8scluster.create_registry(remote)
exclude_list = ['dry-run', 'export-dir']
params_list, params_dict = self.get_params(
data_params, exclude_list)
with remote.get_sudo(remote):
ccpcluster.do_build(remote, *params_list, **params_dict)
k8scluster.create_registry()
ccpcluster.build()
post_install_k8s_checks.check_calico_network(remote, k8sclient)
else:
if not settings.REGISTRY:
raise ValueError("The REGISTRY variable should be set with "
"external registry address, "
"current value {0}".format(settings.REGISTRY))
exclude_list = ['builder-push', 'builder-workers', 'dry-run',
'export-dir']
params_list, params_dict = self.get_params(data_params, exclude_list)
with remote.get_sudo(remote):
ccpcluster.do_deploy(*params_list, **params_dict)
ccpcluster.deploy()
post_os_deploy_checks.check_jobs_status(k8sclient, timeout=1500,
namespace='ccp')
post_os_deploy_checks.check_pods_status(k8sclient, timeout=2500,
@ -133,28 +112,12 @@ class TestDeployOpenstack(base_test.SystemBaseTest):
Duration 35 min
"""
k8sclient = k8scluster.get_k8sclient()
remote = underlay.remote(host=config.k8s.kube_host)
self.pre_build_deploy_step(remote)
yaml_path = os.path.join(
os.getcwd(),
'fuel_ccp_tests/templates/k8s_templates/build-deploy_cluster.yaml')
with open(yaml_path, 'r') as yaml_path:
data = yaml_path.read()
data = data.format(registry_address='127.0.0.1:31500'
if settings.BUILD_IMAGES else settings.REGISTRY,
images_namespace=settings.IMAGES_NAMESPACE,
images_tag=settings.IMAGES_TAG,
deploy_config='~/k8s_topology.yaml',
export_dir='tmp')
data_params = yaml.load(data)['ccp-microservices-options']
dry_run_params = yaml.load(data)['dry_run_options']
exclude_list = ['builder-push', 'builder-workers']
params_list, params_dict = self.get_params(data_params, exclude_list)
params_dict.update(dry_run_params)
with remote.get_sudo(remote):
ccpcluster.do_dry_run(
*params_list, **params_dict)
k8sclient = k8scluster.api
k8scluster.create_registry()
ccpcluster.build()
export_dir = "/home/{user}/export".format(user=settings.SSH_LOGIN)
ccpcluster.dry_deploy(export_dir=export_dir)
k8scluster.create_objects(folder=export_dir)
post_os_deploy_checks.check_jobs_status(k8sclient, timeout=1500,
namespace='default')
post_os_deploy_checks.check_pods_status(k8sclient, timeout=2500,