Skip to content

Add Integration tests #173

@llucax

Description

@llucax

What's needed?

There are currently no integration tests that exercise the gRPC BaseApiClient and its utility functions (call_stub_method(), GrpcStreamBroadcaster) in a minimal and reproducible environment, including authentication and signing interceptors. This makes it difficult to guarantee that core abstractions and security features work together as intended.

Proposed solution

Add a minimal gRPC proto spec (hello world style) with one unary and one server-streaming method (see example below). Use grpc.aio to implement a Python test server, and a test client subclassing BaseApiClient with proper stub typing. Implement integration tests for:

  • Unary and server-streaming RPCs using main utility functions
  • GrpcStreamBroadcaster with multiple consumers
  • API key and signing secret interceptors (server and client)

All tests should use timeouts to ensure reliability. Example proto:

syntax = "proto3";

package demo.hellostream;

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply);
  rpc StreamHellos (HelloRequest) returns (stream HelloReply);
}

message HelloRequest {
  string name = 1;
  int32 count = 2;
}

message HelloReply {
  string message = 1;
  int32 sequence = 2;
}

If there is an official example repo in the gRPC docs with such a spec (see gRPC Python examples), consider using it as a submodule instead; otherwise, use the above proposed proto.

Use cases

  • Ensuring BaseApiClient subclasses integrate generated stubs correctly
  • Validating utility functions and stream broadcasting in real usage
  • Verifying API key and HMAC signing interceptors for security
  • Detecting regressions in gRPC client-server integration

Alternatives and workarounds

  • Using existing official gRPC examples (e.g., helloworld, route_guide): helloworld lacks streaming, route_guide is overly complex. Custom proto preferred for clarity and maintainability.

Additional context

Example server and client should be implemented in Python using grpc.aio. All tests must include explicit timeouts. Reference gRPC core concepts: https://grpc.io/docs/what-is-grpc/core-concepts/.

Metadata

Metadata

Assignees

Labels

part:testsAffects the unit, integration and performance (benchmarks) testspriority:highAddress this as soon as possibletype:enhancementNew feature or enhancement visitble to users

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions