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.

post_install_k8s_checks.py 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. import re
  15. from devops.helpers import helpers
  16. from fuel_ccp_tests import logger
  17. LOG = logger.logger
  18. def check_calico_network(remote, k8sclient):
  19. dns_pod = [
  20. pod for pod in k8sclient.pods.full_list()
  21. if 'kubedns' in pod.name][0]
  22. pods_json_raw = k8sclient.pods.get(
  23. name=dns_pod.name, namespace=dns_pod.metadata.namespace)._data
  24. pods_json = pods_json_raw.to_dict()
  25. pod_ip = pods_json['status']['pod_ip']
  26. cmd = "ping -q -c1 -w10 {0}".format(pod_ip)
  27. helpers.wait(remote.execute(cmd)['exit_code'] == 0,
  28. timeout_msg='Timeout waiting responce from node with '
  29. 'dns_pod {0} '.format(pod_ip))
  30. options = 'ipip,nat-outgoing'
  31. calico_options = remote.execute(
  32. 'calicoctl pool show --ipv4')['stdout'][3].split('|')[2].strip()
  33. assert calico_options == options
  34. def required_images_exists(node_name, underlay, required_images):
  35. """Check if there are all base containers on node
  36. :param node_name: string
  37. :param underlay: fuel_ccp_tests.managers.UnderlaySSHManager
  38. :param required_images: list
  39. """
  40. cmd = "docker ps --no-trunc --format '{{.Image}}'"
  41. result = underlay.sudo_check_call(cmd, node_name=node_name)
  42. images = set([x.strip() for x in result['stdout']])
  43. LOG.debug('Containers on node "{0}" use images: '
  44. '{1}'.format(node_name, images))
  45. # Image name could contain unpredictable Docker registry name
  46. # (host:port), e.g. example.net:5000/hyperkube-amd64:v1.4.1
  47. # Use regex to check that image (base name) is used by some container
  48. assert all(
  49. any(re.match('^([\w.-]+(:\d+)?/)?' # Host:port (optional)
  50. '{0}:\S+$' # image name + ":" + image tag
  51. .format(required_image), image)
  52. for image in images)
  53. for required_image in required_images)