Module tests.test_migration
Functions
def check_detached_volume_data(client, volume_name, data)
-
Attaches the volume to the current node then compares the volumes data against the passed data.
def get_hosts_for_migration_test(clients)
-
Filters out the current node from the returned hosts list
We use the current node for device writing before the test and verification of the data after the test
def migration_confirm_test(clients, volume_name, backing_image='')
def migration_rollback_test(clients, volume_name, backing_image='')
def setup_migration_test(clients, volume_name, backing_image='', replica_cnt=2)
-
Creates a new migratable volume then attaches it to the current node to write some test data on it.
def test_migration_confirm(clients, volume_name)
-
Test that a migratable RWX volume can be live migrated from one node to another.
- Creates a new RWX migratable volume.
- Attach to test node to write some test data on it.
- Detach from test node.
- Get set of nodes excluding the test node
- Attach volume to node 1 (initial node)
- Attach volume to node 2 (migration target)
- Wait for migration ready (engine running on node 2)
- Detach volume from node 1
- Observe volume migrated to node 2 (single active engine)
- Validate initially written test data
def test_migration_rollback(clients, volume_name)
-
Test that a migratable RWX volume can be rolled back to initial node.
- Creates a new RWX migratable volume.
- Attach to test node to write some test data on it.
- Detach from test node.
- Get set of nodes excluding the test node
- Attach volume to node 1 (initial node)
- Attach volume to node 2 (migration target)
- Wait for migration ready (engine running on node 2)
- Detach volume from node 2
- Observe volume stayed on node 1 (single active engine)
- Validate initially written test data
def test_migration_with_failed_replica(clients, request, volume_name)
-
Test that a degraded migratable RWX volume that contain an failed replica can be migrated.
- Create a new RWX migratable volume.
- Attach to node 1 to write some test data on it.
- Remove the replica directory (/var/lib/longhorn/replicas) for one node. This makes one volume replica stay failed.
- Attach volume to node 2 (migration target).
- Wait for migration ready (engine running on node 2). The newly created migration replica count should be the same as that of the healthy current replicas.
- Detach volume from node 1.
- Observe volume migrated to node 2 (single active engine). And the old failed replica will be cleaned up.
- Validate initially written test data.
def test_migration_with_rebuilding_replica(clients, volume_name)
-
Test that a degraded migratable RWX volume that contain a rebuilding replica can be migrated.
- Create a new RWX migratable volume.
- Attach to node 1, then write a large amount if data on it so that the following rebuilding will take a while.
- Remove one healthy replica to trigger rebuilding.
- Immediately attach volume to node 2 (migration target) once the rebuilding starts. There should be no replica created before rebuilding complete.
- Wait for rebuilding complete then migration ready (engine running on node 2). The newly created migration replica count should be the same as that of the current replicas.
- Detach volume from node 1.
- Observe volume migrated to node 2 (single active engine).
- Validate initially written test data.
def test_migration_with_restore_volume(core_api, client, clients, volume_name, storage_class, pvc_name, set_random_backupstore)
-
Test that a restored volume can be migrated. 1. Prepare one backup. 2. Create a StorageClass with
migratable
being enabled andfromBackup
pointing to the above backup. 3. Create a new RWX migratable volume using the StorageClass. 4. Attach to node 1, then write some data. 5. Attach the volume to node 2 (migration target). 6. Wait for the migration ready. Verify that fieldvolume.controllers[0].requestedBackupRestore
is empty. 7. Confirm the migration then validate the data. def test_migration_with_unscheduled_replica(clients, volume_name)
-
Test that a degraded migratable RWX volume that contain an unscheduled replica can be migrated.
- Disable the scheduling for one node.
- Create a new RWX migratable volume.
- Attach to test node to write some test data on it.
- Detach from test node.
- Get set of nodes excluding the test node.
- Attach volume to node 1 (initial node). The volume should be Degraded with an unscheduled replica.
- Attach volume to node 2 (migration target)
- Wait for migration ready (engine running on node 2). The newly created migration replica count should be the same as that of the current replicas.
- Detach volume from node 1.
- Observe volume migrated to node 2 (single active engine)
- Enable the scheduling for the node and wait for rebuilding complete.
- Validate initially written test data.