def test_version(): vre = '\s*vclc\s+Version\s+\d+\.\d+\.\d+\s+Build\s+\d+' try: # libtest.vclc assumes that stdout is valid JSON # This is intentionally not the case for --version. vclc('--version') assert False except VclcError as e: version = e.output print(version) assert(re.match(vre, version))
def test_ns_mk_rm_dir(): dirname = '/Ime3Wp2uMyaHFLVoNKSf'+seed try: vclc('ns', 'rm', '-r', dirname) assert False except VclcError as e: assert(e.returncode == errno.ENOENT) for ns in ('ns', 'namespace'): result = vclc(ns, 'mkdir', dirname) print('mkdir result:', result) assert(result['http_status'] == 200) # result = vclc(ns, 'rm', dirname) print('rm result:', result) assert(result['http_status'] == 200)
def test_ns_mk_rm_dir_deep(): rootname = '/Ime3Wp2uMyaHFLVoNKSf'+seed dirname = rootname + '/91DWiFjayE0F98BH8tgu/C9VcnHmQ8ZBI4rLXHNge' try: vclc('ns', 'rm', '-r', rootname) assert False except VclcError as e: assert(e.returncode == errno.ENOENT) for ns in ('ns', 'namespace'): result = vclc(ns, 'mkdir', '-p', dirname) print('mkdir result:', result) assert(result['http_status'] == 200) # result = vclc(ns, 'rm', '-r', rootname) print('rm result:', result) assert(result['http_status'] == 200)
def test_grid_lifecycle(): # # Define a workspace workspace_name = libtest.random_path(5,1) workspace_spec = libtest.create_workspace(writeback='never') result = vclc('ws', 'set', workspace_name, json.dumps(workspace_spec)) assert(result['http_status'] == 200) # # Post a grid entry grid_id = libtest.random_identifier(6) result = vclc('grid', 'post', grid_id, workspace_name) assert(result['http_status'] == 200) # # Look at the grid entry result = vclc('grid', 'get', grid_id) assert(result['http_status'] == 200) # # Delete the grid entry result = vclc('grid', 'delete', grid_id) assert(result['http_status'] == 200) # # Ensure it's gone try: vclc('grid', 'get', grid_id) assert False except VclcError as e: assert(e.returncode == errno.ENOENT) # # Delete the workspace result = vclc('ws', 'rm', workspace_name) assert(result['http_status'] == 200)
def test_ws_set_get_delete(): root_name = '/GmqYbvjQkoAEPQIGwzRa'+seed ws_spec = '{"writeback": "always", "maps": [{"vp_path": "/", "vtrq_id": 10, "vtrq_path": "/u/carol"}]}' # Clear out any existing spec vclc('ws', 'rm', root_name) for ws in ('ws', 'workspace'): for whack in ('rm', 'delete'): # # Create a workspace specification result = vclc(ws, 'set', root_name, ws_spec) print(ws, 'set', result) assert(result['http_status'] == 200) # # Delete it result = vclc(ws, whack, root_name) print(ws, whack, result) assert(result['http_status'] == 200)
def test_vp_find(): # # We're expecting ENOENT # try: result = vclc('vp', 'find', '--vp_host=scooby', '--mount_point=/doo') print('vp find:', result) assert False except VclcError as e: print('vp find:', e.output) assert(e.http_status == 404) assert(e.returncode == errno.ENOENT)
def test_private_space_reads(): # # Constants # vp_mount_root = '/tmp/vcnc/stress/' vtrq_path = '/test/stress' public_vp_mountpt = vp_mount_root + libtest.random_identifier(8) private_vp_mountpt = vp_mount_root + libtest.random_identifier(8) public_vp_workspace = libtest.create_workspace(vtrq_path=vtrq_path, writeback='always') private_vp_workspace = libtest.create_workspace(vtrq_path=vtrq_path, writeback='never') public_workspace_name = '/test/' + libtest.random_identifier(5) private_workspace_name = '/test/' + libtest.random_identifier(5) large_file_path_public = '{}/{}'.format(public_vp_mountpt, 'large.file') large_file_path_private = '{}/{}'.format(private_vp_mountpt, 'large.file') # # Create the directory in the vtrq # try: libtest.vclc('ns', 'mkdir', '-p', vtrq_path) except libtest.VclcError: pass # # Put the workspaces into the vtrq # libtest.create_workspace_vtrq(public_workspace_name, public_vp_workspace) libtest.create_workspace_vtrq(private_workspace_name, private_vp_workspace) # # Create the mount points # libtest.command('mkdir', '-p', public_vp_mountpt) # # Mount the public VP # libtest.mount_vp(public_vp_mountpt, public_workspace_name, is_private=False) # # Put a large (1MB) file into the vtrq # libtest.command('dd', 'if=/dev/urandom', 'of={}'.format(large_file_path_public), 'bs={}'.format(1024 * 1024), 'count={}'.format(1024)) # # Now mount the private vp and make the (first) md5sum # This shows up as vtrq reads on the dashboard. # libtest.mount_vp(private_vp_mountpt, private_workspace_name, is_private=True) libtest.command('md5sum', large_file_path_private) # # Now do the md5sum twice more. These should show up as # vpm reads on the dashboard. libtest.command('md5sum', large_file_path_private) libtest.command('md5sum', large_file_path_private) # # Delete the large file # libtest.command('rm', large_file_path_public) # # Un-mount the VPs # libtest.unmount_vp(public_vp_mountpt) libtest.unmount_vp(private_vp_mountpt) # # Remove the mount directories # libtest.command('rmdir', public_vp_mountpt) libtest.command('rmdir', private_vp_mountpt) # # Delete the workspaces from the vtrq # libtest.delete_workspace_vtrq(public_workspace_name) libtest.delete_workspace_vtrq(private_workspace_name)
def test_ns_copy(): src_rootname = '/gq4OtHmyQbZhHmbc9dp5'+seed src_tailname = 'Tjso7JcL0zdz0hI3dBcP' srcdir = src_rootname + '/' + src_tailname dest_rootname = '/GmqYbvjQkoAEPQIGwzRa'+seed # # Ensure neither the source nor destination directory exists. # try: vclc('ns', 'rm', '-r', src_rootname) except VclcError as e: pass try: vclc('ns', 'rm', '-r', dest_rootname) except VclcError as e: pass # # Try to copy non-existent directories. # try: vclc('ns', 'cp', srcdir, dest_rootname) assert False except VclcError as e: assert(e.returncode == errno.ENOENT) # # Copy directories that exist. Test all aliases. Expect success. # for ns in ('ns', 'namespace'): for cmd in ('cp', 'copy'): vclc('ns', 'mkdir', '-p', srcdir) result = vclc(ns, cmd, src_rootname, dest_rootname) print('ns copy result:', result) assert(result['http_status'] == 200) # vclc('ns', 'rm', '-r', src_rootname) vclc('ns', 'rm', '-r', dest_rootname)
def test_ns_ls(): for ns in ('ns', 'namespace'): result = vclc(ns, 'ls', '/') print(result) assert(result["http_status"] == 200)
def test_grid_list(): result = vclc('grid', 'list') assert(result['http_status'] == 200)
def test_ws_list(): result = vclc('ws', 'list', '/') print('ws list result:', result) assert(result['http_status'] == 200)
def test_vp_delete(): try: vclc('vp', 'delete', '0x0123456789ABCDEF') assert False except VclcError as e: assert(e.returncode == errno.ENOENT)