kayobe/ansible/roles/swift-block-devices/tests/test-bootstrapped.yml
Mark Goddard 0c309a18c8 Ubuntu: update Apt cache before package installation
Update Apt cache prior to all package installation tasks.

Adds apt_cache_valid_time, which defaults to 3600 seconds. This allows
the time for which the Apt cache is valid to be configured.

Change-Id: I0ecf4f4ce9b7333d3e41c69c3f908bee83391781
Story: 2004960
Task: 41766
2021-03-01 18:00:49 +00:00

70 lines
1.8 KiB
YAML

---
# Test case with one device that has already been partitioned.
- hosts: localhost
connection: local
tasks:
- name: Allocate a temporary file for a fake device
tempfile:
register: tempfile
- name: Allocate a fake device file
command: fallocate -l 32M {{ tempfile.path }}
- name: Find a free loopback device
command: losetup -f
register: loopback
become: true
- name: Create a loopback device
command: losetup {{ loopback.stdout }} {{ tempfile.path }}
become: true
- name: Add a partition
become: True
parted:
device: "{{ loopback.stdout }}"
number: 1
label: gpt
name: KOLLA_SWIFT_DATA
state: present
- block:
- name: Test the swift-block-devices role
include_role:
name: ../../swift-block-devices
vars:
swift_block_devices:
- device: "{{ loopback.stdout }}"
apt_cache_valid_time: 3600
- name: Get name of fake partition
parted:
device: "{{ loopback.stdout }}"
register: "disk_info"
become: True
- name: Validate number of partition
assert:
that: disk_info.partitions | length == 1
msg: >
Number of partitions is not correct.
- name: Validate partition label is present
assert:
that: "disk_info.partitions.0.name == 'KOLLA_SWIFT_DATA'"
msg: >
Name of partition is not correct.
always:
- name: Remove the fake file
file:
name: "{{ loopback.stdout }}"
state: absent
become: true
rescue:
- name: Flag that a failure occurred
set_fact:
test_failures: "{{ test_failures | default(0) | int + 1 }}"