コード例 #1
0
ファイル: runner.py プロジェクト: pyzh/neoppod
    def start(self):
        config = self._config
        logging.backlog(max_packet=1 << 20,
                        **({
                            'max_size': None
                        } if config.log else {}))
        only = config.only
        # run requested tests
        runner = NeoTestRunner(config.title or 'Neo', config.verbosity,
                               config.stop_on_success, config.readable_tid)
        if config.cov_unit:
            from coverage import Coverage
            cov_dir = runner.temp_directory + '/coverage'
            os.mkdir(cov_dir)

            @Patch(NeoTestBase)
            def setUp(orig, self):
                orig(self)
                self.__coverage = Coverage('%s/%s' % (cov_dir, self.id()))
                self.__coverage.start()

            @Patch(NeoTestBase)
            def _tearDown(orig, self, success):
                self.__coverage.stop()
                self.__coverage.save()
                del self.__coverage
                orig(self, success)

        try:
            for _ in xrange(config.loop):
                if config.unit:
                    runner.run('Unit tests', UNIT_TEST_MODULES, only)
                if config.functional:
                    runner.run('Functional tests', FUNC_TEST_MODULES, only)
                if config.zodb:
                    runner.run('ZODB tests', ZODB_TEST_MODULES, only)
        except KeyboardInterrupt:
            config['mail_to'] = None
            traceback.print_exc()
        except StopOnSuccess:
            pass
        if config.coverage:
            coverage.stop()
            if coverage.neotestrunner:
                coverage.combine(coverage.neotestrunner)
            coverage.save()
        if runner.dots:
            print
        # build report
        if (only or config.stop_on_success) and not config.mail_to:
            runner._buildSummary = lambda *args: (
                runner.__class__._buildSummary(runner, *args)[0], '')
            self.build_report = str
        self._successful = runner.wasSuccessful()
        return runner.buildReport(self.add_status)
コード例 #2
0
def main(args=None):
    from neo.neoctl.neoctl import NeoCTL
    config = NeoCTL.option_parser.parse(args)

    logfile = config.get('logfile')
    if logfile:
        # Contrary to daemons, we log everything to disk automatically
        # because a user using -l option here:
        # - is certainly debugging an issue and wants everything,
        # - would not have to time to send SIGRTMIN before neoctl exits.
        logging.backlog(None)
        logging.setup(logfile)

    from neo.neoctl.app import Application
    app = Application(config['address'], ssl=config.get('ssl'))
    r = app.execute(config['cmd'])
    if r is not None:
        print r
コード例 #3
0
ファイル: neoctl.py プロジェクト: Nexedi/neoppod
def main(args=None):
    (options, args) = parser.parse_args(args=args)
    if options.address is not None:
        address = parseNodeAddress(options.address, 9999)
    else:
        address = ('127.0.0.1', 9999)

    if options.logfile:
        # Contrary to daemons, we log everything to disk automatically
        # because a user using -l option here:
        # - is certainly debugging an issue and wants everything,
        # - would not have to time to send SIGRTMIN before neoctl exits.
        logging.backlog(None)
        logging.setup(options.logfile)
    from neo.neoctl.app import Application

    ssl = options.ca, options.cert, options.key
    r = Application(address, ssl=ssl if any(ssl) else None).execute(args)
    if r is not None:
        print r
コード例 #4
0
def main(args=None):
    (options, args) = parser.parse_args(args=args)
    if options.address is not None:
        address = parseNodeAddress(options.address, 9999)
    else:
        address = ('127.0.0.1', 9999)

    if options.logfile:
        # Contrary to daemons, we log everything to disk automatically
        # because a user using -l option here:
        # - is certainly debugging an issue and wants everything,
        # - would not have to time to send SIGRTMIN before neoctl exits.
        logging.backlog(None)
        logging.setup(options.logfile)
    from neo.neoctl.app import Application

    ssl = options.ca, options.cert, options.key
    r = Application(address, ssl=ssl if any(ssl) else None).execute(args)
    if r is not None:
        print r
