Name: test-with-irods
Owner: Wellcome Trust Sanger Institute - Human Genetics Informatics
Description: Deprecated: Use https://github.com/wtsi-hgi/useintest/ instead
Created: 2016-08-12 09:02:00.0
Updated: 2017-02-21 15:28:42.0
Pushed: 2017-01-11 15:50:25.0
Size: 73
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Deprecated: please use Use In Test instead, which has a predefined setup for iRODS.
Test with iRODS exploits Docker to simplify the testing of software that interacts with an iRODS (iCAT) server.
testwithirods.api import IrodsVersion
testwithirods.api import get_static_irods_server_controller
ntrollers available for iRODS version: 3.3.1, 4.1.8, 4.1.9, 4.1.10
roller = get_static_irods_server_controller(irods_version=IrodsVersion.v4_1_10)
# Start a server (any number can be started)
irods_server = Controller.start_server()
# Do interesting things with iRODS...
# Stop a single server
Controller.stop_server(irods_server)
lly:
# Ensure all servers are stopped
Controller.tear_down()
Warning: ensure servers are stopped else they will keep running after your program exits! You may wish to exploit
try... finally
blocks or Python's
atexit functionality to achieve this.
This library provides the ability to create a temporary set of icommand-like executables on the host machine. The executables use icommands inside of a Docker instance linked to the iCAT server to produce the same results as they would if the icommands were installed on the host machine.
testwithirods.proxies import ICommandProxyController
y_controller = ICommandProxyController(irods_server, "mercury/icat:%s" % irods_server.version)
icommands_location = proxy_controller.create_proxy_binaries()
# Do interesting things with icommands, linked to the iRODS server
lly:
proxy_controller.tear_down()
To help with the setup of tests, a number of helper methods are available:
testwithirods.helpers import SetupHelper, AccessLevel
testwithirods.models import IrodsResource, IrodsUser, Metadata
p_helper = SetupHelper("icommands_location")
p_helper.create_data_object("name", contents="contents") # type: str
p_helper.replicate_data_object("/path/to/data_object", "resourceName")
p_helper.create_collection("name") # type: str
p_helper.add_metadata_to("/path/to/entity", Metadata({"attribute": "value"}))
p_helper.get_checksum("/path/to/entity") # type: str
p_helper.create_replica_storage() # type: IrodsResource
p_helper.create_user("username", "zone") # type: IrodsUser
p_helper.set_access("username_or_group", AccessLevel.OWN, "/path/to/entity")
p_helper.run_icommand(["icommand_binary", "--any", "arguments"]) # type: str
It is possible to specify the Docker daemon that you wish to use by setting environment variables. In particular,
DOCKER_TLS_VERIFY
, DOCKER_HOST
and DOCKER_CERT_PATH
can be set. For example, the configuration's environment
variables could be:
ER_TLS_VERIFY=1
ER_HOST=tcp://192.168.99.100:2376
ER_CERT_PATH=/Users/you/.docker/machine/machines/default
Information on how to set these variables in Pycharm.
If these variables are not set, it is assumed the daemon is accessible via the default UNIX socket:
unix:///var/run/docker.sock
.
Install both the library dependencies and the dependencies needed for testing:
p3 install -q -r requirements.txt
p3 install -q -r test_requirements.txt
Using nosetests, in the project directory, run:
setests -v --exclude-test=testwithirods.tests._common.create_tests_for_all_icat_setups --exclude-test=testwithirods.tests._common.IcatTest
To generate a test coverage report with nosetests:
setests -v --with-coverage --cover-package=testwithirods --cover-inclusive --exclude-test=testwithirods.tests._common.create_tests_for_all_icat_setups --exclude-test=testwithirods.tests._common.IcatTest
To limit testing to a specific version iRODS, set the environment variable SINGLE_TEST_SETUP
to match
the name of the controller associated to the server, e.g.
SINGLE_TEST_SETUP=Irods4_1_8ServerController
.