def loop_device(device_host): dev_file = '/tmp/disk' loop_device_cleanup(device_host, dev_file, password=LOGS_SSH_PASSWORD) print('adding loop device') run_ssh(device_host, 'dd if=/dev/zero bs=1M count=10 of={0}'.format(dev_file), password=LOGS_SSH_PASSWORD) run_ssh(device_host, 'sync', password=LOGS_SSH_PASSWORD) run_ssh(device_host, 'ls -la {0}'.format(dev_file), password=LOGS_SSH_PASSWORD) loop = run_ssh(device_host, 'losetup -f --show {0}'.format(dev_file), password=LOGS_SSH_PASSWORD) run_ssh(device_host, 'losetup', password=LOGS_SSH_PASSWORD) run_ssh(device_host, 'losetup -j {0} | grep {0}'.format(dev_file), password=LOGS_SSH_PASSWORD, retries=3) run_ssh(device_host, 'file -s {0}'.format(loop), password=LOGS_SSH_PASSWORD) run_ssh(device_host, 'sync', password=LOGS_SSH_PASSWORD) run_ssh(device_host, 'partprobe {0}'.format(loop), password=LOGS_SSH_PASSWORD, retries=3) yield loop loop_device_cleanup(device_host, dev_file, password=LOGS_SSH_PASSWORD)
def test_disk_physical_remove(loop_device, public_web_session, device_host, installer, ssh_env_vars, app_dir): disk_create(loop_device, 'ext4', device_host, installer) assert disk_activate(loop_device, public_web_session, device_host, ssh_env_vars, app_dir) == '/opt/disk/external/platform' loop_device_cleanup(device_host, '/opt/disk/external', password=DEVICE_PASSWORD) run_ssh(device_host, 'udevadm trigger --action=remove -y {0}'.format(loop_device.split('/')[2]), password=DEVICE_PASSWORD) run_ssh(device_host, 'udevadm settle', password=DEVICE_PASSWORD) assert current_disk_link(device_host, ssh_env_vars, app_dir) == '/opt/disk/internal/platform'
def test_disk(app_domain, device, domain, device_user, device_password, artifact_dir): loop_device_cleanup(domain, '/tmp/test0', device_password) loop_device_cleanup(domain, '/tmp/test1', device_password) __create_test_dir('test00', app_domain, device_user, device_password, artifact_dir) files_scan(device) __check_test_dir(device_user, device_password, 'test00', app_domain, artifact_dir) device0 = loop_device_add(domain, 'ext4', '/tmp/test0', device_password) __activate_disk(device0, device, domain) __create_test_dir('test0', app_domain, device_user, device_password, artifact_dir) __check_test_dir(device_user, device_password, 'test0', app_domain, artifact_dir) device1 = loop_device_add(domain, 'ext2', '/tmp/test1', device_password) __activate_disk(device1, device, domain) __create_test_dir('test1', app_domain, device_user, device_password, artifact_dir) __check_test_dir(device_user, device_password, 'test1', app_domain, artifact_dir) __activate_disk(device0, device, domain) __check_test_dir(device_user, device_password, 'test0', app_domain, artifact_dir) __deactivate_disk(device, domain)