コード例 #5
0
ファイル: custom_zodb.py プロジェクト: jgpjuniorj/j
      os.environ['zserver'] = i < len(zserver_list) and zserver_list[i] or ''
      break
    node_pid_list.append(pid)

cluster = True

if neo_storage:
  if zeo_client:
    sys.exit("--neo_storage conflicts with --zeo_client")
  demo_storage = load and not save
  if activity_node > 1 and demo_storage:
    sys.exit("--save is required when running several"
             " zope nodes on an existing NEO database")
  from neo.lib import logging
  from neo.tests.functional import NEOCluster
  logging.backlog()
  storage_count = 2
  if load or save:
      db_list = [os.path.join(instance_home, 'var', 'neo%u.sqlite' % i)
                 for i in xrange(1, storage_count+1)]
  else:
      db_list = [None] * storage_count
  cwd = os.getcwd()
  neo_cluster = NEOCluster(db_list, partitions=4, name='erp5/unit_test',
                           temp_dir=cwd, logger=save,
                           adapter='SQLite', clear_databases=not load)
  forkNodes()
  if node_pid_list is None:
      save_mysql = None
  else:
      cluster = bool(node_pid_list)
コード例 #6
0
ファイル: benchmark.py プロジェクト: Nexedi/neoppod
import sys
import smtplib
import optparse
import platform
import datetime
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

MAIL_SERVER = '127.0.0.1:25'

from neo.lib import logging
logging.backlog()

class AttributeDict(dict):

    def __getattr__(self, item):
        return self.__getitem__(item)

class BenchmarkRunner(object):
    """
        Base class for a command-line benchmark test runner.
    """

    def __init__(self):
        self._successful = True
        self._status = []
        parser = optparse.OptionParser()
        # register common options
        parser.add_option('', '--title')
        parser.add_option('', '--mail-to', action='append')
コード例 #7
0
ファイル: __init__.py プロジェクト: Nexedi/neoppod
DB_PASSWD = os.getenv('NEO_DB_PASSWD', '')
DB_USER = os.getenv('NEO_DB_USER', 'test')
DB_SOCKET = os.getenv('NEO_DB_SOCKET', '')

IP_VERSION_FORMAT_DICT = {
    socket.AF_INET:  '127.0.0.1',
    socket.AF_INET6: '::1',
}

ADDRESS_TYPE = socket.AF_INET

SSL = os.path.dirname(__file__) + os.sep
SSL = SSL + "ca.crt", SSL + "node.crt", SSL + "node.key"

logging.default_root_handler.handle = lambda record: None
logging.backlog(None, 1<<20)

debug.register()
# prevent "signal only works in main thread" errors in subprocesses
debug.register = lambda on_log=None: None

def mockDefaultValue(name, function):
    def method(self, *args, **kw):
        if name in self.mockReturnValues:
            return self.__getattr__(name)(*args, **kw)
        return function(self, *args, **kw)
    method.__name__ = name
    setattr(Mock, name, method)

mockDefaultValue('__nonzero__', lambda self: self.__len__() != 0)
mockDefaultValue('__repr__', lambda self:
コード例 #8
0
DB_PASSWD = os.getenv('NEO_DB_PASSWD', '')
DB_USER = os.getenv('NEO_DB_USER', 'test')
DB_SOCKET = os.getenv('NEO_DB_SOCKET', '')

IP_VERSION_FORMAT_DICT = {
    socket.AF_INET: '127.0.0.1',
    socket.AF_INET6: '::1',
}

ADDRESS_TYPE = socket.AF_INET

SSL = os.path.dirname(__file__) + os.sep
SSL = SSL + "ca.crt", SSL + "node.crt", SSL + "node.key"

logging.default_root_handler.handle = lambda record: None
logging.backlog(None, 1 << 20)

debug.register()
# prevent "signal only works in main thread" errors in subprocesses
debug.register = lambda on_log=None: None


def mockDefaultValue(name, function):
    def method(self, *args, **kw):
        if name in self.mockReturnValues:
            return self.__getattr__(name)(*args, **kw)
        return function(self, *args, **kw)

    method.__name__ = name
    setattr(Mock, name, method)