def test_auto_backend(): """Check the backend detection logic.""" original_env_backend = os.environ.get('CLUSTERLIB_BACKEND', None) if original_env_backend is not None: del os.environ['CLUSTERLIB_BACKEND'] try: # Check detection when no environment variable is set. if _which('scontrol'): # SLURM should be detected assert_equal(_get_backend('auto'), 'slurm') elif _which('qmod'): # SGE should be detected assert_equal(_get_backend('auto'), 'sge') else: # No backend can be detected assert_raises(RuntimeError, _get_backend, 'auto') # Check the use of the environment variable os.environ['CLUSTERLIB_BACKEND'] = 'slurm' assert_equal(_get_backend('auto'), 'slurm') os.environ['CLUSTERLIB_BACKEND'] = 'sge' assert_equal(_get_backend('auto'), 'sge') finally: # Restore the previous environment if original_env_backend is None: del os.environ['CLUSTERLIB_BACKEND'] else: os.environ['CLUSTERLIB_BACKEND'] = original_env_backend
def test_queued_or_running_jobs_nobackend(): """Test queued or running whenever no backend is available.""" # Note that we can't use _get_backend since the user might # have set the CLUSTERLIB_BACKEND environment variable. if _which('qmod') is None and _which('scontrol') is None: # No backend available, thus no running job assert_equal(queued_or_running_jobs(), []) else: raise SkipTest("A backend is installed")
def _skip_if_no_backend(): """Test decorator to skip test if no backend is available.""" # Note that we can't use _get_backend since the user might # have set the CLUSTERLIB_BACKEND environment variable. if _which('qmod') is None and _which('scontrol') is None: raise SkipTest('A scheduler backend is required for this test.')