Exemple #1
0
def main(argv):
  if len(argv) > 1:
    raise app.UsageError('Unrecognized arguments')
  if FLAGS.generator_batch_size <= 0:
    raise app.UsageError('--generator_batch_size must be positive')
  datastore_config = services.ServiceConfigFromFlag(
      'datastore_config', datastore_pb2.DataStore())
  generator_config = services.ServiceConfigFromFlag(
      'generator_config', generator_pb2.ClgenGenerator())

  datastore_stub = services.GetServiceStub(
      datastore_config, datastore_pb2_grpc.DataStoreServiceStub)
  generator_stub = services.GetServiceStub(
      generator_config, generator_pb2_grpc.GeneratorServiceStub)

  target_total_testcases = FLAGS.target_total_testcases
  generator_batch_size = FLAGS.generator_batch_size
  capabilities = GetGeneratorCapabilities(generator_stub)

  while True:
    num_testcases = GetNumberOfTestcasesInDataStore(
        datastore_stub, capabilities)
    logging.info(f'Number of testcases in datastore: %d', num_testcases)
    if 0 <= target_total_testcases <= num_testcases:
      logging.info('Stopping generation with %d testcases in the DataStore.',
                   num_testcases)
      break

    num_to_generate = generator_batch_size
    if target_total_testcases >= 0:
      num_to_generate = min(
          generator_batch_size, target_total_testcases - num_testcases)

    testcases = GenerateTestcases(generator_stub, num_to_generate)
    SubmitTestcases(datastore_stub, testcases)
Exemple #2
0
def main(argv):
    if len(argv) > 1:
        raise app.UsageError("Unrecognized arguments")
    if FLAGS.harness_batch_size <= 0:
        raise app.UsageError("--harness_batch_size must be positive")
    datastore_config = services.ServiceConfigFromFlag(
        "datastore_config", datastore_pb2.DataStore())
    harness_config = services.ServiceConfigFromFlag(
        "harness_config", harness_pb2.CldriveHarness())

    datastore_stub = services.GetServiceStub(
        datastore_config, datastore_pb2_grpc.DataStoreServiceStub)
    harness_stub = services.GetServiceStub(harness_config,
                                           harness_pb2_grpc.HarnessServiceStub)

    target_total_results = FLAGS.target_total_results
    harness_batch_size = FLAGS.harness_batch_size
    capabilities = GetHarnessCapabilities(harness_stub)
    testbeds = collections.deque(capabilities.testbeds)
    if testbeds:
        app.Log(
            1,
            "%d testbeds: %s",
            len(capabilities.testbeds),
            ", ".join(x.name for x in capabilities.testbeds),
        )
        while testbeds:
            testbed = testbeds.popleft()
            testcases = GetTestcasesToRun(
                datastore_stub,
                capabilities.harness,
                testbed,
                target_total_results,
                harness_batch_size,
            )
            app.Log(
                1,
                "Received %d testcases to execute on %s",
                len(testcases),
                testbed.name,
            )
            if testcases:
                results = RunTestcases(harness_stub, testbed, testcases)
                SubmitResults(datastore_stub, results)
                # If there are testcases to run, then we add it back to the testbeds
                # queue, as there may be more.
                testbeds.append(testbed)
        app.Log(1, "done")
    else:
        app.Warning("No testbeds, nothing to do!")
