Ejemplo n.º 1
0
    def testServer(self):
        _c.init()

        completion_queue = _c.CompletionQueue()
        server = _c.Server(completion_queue)
        server.add_http2_addr('[::]:0')
        server.start()
        server.stop()
        completion_queue.stop()
        del server
        del completion_queue

        service_tag = object()
        completion_queue = _c.CompletionQueue()
        server = _c.Server(completion_queue)
        server.add_http2_addr('[::]:0')
        server.start()
        server.service(service_tag)
        server.stop()
        completion_queue.stop()
        event = completion_queue.get(time.time() + _TIMEOUT)
        self.assertIs(event.kind, _datatypes.Event.Kind.SERVICE_ACCEPTED)
        self.assertIs(event.tag, service_tag)
        self.assertIsNone(event.service_acceptance)
        for _ in range(_IDEMPOTENCE_DEMONSTRATION):
            event = completion_queue.get(time.time() + _TIMEOUT)
            self.assertIs(event.kind, _datatypes.Event.Kind.STOP)
        del server
        del completion_queue

        completion_queue = _c.CompletionQueue()
        server = _c.Server(completion_queue)
        server.add_http2_addr('[::]:0')
        server.start()
        thread = threading.Thread(target=completion_queue.get,
                                  args=(_FUTURE, ))
        thread.start()
        time.sleep(1)
        server.stop()
        completion_queue.stop()
        for _ in range(_IDEMPOTENCE_DEMONSTRATION):
            event = completion_queue.get(time.time() + _TIMEOUT)
            self.assertIs(event.kind, _datatypes.Event.Kind.STOP)
        thread.join()
        del server
        del completion_queue

        _c.shut_down()
Ejemplo n.º 2
0
  def test_secure_server(self):
    _c.init()

    server_credentials = _c.ServerCredentials(
        'root certificate', (('private key', 'certificate chain'),))

    completion_queue = _c.CompletionQueue()
    server = _c.Server(completion_queue, server_credentials)
    server.add_http2_addr('[::]:0')
    server.start()
    thread = threading.Thread(target=completion_queue.get, args=(_FUTURE,))
    thread.start()
    time.sleep(1)
    server.stop()
    completion_queue.stop()
    for _ in range(_IDEMPOTENCE_DEMONSTRATION):
      event = completion_queue.get(time.time() + _TIMEOUT)
      self.assertIs(event.kind, _datatypes.Event.Kind.STOP)
    thread.join()
    del server
    del completion_queue

    _c.shut_down()
Ejemplo n.º 3
0
 def testServerUpDown(self):
     completion_queue = _c.CompletionQueue()
     serv = _c.Server(completion_queue, [])
     del serv
     del completion_queue
Ejemplo n.º 4
0
 def __init__(self, completion_queue, args):
     self.server = _c.Server(completion_queue.completion_queue, args)