Skip to content

Commit

Permalink
Merge 15ed60b into bc5a025
Browse files Browse the repository at this point in the history
  • Loading branch information
andamian committed Sep 18, 2020
2 parents bc5a025 + 15ed60b commit 34b16f3
Show file tree
Hide file tree
Showing 35 changed files with 2,668 additions and 2,003 deletions.
1 change: 1 addition & 0 deletions vofs/test/scripts/vospace-mountvospace-atest.tcsh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ rm -fR $VOS_CACHE #clean the cache
# For the anonymous mount test we use a separate temporary log
echo -n "mount vospace anonymously"
rm $ANONLOGFILE >& /dev/null
echo "$MOUNTCMD --certfile=anonymous --mountpoint=$MOUNTPOINT --cache_dir=$VOS_CACHE --log=$ANONLOGFILE -d"
$MOUNTCMD --certfile=anonymous --mountpoint=$MOUNTPOINT --cache_dir=$VOS_CACHE --log=$ANONLOGFILE -d >& /dev/null || echo " [FAIL]" && exit -1
sleep 3
ls $MOUNTPOINT >& /dev/null || echo " [FAIL]" && exit -1
Expand Down
2 changes: 1 addition & 1 deletion vofs/tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py34, py35, py36
envlist = py27, py34, py35, py36, py37, py38
skip_missing_interpreters = True

[testenv]
Expand Down
20 changes: 18 additions & 2 deletions vofs/vofs/mountvofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import os
import logging
import getpass
from six.moves.urllib.parse import urlparse

from vos import vos
from .version import version
from .vofs import VOFS
from .vofs import MyFuse
from vos.commonparser import CommonParser, set_logging_level_from_args
from vos import vosconfig

DAEMON_TIMEOUT = 60

Expand All @@ -20,7 +22,12 @@ def mountvofs():
parser = CommonParser(description='mount vospace as a filesystem.')

# mountvofs specific options
parser.add_option("--vospace", help="the VOSpace to mount", default="vos:")
parser.add_option("--vospace",
help="the VOSpace to mount. Default is vos (CADC vault "
"service) but other VOSpaces can be used and "
"referred to through their configured prefix (see "
"vos-config command)",
default="vos:")
parser.add_option("--mountpoint",
help="the mountpoint on the local filesystem",
default="/tmp/vospace")
Expand Down Expand Up @@ -95,7 +102,16 @@ def mountvofs():
else:
certfile = os.path.abspath(opt.certfile)

conn = vos.Connection(vospace_certfile=certfile, vospace_token=opt.token)
service_prefix = None # default service prefix
if opt.vospace:
service_prefix = urlparse(opt.vospace).scheme
try:
resource_id = vosconfig.vos_config.get_resource_id(service_prefix)
except Exception as e:
raise RuntimeError(
'Cannot identify vospace service: {}'.format(str(e)))
conn = vos.Connection(resource_id=resource_id,
vospace_certfile=certfile, vospace_token=opt.token)
if opt.token:
readonly = opt.readonly
logger.debug("Got a token, connections should work")
Expand Down
24 changes: 12 additions & 12 deletions vofs/vofs/tests/test_vofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def readData(self, start, mandatory, optional):


