Skip to content

Commit

Permalink
update test to run with quick stat
Browse files Browse the repository at this point in the history
  • Loading branch information
jreadey committed Aug 18, 2023
1 parent 74d38bf commit 60a87a4
Show file tree
Hide file tree
Showing 15 changed files with 176 additions and 189 deletions.
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ RUN mkdir /usr/local/src/hsds/ \
/usr/local/src/hsds/hsds/util/ \
/etc/hsds/

COPY setup.py /usr/local/src/hsds/
COPY pyproject.toml /usr/local/src/hsds/
COPY setup.cfg /user/local/src/hsds/
COPY hsds/*.py /usr/local/src/hsds/hsds/
COPY hsds/util/*.py /usr/local/src/hsds/hsds/util/
COPY admin/config/config.yml /etc/hsds/
COPY admin/config/config.yml /usr/local/src/hsds/admin/config/
COPY entrypoint.sh /
RUN /bin/bash -c 'cd /usr/local/src/hsds; pip install -e ".[azure]" ; cd -'
RUN /bin/bash -c 'cd /usr/local/src/hsds; \
pip install build;\
python -m build;\
pip install dist/hsds-0.8.2.tar.gz;\
cd -'

EXPOSE 5100-5999
ENTRYPOINT ["/bin/bash", "-c", "/entrypoint.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
HSDS is a web service that implements a REST-based web service for HDF5 data stores.
Data can be stored in either a POSIX files system, or using object-based storage such as
AWS S3, Azure Blob Storage, or [MinIO](https://min.io).
HSDS can be run a single machine using Docker or on a cluster using Kubernetes (or AKS on Microsoft Azure).
HSDS can be run a single machine or on a cluster using Kubernetes (or AKS on Microsoft Azure).

In addition, HSDS can be run in serverless mode with AWS Lambda or h5pyd local mode.

Expand Down
18 changes: 12 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ if [ $run_pyflakes ]; then
fi
fi

echo "running setup.py"
python setup.py install
pip install --upgrade build

echo "clean stopped containers"
docker rm -v $(docker ps -aq -f status=exited)
echo "running build"
python -m build
pip install dist/hsds-8.8.2.tar.gz

echo "building docker image"
docker build -t hdfgroup/hsds .
command -v docker
if [ $? -ne 1 ]; then
echo "clean stopped containers"
docker rm -v $(docker ps -aq -f status=exited)

echo "building docker image"
docker build -t hdfgroup/hsds .
fi
4 changes: 0 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ elif [ $NODE_TYPE == "head_node" ]; then
echo "running hsds-headnode"
export PYTHONUNBUFFERED="1"
hsds-headnode
elif [ $NODE_TYPE == "rangeget" ]; then
echo "running hsds-rangeget"
export PYTHONUNBUFFERED="1"
hsds-rangeget
else
echo "Unknown NODE_TYPE: " $NODE_TYPE
fi
2 changes: 1 addition & 1 deletion hsds/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .hsds_app import HsdsApp
from . import config

_HELP_USAGE = "Starts hsds a REST-based service for HDF5 data."
_HELP_USAGE = "Starts HSDS, a REST-based service for HDF5 data."

_HELP_EPILOG = """Examples:
Expand Down
2 changes: 1 addition & 1 deletion hsds/basenode.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from .util.k8sClient import getDnLabelSelector, getPodIps
from . import hsds_logger as log

HSDS_VERSION = "0.8.1"
HSDS_VERSION = "0.8.2"


def getVersion():
Expand Down
1 change: 0 additions & 1 deletion hsds/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def _load_cfg():
debug("set default location for config dirs")
config_dirs = ["./", "/config", "/etc/hsds/"] # default locations
for config_dir in config_dirs:
eprint("using config_dir:", config_dir)
file_name = os.path.join(config_dir, "config.yml")
debug("checking config path:", file_name)
if os.path.isfile(file_name):
Expand Down
85 changes: 0 additions & 85 deletions setup.py

This file was deleted.

21 changes: 15 additions & 6 deletions tests/integ/acl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ def testGetAcl(self):
# try fetching an ACL from a user who doesn't have readACL permissions
req = helper.getEndpoint() + "/acls/" + username
user2name = config.get("user2_name")
headers = helper.getRequestHeaders(domain=self.base_domain, username=user2name)
rsp = self.session.get(req, headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden
if user2name:
headers = helper.getRequestHeaders(domain=self.base_domain, username=user2name)
rsp = self.session.get(req, headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden
else:
print("user2_name not set")

def testGetAcls(self):
print("testGetAcls", self.base_domain)
Expand Down Expand Up @@ -224,16 +227,22 @@ def testGetAcls(self):
# try fetching ACLs from a user who doesn't have readACL permissions
req = helper.getEndpoint() + "/acls"
user2name = config.get("user2_name")
headers = helper.getRequestHeaders(domain=self.base_domain, username=user2name)
rsp = self.session.get(req, headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden
if user2name:
headers = helper.getRequestHeaders(domain=self.base_domain, username=user2name)
rsp = self.session.get(req, headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden
else:
print("user2name not set")

def testPutAcl(self):
print("testPutAcl", self.base_domain)
headers = helper.getRequestHeaders(domain=self.base_domain)

# create an ACL for "test_user2" with read and update access
user2name = config.get("user2_name")
if not user2name:
print("user2_name not set")
return
req = helper.getEndpoint() + "/acls/" + user2name
perm = {"read": True, "update": True}

Expand Down
15 changes: 10 additions & 5 deletions tests/integ/attr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import json
import numpy as np
import helper
import config


class AttributeTest(unittest.TestCase):
Expand Down Expand Up @@ -238,11 +239,15 @@ def testObjAttr(self):
self.assertEqual(rsp.status_code, 404) # not found

# try adding the attribute as a different user
headers = helper.getRequestHeaders(
domain=self.base_domain, username="test_user2"
)
rsp = self.session.put(req, data=json.dumps(attr_payload), headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden
user2_name = config.get("user2_name")
if user2_name:
headers = helper.getRequestHeaders(
domain=self.base_domain, username="test_user2"
)
rsp = self.session.put(req, data=json.dumps(attr_payload), headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden
else:
print("user2_name not set")

# try adding again with original user, but outside this domain
another_domain = helper.getParentDomain(self.base_domain)
Expand Down
37 changes: 24 additions & 13 deletions tests/integ/dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,18 @@ def testScalarDataset(self):
# self.assertTrue("allocated_size" in rspJson)

# try get with a different user (who has read permission)
headers = helper.getRequestHeaders(domain=domain, username="test_user2")
rsp = self.session.get(req, headers=headers)
if config.get("default_public"):
self.assertEqual(rsp.status_code, 200)
rspJson = json.loads(rsp.text)
self.assertEqual(rspJson["id"], dset_id)
user2_name = config.get('user2_name')
if user2_name:
headers = helper.getRequestHeaders(domain=domain, username=user2_name)
rsp = self.session.get(req, headers=headers)
if config.get("default_public"):
self.assertEqual(rsp.status_code, 200)
rspJson = json.loads(rsp.text)
self.assertEqual(rspJson["id"], dset_id)
else:
self.assertEqual(rsp.status_code, 403)
else:
self.assertEqual(rsp.status_code, 403)
print('user2_name not set')

# try to do a GET with a different domain (should fail)
another_domain = self.base_domain + "/testScalarDataset2.h5"
Expand All @@ -152,9 +156,12 @@ def testScalarDataset(self):
self.assertEqual(rsp.status_code, 400)

# try DELETE with user who doesn't have create permission on this domain
headers = helper.getRequestHeaders(domain=domain, username="test_user2")
rsp = self.session.delete(req, headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden
if user2_name:
headers = helper.getRequestHeaders(domain=domain, username=user2_name)
rsp = self.session.delete(req, headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden
else:
print("user2_name not set")

# try to do a DELETE with a different domain (should fail)
# Test creation/deletion of scalar dataset obj
Expand Down Expand Up @@ -475,9 +482,13 @@ def testDelete(self):
self.assertEqual(rspJson["id"], dset_id)

# try DELETE with user who doesn't have create permission on this domain
headers = helper.getRequestHeaders(domain=domain, username="test_user2")
rsp = self.session.delete(req, headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden
user2_name = config.get('user2_name')
if user2_name:
headers = helper.getRequestHeaders(domain=domain, username=user2_name)
rsp = self.session.delete(req, headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden
else:
print("test_user2 not set")

# try to do a DELETE with a different domain (should fail)
another_domain = helper.getParentDomain(domain)
Expand Down
35 changes: 19 additions & 16 deletions tests/integ/datatype_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,33 @@ def testCommittedType(self):
self.assertEqual(type_json["base"], "H5T_IEEE_F32LE")

# try get with a different user (who has read permission)
headers = helper.getRequestHeaders(
domain=self.base_domain, username="test_user2"
)
rsp = self.session.get(req, headers=headers)
if config.get("default_public"):
self.assertEqual(rsp.status_code, 200)
rspJson = json.loads(rsp.text)
self.assertEqual(rspJson["root"], root_uuid)
test_user2 = config.get("user2_name") # some tests will be skipped if not
if test_user2:
headers = helper.getRequestHeaders(
domain=self.base_domain, username="test_user2"
)
rsp = self.session.get(req, headers=headers)
if config.get("default_public"):
self.assertEqual(rsp.status_code, 200)
rspJson = json.loads(rsp.text)
self.assertEqual(rspJson["root"], root_uuid)
else:
self.assertEqual(rsp.status_code, 403)
# try DELETE with user who doesn't have create permission on this domain
headers = helper.getRequestHeaders(
domain=self.base_domain, username="test_user2"
)
rsp = self.session.delete(req, headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden
else:
self.assertEqual(rsp.status_code, 403)
print('test_user2 not set')

# try to do a GET with a different domain (should fail)
another_domain = helper.getParentDomain(self.base_domain)
headers = helper.getRequestHeaders(domain=another_domain)
rsp = self.session.get(req, headers=headers)
self.assertEqual(rsp.status_code, 400)

# try DELETE with user who doesn't have create permission on this domain
headers = helper.getRequestHeaders(
domain=self.base_domain, username="test_user2"
)
rsp = self.session.delete(req, headers=headers)
self.assertEqual(rsp.status_code, 403) # forbidden

# try to do a DELETE with a different domain (should fail)
another_domain = helper.getParentDomain(self.base_domain)
headers = helper.getRequestHeaders(domain=another_domain)
Expand Down
Loading

0 comments on commit 60a87a4

Please sign in to comment.