Module tests.test_snapshot
Functions
def check_hashed_and_with_immediate_hash(client, volume_name, snapshot_data_integrity, volume_size=16, data_size=1)
-
- Create and attach a volume
- Create snapshots
- Check snapshots' checksums are calculated and set and also check the checksums of the snapshot disk files are matched with the values from the api
def check_hashed_and_without_immediate_hash(client, volume_name, snapshot_data_integrity)
-
- Create and attach a volume
- Create snapshots
- Sleep for 120 seconds. Check snapshots' checksums are not calculated and not set, because the immediate hash after snapshot creation feature is disabled
- Check snapshots' checksums are calculated and set by the periodic check mechanism
def check_per_volume_hash_disable(client, volume_name, snapshot_data_integrity)
-
- Create and attach a volume
- Create snapshots
- Sleep for SNAPSHOT_CHECK_PERIOD+SNAPSHOT_CHECK_TOLERATION_DELAY seconds. Check snapshots' checksums are calculated and set and also check the checksums of the snapshot disk files are matched with the values from the api Check snapshots' checksums are calculated by periodic snapshot verification mechanism and set and also check the checksums of the snapshot disk files are matched with the values from the api
def check_snapshot_checksums_and_change_timestamps(volume)
def check_snapshot_checksums_set(volume)
def corrupt_snapshot_on_local_host(volume, snapshot_name)
def create_snapshots(client, volume, data_size, num_snapshots)
def detect_and_repair_corrupted_replica(client, volume_name, data_integrity_mode, retry_count=360)
-
- Create and attach a volume
- Create snapshots
- Check snapshots' checksums are calculated and set and also check the checksums of the snapshot disk files are matched with the values from the api
- Corrupt the snapshot of replica on the local host
- Check the replica rebuild is ran correctly
- Check snapshots are repaired
def get_available_snapshot(volume)
def get_available_snapshots(volume)
def get_checksum_from_snapshot_disk_file(data_path, snapshot_name)
def get_checksum_in_checksum_file(disk_path)
def get_ctime_from_snapshot_disk_file(data_path, snapshot_name)
def get_ctime_in_checksum_file(disk_path)
def get_local_host_replica_data_path(volume)
def prepare_settings_for_snapshot_test(client, data_integrity, immediate_check, fast_replica_rebuild, period_in_second=300)
def test_freeze_file_system_for_snapshot()
-
- Record the test start time.
- Set freeze-filesystem-for-snapshot to true.
- Create a Longhorn volume 6 GiB with a replica on every Longhorn node.
- Create a workload pod that mounts the volume and runs "dd if=/dev/random of=/path/to/file/under/mount/point bs=1M count=5000". (Add "status=progress" if running manually to see the progress freeze.)
- After the workload is running, take a snapshot.
- Verify the snapshot succeeded.
- Verify the pod completed successfully.
- Verify the following logs appeared in the instance-manager running the volume engine after the test began. (Checking logs this way isn't ideal, but there isn't really a better way to confirm the freeze.)
- "Freezing filesystem mounted at"
- "Unfreezing filesystem mounted at"
def test_snapshot_cr(client, volume_name, settings_reset)
-
GitHub ticket: https://github.com/longhorn/longhorn/issues/6298
- set auto-cleanup-system-generated-snapshot to true
- Create and attach a volume with 3 replicas
- Delete one of the volumes replicas.
- Wait for the replica to rebuild and volume become healthy
- Verify that there is one Longhorn snapshot CR of this volume
- Repeat steps 3-5 about 10 times
def test_snapshot_hash_detect_corruption_in_global_enabled_mode(client, volume_name, settings_reset)
-
Check the snapshot corruption can be detected and replica is rebuilt - global data-integrity is set to enabled - global immediate_hash is enabled
def test_snapshot_hash_detect_corruption_in_global_fast_check_mode(client, volume_name, settings_reset)
-
Check the snapshot corruption can be detected and replica is rebuilt - global data-integrity is set to fast-check - global immediate_hash is enabled
def test_snapshot_hash_global_disabled_and_per_volume_enabled_and_with_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are immediately calculated when the snapshots check when - global data-integrity is set to disabled - global immediate_hash is enabled - per-volume data-integrity is set to enabled
def test_snapshot_hash_global_disabled_and_per_volume_enabled_and_without_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are calculated by the periodic checksum check - global data-integrity is set to disabled - global immediate_hash is disabled - per-volume data-integrity is set to enabled
def test_snapshot_hash_global_disabled_and_per_volume_fast_check_and_with_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are immediately calculated when the snapshots check when - global data-integrity is set to disabled - global immediate_hash is enabled - per-volume data-integrity is set to fast-check
def test_snapshot_hash_global_disabled_and_per_volume_fast_check_and_without_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are calculated by the periodic checksum check - global data-integrity is set to disabled - global immediate_hash is disabled - per-volume data-integrity is set to fast-check
def test_snapshot_hash_global_disabled_with_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are not calculated when check when - global data-integrity is set to disabled - global immediate_hash is enabled - per-volume data-integrity is set to disabled and follows the global setting
def test_snapshot_hash_global_disabled_without_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are not calculated when check when - global data-integrity is set to disabled - global immediate_hash is disabled - per-volume data-integrity is set to disabled and follows the global setting
def test_snapshot_hash_global_enabled_and_per_volume_disable_and_with_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are not calculated - global data-integrity is set to enabled - global immediate_hash is enabled - per-volume data-integrity is set to disabled
def test_snapshot_hash_global_enabled_and_per_volume_disable_and_without_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are not calculated - global data-integrity is set to enabled - global immediate_hash is disabled - per-volume data-integrity is set to disabled
def test_snapshot_hash_global_enabled_with_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are immediately calculated when the snapshots are created - global data-integrity is set to enabled - global immediate_hash is enabled
def test_snapshot_hash_global_enabled_without_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are calculated by the periodic checksum check - global data-integrity is set to enabled - global immediate_hash is disabled
def test_snapshot_hash_global_fast_check_and_per_volume_disable_and_with_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are not calculated - global data-integrity is set to fast-check - global immediate_hash is enabled - per-volume data-integrity is set to disabled
def test_snapshot_hash_global_fast_check_and_per_volume_disable_and_without_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are not calculated - global data-integrity is set to fast-check - global immediate_hash is disabled - per-volume data-integrity is set to disabled
def test_snapshot_hash_global_fast_check_with_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are immediately calculated when the snapshots are created - global data-integrity is set to fast-check - global immediate_hash is enabled
def test_snapshot_hash_global_fast_check_without_immediate_hash(client, volume_name, settings_reset)
-
Check snapshots' checksums are calculated by the periodic checksum check - global data-integrity is set to fast-check - global immediate_hash is disabled
def wait_for_snapshot_checksums_generate(volume_name)
def write_device_random_data(dev, size)