예제 #1
0
 def test_random_word(self):
     dict = open('/usr/share/dict/words', 'r')
     wordlist = [l.rstrip() for l in dict.readlines()]
     nfsmount = qnfs.NFSMount(ipaddr=MOUNT_ADDRESS)
     word = nfsmount.random_word()
     print word
     self.assertTrue(word in wordlist)
예제 #2
0
 def test_multiple_random_words(self):
     dict = open('/usr/share/dict/words', 'r')
     numwords = 2
     wordlist = [l.rstrip() for l in dict.readlines()]
     nfsmount = qnfs.NFSMount(ipaddr=MOUNT_ADDRESS)
     word = nfsmount.random_word(count=numwords)
     words = word.split("_")
     self.assertTrue(words[0] in wordlist)
     self.assertEqual(numwords, len(words))
예제 #3
0
 def test_write_file(self):
     filename = 'foo.txt'
     filepath = os.path.join(MOUNT_DIR, filename)
     contents = StringIO.StringIO()
     contents.write('foo' * 10)
     #print contents.getvalue()
     nfsmount = qnfs.NFSMount(MOUNT_ADDRESS)
     nfsmount.write_file(filepath, contents)
     with open(filepath, 'r') as f:
         read_contents = f.read()
         f.flush()
         f.close()
     self.assertEqual(read_contents, contents.getvalue())
예제 #4
0
 def test_read_file(self):
     filename = 'bar.txt'
     filepath = os.path.join(MOUNT_DIR, filename)
     contents = StringIO.StringIO()
     contents.write('bar' * 10)
     nfsmount = qnfs.NFSMount(MOUNT_ADDRESS)
     nfsmount.write_file(
         filepath, contents
     )  # we should not be using the object to create this file tbh
     read_contents = StringIO.StringIO()
     #read_contents.write(contents.getvalue())
     nfsmount.read_file(filepath, read_contents)
     #print read_contents.getvalue()
     self.assertEqual(read_contents.getvalue(), contents.getvalue())
예제 #5
0
 def test_randomname_words(self):
     numwords = 2
     nfsmount = qnfs.NFSMount(ipaddr=MOUNT_ADDRESS)
     result = nfsmount.random_name(length=2, words=True)
     wordlist = result.split("_")
     self.assertEqual(numwords, len(wordlist))
예제 #6
0
 def test_randomname2(self):
     target_length = 16
     nfsmount = qnfs.NFSMount(ipaddr=MOUNT_ADDRESS)
     result = nfsmount.random_name(target_length)
     self.assertEqual(target_length, len(result))
예제 #7
0
 def test_get_fullpath_leading_slash_on_file(self):
     nfsmount = qnfs.NFSMount(ipaddr=MOUNT_ADDRESS)
     filepath = '/foo.txt'
     targetfullpath = '%s/foo.txt' % MOUNT_DIR
     self.assertEqual(targetfullpath, nfsmount.get_fullpath(filepath))
예제 #8
0
 def test_get_fullpath(self):
     filename = 'foo.txt'
     fullpath = os.path.join(MOUNT_DIR, filename)
     nfsmount = qnfs.NFSMount(ipaddr=MOUNT_ADDRESS)
     result = nfsmount.get_fullpath(filename)
     self.assertEqual(result, fullpath)
예제 #9
0
 def test_instantiate_and_guess_directory(self):
     targetaddr = '192.168.11.147'
     targetdir = '/Volumes/%s' % targetaddr
     nfsmount = qnfs.NFSMount(ipaddr=targetaddr)
     self.assertEqual(targetdir, nfsmount.mount_root)
예제 #10
0
 def test_instantiate_with_target_addr(self):
     targetaddr = '192.168.11.147'
     nfsmount = qnfs.NFSMount(ipaddr=targetaddr)
     self.assertEqual(targetaddr, nfsmount.ipaddr)
예제 #11
0
 def test_discover_local_mount_fail(self):
     """the object should eval to false until a mount is made/discovered"""
     nfsmount = qnfs.NFSMount()
     self.assertFalse(nfsmount)
예제 #12
0
 def setUp(self):
     self.nfsmount = qnfs.NFSMount(ipaddr=MOUNT_ADDRESS)
예제 #13
0
 def test_resolve_local_filename(self):
     """Given a path to a file on the fs, return the local filename (including mount path)"""
     qpath = "/foo/bar/baz.txt"
     realpath = "/Volumes/%s/foo/bar/baz.txt" % MOUNT_ADDRESS
     nfsmount = qnfs.NFSMount(ipaddr=MOUNT_ADDRESS)
     self.assertEqual(realpath, nfsmount.resolve_local_filename(qpath))
예제 #14
0
 def test_remove_local_mount(self):
     create_local_mount(MOUNT_ADDRESS)
     nfsmount = qnfs.NFSMount(ipaddr=MOUNT_ADDRESS)
     self.assertTrue(nfsmount)
     nfsmount.unmount()
     self.assertFalse(nfsmount)
예제 #15
0
 def test_discover_local_mount_success(self):
     """the object should eval to true once a mount is made/discovered"""
     create_local_mount(MOUNT_ADDRESS)
     nfsmount = qnfs.NFSMount(ipaddr=MOUNT_ADDRESS)
     self.assertTrue(nfsmount)
     local_unmount(MOUNT_ADDRESS)
예제 #16
0
    args = parser.parse_args()
    api = json.loads(args.api)

    if args.threads is not None:
        process_count = int(args.threads)
    if args.count is not None:
        count = int(args.count)

    rc = [None] * process_count
    for i in range(0,process_count):
        rc[i] = RestClient(api["host"], api["port"])
        rc[i].login(api["user"], api["password"])

    if args.op == 'heat':
        nfs = qnfs.NFSMount(ipaddr=args.nfsaddr)
        try:
            if args.walterdelay:
                load_it(args.heat, count, walterdelay=float(args.walterdelay), nfs=nfs)
            else:
                load_it(args.heat, count, nfs=nfs)
        except KeyboardInterrupt:
            sys.exit(1)

    if args.op == 'create':
        create_assets("/", int(args.size))
        create_share("/", int(args.size)*1.5)

    if args.op == 'files':
        create_dir_api("/" + args.folder)
        pool = Pool(processes=process_count)
예제 #17
0
 def test_instantiate(self):
     nfsmount = qnfs.NFSMount()
     self.assertIsNotNone(nfsmount)