class TestVOFS(unittest.TestCase):
testMountPoint = "/tmp/testfs"
testMountPoint = "vos:tmp/testfs"
testCacheDir = "/tmp/testCache"

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -298,17 +298,17 @@ def test_create(self):
parentNode.groupread = True
parentNode.groupwrite = True
testfs.client.open = Mock()
testfs.getNode = Mock(side_effect=SideEffect({
testfs.client.get_node = Mock(side_effect=SideEffect({
('/dir1/dir2/file',): node,
('/dir1/dir2',): parentNode}, name="testfs.getNode"))
with patch('vos.vos.Client.create', Mock(return_value=node)):
with self.assertRaises(FuseOSError):
testfs.create(file, os.O_RDWR)
testfs.client.create = Mock(return_value=node)
with self.assertRaises(OSError):
testfs.create(file, os.O_RDWR)

testfs.getNode = Mock(side_effect=FuseOSError(errno=5))
with patch('vos.vos.Client.create', Mock(return_value=node)):
with self.assertRaises(FuseOSError):
testfs.create(file, os.O_RDWR)
testfs.client.create = Mock(return_value=node)
with self.assertRaises(FuseOSError):
testfs.create(file, os.O_RDWR)

node.props.get = Mock(return_value=False)
testfs = vofs.VOFS(self.testMountPoint, self.testCacheDir, opt)
Expand All @@ -317,8 +317,8 @@ def test_create(self):
testfs.getNode = Mock(side_effect=SideEffect({
('/dir1/dir2/file',): node,
('/dir1/dir2',): parentNode}, name="testfs.getNode"))
with patch('vos.vos.Client.create', Mock(return_value=node)):
testfs.create(file, os.O_RDWR)
testfs.client.create = Mock(return_value=node)
testfs.create(file, os.O_RDWR)
testfs.open.assert_called_once_with(file, os.O_WRONLY)

@unittest.skipIf(skipTests, "Individual tests")
Expand Down Expand Up @@ -1080,7 +1080,7 @@ def test_MyFuse(self, mock_libfuse):
conn = MagicMock()
mock_libfuse.fuse_main_real.return_value = False
fuseops = fuse_operations()
MyFuse(VOFS(":vos", "/tmp/vos_", None, conn=conn,
MyFuse(VOFS("vos:", "/tmp/vos_", None, conn=conn,
cache_limit=100,
cache_max_flush_threads=3),
"/tmp/vospace",
Expand All @@ -1094,7 +1094,7 @@ def test_MyFuse(self, mock_libfuse):
ctypes.sizeof(fuseops),
None)

MyFuse(VOFS(":vos", "/tmp/vos_", None, conn=conn,
MyFuse(VOFS("vos:", "/tmp/vos_", None, conn=conn,
cache_limit=100,
cache_max_flush_threads=3),
"/tmp/vospace",
Expand Down
4 changes: 2 additions & 2 deletions vofs/vofs/vofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import sys
import urllib
import re
import logging
import six.moves
from cadcutils import exceptions
from fuse import FUSE, Operations, FuseOSError
from threading import Lock
Expand All @@ -17,8 +19,6 @@
from .CadcCache import Cache, CacheCondition, CacheRetry, CacheAborted, \
IOProxy, FlushNodeQueue, CacheError
from vos.logExceptions import logExceptions
import logging
import six.moves

logger = logging.getLogger('vofs')
# logger.setLevel(logging.DEBUG)
Expand Down
4 changes: 2 additions & 2 deletions vos/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ edit_on_github = False
github_project = opencadc/vostools
install_requires = html2text>=2016.5.29 cadcutils>=1.1.20 future aenum
# version should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440)
version = 3.1.1
version = 3.2a


[entry_points]
Expand All @@ -66,4 +66,4 @@ vrm = vos.commands.vrm:vrm
vrmdir = vos.commands.vrmdir:vrmdir
vsync = vos.commands.vsync:vsync
vtag = vos.commands.vtag:vtag

vos-config = vos.vosconfig:vos_config_main
38 changes: 15 additions & 23 deletions vos/test/scripts/vospace-all.tcsh
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,35 @@
set THIS_DIR = `dirname $0`
set THIS_DIR = `cd $THIS_DIR && pwd`

if ($#argv == 1) then
setenv CADC_TESTCERT_PATH $1
else
if ($#argv == 0) then
echo "Enter path to the CADC test certificates"
echo -n "Cert path: "
set certpath = "$<"
setenv CADC_TESTCERT_PATH ${certpath}
else
echo "usage: vospace-all [cadc_test_cert_path]"
exit -1
endif
endif
echo "Enter path to the CADC test certificates"
echo -n "Cert path: "
set certpath = "$<"
setenv CADC_TESTCERT_PATH ${certpath}

echo "cert files path: $CADC_TESTCERT_PATH"
echo
echo "*** start all tests ***"
echo "vospace-client-atest.tcsh"
$THIS_DIR/vospace-client-atest.tcsh || echo "FAIL vospace-client-atest.tcsh" && exit -1
set args = ($argv)
$THIS_DIR/vospace-client-atest.tcsh $args || echo "FAIL vospace-client-atest.tcsh" && exit -1
echo "vospace-move-atest.tcsh"
$THIS_DIR/vospace-move-atest.tcsh || echo "FAIL vospace-move-atest.tcsh" && exit -1
$THIS_DIR/vospace-move-atest.tcsh $args || echo "FAIL vospace-move-atest.tcsh" && exit -1
echo "vospace-delete-permission-atest.tcsh"
$THIS_DIR/vospace-delete-permission-atest.tcsh || echo "FAIL vospace-delete-permission-atest.tcsh" && exit -1
$THIS_DIR/vospace-delete-permission-atest.tcsh $args || echo "FAIL vospace-delete-permission-atest.tcsh" && exit -1
echo "vospace-vsync-atest.tcsh"
$THIS_DIR/vospace-vsync-atest.tcsh || echo "FAIL vospace-vsync-atest.tcsh" && exit -1
$THIS_DIR/vospace-vsync-atest.tcsh $args || echo "FAIL vospace-vsync-atest.tcsh" && exit -1
echo "vospace-quota-atest.tcsh"
$THIS_DIR/vospace-quota-atest.tcsh || echo "FAIL vospace-quota-atest.tcsh" && exit -1
$THIS_DIR/vospace-quota-atest.tcsh $args || echo "FAIL vospace-quota-atest.tcsh" && exit -1
echo "vospace-link-atest.tcsh"
$THIS_DIR/vospace-link-atest.tcsh || echo "FAIL vospace-link-atest.tcsh" && exit -1
$THIS_DIR/vospace-link-atest.tcsh $args || echo "FAIL vospace-link-atest.tcsh" && exit -1
echo "vospace-read-permission-atest.tcsh"
$THIS_DIR/vospace-read-permission-atest.tcsh || echo "FAIL vospace-read-permission-atest.tcsh" && exit -1
$THIS_DIR/vospace-read-permission-atest.tcsh $args || echo "FAIL vospace-read-permission-atest.tcsh" && exit -1
echo "vospace-node-properties.tcsh"
$THIS_DIR/vospace-node-properties.tcsh || echo "FAIL vospace-node-properties.tcsh" && exit -1
$THIS_DIR/vospace-node-properties.tcsh $args || echo "FAIL vospace-node-properties.tcsh" && exit -1
echo "vospace-lock-atest.tcsh"
$THIS_DIR/vospace-lock-atest.tcsh || echo "FAIL vospace-lock-atest.tcsh" && exit -1
$THIS_DIR/vospace-lock-atest.tcsh $args || echo "FAIL vospace-lock-atest.tcsh" && exit -1
echo "vospace-cookie-atest.tcsh"
$THIS_DIR/vospace-token-atest.tcsh || echo "FAIL vospace-cookie-atest.tcsh" && exit -1
$THIS_DIR/vospace-token-atest.tcsh $args || echo "FAIL vospace-cookie-atest.tcsh" && exit -1

echo
echo "*** all test sequences passed ***"
Expand Down

0 comments on commit 34b16f3

Please sign in to comment.