Fuel CCP - Tests sub-project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

base_test.py 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Copyright 2016 Mirantis, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  4. # not use this file except in compliance with the License. You may obtain
  5. # a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations
  13. # under the License.
  14. from fuel_ccp_tests import logger
  15. from fuel_ccp_tests.helpers import post_install_k8s_checks
  16. LOG = logger.logger
  17. LOG.addHandler(logger.console)
  18. class SystemBaseTest(object):
  19. """SystemBaseTest contains setup/teardown for environment creation"""
  20. def calico_ipip_exists(self, underlay):
  21. """Check if ipip is in calico pool config
  22. :param underlay: fuel_ccp_tests.managers.UnderlaySSHManager
  23. """
  24. cmd = "calicoctl pool show | grep ipip"
  25. for node_name in underlay.node_names():
  26. underlay.sudo_check_call(cmd, node_name=node_name)
  27. def check_list_required_images(self, underlay, required_images):
  28. """Check running containers on each node
  29. :param underlay: fuel_ccp_tests.managers.UnderlaySSHManager
  30. :param required_images: list
  31. """
  32. LOG.info("Check that required containers exist")
  33. for node_name in underlay.node_names():
  34. post_install_k8s_checks.required_images_exists(node_name,
  35. underlay,
  36. required_images)
  37. def check_number_kube_nodes(self, underlay, k8sclient):
  38. """Check number of slaves"""
  39. LOG.info("Check number of nodes")
  40. k8s_nodes = k8sclient.nodes.list()
  41. node_names = underlay.node_names()
  42. assert len(k8s_nodes) == len(node_names),\
  43. "Check number k8s nodes failed!"
  44. def check_etcd_health(self, underlay):
  45. node_names = underlay.node_names()
  46. cmd = "etcdctl cluster-health | grep -c 'got healthy result'"
  47. etcd_nodes = underlay.sudo_check_call(
  48. cmd, node_name=node_names[0])['stdout'][0]
  49. assert int(etcd_nodes) == len(node_names),\
  50. "Number of etcd nodes is {0}," \
  51. " should be {1}".format(int(etcd_nodes), len(node_names))
  52. def create_env_snapshot(self, name, hardware, description=None):
  53. hardware.create_snapshot(name, description=description)