iRODS Test Suite
================

The tests in this directory have been designed to run with iRODS.

Warning
=======

These tests are assumed to be run as the "irods" unix user.  These are for development and should not be run on a production system as they make many assumptions about resource names, trash behavior, and deletion policy.

* Please do not run this suite on a grid with data that you care about. *

Overview
========

This test suite is based on the Python unittest framework.  It uses inheritance to provide an extensible mechanism for coverage for the plugin model that underpins iRODS.  This is best explained with a short example from the resource tests.

The file test_resource_types.py provides many classes, one of which is the Test_Resource_Random.  The Test_Resource_Random class defines the resource standup and teardown steps that should run before and after each test in the class.  Mostly, this involves a shuffling of the default "demoResc" resource and replacing it with a resource of the type being tested.  For coordinating resources, this could be a multilevel hierarchy that requires the creation and wiring up of multiple parent and children resources (as well as their teardown, in reverse).  The intent is to provide test coverage for the composite nature of the resource model.

The Test_Resource_Random class, defined in test_resource_types.py, only has to override the tests that would fail because the intended behavior of the new resource type is different from the behavior defined in the base class's test.  In addition, any new test functionality can also be defined in Test_Resource_Random.


  class Test_Resource_Random(unittest.TestCase, ResourceSuite, ChunkyDevTest):
inherits from
  class ResourceSuite(ResourceBase):
  and
  class ChunkyDevTest(ResourceBase):
which both inherit from
  class ResourceBase(object):

Test_Resource_Random defines...

@unittest.skip("EMPTY_RESC_PATH - no vault path for coordinating resources")
def test_ireg_as_rodsuser_in_vault(self):
    pass

The test_ireg_as_rodsuser_in_vault test as inherited from ResourceSuite needs to be overriden since it assumes a vault path exists, and coordinating resources do not have vault paths.


Run the test suite as irods
===========================

* For test grids only *

The following command will run the entire test suite and take a few seconds for each test.  This could take a couple hours to run on a relatively modern machine:

  python run_tests.py --run_python_suite --include_auth_tests --run_devtesty

The following command will run specific tests

  python run_tests.py --run_specific_test <module name [.class name [.method name]]>


The run_tests.py requires Python 2.6 or Python 2.7


Clean up this directory
=======================

The following script deletes generated coverage directories, .pyc files, and anything else left around by the test suite:

  ./cleanup.sh








For profiling... still a work in progress
=========================================
# http://stefaanlippens.net/python_profiling_with_pstats_interactive_mode
# http://amjith.blogspot.com/2012/05/python-profiling-part-1.html
sudo apt-get install python-profiler
sudo easy_install nose-cprof nose-progressive
python -m pstats stats.dat
% sort time
% stats 10

