# Copyright 2021 Google LLC
#
# 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.

---

- name: Get partition info
  command: sinfo --format='%P' --noheader
  register: partition_output
- name: Check partition compute exists
  fail:
    msg: Test Check Partitions failed
  when: item not in partition_output.stdout
  loop: "{{ partitions }}"

- name: Get mount info
  stat:
    path: "{{ item }}"
  register: stat_mounts
  loop: "{{ mounts }}"
- name: Check if mount exists
  fail:
    msg: "{{ item.item }} not mounted"
  when: not item.stat.exists
  loop: "{{ stat_mounts.results }}"

- name: Test Mounts on partitions
  command: srun -N 1 ls -laF {{ mounts | join(' ') }}
  loop: "{{ partitions }}"

- name: Test partitions with hostname
  command: srun -N 2 --partition {{ item }} hostname
  loop: "{{ partitions }}"

# Copyright 2021 Google LLC
#
# 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.

---

- name: Get partition info
  command: sinfo --format='%P' --noheader
  register: partition_output
- name: Check partition compute exists
  fail:
    msg: Test Check Partitions failed
  when: item not in partition_output.stdout
  loop: "{{ partitions }}"

- name: Get mount info
  stat:
    path: "{{ item }}"
  register: stat_mounts
  loop: "{{ mounts }}"
- name: Check if mount exists
  fail:
    msg: "{{ item.item }} not mounted"
  when: not item.stat.exists
  loop: "{{ stat_mounts.results }}"

- name: Test Mounts on partitions
  shell: srun -N 1 ls -laF {{ mounts | join(' ') }} && sleep 120
  loop: "{{ partitions }}"

- name: Test partitions with hostname
  shell: srun -N 2 --partition {{ item }} hostname && sleep 120
  loop: "{{ partitions }}"

Add a pause between slurm srun tests
Add a pause between slurm srun tests
