How to use the cma.systemtests.testcases.AssimSysTest function in cma

To help you get started, we’ve selected a few cma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github assimilation / assimilation-official / cma / systemtests / testcases.py View on Github external
"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("DEBUG: query.check() FAILED", file=sys.stderr)
        logger("ERROR: Test %s failed query %s" % (self.__class__.__name__, querystring))
        return self._record(AssimSysTest.FAIL)
github assimilation / assimilation-official / cma / systemtests / testcases.py View on Github external
rc = StopNanoprobe(self.store, self.logfilename, self.testenviron).run(
            nano, debug=self.debug, timeout=timeout
        )
        if rc != AssimSysTest.SUCCESS:
            return self._record(rc)
        if self.delay > 0:
            time.sleep(self.delay)
        return self._record(
            StartNanoprobe(self.store, self.logfilename, self.testenviron).run(
                nano, debug=self.debug, timeout=timeout
            )
        )


@AssimSysTest.register
class RestartCMA(AssimSysTest):
    "A restart CMA test: stop then restart the CMA.  Scary stuff!"

    def __init__(self, store, logfilename, testenviron, debug=False, delay=0):
        AssimSysTest.__init__(self, store, logfilename, testenviron, debug)
        self.delay = delay

    def run(self, nano=None, debug=None, timeout=60):
        "Actually stop and start (restart) the CMA and see if it worked"
        if debug is None:
            debug = self.debug
        cma = self.testenviron.cma
        cma.stopservice(SystemTestEnvironment.CMASERVICE)
        regexes = self.cma_start_regexes()
        watch = LogWatcher(self.logfilename, regexes, timeout=timeout, debug=debug)
        watch.setwatch()
        if self.delay > 0:
github assimilation / assimilation-official / cma / systemtests / testcases.py View on Github external
def run(self, nano=None, debug=None, timeout=180):
        "Actually stop the nanoprobe and see if it worked"
        if debug is None:
            debug = self.debug
        if nano is None:
            nanozero = self.testenviron.select_nano_service()
            if len(nanozero) > 0:
                nano = nanozero[0]
        if (
            nano is None
            or nano.status != TestSystem.RUNNING
            or SystemTestEnvironment.NANOSERVICE not in nano.runningservices
        ):
            return self._record(AssimSysTest.SKIPPED)
        regexes = self.nano_kill9_regexes(nano)
        print("KILL9_REGEXES ARE:", regexes, file=sys.stderr)
        watch = LogWatcher(self.logfilename, regexes, timeout=timeout, debug=debug)
        watch.setwatch()
        qstr = (
            """START drone=node:Drone('*:*') """
            """WHERE drone.designation = "{0.hostname}" and drone.status = "dead" """
            """and drone.reason = "HBDEAD packet received"       RETURN drone"""
        )
        nano.kill9service(SystemTestEnvironment.NANOSERVICE)
        # print >> sys.stderr, 'NANO NEIGHBORS', get_nano_neighbors(self.store, None, nano)
        return self.checkresults(watch, timeout, qstr, None, nano)
github assimilation / assimilation-official / cma / systemtests / testcases.py View on Github external
):
            return self._record(AssimSysTest.SKIPPED)
        regexes = self.nano_stop_regexes(nano)
        watch = LogWatcher(self.logfilename, regexes, timeout=timeout, debug=debug)
        watch.setwatch()
        qstr = (
            """START drone=node:Drone('*:*') """
            """WHERE drone.designation = "{0.hostname}" and drone.status = "dead" """
            """and drone.reason = "HBSHUTDOWN"       RETURN drone"""
        )
        nano.stopservice(SystemTestEnvironment.NANOSERVICE)
        return self.checkresults(watch, timeout, qstr, None, nano)


@AssimSysTest.register
class KillNanoprobe(AssimSysTest):
    "A kill -9 nanoprobe test"

    def run(self, nano=None, debug=None, timeout=180):
        "Actually stop the nanoprobe and see if it worked"
        if debug is None:
            debug = self.debug
        if nano is None:
            nanozero = self.testenviron.select_nano_service()
            if len(nanozero) > 0:
                nano = nanozero[0]
        if (
            nano is None
            or nano.status != TestSystem.RUNNING
            or SystemTestEnvironment.NANOSERVICE not in nano.runningservices
        ):
            return self._record(AssimSysTest.SKIPPED)
github assimilation / assimilation-official / cma / systemtests / testcases.py View on Github external
regexes = self.nano_start_regexes(nano)

        watch = LogWatcher(self.logfilename, regexes, timeout=timeout, debug=debug)
        watch.setwatch()
        qstr = (
            """START drone=node:Drone('*:*') """
            """WHERE drone.designation = "{0.hostname}" and drone.status = "up" """
            """RETURN drone"""
        )
        nano.startservice(SystemTestEnvironment.NANOSERVICE)
        return self.checkresults(watch, timeout, qstr, None, nano)


