2021-04-19 07:04:29 +02:00
|
|
|
|
---
|
2022-08-05 14:03:38 +02:00
|
|
|
|
# Copyright (c) Ansible Project
|
|
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2021-04-19 07:04:29 +02:00
|
|
|
|
# Test module with sparse files
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Create a huge sparse file of 2TB (check mode)
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2TB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_01
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
- name: Stat the file (should not exist)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_01
|
|
|
|
|
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Create a huge sparse file of 2TB
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2TB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_02
|
|
|
|
|
|
|
|
|
|
- name: Stat the resulting file (should exist now)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_02
|
|
|
|
|
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Create a huge sparse file of 2TB (2000GB) (check mode, idempotency)
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2000GB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_03
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Create a huge sparse file of 2TB (2000GB) (idempotency)
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2000GB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_04
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Create a huge sparse file of 2TB (2000000 × 1MB) (check mode, idempotency)
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2000000
|
2021-04-19 07:04:29 +02:00
|
|
|
|
blocksize: 1MB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_05
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Create a huge sparse file of 2TB (2000000 × 1MB) (idempotency)
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2000000
|
2021-04-19 07:04:29 +02:00
|
|
|
|
blocksize: 1MB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_06
|
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should remain the same)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_06
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that results are as expected
|
|
|
|
|
ansible.builtin.assert:
|
|
|
|
|
that:
|
|
|
|
|
- filesize_test_sparse_01 is changed
|
|
|
|
|
- filesize_test_sparse_02 is changed
|
|
|
|
|
- filesize_test_sparse_03 is not changed
|
|
|
|
|
- filesize_test_sparse_04 is not changed
|
|
|
|
|
- filesize_test_sparse_05 is not changed
|
|
|
|
|
- filesize_test_sparse_06 is not changed
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_02.cmd == filesize_test_sparse_01.cmd
|
|
|
|
|
- filesize_test_sparse_03.cmd is undefined
|
|
|
|
|
- filesize_test_sparse_04.cmd is undefined
|
|
|
|
|
- filesize_test_sparse_05.cmd is undefined
|
|
|
|
|
- filesize_test_sparse_06.cmd is undefined
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- filesize_test_sparse_01.filesize.bytes == 2*1000**4
|
|
|
|
|
- filesize_test_sparse_02.filesize.bytes == 2*1000**4
|
|
|
|
|
- filesize_test_sparse_03.filesize.bytes == 2*1000**4
|
|
|
|
|
- filesize_test_sparse_04.filesize.bytes == 2*1000**4
|
|
|
|
|
- filesize_test_sparse_05.filesize.bytes == 2*1000**4
|
|
|
|
|
- filesize_test_sparse_06.filesize.bytes == 2*1000**4
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- filesize_test_sparse_01.size_diff == 2*1000**4
|
|
|
|
|
- filesize_test_sparse_02.size_diff == 2*1000**4
|
2021-04-19 07:04:29 +02:00
|
|
|
|
- filesize_test_sparse_03.size_diff == 0
|
|
|
|
|
- filesize_test_sparse_04.size_diff == 0
|
|
|
|
|
- filesize_test_sparse_05.size_diff == 0
|
|
|
|
|
- filesize_test_sparse_06.size_diff == 0
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_01.state is undefined
|
|
|
|
|
- filesize_test_sparse_02.state in ["file"]
|
|
|
|
|
- filesize_test_sparse_01.size is undefined
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- filesize_test_sparse_02.size == 2*1000**4
|
|
|
|
|
- filesize_test_sparse_03.size == 2*1000**4
|
|
|
|
|
- filesize_test_sparse_04.size == 2*1000**4
|
|
|
|
|
- filesize_test_sparse_05.size == 2*1000**4
|
|
|
|
|
- filesize_test_sparse_06.size == 2*1000**4
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
- not filesize_stat_sparse_01.stat.exists
|
|
|
|
|
- filesize_stat_sparse_02.stat.exists
|
|
|
|
|
- filesize_stat_sparse_02.stat.isreg
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- filesize_stat_sparse_02.stat.size == 2*1000**4
|
|
|
|
|
- filesize_stat_sparse_06.stat.size == 2*1000**4
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Change sparse file size to 2TiB (check mode)
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2TiB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_11
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should remain the same)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_11
|
|
|
|
|
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Change sparse file size to 2TiB
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2TiB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_12
|
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should have grown)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_12
|
|
|
|
|
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Change sparse file size to 2TiB (2048GiB) (check mode, idempotency)
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2048GiB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_13
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Change sparse file size to 2TiB (2048GiB) (idempotency)
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2048GiB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_14
|
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should remain the same)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_14
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that results are as expected
|
|
|
|
|
ansible.builtin.assert:
|
|
|
|
|
that:
|
|
|
|
|
- filesize_test_sparse_11 is changed
|
|
|
|
|
- filesize_test_sparse_12 is changed
|
|
|
|
|
- filesize_test_sparse_13 is not changed
|
|
|
|
|
- filesize_test_sparse_14 is not changed
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_12.cmd == filesize_test_sparse_11.cmd
|
|
|
|
|
- filesize_test_sparse_13.cmd is undefined
|
|
|
|
|
- filesize_test_sparse_14.cmd is undefined
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- filesize_test_sparse_11.size_diff == 199023255552
|
|
|
|
|
- filesize_test_sparse_12.size_diff == 199023255552
|
2021-04-19 07:04:29 +02:00
|
|
|
|
- filesize_test_sparse_13.size_diff == 0
|
|
|
|
|
- filesize_test_sparse_14.size_diff == 0
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- filesize_test_sparse_11.size == 2000000000000
|
|
|
|
|
- filesize_test_sparse_12.size == 2199023255552
|
|
|
|
|
- filesize_test_sparse_13.size == 2199023255552
|
|
|
|
|
- filesize_test_sparse_14.size == 2199023255552
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- filesize_stat_sparse_11.stat.size == 2000000000000
|
|
|
|
|
- filesize_stat_sparse_12.stat.size == 2199023255552
|
|
|
|
|
- filesize_stat_sparse_14.stat.size == 2199023255552
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Change sparse file size to 2.321TB (check mode)
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2.321TB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_21
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should remain the same)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_21
|
|
|
|
|
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Change sparse file size to 2.321TB
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2.321TB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_22
|
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should have been reduced)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_22
|
|
|
|
|
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Change sparse file size to 2321×1GB (check mode, idempotency)
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2321
|
2021-04-19 07:04:29 +02:00
|
|
|
|
blocksize: 1GB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_23
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- name: Change sparse file size to 2321×1GB (idempotency)
|
2021-04-19 07:04:29 +02:00
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2024-02-03 15:27:31 +01:00
|
|
|
|
size: 2321
|
2021-04-19 07:04:29 +02:00
|
|
|
|
blocksize: 1GB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_24
|
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should remain the same)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_24
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that results are as expected
|
|
|
|
|
ansible.builtin.assert:
|
|
|
|
|
that:
|
|
|
|
|
- filesize_test_sparse_21 is changed
|
|
|
|
|
- filesize_test_sparse_22 is changed
|
|
|
|
|
- filesize_test_sparse_23 is not changed
|
|
|
|
|
- filesize_test_sparse_24 is not changed
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_22.cmd == filesize_test_sparse_21.cmd
|
|
|
|
|
- filesize_test_sparse_23.cmd is undefined
|
|
|
|
|
- filesize_test_sparse_24.cmd is undefined
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- filesize_test_sparse_21.size_diff == 2321*1000**3 - 2*1024**4
|
|
|
|
|
- filesize_test_sparse_22.size_diff == 2321*1000**3 - 2*1024**4
|
2021-04-19 07:04:29 +02:00
|
|
|
|
- filesize_test_sparse_23.size_diff == 0
|
|
|
|
|
- filesize_test_sparse_24.size_diff == 0
|
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- filesize_test_sparse_21.size == 2199023255552
|
|
|
|
|
- filesize_test_sparse_22.size == 2321000000000
|
|
|
|
|
- filesize_test_sparse_23.size == 2321000000000
|
|
|
|
|
- filesize_test_sparse_24.size == 2321000000000
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
2024-02-03 15:27:31 +01:00
|
|
|
|
- filesize_stat_sparse_21.stat.size == 2199023255552
|
|
|
|
|
- filesize_stat_sparse_22.stat.size == 2321000000000
|
|
|
|
|
- filesize_stat_sparse_24.stat.size == 2321000000000
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Remove test file
|
|
|
|
|
ansible.builtin.file:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
state: absent
|