Ejemplo n.º 1
0
    def runTests():
        if args.timeout is not None:
            UnitTestCommon.startTimeoutThread(args.timeout[0])

        try:
            return executeTests(args)
        except:
            import traceback
            logging.error("executeTests() threw an exception: \n%s",
                          traceback.format_exc())
            return 1

    if args.repeat:
        while True:
            runTests()
    else:
        return runTests()


if __name__ == "__main__":
    #parse args, return zero and exit if help string was printed
    parser = UnitTestArgumentParser()
    generalArgumentsGroup = parser.add_argument_group(
        title="General Arguments",
        description="Arguments that affect the system as a whole")

    Setup.addDefaultArguments(generalArgumentsGroup)
    Mainline.addNoseVerbosityArgument(parser)
    Mainline.UserFacingMainline(main, sys.argv, [], parser=parser)
Ejemplo n.º 2
0
            CumulusNative.replayCumulusWorkerEventStream(
                events, parsedArguments.validation)
    else:
        CumulusNative.replayCumulusWorkerEventStreamFromFile(
            parsedArguments.file, parsedArguments.validation)

    return 0


def createParser():
    desc = """Utility for validating a stream of LocalSchedulerEvent objects in a test failure. """
    parser = Setup.defaultParser(description=desc)
    parser.add_argument('file', help='names of file to be read')
    parser.add_argument('-n',
                        '--no_validation',
                        dest='validation',
                        action='store_false',
                        default=True,
                        required=False,
                        help="don't validate the response stream")

    return parser


if __name__ == "__main__":
    Mainline.UserFacingMainline(main,
                                sys.argv,
                                modulesToInitialize=[],
                                parser=createParser())
Ejemplo n.º 3
0
        dataLen = struct.unpack('I', sys.stdin.read(struct.calcsize('I')))[0]
        data = sys.stdin.read(dataLen)

        connectionData = pickle.loads(data)

        maxFD = os.sysconf("SC_OPEN_MAX")
        for fd in range(3, maxFD):
            if fd != connectionData['socketFd']:
                try:
                    os.close(fd)
                except:
                    pass

        handler = BackendGatewayRequestHandler(
            connectionData['socketFd'],
            connectionData['sharedStateAddress']
        )

        handler.handle()
    finally:
        sys.stderr.write(traceback.format_exc())
        sys.stderr.write("closing connection handler\n")
        sys.stderr.flush()
    return 0


if __name__ == "__main__":
    Mainline.UserFacingMainline(main, sys.argv, [FORA])


Ejemplo n.º 4
0
import signal
import sys
import ufora.config.Mainline as Mainline
import ufora.test.ClusterSimulation as ClusterSimulation


def main(args):
    print "Starting cluster simulation..."
    simulator = ClusterSimulation.Simulator.createGlobalSimulator()
    simulator.startService()

    def signal_handler(sig, _):
        signal_name = '(unknown)'
        if sig == signal.SIGINT:
            signal_name = 'SIGINT'
        elif sig == signal.SIGTERM:
            signal_name = 'SIGTERM'

        print 'Received ', signal_name, 'signal. Exiting.'
        simulator.stopService()
        sys.exit(0)

    signal.signal(signal.SIGINT, signal_handler)
    signal.signal(signal.SIGTERM, signal_handler)
    print "Press Ctrl+C to exit."
    signal.pause()


if __name__ == "__main__":
    Mainline.UserFacingMainline(main, sys.argv, modulesToInitialize=[])
Ejemplo n.º 5
0
if __name__ == "__main__":
    callbackSchedulerFactory = CallbackScheduler.createSimpleCallbackSchedulerFactory(
    )
    callbackScheduler = callbackSchedulerFactory.createScheduler(
        "sharedStateScheduler", 1)
    parser = argparse.ArgumentParser()
    parser.add_argument('--cacheDir')
    parsed, remaining = parser.parse_known_args(sys.argv[1:])

    def startSharedState(args):
        if parsed.cacheDir:
            logging.info("Shared state cache directory: %s", parsed.cacheDir)
            Setup.config().sharedStateCache = parsed.cacheDir

        service = SharedStateService.SharedStateService(callbackScheduler)

        service.startService()
        service.blockUntilListening()

        def handleSigTerm(signum, frame):
            logging.info("SIGTERM received - shutting down")
            service.stopService()

        signal.signal(signal.SIGTERM, handleSigTerm)

        signal.pause()
        logging.info("process exiting")

    Mainline.UserFacingMainline(startSharedState, [sys.argv[0]] + remaining)
Ejemplo n.º 6
0
# should appear as a dependent module


def removeFirstLine(string):
    return string[string.find('\n') + 1:]


def testInMem():
    val = subprocess.Popen(
        ['fora -e "1+2"'],
        shell=True,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        #make sure we pass the script-setup environment variables down
        env=dict(os.environ)).communicate()

    if removeFirstLine(val[0]).lstrip().rstrip() == '3':
        return True
    print 'testInMem failed:', val
    return False


def main(parsedArguments):
    if testInMem():
        return 0
    return 1


if __name__ == "__main__":
    Mainline.UserFacingMainline(main, sys.argv)