Exemple #1
0
def test_run_xfstest(test_dir,s_dir):
  '''Wrapper over invoking xfstest on the given host default it will test xfs '''
  test_share = shares.find_share(test_dir)
  scratch_share = shares.find_share(s_dir)
  # create scratch_mnt if it does not exist otherwise xfstests abort
  command = '/usr/bin/mkdir -p ' +  env.env['xfstest']['scratch_mnt']
  pd.run_cmd('client', command)

  command = '(cd ' + env.env['paths']['xfstestpath'] + ' ; export TEST_DIR=' +  env.env['paths']['mount'] + ' ; export TEST_DEV=' + env.env['dd']['address'] + ':' + test_share['path'] + ' ; export SCRATCH_DEV=' + env.env['dd']['address'] + ':' + scratch_share['path'] +  '; export SCRATCH_MNT=' + env.env['xfstest']['scratch_mnt'] + ' ; export NFS_MOUNT_OPTIONS=\"-o minorversion=2\"' + ' ; ./check -nfs -T  )'
  print command
  return pd.run_cmd('client', command)
Exemple #2
0
def share_remove(name,exit_on_fail=True):
  '''Try to remove the given share, making sure to empty it first'''
  share = find_share(name)
  retval = pd.run_cmd('client', '/usr/bin/rm -rf ' + client_path(name))
  if retval != 0:
    print 'Could not empty share: ' + str(share['id'])
  command = env.pdshare_ctl + ' remove ' + str(share['id'])
  print command
  retval = pd.run_cmd('dd', command)
  if retval != 0:
    print 'Could not remove share: ' + str(share['id'])
    if exit_on_fail:
      sys.exit(retval)
  return retval
Exemple #3
0
def share_create(share):
  '''Try to create the given share'''
  command = pdshare_ctl_create(share)
  print command
  retval = pd.run_cmd('dd', command)
  if retval != 0:
    print 'Could not create a share for ' + share
  return retval
Exemple #4
0
def share_create_name(share, alias):
  '''Try to create the given share, overridding the name with the supplied value'''
  command = pdshare_ctl_create_name(share, alias)
  print command
  retval = pd.run_cmd('dd', command)
  if retval == 0:
    print 'Created the name ' + alias + '  on share for ' + share
  return retval
Exemple #5
0
def share_create_path(share, path):
  '''Try to create the given share, overridding the path with the supplied value'''
  command = pdshare_ctl_create_path(share, path)
  print command
  retval = pd.run_cmd('dd', command)
  if retval == 0:
    print 'Created the path ' + path + '  of share for ' + share
  return retval
Exemple #6
0
def share_create_id(share, shr):
  '''Try to create the given share, overridding the id with the supplied value'''
  command = pdshare_ctl_create_id(share, shr)
  print command
  retval = pd.run_cmd('dd', command)
  if retval == 0:
    print 'Created the shareid ' + shr + '  of share for ' + share
  return retval
Exemple #7
0
def test_run_fstest(test_dir):
  '''Wrapper over invoking fstest on the given share'''
  share = shares.find_share(test_dir)

  exclude_list = '-t:-filename:chmod/ctime -t:-filename:chown/ctime -t:-filename:read_write/mctime -t:-filename:unlink/mctime -t:-filename:open/flag_creat -t:-filename:chown/setid_nonroot -t:-filename:open/mctime -t:-filename:readlink/atime -t:-filename:read_write/atime'

  command = '(cd ' + env.env['paths']['fstest'] + '; ./fstest-suite -f nfs4p -d ' + env.env['paths']['mount'] + share['path'] + ' ' + exclude_list +  ')'
  return pd.run_cmd('client', command)
Exemple #8
0
def test_client_ls(name, subdir = ''):
  '''Test wrapper on readdir'ing a path on the client'''
  path = client_mounted_path(name)
  if subdir == '':
    rpath = path
  else:
    rpath = path + '/' + subdir
  return pd.run_cmd('client', '/usr/bin/ls -laiR ' + rpath)
Exemple #9
0
def test_client_echo(name, sup_text, dst_file):
  '''Test wrapper on echoing to a file on the client'''
  path = client_mounted_path(name)
  rpath =  path + '/' + dst_file
  retval = pd.run_cmd('client', '/usr/bin/echo '' + sup_text + '' > ' + rpath)
  if retval != 0:
    return retval
  return test_check_file(rpath)
Exemple #10
0
def test_client_mkdir(name, subdir):
  '''Test wrapper on making a directory on the client'''
  path = client_mounted_path(name)
  rpath = path + '/' + subdir
  retval = pd.run_cmd('client', '/usr/bin/mkdir -p ' + rpath)
  if retval != 0:
    return retval
  return test_check_path(rpath)
Exemple #11
0
def list_all_shares():
  '''List all of the shares'''
  command = env.pdshare_ctl + ' list';
  print command
  retval = pd.run_cmd('dd', command)
  if retval != 0:
    print 'Could not list all shares: retval = ' + str(retval) + '\n'
    sys.exit(retval)
  return retval
Exemple #12
0
def test_reload_protod(delegations, pnfs):
  '''Test wrapper over resetting the config file for protod on the dd'''
  if delegations:
    delegations_enabled = 'true'
  else:
    delegations_enabled = 'false'

  if pnfs:
    pnfs_enabled = 'true'
  else:
    pnfs_enabled = 'false'

  command = env.env['paths']['rgr'] + '/protod_conf.py -p ' + pnfs_enabled + ' -d ' + delegations_enabled
  return pd.run_cmd('dd', command)
