def setUp(self): gwtests.setup() self.iocControl = IOCControl.IOCControl() self.gatewayControl = GatewayControl.GatewayControl() self.iocControl.startIOC() self.gatewayControl.startGateway() self.propSupported = False os.environ["EPICS_CA_AUTO_ADDR_LIST"] = "NO" os.environ[ "EPICS_CA_ADDR_LIST"] = "localhost:{0} localhost:{1}".format( gwtests.iocPort, gwtests.gwPort) ca.initialize_libca() # Check if IOC supports DBE_PROPERTY self.eventsReceivedIOC = 0 ioc = epics.PV("ioc:passive0", auto_monitor=epics.dbr.DBE_PROPERTY) ioc.add_callback(self.onChangeIOC) ioc.get() pvhigh = epics.PV("ioc:passive0.HIGH", auto_monitor=None) pvhigh.put(18.0, wait=True) time.sleep(.05) if self.eventsReceivedIOC == 2: self.propSupported = True ioc.disconnect() self.connectGwStats()
def test_gateway_does_not_crash_after_requesting_waveform_when_max_array_bytes_too_small( self): gwtests.setup() self.iocControl = IOCControl.IOCControl() self.gatewayControl = GatewayControl.GatewayControl() # If the bug is present this test is designed to pass the first case # and fail the second case max_array_bytes_cases = ["6000000", "16384"] for max_array_bytes in max_array_bytes_cases: print(("\n\n\n>>>>>{}={}\n\n\n".format(MAX_ARRAY_BYTES_KEY, max_array_bytes))) # The bug crashes the gateway when EPICS_CA_MAX_ARRAY_BYTES # on the IOC is too small. Set it here os.environ[MAX_ARRAY_BYTES_KEY] = max_array_bytes self.iocControl.startIOC() # The no_cache argument is required to trigger the bug self.gatewayControl.startGateway(extra_args="-no_cache") os.environ["EPICS_CA_AUTO_ADDR_LIST"] = "NO" os.environ["EPICS_CA_ADDR_LIST"] = ( "localhost:{0} localhost:{1}".format(gwtests.iocPort, gwtests.gwPort)) # First check that a simple PV can be put and got through gateway put_value = 5 caput("gateway:passive0", put_value, wait=True) result = caget("gateway:passive0") self.assertIsNotNone(result) self.assertEqual(result, put_value, msg="Initial get: got {} expected {}".format( result, put_value)) # Then try to get waveform through gateway try: w = PV("gateway:bigpassivewaveform").get( count=3000, # CTRL type is required to trigger the bug with_ctrlvars=True) self.gatewayControl.poll() except TypeError as e: raise RuntimeError( "Gateway has crashed - " "exception from pyepics: %s", e) except OSError as e: raise RuntimeError( "Gateway has crashed - " "exception from subprocess: %s", e) else: waveform_from_gateway = w print(waveform_from_gateway) print("waveform_from_gateway") finally: self.gatewayControl.stop() self.iocControl.stop()
def setUp(self): gwtests.setup() self.iocControl = IOCControl.IOCControl() self.gatewayControl = GatewayControl.GatewayControl() self.iocControl.startIOC() self.gatewayControl.startGateway() os.environ["EPICS_CA_AUTO_ADDR_LIST"] = "NO" os.environ["EPICS_CA_ADDR_LIST"] = "localhost:{0} localhost:{1}".format(gwtests.iocPort,gwtests.gwPort) epics.ca.initialize_libca() self.eventsReceived = 0
def setUp(self): gwtests.setup() self.iocControl = IOCControl.IOCControl() self.gatewayControl = GatewayControl.GatewayControl() self.iocControl.startIOC() self.gatewayControl.startGateway() self.propSupported = False self.eventsReceivedIOC = 0 self.eventsReceivedGW = 0 self.iocStruct = dict() self.gwStruct = dict() os.environ["EPICS_CA_AUTO_ADDR_LIST"] = "NO" os.environ[ "EPICS_CA_ADDR_LIST"] = "localhost:{0} localhost:{1}".format( gwtests.iocPort, gwtests.gwPort) ca.initialize_libca()
def setUp(self): gwtests.setup() self.iocControl = IOCControl.IOCControl() self.gatewayControl = GatewayControl.GatewayControl() self.iocControl.startIOC() self.gatewayControl.startGateway() self.propSupported = False os.environ["EPICS_CA_AUTO_ADDR_LIST"] = "NO" os.environ["EPICS_CA_ADDR_LIST"] = "localhost:{0} localhost:{1}".format(gwtests.iocPort,gwtests.gwPort) ca.initialize_libca() # Check if IOC supports DBE_PROPERTY self.eventsReceivedIOC = 0 ioc = epics.PV("ioc:passive0", auto_monitor=epics.dbr.DBE_PROPERTY) ioc.add_callback(self.onChangeIOC) ioc.get() pvhigh = epics.PV("ioc:passive0.HIGH", auto_monitor=None) pvhigh.put(18.0, wait=True) time.sleep(.05) if self.eventsReceivedIOC == 2: self.propSupported = True
if arglist is None: iocCommand.extend(['-d', 'test.db']) else: iocCommand.extend(arglist) if gwtests.verbose: print("Starting the IOC using\n", " ".join(iocCommand)) self.iocProcess = subprocess.Popen(iocCommand, env=childEnviron, stdin=subprocess.PIPE, stdout=self.DEVNULL, stderr=subprocess.STDOUT) time.sleep(.5) atexit.register(self.stop) def stop(self): '''Stops the test IOC''' if self.iocProcess: self.iocProcess.stdin.close() self.iocProcess = None if self.DEVNULL: self.DEVNULL.close() if __name__ == "__main__": gwtests.setup() print("Running the test IOC in verbose mode for {0} seconds".format(gwtests.gwRunDuration)) gwtests.verbose = True iocControl = IOCControl() iocControl.startIOC() time.sleep(gwtests.iocRunDuration) iocControl.stop()
if arglist is None: iocCommand.extend(['-d', 'test.db']) else: iocCommand.extend(arglist) if gwtests.verbose: print "Starting the IOC using\n", " ".join(iocCommand) self.iocProcess = subprocess.Popen(iocCommand, env=childEnviron, stdin=subprocess.PIPE, stdout=self.DEVNULL, stderr=subprocess.STDOUT) time.sleep(.5) atexit.register(self.stop) def stop(self): '''Stops the test IOC''' if self.iocProcess: self.iocProcess.stdin.close() self.iocProcess = None if self.DEVNULL: self.DEVNULL.close() if __name__ == "__main__": gwtests.setup() print "Running the test IOC in verbose mode for {0} seconds".format(gwtests.gwRunDuration) gwtests.verbose = True iocControl = IOCControl() iocControl.startIOC() time.sleep(gwtests.iocRunDuration) iocControl.stop()