예제 #1
0
    def initenviron(logname, maxdrones, debug=False, timeout=90, nanodebug=0, cmadebug=0):
        'Initialize the test environment.'
        logwatch = LogWatcher(logname, [], timeout, returnonlymatch=True, debug=debug)
        logwatch.setwatch()
        sysenv = SystemTestEnvironment(logname, maxdrones, nanodebug=nanodebug, cmadebug=cmadebug)
        CMAinit(None, host=str(sysenv.cma.ipaddr), readonly=True,
                neologin=SystemTestEnvironment.NEO4JLOGIN, neopass=SystemTestEnvironment.NEO4JPASS)
        url = 'http://%s:%d/db/data/' % (sysenv.cma.ipaddr, 7474)
        print >> sys.stderr, 'OPENING Neo4j at URL %s' % url
        neo4j.authenticate('%s:7474' % sysenv.cma.ipaddr,
                           SystemTestEnvironment.NEO4JLOGIN,
                           SystemTestEnvironment.NEO4JPASS)
        store = Store(neo4j.Graph(url), readonly=True)
        for classname in GN.GraphNode.classmap:
            GN.GraphNode.initclasstypeobj(store, classname)

        logger('$(grep MemFree: /proc/meminfo)', hardquote=False)
        tq = QueryTest(store
        ,   '''START drone=node:Drone('*:*') WHERE drone.status = "up" RETURN drone'''
        ,   GN.nodeconstructor, debug=debug)

        if not tq.check([None,], minrows=maxdrones+1, maxrows=maxdrones+1
            ,   delay=0.5, maxtries=20):
            sysenv.cma.cleanupwhendone = False
            raise RuntimeError('Query of "up" status failed. Weirdness')
        return sysenv, store
    def checkresults(self, watcher, timeout, querystring, validator
        ,   nano, service=None, allregexes=True, debug=False, minrows=1, maxrows=1):
        '''
        A utility function for checking the results of a test.  It assumes
        that you have already done a watcher.setwatch and initiated the
        test.  We then wait for the test results in the logs and
        perform the query to validate the results.
        '''

        query = QueryTest(self.store, querystring, GN.nodeconstructor, debug=debug)
        if allregexes:
            match = watcher.lookforall(timeout=timeout)
        else:
            match = watcher.look(timeout=timeout)
        if debug:
            print >> sys.stderr, ('DEBUG: Match returned %s' % match)
        if match is None:
            logger('ERROR: Test %s timed out waiting for %s [timeout:%s]'
            %   (self.__class__.__name__, str(watcher.unmatched), timeout))
            return self._record(AssimSysTest.FAIL)
        if debug:
            print('DEBUG: Test %s found regex %s'
            %   (self.__class__.__name__, str(watcher.regexes)))
        if query.check((nano, self.testenviron.cma, service), validator
            ,       minrows=minrows, maxrows=maxrows):
            if debug:
                print('DEBUG: Test %s passed query %s'
                %   (self.__class__.__name__, querystring))
            return self._record(AssimSysTest.SUCCESS)

        print >> sys.stderr, ('DEBUG: query.check() FAILED')
        logger('ERROR: Test %s failed query %s' % (self.__class__.__name__, querystring))
        return self._record(AssimSysTest.FAIL)
예제 #3
0
    def checkresults(self, watcher, timeout, querystring, validator
        ,   nano, service=None, allregexes=True, debug=False, minrows=1, maxrows=1):
        '''
        A utility function for checking the results of a test.  It assumes
        that you have already done a watcher.setwatch and initiated the
        test.  We then wait for the test results in the logs and
        perform the query to validate the results.
        '''

        query = QueryTest(self.store, querystring, GN.nodeconstructor, debug=debug)
        if allregexes:
            match = watcher.lookforall(timeout=timeout)
        else:
            match = watcher.look(timeout=timeout)
        if debug:
            print >> sys.stderr, ('DEBUG: Match returned %s' % match)
        if match is None:
            logger('ERROR: Test %s timed out waiting for %s [timeout:%s]'
            %   (self.__class__.__name__, str(watcher.unmatched), timeout))
            return self._record(AssimSysTest.FAIL)
        if debug:
            print('DEBUG: Test %s found regex %s'
            %   (self.__class__.__name__, str(watcher.regexes)))
        if query.check((nano, self.testenviron.cma, service), validator
            ,       minrows=minrows, maxrows=maxrows):
            if debug:
                print('DEBUG: Test %s passed query %s'
                %   (self.__class__.__name__, querystring))
            return self._record(AssimSysTest.SUCCESS)

        print >> sys.stderr, ('DEBUG: query.check() FAILED')
        logger('ERROR: Test %s failed query %s' % (self.__class__.__name__, querystring))
        return self._record(AssimSysTest.FAIL)
    def initenviron(logname,
                    maxdrones,
                    mgmtsystem,
                    debug=False,
                    cmaimage='',
                    nanoimages=[],
                    timeout=90,
                    nanodebug=0,
                    cmadebug=0):
        'Initialize the test environment.'
        logwatch = LogWatcher(logname, [],
                              timeout,
                              returnonlymatch=True,
                              debug=debug)
        logwatch.setwatch()

        sysenv = SystemTestEnvironment(logname,
                                       maxdrones,
                                       mgmtsystem,
                                       cmaimage=cmaimage,
                                       nanoimages=nanoimages,
                                       nanodebug=nanodebug,
                                       cmadebug=cmadebug)
        CMAinit(None,
                host=str(sysenv.cma.ipaddr),
                readonly=True,
                neologin=SystemTestEnvironment.NEO4JLOGIN,
                neopass=SystemTestEnvironment.NEO4JPASS)
        url = 'http://%s:%d/db/data/' % (sysenv.cma.ipaddr, 7474)
        print >> sys.stderr, 'OPENING Neo4j at URL %s' % url
        neo4j.authenticate('%s:7474' % sysenv.cma.ipaddr,
                           SystemTestEnvironment.NEO4JLOGIN,
                           SystemTestEnvironment.NEO4JPASS)
        store = Store(neo4j.Graph(url), readonly=True)
        for classname in GN.GraphNode.classmap:
            GN.GraphNode.initclasstypeobj(store, classname)

        logger('$(grep MemFree: /proc/meminfo)', hardquote=False)
        tq = QueryTest(
            store,
            '''START drone=node:Drone('*:*') WHERE drone.status = "up" RETURN drone''',
            GN.nodeconstructor,
            debug=debug)

        if not tq.check([
                None,
        ],
                        minrows=maxdrones + 1,
                        maxrows=maxdrones + 1,
                        delay=0.5,
                        maxtries=20):
            sysenv.cma.cleanupwhendone = False
            raise RuntimeError('Query of "up" status failed. Weirdness')
        return sysenv, store