Exemple #13
0
def test_run_cthon(test_dir):
    """Wrapper over invoking cthon on the given share"""
    share = shares.find_share(test_dir)
    command = (
        "(cd "
        + env.env["paths"]["cthon"]
        + "; /usr/bin/echo y | ./server -o vers=4.2 -p "
        + share["path"]
        + " -m "
        + env.env["paths"]["mount"]
        + " "
        + env.env["dd"]["address"]
        + ")"
    )
    return pd.run_cmd("client", command)
Exemple #14
0
def test_ln_s_file(src, dst):
  '''Test wrapper on soft linking a file on the client'''
  return pd.run_cmd('client', '/usr/bin/ln -s ' + src + ' ' + dst)
Exemple #15
0
def test_pcs_protod(state):
  '''Test wrapper over changing the state of protod on the dd'''
  return pd.run_cmd('dd', '/usr/sbin/pcs resource ' + state + ' PdProtodResource --wait')
Exemple #16
0
def test_open_up_share(name):
  '''Test wrapper to make sure anyone can access a share on the client'''
  path = client_mounted_path(name)
  return pd.run_cmd('client', '/usr/bin/chmod 777 ' + path)
Exemple #17
0
def test_check_path(path):
  '''Test wrapper on checking a directory exists on the client'''
  return pd.run_cmd('client', env.env['paths']['rgr'] + '/check_path.py -p ' + path)
Exemple #18
0
def test_run_mtime():
  '''Test wrapper to run the mtime test on the client'''
  return pd.run_cmd('client', env.env['paths']['rgr'] + '/mtime.py -p ' + env.env['paths']['mount'])
Exemple #19
0
def test_copy_file(src, dst):
  '''Test wrapper on copying a file on the client'''
  return pd.run_cmd('client', env.env['paths']['rgr'] + '/copy_file.py -s ' + src + ' -d ' + dst)
Exemple #20
0
def delete_all_shares():
  '''Clean the slate by deleting all of the shares'''
  share = ''
  path = ''

  shares = []

  share_re = re.compile(r'^ (share) ([0-9]+):(.*)')
  path_re = re.compile(r'^\t(path)=(.*)$')

  ssh = paramiko.SSHClient()
  ssh.load_system_host_keys()
  ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

  host = 'dd'
  command = env.pdshare_ctl + ' list';
  print 'The host is ' + host
  print 'Trying to connect to ' + env.env[host]['address']

  # First find the set of shares to delete
  try:
    ssh.connect(env.env[host]['address'], username=env.env[host]['username'], password=env.env[host]['password'], timeout=300)
  except paramiko.AuthenticationException:
    print 'Authentication failed when connecting to %s' % env.env[host]['address']
    sys.exit(1)
  except:
    print 'Random error connecting to %s' % env.env[host]['address']
    sys.exit(1)

  try:
    stdin, stdout, stderr = ssh.exec_command(command,timeout=300)
  except paramiko.SSHException:
    print 'Cannot execute ' + command + ' on %s' % env.env[host]['address']
    sys.exit(1)

  retval = stdout.channel.recv_exit_status()

  for line in stdout:
    if ' share ' in line:
      m = re.match(share_re, line)
      share = m.group(2)
      print 'found SHARE ' + share,
    elif 'path=' in line:
      m = re.match(path_re, line)
      path = m.group(2)
      print 'with PATH ' + path,
      shares.append({'share':share, 'path':path})

  ssh.close()

  for share in sorted(shares, key=lambda share: share['path'], reverse=True):
    # shares are supposed to be empty before being deleted
    retval = pd.mount('client', env.env['paths']['mount'], 'dd', share['path'])
    if retval == 0:
      retval = pd.run_cmd('client', '/usr/bin/rm -rf ' + env.env['paths']['mount'])
      retval = pd.umount('client', env.env['paths']['mount'])

    command = env.pdshare_ctl + ' remove ' + share['share']
    print command
    retval = pd.run_cmd('dd', command)
    if retval != 0:
      print 'Could not remove share: ' + share['share'] + '\n'
      sys.exit(retval)

  return retval
Exemple #21
0
def test_cmp_file(src, dst):
  '''Test wrapper on comparing two files on the client'''
  return pd.run_cmd('client', env.env['paths']['rgr'] + '/cmp_file.py -s ' + src + ' -d ' + dst)
Exemple #22
0
def test_host_time(host, blurb):
  '''Test wrapper on getting the current time on the host'''
  print 'Getting the time on ' + host + ' for ' + blurb
  return pd.run_cmd(host, '/usr/bin/date')
Exemple #23
0
def test_client_cat(name, dst_file):
  '''Test wrapper on catting a file on the client'''
  path = client_mounted_path(name)
  return pd.run_cmd('client', '/usr/bin/cat ' + path + '/' + dst_file)
Exemple #24
0
def test_mknod_file(src):
  '''Test wrapper on mknoding a file on the client'''
  return pd.run_cmd('client', '/usr/bin/mknod -m 666 ' + src + ' c 1 3')
Exemple #25
0
def test_mv_obj(src, dst):
  '''Test wrapper on moving a file on the client'''
  return pd.run_cmd('client', '/usr/bin/mv ' + src + ' ' + dst)