
Include: - util modules. such as table_parser, ssh/localhost clients, cli module, exception, logger, etc. Util modules are mostly used by keywords. - keywords modules. These are helper functions that are used directly by test functions. - platform (with platform or platform_sanity marker) and stx-openstack (with sanity, sx_sanity, cpe_sanity, or storage_sanity marker) sanity testcases - pytest config conftest, and test fixture modules - test config file template/example Required packages: - python3.4 or python3.5 - pytest >=3.10,<4.0 - pexpect - requests - pyyaml - selenium (firefox, ffmpeg, pyvirtualdisplay, Xvfb or Xephyr or Xvnc) Limitations: - Anything that requires copying from Test File Server will not work until a public share is configured to shared test files. Tests skipped for now. Co-Authored-By: Maria Yousaf <maria.yousaf@windriver.com> Co-Authored-By: Marvin Huang <marvin.huang@windriver.com> Co-Authored-By: Yosief Gebremariam <yosief.gebremariam@windriver.com> Co-Authored-By: Paul Warner <paul.warner@windriver.com> Co-Authored-By: Xueguang Ma <Xueguang.Ma@windriver.com> Co-Authored-By: Charles Chen <charles.chen@windriver.com> Co-Authored-By: Daniel Graziano <Daniel.Graziano@windriver.com> Co-Authored-By: Jordan Li <jordan.li@windriver.com> Co-Authored-By: Nimalini Rasa <nimalini.rasa@windriver.com> Co-Authored-By: Senthil Mukundakumar <senthil.mukundakumar@windriver.com> Co-Authored-By: Anuejyan Manokeran <anujeyan.manokeran@windriver.com> Co-Authored-By: Peng Peng <peng.peng@windriver.com> Co-Authored-By: Chris Winnicki <chris.winnicki@windriver.com> Co-Authored-By: Joe Vimar <Joe.Vimar@windriver.com> Co-Authored-By: Alex Kozyrev <alex.kozyrev@windriver.com> Co-Authored-By: Jack Ding <jack.ding@windriver.com> Co-Authored-By: Ming Lei <ming.lei@windriver.com> Co-Authored-By: Ankit Jain <ankit.jain@windriver.com> Co-Authored-By: Eric Barrett <eric.barrett@windriver.com> Co-Authored-By: William Jia <william.jia@windriver.com> Co-Authored-By: Joseph Richard <Joseph.Richard@windriver.com> Co-Authored-By: Aldo Mcfarlane <aldo.mcfarlane@windriver.com> Story: 2005892 Task: 33750 Signed-off-by: Yang Liu <yang.liu@windriver.com> Change-Id: I7a88a47e09733d39f024144530f5abb9aee8cad2
94 lines
3.4 KiB
Python
94 lines
3.4 KiB
Python
#
|
|
# Copyright (c) 2019 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
|
|
import re
|
|
|
|
from pytest import mark, skip
|
|
|
|
from keywords import kube_helper, system_helper, host_helper
|
|
from consts.stx import PodStatus, HostAvailState
|
|
from utils.tis_log import LOG
|
|
|
|
|
|
def check_host(controller):
|
|
host = system_helper.get_active_controller_name()
|
|
if controller == 'standby':
|
|
controllers = system_helper.get_controllers(
|
|
availability=(HostAvailState.AVAILABLE, HostAvailState.DEGRADED,
|
|
HostAvailState.ONLINE))
|
|
controllers.remove(host)
|
|
if not controllers:
|
|
skip('Standby controller does not exist or not in good state')
|
|
host = controllers[0]
|
|
return host
|
|
|
|
|
|
@mark.platform_sanity
|
|
@mark.parametrize('controller', [
|
|
'active',
|
|
'standby'
|
|
])
|
|
def test_kube_system_services(controller):
|
|
"""
|
|
Test kube-system pods are deployed and running
|
|
|
|
Test Steps:
|
|
- ssh to given controller
|
|
- Check all kube-system pods are running
|
|
- Check kube-system services displayed: 'calico-typha',
|
|
'kube-dns', 'tiller-deploy'
|
|
- Check kube-system deployments displayed: 'calico-typha',
|
|
'coredns', 'tiller-deploy'
|
|
|
|
"""
|
|
host = check_host(controller=controller)
|
|
|
|
with host_helper.ssh_to_host(hostname=host) as con_ssh:
|
|
|
|
kube_sys_pods_values = kube_helper.get_resources(
|
|
field=('NAME', 'STATUS'), resource_type='pod',
|
|
namespace='kube-system', con_ssh=con_ssh)
|
|
kube_sys_services = kube_helper.get_resources(
|
|
resource_type='service', namespace='kube-system', con_ssh=con_ssh)
|
|
kube_sys_deployments = kube_helper.get_resources(
|
|
resource_type='deployment.apps', namespace='kube-system',
|
|
con_ssh=con_ssh)
|
|
|
|
LOG.tc_step("Check kube-system pods status on {}".format(controller))
|
|
# allow max 1 coredns pending on aio-sx
|
|
coredns_pending = False if system_helper.is_aio_simplex() else True
|
|
for pod_info in kube_sys_pods_values:
|
|
pod_name, pod_status = pod_info
|
|
if not coredns_pending and 'coredns-' in pod_name and \
|
|
pod_status == PodStatus.PENDING:
|
|
coredns_pending = True
|
|
continue
|
|
|
|
valid_status = PodStatus.RUNNING
|
|
if re.search('audit-|init-', pod_name):
|
|
valid_status = PodStatus.COMPLETED
|
|
|
|
if pod_status not in valid_status:
|
|
kube_helper.wait_for_pods_status(pod_names=pod_name,
|
|
status=valid_status,
|
|
namespace='kube-system',
|
|
con_ssh=con_ssh, timeout=300)
|
|
|
|
services = ('kube-dns', 'tiller-deploy')
|
|
LOG.tc_step("Check kube-system services on {}: {}".format(controller,
|
|
services))
|
|
for service in services:
|
|
assert service in kube_sys_services, \
|
|
"{} not in kube-system service table".format(service)
|
|
|
|
deployments = ('calico-kube-controllers', 'coredns', 'tiller-deploy')
|
|
LOG.tc_step("Check kube-system deployments on {}: "
|
|
"{}".format(controller, deployments))
|
|
for deployment in deployments:
|
|
assert deployment in kube_sys_deployments, \
|
|
"{} not in kube-system deployment.apps table".format(deployment)
|