Giter Club home page Giter Club logo

test-with-irods's Introduction


Deprecated: please use Use In Test instead, which has a predefined setup for iRODS.


ย 

Build Status codecov.io

Test with iRODS

Test with iRODS exploits Docker to simplify the testing of software that interacts with an iRODS (iCAT) server.

Use

Basic Usage

from testwithirods.api import IrodsVersion
from testwithirods.api import get_static_irods_server_controller

# Controllers available for iRODS version: 3.3.1, 4.1.8, 4.1.9, 4.1.10
Controller = get_static_irods_server_controller(irods_version=IrodsVersion.v4_1_10)
try:
    # 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)
finally:
    # 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.

iCommands

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.

from testwithirods.proxies import ICommandProxyController

proxy_controller = ICommandProxyController(irods_server, "mercury/icat:%s" % irods_server.version)
try:
    icommands_location = proxy_controller.create_proxy_binaries()
    
    # Do interesting things with icommands, linked to the iRODS server
finally:
    proxy_controller.tear_down()

Setup Helpers

To help with the setup of tests, a number of helper methods are available:

from testwithirods.helpers import SetupHelper, AccessLevel
from testwithirods.models import IrodsResource, IrodsUser, Metadata

setup_helper = SetupHelper("icommands_location")
setup_helper.create_data_object("name", contents="contents")   # type: str
setup_helper.replicate_data_object("/path/to/data_object", "resourceName")
setup_helper.create_collection("name")   # type: str
setup_helper.add_metadata_to("/path/to/entity", Metadata({"attribute": "value"}))
setup_helper.get_checksum("/path/to/entity")   # type: str
setup_helper.create_replica_storage()   # type: IrodsResource
setup_helper.create_user("username", "zone")    # type: IrodsUser
setup_helper.set_access("username_or_group", AccessLevel.OWN, "/path/to/entity")
setup_helper.run_icommand(["icommand_binary", "--any", "arguments"])    # type: str

Specifying the Docker Daemon

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:

DOCKER_TLS_VERIFY=1
DOCKER_HOST=tcp://192.168.99.100:2376
DOCKER_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.

Development

Setup

Install both the library dependencies and the dependencies needed for testing:

$ pip3 install -q -r requirements.txt
$ pip3 install -q -r test_requirements.txt

Testing

Using nosetests, in the project directory, run:

$ nosetests -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:

$ nosetests -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.

test-with-irods's People

Watchers

 avatar  avatar  avatar

test-with-irods's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.