Exemple #3
0
def main(argv):
    if len(argv) > 1:
        raise app.UsageError('Unrecognized arguments')
    if FLAGS.harness_batch_size <= 0:
        raise app.UsageError('--harness_batch_size must be positive')
    datastore_config = services.ServiceConfigFromFlag(
        'datastore_config', datastore_pb2.DataStore())
    harness_config = services.ServiceConfigFromFlag(
        'harness_config', harness_pb2.CldriveHarness())

    datastore_stub = services.GetServiceStub(
        datastore_config, datastore_pb2_grpc.DataStoreServiceStub)
    harness_stub = services.GetServiceStub(harness_config,
                                           harness_pb2_grpc.HarnessServiceStub)

    target_total_results = FLAGS.target_total_results
    harness_batch_size = FLAGS.harness_batch_size
    capabilities = GetHarnessCapabilities(harness_stub)
    testbeds = collections.deque(capabilities.testbeds)
    if testbeds:
        logging.info('%d testbeds: %s', len(capabilities.testbeds),
                     ', '.join(x.name for x in capabilities.testbeds))
        while testbeds:
            testbed = testbeds.popleft()
            testcases = GetTestcasesToRun(datastore_stub, capabilities.harness,
                                          testbed, target_total_results,
                                          harness_batch_size)
            logging.info('Received %d testcases to execute on %s',
                         len(testcases), testbed.name)
            if testcases:
                results = RunTestcases(harness_stub, testbed, testcases)
                SubmitResults(datastore_stub, results)
                # If there are testcases to run, then we add it back to the testbeds
                # queue, as there may be more.
                testbeds.append(testbed)
        logging.info('done')
    else:
        logging.warning('No testbeds, nothing to do!')
Exemple #4
0
def main(argv):
    if len(argv) > 1:
        raise app.UsageError('Unrecognized arguments')
    harness_config = services.ServiceConfigFromFlag(
        'harness_config', harness_pb2.CldriveHarness())
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    services.AssertLocalServiceHostname(harness_config.service)
    service = CldriveHarness(harness_config)
    harness_pb2_grpc.add_HarnessServiceServicer_to_server(service, server)
    server.add_insecure_port(f'[::]:{harness_config.service.port}')
    logging.info('%s listening on %s:%s',
                 type(service).__name__, harness_config.service.hostname,
                 harness_config.service.port)
    server.start()
    try:
        while True:
            time.sleep(3600 * 24)
    except KeyboardInterrupt:
        server.stop(0)
Exemple #5
0
 def RunMain(argv: typing.List[str]) -> None:
   if len(argv) > 1:
     raise app.UsageError('Unrecognized arguments')
   generator_config = services.ServiceConfigFromFlag(
       'generator_config', config_proto_class())
   server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
   services.AssertLocalServiceHostname(generator_config.service)
   service = cls(generator_config)
   generator_pb2_grpc.add_GeneratorServiceServicer_to_server(service, server)
   server.add_insecure_port(f'[::]:{generator_config.service.port}')
   logging.info('%s listening on %s:%s', type(service).__name__,
                generator_config.service.hostname,
                generator_config.service.port)
   server.start()
   try:
     while True:
       time.sleep(3600 * 24)
   except KeyboardInterrupt:
     server.stop(0)
Exemple #6
0
def main(argv):
    if len(argv) > 1:
        raise app.UsageError("Unrecognized arguments")
    datastore_config = services.ServiceConfigFromFlag(
        "datastore_config", datastore_pb2.DataStore())
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    services.AssertLocalServiceHostname(datastore_config.service)
    service = DataStore(datastore_config)
    datastore_pb2_grpc.add_DataStoreServiceServicer_to_server(service, server)
    server.add_insecure_port(f"[::]:{datastore_config.service.port}")
    app.Log(
        1,
        "%s listening on %s:%s",
        type(service).__name__,
        datastore_config.service.hostname,
        datastore_config.service.port,
    )
    server.start()
    try:
        while True:
            time.sleep(3600 * 24)
    except KeyboardInterrupt:
        server.stop(0)
Exemple #7
0
def main(argv):
    """Main entry point."""
    if len(argv) > 1:
        raise app.UsageError("Unrecognized arguments")
    config = services.ServiceConfigFromFlag("harness_config",
                                            harness_pb2.ClLauncherHarness())
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    services.AssertLocalServiceHostname(config.service)
    service = ClLauncherHarness(config)
    harness_pb2_grpc.add_HarnessServiceServicer_to_server(service, server)
    server.add_insecure_port(f"[::]:{config.service.port}")
    app.Log(
        1,
        "%s listening on %s:%s",
        type(service).__name__,
        config.service.hostname,
        config.service.port,
    )
    server.start()
    try:
        while True:
            time.sleep(3600 * 24)
    except KeyboardInterrupt:
        server.stop(0)