#  Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
#
#  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.
---

# OMNIA_UKP_US_VFKP_TC_013
# Execute k8s_start_services role in manager nodes with os installed centos 7.9
- name: OMNIA_UKP_US_VFKP_TC_013
  hosts: manager
  gather_facts: false
  vars_files:
    - test_vars/test_k8s_start_services_vars.yml
  tasks:
    - block:
        - name: Call k8s_start_services role
          include_role:
            name: ../roles/k8s_start_services
      tags: TC_013

    - name: Waiting for the pods deployment
      pause:
        minutes: 10
      tags: TC_013

    - name: Checking all running pods
      command: kubectl get pods --all-namespaces --field-selector=status.phase=Running
      register: running_pods
      changed_when: false
      ignore_errors: True
      tags: TC_013, VERIFY_013

    - name: Checking default storage class
      command: kubectl get sc
      register: default_storage_class
      changed_when: false
      ignore_errors: True
      tags: TC_013, VERIFY_013

    - name: Validating Metallb, Prometheus and MPI pods
      assert:
        that:
          - "'metallb' in running_pods.stdout"
          - "'prometheus' in running_pods.stdout"
          - "'mpi-operator' in running_pods.stdout"
        fail_msg: "{{ metallb_prometheus_mpi_pods_fail_msg }}"
        success_msg: "{{ metallb_prometheus_mpi_pods_success_msg }}"
      tags: TC_013, VERIFY_013

    - name: Validating K8s dashboard
      assert:
        that:
          - "'kubernetes-dashboard' in running_pods.stdout"
        fail_msg: "{{ kubernetes_dashboard_fail_msg }}"
        success_msg: "{{ kubernetes_dashboard_success_msg }}"
      tags: TC_013, VERIFY_013

    - name: Validating NFS Client Provisioner pods
      assert:
        that:
          - "'nfs-client-provisioner' in running_pods.stdout"
        fail_msg: "{{ nfs_client_provisioner_pods_fail_msg }}"
        success_msg: "{{ nfs_client_provisioner_pods_success_msg }}"
      tags: TC_013, VERIFY_013

    - name: Validating default storage class
      assert:
        that:
          - "'nfs-client' in default_storage_class.stdout"
        fail_msg: "{{ default_storage_class_fail_msg }}"
        success_msg: "{{ default_storage_class_success_msg }}"
      tags: TC_013, VERIFY_013

    - name: Validating Node Feature Discovery pods
      assert:
        that:
          - "'node-feature-discovery' in running_pods.stdout"
        fail_msg: "{{ node_feature_discovery_pods_fail_msg }}"
        success_msg: "{{ node_feature_discovery_pods_success_msg }}"
      tags: TC_013, VERIFY_013

    - name: Validating Nvidia device plugin pods
      assert:
        that:
          - "'nvidia-device-plugin' in running_pods.stdout"
        fail_msg: "{{ nvidia_device_plugin_pods_fail_msg }}"
        success_msg: "{{ nvidia_device_plugin_pods_success_msg }}"
      tags: TC_013, VERIFY_013