@AssimSysTest.register
class FlipNanoprobe(AssimSysTest):
    """A flip nanoprobe test - if it's up, bring it down -- and vice versa"""

    def run(self, nano=None, debug=None, timeout=240):
        "Actually flip the nanoprobe and see if it worked"
        if debug is None:
            debug = self.debug
        if nano is None:
            nanozero = self.testenviron.select_nanoprobe()
            if len(nanozero) > 0:
                nano = nanozero[0]
        if nano is None:
            return self._record(AssimSysTest.SKIPPED)
        if SystemTestEnvironment.NANOSERVICE in nano.runningservices:
            return self._record(
                StopNanoprobe(self.store, self.logfilename, self.testenviron).run(
                    nano, debug=self.debug, timeout=timeout
github assimilation / assimilation-official / cma / systemtests / testcases.py View on Github external
def _record(self, result):
        "Record results from a test -- success or failure"
        AssimSysTest.stats[self.__class__.__name__][result] += 1
        # print >> sys.stderr, '_RECORD RETURNING', result
        self.result = result
        return result
github assimilation / assimilation-official / cma / systemtests / testcases.py View on Github external
def __init__(self, store, logfilename, testenviron, debug=False, delay=1):
        AssimSysTest.__init__(self, store, logfilename, testenviron, debug)
        self.delay = delay
github assimilation / assimilation-official / cma / systemtests / testcases.py View on Github external
return rc
        AssimSysTest.stats[self.__class__.__name__][rc] -= 1
        # We have to do this in two parts because of the asynchronous shutdown above
        regexes = self.nano_start_regexes(nano)
        watch = LogWatcher(self.logfilename, regexes, timeout=timeout, debug=debug)
        watch.setwatch()
        nano.startservice(SystemTestEnvironment.NANOSERVICE)
        qstr = (
            """START drone=node:Drone('*:*') """
            """WHERE drone.designation = "{0.hostname}" and drone.status = "up" """
            """RETURN drone"""
        )
        return self.checkresults(watch, timeout, qstr, None, nano)


@AssimSysTest.register
class DiscoverService(AssimSysTest):
    """We find a system not running some particular service, then we
    start the service and restart the nanoprobe - forcing it to
    discover the service pretty quickly.
    """

    def __init__(
        self, store, logfilename, testenviron, debug=False, service="ssh", monitorname=None
    ):
        "Initializer for the DiscoverService class"
        AssimSysTest.__init__(self, store, logfilename, testenviron, debug)
        self.service = service
        if monitorname is None:
            monitorname = service
        self.monitorname = monitorname
github assimilation / assimilation-official / cma / systemtests / testcases.py View on Github external
if debug is None:
            debug = self.debug
        rc = RestartCMA(
            self.store, self.logfilename, self.testenviron, debug=debug, delay=self.delay
        ).run(timeout=timeout)
        if rc != AssimSysTest.SUCCESS:
            return self._record(rc)
        return self._record(
            RestartNanoprobe(
                self.store, self.logfilename, self.testenviron, debug=debug, delay=self.delay
            ).run(timeout=timeout)
        )


@AssimSysTest.register
class SimulCMAandNanoprobeRestart(AssimSysTest):
    "Simultaneously restart the CMA and a nanoprobe"

    def __init__(self, store, logfilename, testenviron, debug=False, delay=1):
        AssimSysTest.__init__(self, store, logfilename, testenviron, debug)
        self.delay = delay

    def run(self, nano=None, debug=None, timeout=300):
        """Our default timeout is so long because we can take a while to give up shutting down
        the nanoprobe - an ACK timeout might have to occur before it can shut down.
        """
        if debug is None:
            debug = self.debug
        if nano is None:
            nanozero = self.testenviron.select_nano_service()
            if len(nanozero) < 1:
                return self._record(AssimSysTest.SKIPPED)
github assimilation / assimilation-official / cma / systemtests / testcases.py View on Github external
regexes.extend(self.cma_stop_regexes())
        regexes.extend(self.cma_start_regexes())
        watch = LogWatcher(self.logfilename, regexes, timeout=timeout, debug=debug)
        watch.setwatch()
        cma.stopservice(SystemTestEnvironment.CMASERVICE)
        nano.stopservice(SystemTestEnvironment.NANOSERVICE, async=True)
        if self.delay > 0:
            time.sleep(self.delay)
        cma.startservice(SystemTestEnvironment.CMASERVICE)
        qstr = (
            """START drone=node:Drone('*:*') """
            """WHERE drone.designation = "{0.hostname}" and drone.status = "dead" """
            """and drone.reason = "HBSHUTDOWN"       RETURN drone"""
        )
        rc = self.checkresults(watch, timeout, qstr, None, nano)
        if rc != AssimSysTest.SUCCESS:
            return rc
        AssimSysTest.stats[self.__class__.__name__][rc] -= 1
        # We have to do this in two parts because of the asynchronous shutdown above
        regexes = self.nano_start_regexes(nano)
        watch = LogWatcher(self.logfilename, regexes, timeout=timeout, debug=debug)
        watch.setwatch()
        nano.startservice(SystemTestEnvironment.NANOSERVICE)
        qstr = (
            """START drone=node:Drone('*:*') """
            """WHERE drone.designation = "{0.hostname}" and drone.status = "up" """
            """RETURN drone"""
        )
        return self.checkresults(watch, timeout, qstr, None, nano)