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.

  1. Creates a new RWX migratable volume.
  2. Attach to test node to write some test data on it.
  3. Detach from test node.
  4. Get set of nodes excluding the test node
  5. Attach volume to node 1 (initial node)
  6. Attach volume to node 2 (migration target)
  7. Wait for migration ready (engine running on node 2)
  8. Detach volume from node 1
  9. Observe volume migrated to node 2 (single active engine)
  10. 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.

  1. Creates a new RWX migratable volume.
  2. Attach to test node to write some test data on it.
  3. Detach from test node.
  4. Get set of nodes excluding the test node
  5. Attach volume to node 1 (initial node)
  6. Attach volume to node 2 (migration target)
  7. Wait for migration ready (engine running on node 2)
  8. Detach volume from node 2
  9. Observe volume stayed on node 1 (single active engine)
  10. 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.

  1. Create a new RWX migratable volume.
  2. Attach to node 1 to write some test data on it.
  3. Remove the replica directory (/var/lib/longhorn/replicas) for one node. This makes one volume replica stay failed.
  4. Attach volume to node 2 (migration target).
  5. 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.
  6. Detach volume from node 1.
  7. Observe volume migrated to node 2 (single active engine). And the old failed replica will be cleaned up.
  8. 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.

  1. Create a new RWX migratable volume.
  2. Attach to node 1, then write a large amount if data on it so that the following rebuilding will take a while.
  3. Remove one healthy replica to trigger rebuilding.
  4. Immediately attach volume to node 2 (migration target) once the rebuilding starts. There should be no replica created before rebuilding complete.
  5. 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.
  6. Detach volume from node 1.
  7. Observe volume migrated to node 2 (single active engine).
  8. 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 and fromBackup 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 field volume.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.

  1. Disable the scheduling for one node.
  2. Create a new RWX migratable volume.
  3. Attach to test node to write some test data on it.
  4. Detach from test node.
  5. Get set of nodes excluding the test node.
  6. Attach volume to node 1 (initial node). The volume should be Degraded with an unscheduled replica.
  7. Attach volume to node 2 (migration target)
  8. 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.
  9. Detach volume from node 1.
  10. Observe volume migrated to node 2 (single active engine)
  11. Enable the scheduling for the node and wait for rebuilding complete.
  12. Validate initially written test data.