# SPDX-License-Identifier: MIT
---
- name: Test configuration of retention period
  hosts: all
  vars:
    __test_retention: 137
    metrics_retention_days: "{{ __test_retention }}"

  pre_tasks:
    - name: Save state of services
      import_tasks: get_services_state.yml

  tasks:
    - name: Run test
      block:
        - name: Run the role
          include_role:
            name: linux-system-roles.metrics
            public: true

        - name: Check basic services and the retention
          include_tasks: "{{ item }}"
          loop:
            - check_pcp.yml
            - check_pmlogger.yml
            - check_pmie.yml
            - check_retention.yml
            - check_firewall_selinux.yml

        - name: Flush handlers
          meta: flush_handlers

      rescue:
        - name: Handle failure case
          include_tasks: handle_test_failure.yml

      always:
        - name: Restore state of services
          import_tasks: restore_services_state.yml
