def test_pass2(self): t = TestRepository(1) while not t.isReadyForCheck(): pass returnable = t.checkTest() disableInternalServices() enableInternalServices() return returnable
def test_pass2(self): t = testRepository(1) while not t.isReadyForCheck(): pass returnable = t.checkTest() from Ganga.Core.InternalServices.Coordinator import enableInternalServices, disableInternalServices disableInternalServices() enableInternalServices() return returnable
def test_pass2(self): t = testRepository(1) while not t.isReadyForCheck(): pass returnable = t.checkTest() from Ganga.Core.InternalServices.Coordinator import enableInternalServices, disableInternalServices disableInternalServices() enableInternalServices() return returnable
def start_ganga(gangadir_for_test, extra_opts=[]): """ Startup Ganga by calling the same set of 'safe' functions each time Args: gangadir_for_test (str): This is the directory which the GangaUnitTest is to be run, a new gangadir has been created per test to avoid collisions extra_opts (list): A list of tuples which are used to pass command line style options to Ganga """ import Ganga.PACKAGE Ganga.PACKAGE.standardSetup() # End taken from the ganga binary import Ganga.Runtime from Ganga.Utility.logging import getLogger logger = getLogger() # Start ganga by passing some options for unittesting logger.info("Starting ganga") logger.info("Parsing Command Line options") this_argv = [ 'ganga', # `argv[0]` is usually the name of the program so fake that here ] # These are the default options for all test instances # They can be overridden by extra_opts default_opts = [ ('Configuration', 'RUNTIME_PATH', 'GangaTest'), ('Configuration', 'gangadir', gangadir_for_test), ('Configuration', 'user', 'testframework'), ('Configuration', 'repositorytype', 'LocalXML'), ('Configuration', 'UsageMonitoringMSG', False), # Turn off spyware ('TestingFramework', 'ReleaseTesting', True), ('Queues', 'NumWorkerThreads', 2), ] # FIXME Should we need to add the ability to load from a custom .ini file # to configure tests without editting this? # Actually parse the options Ganga.Runtime._prog = Ganga.Runtime.GangaProgram(argv=this_argv) Ganga.Runtime._prog.default_config_file = ganga_config_file Ganga.Runtime._prog.parseOptions() # For all the default and extra options, we set the session value from Ganga.Utility.Config import setConfigOption for opt in default_opts + extra_opts: setConfigOption(*opt) # The configuration is currently created at module import and hence can't be # regenerated. # The values read in from any .ini file or from command line will change this # but the configuration can't be obliterated and re-created. (yet, 16.06.16) # Perform the configuration and bootstrap steps in ganga logger.info("Parsing Configuration Options") Ganga.Runtime._prog.configure() logger.info("Initializing") Ganga.Runtime._prog.initEnvironment() logger.info("Bootstrapping") Ganga.Runtime._prog.bootstrap(interactive=False) # We need to test if the internal services need to be reinitialized from Ganga.Core.InternalServices import Coordinator if not Coordinator.servicesEnabled: # Start internal services logger.info("InternalServices restarting") from Ganga.Core.InternalServices.Coordinator import enableInternalServices enableInternalServices() else: logger.info("InternalServices still running") # Adapted from the Coordinator class, check for the required credentials and stop if not found # Hopefully stops us falling over due to no AFS access of something similar from Ganga.Core.InternalServices import Coordinator missing_cred = Coordinator.getMissingCredentials() logger.info("Checking Credentials") if missing_cred: raise Exception("Failed due to missing credentials %s" % str(missing_cred)) # Make sure that all the config options are really set. # Some from plugins may not have taken during startup for opt in default_opts + extra_opts: setConfigOption(*opt) logger.info("Passing to Unittest")
def start_ganga(gangadir_for_test, extra_opts=[]): """ Startup Ganga by calling the same set of 'safe' functions each time Args: gangadir_for_test (str): This is the directory which the GangaUnitTest is to be run, a new gangadir has been created per test to avoid collisions extra_opts (list): A list of tuples which are used to pass command line style options to Ganga """ import Ganga.PACKAGE Ganga.PACKAGE.standardSetup() # End taken from the ganga binary import Ganga.Runtime from Ganga.Utility.logging import getLogger logger = getLogger() # Start ganga by passing some options for unittesting logger.info("Starting ganga") logger.info("Parsing Command Line options") this_argv = [ 'ganga', # `argv[0]` is usually the name of the program so fake that here ] # These are the default options for all test instances # They can be overridden by extra_opts default_opts = [ ('Configuration', 'RUNTIME_PATH', 'GangaTest'), ('Configuration', 'gangadir', gangadir_for_test), ('Configuration', 'user', 'testframework'), ('Configuration', 'repositorytype', 'LocalXML'), ('Configuration', 'UsageMonitoringMSG', False), # Turn off spyware ('TestingFramework', 'ReleaseTesting', True), ('Queues', 'NumWorkerThreads', 2), ] # FIXME Should we need to add the ability to load from a custom .ini file # to configure tests without editting this? # Actually parse the options Ganga.Runtime._prog = Ganga.Runtime.GangaProgram(argv=this_argv) Ganga.Runtime._prog.parseOptions() # For all the default and extra options, we set the session value from Ganga.Utility.Config import setConfigOption for opt in default_opts + extra_opts: setConfigOption(*opt) # The configuration is currently created at module import and hence can't be # regenerated. # The values read in from any .ini file or from command line will change this # but the configuration can't be obliterated and re-created. (yet, 16.06.16) # Perform the configuration and bootstrap steps in ganga logger.info("Parsing Configuration Options") Ganga.Runtime._prog.configure() logger.info("Initializing") Ganga.Runtime._prog.initEnvironment() logger.info("Bootstrapping") Ganga.Runtime._prog.bootstrap(interactive=False) # We need to test if the internal services need to be reinitialized from Ganga.Core.InternalServices import Coordinator if not Coordinator.servicesEnabled: # Start internal services logger.info("InternalServices restarting") from Ganga.Core.InternalServices.Coordinator import enableInternalServices enableInternalServices() else: logger.info("InternalServices still running") # Adapted from the Coordinator class, check for the required credentials and stop if not found # Hopefully stops us falling over due to no AFS access of something similar from Ganga.Core.InternalServices import Coordinator missing_cred = Coordinator.getMissingCredentials() logger.info("Checking Credentials") if missing_cred: raise Exception("Failed due to missing credentials %s" % str(missing_cred)) # Make sure that all the config options are really set. # Some from plugins may not have taken during startup for opt in default_opts + extra_opts: setConfigOption(*opt) logger.info("Passing to Unittest")
def start_ganga(gangadir_for_test, extra_opts=[], extra_args=None): """ Startup Ganga by calling the same set of 'safe' functions each time Args: gangadir_for_test (str): This is the directory which the GangaUnitTest is to be run, a new gangadir has been created per test to avoid collisions extra_opts (list): A list of tuples which are used to pass command line style options to Ganga """ import Ganga.PACKAGE Ganga.PACKAGE.standardSetup() # End taken from the ganga binary import Ganga.Runtime from Ganga.Utility.Config import getConfig from Ganga.Utility.logging import getLogger logger = getLogger() # Start ganga by passing some options for unittesting logger.info("Starting ganga") logger.info("Parsing Command Line options") this_argv = [ 'ganga', # `argv[0]` is usually the name of the program so fake that here ] if extra_args: this_argv += extra_args # These are the default options for all test instances # They can be overridden by extra_opts lhcb_test = pytest.config.getoption("--testLHCb") if lhcb_test: import getpass cred_opts = [('Configuration', 'user', getpass.getuser()), ('defaults_DiracProxy', 'group', 'lhcb_user')] else: cred_opts = [('Configuration', 'user', 'testframework'), ('defaults_DiracProxy', 'group', 'gridpp_user'), ('DIRAC', 'DiracEnvSource', '/cvmfs/ganga.cern.ch/dirac_ui/bashrc')] #Sort out eos outputConfig = getConfig('Output') outputConfig['MassStorageFile']['uploadOptions']['cp_cmd'] = 'cp' outputConfig['MassStorageFile']['uploadOptions']['ls_cmd'] = 'ls' outputConfig['MassStorageFile']['uploadOptions']['mkdir_cmd'] = 'mkdir' outputConfig['MassStorageFile']['uploadOptions']['path'] = '/tmp' default_opts = [ ('Configuration', 'RUNTIME_PATH', 'GangaTest'), ('Configuration', 'gangadir', gangadir_for_test), ('Configuration', 'repositorytype', 'LocalXML'), ('Configuration', 'UsageMonitoringMSG', False), # Turn off spyware ('Configuration', 'lockingStrategy', 'FIXED'), ('TestingFramework', 'ReleaseTesting', True), ('Queues', 'NumWorkerThreads', 3), ('Output', 'MassStorageFile', outputConfig['MassStorageFile']), ] default_opts += cred_opts # FIXME Should we need to add the ability to load from a custom .ini file # to configure tests without editting this? # Actually parse the options Ganga.Runtime._prog = Ganga.Runtime.GangaProgram(argv=this_argv) Ganga.Runtime._prog.default_config_file = ganga_config_file Ganga.Runtime._prog.parseOptions() # For all the default and extra options, we set the session value from Ganga.Utility.Config import setUserValue for opts in default_opts, extra_opts: for opt in opts: try: setUserValue(*opt) except Exception as err: print("Error Setting: %s" % str(opt)) print("Err: %s" % err) # The configuration is currently created at module import and hence can't be # regenerated. # The values read in from any .ini file or from command line will change this # but the configuration can't be obliterated and re-created. (yet, 16.06.16) # Perform the configuration and bootstrap steps in ganga logger.info("Parsing Configuration Options") Ganga.Runtime._prog.configure() logger.info("Initializing") Ganga.Runtime._prog.initEnvironment() logger.info("Bootstrapping") Ganga.Runtime._prog.bootstrap(interactive=False) # We need to test if the internal services need to be reinitialized from Ganga.Core.InternalServices import Coordinator if not Coordinator.servicesEnabled: # Start internal services logger.info("InternalServices restarting") from Ganga.Core.InternalServices.Coordinator import enableInternalServices enableInternalServices() else: logger.info("InternalServices still running") # Adapted from the Coordinator class, check for the required credentials and stop if not found # Hopefully stops us falling over due to no AFS access of something similar from Ganga.GPIDev.Credentials import get_needed_credentials missing_cred = get_needed_credentials() logger.info("Checking Credentials") if missing_cred: raise Exception("Failed due to missing credentials %s" % missing_cred) # Make sure that all the config options are really set. # Some from plugins may not have taken during startup for opts in default_opts, extra_opts: for opt in opts: try: setUserValue(*opt) except Exception as err: print("Error Setting: %s" % str(opt)) print("Err: %s" % err) logger.info("Passing to Unittest")
def start_ganga(gangadir_for_test, extra_opts=[]): import Ganga.PACKAGE Ganga.PACKAGE.standardSetup() # End taken from the ganga binary import Ganga.Runtime from Ganga.Utility.logging import getLogger logger = getLogger() # Start ganga by passing some options for unittesting logger.info("Starting ganga") logger.info("Parsing Command Line options") this_argv = [ 'ganga', # `argv[0]` is usually the name of the program so fake that here '--no-rexec', # Don't re-exec Ganga when running tests ] # These are the default options for all test instances # They can be overridden by extra_opts default_opts = [ ('Configuration', 'RUNTIME_PATH', 'GangaTest'), ('Configuration', 'gangadir', gangadir_for_test), ('Configuration', 'user', 'testframework'), ('Configuration', 'repositorytype', 'LocalXML'), ('TestingFramework', 'ReleaseTesting', True), ('Queues', 'NumWorkerThreads', 2), ] # FIXME Should we need to add the ability to load from a custom .ini file # to configure tests without editting this? # Actually parse the options Ganga.Runtime._prog = Ganga.Runtime.GangaProgram(argv=this_argv) Ganga.Runtime._prog.parseOptions() # Determine if ganga has actually finished initializing... # This is here to protect against the startGanga being called on an # initialized ganga environment try: do_config = not Ganga.Utility.Config.Config._after_bootstrap except: do_config = True # For all the default and extra options, we set the session value from Ganga.Utility.Config import setConfigOption for opt in default_opts + extra_opts: setConfigOption(*opt) if do_config: # Perform the configuration and bootstrap steps in ganga logger.info("Parsing Configuration Options") Ganga.Runtime._prog.configure() logger.info("Initializing") Ganga.Runtime._prog.initEnvironment(opt_rexec=False) else: from Ganga.Runtime.Repository_runtime import startUpRegistries from Ganga.Utility.Config import getConfig if getConfig('Configuration')['AutoStartReg']: startUpRegistries() # The queues are shut down by the atexit handlers so we need to start them here from Ganga.Core.GangaThread.WorkerThreads import startUpQueues startUpQueues() # We need to test if the internal services need to be reinitialized from Ganga.Core.InternalServices import Coordinator if not Coordinator.servicesEnabled: # Start internal services logger.info("InternalServices restarting") from Ganga.Core.InternalServices.Coordinator import enableInternalServices enableInternalServices() else: logger.info("InternalServices still running") logger.info("Bootstrapping") Ganga.Runtime._prog.bootstrap(interactive=False) # Adapted from the Coordinator class, check for the required credentials and stop if not found # Hopefully stops us falling over due to no AFS access of something similar from Ganga.Core.InternalServices import Coordinator missing_cred = Coordinator.getMissingCredentials() logger.info("Checking Credentials") if missing_cred: raise Exception("Failed due to missing credentials %s" % str(missing_cred)) logger.info("Passing to Unittest")