def _start_container(self): # hack to force queue auto delete on for int tests self._turn_on_queue_auto_delete() self._patch_out_diediedie() db_type = os.environ.get('DB_TYPE', None) if not db_type: pass elif db_type == 'MOCK': self._turn_on_mockdb() elif db_type == 'COUCH': self._turn_on_couchdb() # delete/create any known DBs with names matching our prefix - should be rare self._force_clean(True) if os.environ.get('CEI_LAUNCH_TEST', None): self._patch_out_start_rel() self._turn_on_couchdb() self._turn_off_force_clean() from ion.processes.bootstrap.datastore_loader import DatastoreLoader DatastoreLoader.load_datastore('res/dd') # hack to force_clean on filesystem try: CFG['container']['filesystem']['force_clean'] = True except KeyError: CFG['container']['filesystem'] = {} CFG['container']['filesystem']['force_clean'] = True self.container = None self.addCleanup(self._stop_container) self.container = Container() self.container.start() # For integration tests, if class variable "service_dependencies" exists self._start_dependencies()
def _start_container(self): # hack to force queue auto delete on for int tests self._turn_on_queue_auto_delete() self._patch_out_diediedie() db_type = os.environ.get('DB_TYPE', None) if not db_type: pass elif db_type == 'MOCK': self._turn_on_mockdb() elif db_type == 'COUCH': self._turn_on_couchdb() # delete/create any known DBs with names matching our prefix - should be rare self._force_clean(True) if os.environ.get('CEI_LAUNCH_TEST', None): self._patch_out_start_rel() self._turn_on_couchdb() self._turn_off_force_clean() from ion.processes.bootstrap.datastore_loader import DatastoreLoader DatastoreLoader.load_datastore('res/dd') # hack to force_clean on filesystem try: CFG['container']['filesystem']['force_clean']=True except KeyError: CFG['container']['filesystem'] = {} CFG['container']['filesystem']['force_clean'] = True self.container = None self.addCleanup(self._stop_container) self.container = Container() self.container.start() # For integration tests, if class variable "service_dependencies" exists self._start_dependencies()
def _start_container(self): # hack to force queue auto delete on for int tests self._turn_on_queue_auto_delete() self._patch_out_diediedie() db_type = os.environ.get("DB_TYPE", None) if not db_type: pass elif db_type == "MOCK": self._turn_on_mockdb() elif db_type == "COUCH": self._turn_on_couchdb() if os.environ.get("CEI_LAUNCH_TEST", None): self._patch_out_start_rel() self._turn_on_couchdb() self._turn_off_force_clean() from ion.processes.bootstrap.datastore_loader import DatastoreLoader DatastoreLoader.load_datastore("res/dd") # hack to force_clean on filesystem try: CFG["container"]["filesystem"]["force_clean"] = True except KeyError: CFG["container"]["filesystem"] = {} CFG["container"]["filesystem"]["force_clean"] = True self.container = None self.addCleanup(self._stop_container) self.container = Container() self.container.start() # For integration tests, if class variable "service_dependencies" exists self._start_dependencies()
def finalize(self, result): """Called after all report output, including output from all plugins, has been sent to the stream. Use this to print final test results or perform final cleanup. Return None to allow other plugins to continue printing, or any other value to stop them. """ self.container_shutdown() from ion.processes.bootstrap.datastore_loader import DatastoreLoader DatastoreLoader.clear_datastore(prefix=self.sysname) import subprocess subprocess.call(['rm', '-rf', 'res/dd'])
def finalize(self, result): """Called after all report output, including output from all plugins, has been sent to the stream. Use this to print final test results or perform final cleanup. Return None to allow other plugins to continue printing, or any other value to stop them. """ self.container_shutdown() from ion.processes.bootstrap.datastore_loader import DatastoreLoader DatastoreLoader.clear_datastore(prefix=self.sysname) import subprocess subprocess.call(['rm', '-rf', 'res/dd'])
def afterTest(self, test): from ion.processes.bootstrap.datastore_loader import DatastoreLoader blame = DatastoreLoader.get_blame_objects() # Having a hard time detecting skips. Since skipped tests don't # clean we should not save duplicate blames... if blame != self.last_blame: for key in blame.keys(): self.blames[key].extend(blame[key]) self.last_blame = blame
def afterTest(self, test): from ion.processes.bootstrap.datastore_loader import DatastoreLoader blame = DatastoreLoader.get_blame_objects() # Having a hard time detecting skips. Since skipped tests don't # clean we should not save duplicate blames... if blame != self.last_blame: for key in blame.keys(): self.blames[key].extend(blame[key]) self.last_blame = blame
def begin(self): """Called before any tests are collected or run. Use this to perform any setup needed before testing begins. """ try: from pyon.public import get_sys_name self.sysname = get_sys_name() # Force datastore loader to use the same sysname from ion.processes.bootstrap.datastore_loader import DatastoreLoader DatastoreLoader.clear_datastore(prefix=self.sysname) def die(signum, frame): # For whatever reason, the parent doesn't die some times # when getting KeyboardInterrupt. Hence this signal # handler. # Signal is pass through. The child pycc gets # its own KeyboardInterrupt and will shut down accordingly. debug.write('Received Keyboard Interrupt. Exiting now.\n') os._exit(9) signal.signal(signal.SIGINT, die) def no_zombie(signum, frame): # Debug to figure out who's dying debug.write('SIGCHLD received\n') stack = [] while frame: stack.append(frame) frame =frame.f_back stack.reverse() for frame in stack: debug.write('Frame %s in %s at line %s\n' % (frame.f_code.co_name, frame.f_code.co_filename, frame.f_lineno)) debug.write('Child is dead...Clean up now so there is no zombie\n') (pid, status) = os.wait() exitstatus, signum = status & 0xff, (status & 0xff00) >> 8 debug.write('Child pid %d with exit status %d and signum %d\n' % (pid, exitstatus, signum)) # Could be dangerous. Comment this out. # signal.signal(signal.SIGCHLD, no_zombie) def container_started_cb(signum, frame): """Callback when child pycc service is ready""" self.container_started = True signal.signal(signal.SIGUSR1, container_started_cb) # Make sure the pycc process has the same sysname as the nose ccargs = ['bin/pycc', '--noshell', '-sp', '--sysname=%s' % self.sysname, '--logcfg=res/config/logging.pycc.yml', '--rel=%s' % self.rel, "--config={'system': {'force_clean': False, 'auto_bootstrap': True}}"] debug.write('Starting cc process: %s\n' % ' '.join(ccargs)) newenv = os.environ.copy() po = subprocess.Popen(ccargs, env=newenv, close_fds=True) self.ccs.append(po) # Wait for container to be ready while not self.container_started: time.sleep(0.2) debug.write('Child container is ready...\n') # Dump datastore DatastoreLoader.dump_datastore(path='res/dd') debug.write('Dump child container state to file...\n') # Enable CEI mode for the tests os.environ['CEI_LAUNCH_TEST'] = '1' debug.write('Start nose tests now...\n') except Exception as e: self.container_shutdown() raise e
def begin(self): """Called before any tests are collected or run. Use this to perform any setup needed before testing begins. """ try: from pyon.public import get_sys_name sysname = get_sys_name() # Force datastore loader to use the same sysname from ion.processes.bootstrap.datastore_loader import DatastoreLoader DatastoreLoader.clear_datastore(prefix=sysname) def die(signum, frame): # For whatever reason, the parent doesn't die some times # when getting KeyboardInterrupt. Hence this signal # handler. # Signal is pass through. The child pycc gets # its own KeyboardInterrupt and will shut down accordingly. debug.write('Received Keyboard Interrupt. Exiting now.\n') os._exit(9) signal.signal(signal.SIGINT, die) def no_zombie(signum, frame): # Debug to figure out who's dying debug.write('SIGCHLD received\n') stack = [] while frame: stack.append(frame) frame = frame.f_back stack.reverse() for frame in stack: debug.write('Frame %s in %s at line %s\n' % (frame.f_code.co_name, frame.f_code.co_filename, frame.f_lineno)) debug.write( 'Child is dead...Clean up now so there is no zombie\n') (pid, status) = os.wait() exitstatus, signum = status & 0xff, (status & 0xff00) >> 8 debug.write( 'Child pid %d with exit status %d and signum %d\n' % (pid, exitstatus, signum)) # Could be dangerous. Comment this out. # signal.signal(signal.SIGCHLD, no_zombie) def container_started_cb(signum, frame): """Callback when child pycc service is ready""" self.container_started = True signal.signal(signal.SIGUSR1, container_started_cb) # Make sure the pycc process has the same sysname as the nose ccargs = [ 'bin/pycc', '--noshell', '-sp', '--system.name=%s' % sysname, '--logcfg=res/config/logging.pycc.yml', '--rel=%s' % self.rel, 'system.force_clean=False' ] debug.write('Starting cc process: %s\n' % ' '.join(ccargs)) newenv = os.environ.copy() po = subprocess.Popen(ccargs, env=newenv, close_fds=True) self.ccs.append(po) # Wait for container to be ready while not self.container_started: time.sleep(0.2) debug.write('Child container is ready...\n') # Dump datastore DatastoreLoader.dump_datastore(path='res/dd') debug.write('Dump child container state to file...\n') # Enable CEI mode for the tests os.environ['CEI_LAUNCH_TEST'] = '1' debug.write('Start nose tests now...\n') except Exception as e: self.container_shutdown() raise e