Validations only on integration tests could be present also on code generation (incl. unit tests?)

There all,

Thinking it shouldn’t be needed to implement an integration test on a very simple use case, I found after implementing one just for trying that there were additional mandatory requirements verified on integration tests.

In my case:

rror reported from Akka Serverless system: AS-00007 akkaserverless.component.valueentity.ValueEntities entity method management.api.UserService.GetAllUsersForAccount input parameter GetAllUsersForAccountRequest does not declare a field with an entity key.

To fix this issue, annotate a field in GetAllUsersForAccountRequest that represents the key of the entity with (akkaserverless.field).entity_key, for example:

message GetAllUsersForAccountRequest {
    string account_id = 1 [(akkaserverless.field).entity_key = true];
    ...

Alternatively, if this method creates an entity, you can generate the entity key using the generator annotation on the method, for example:

rpc GetAllUsersForAccount(GetAllUsersForAccountRequest) returns (GetAllUsersForAccountResult) {
  option (akkaserverless.method).entity.generator_key = VERSION_4_UUID;
};

This mandatory requirements that impede the service to launch successfully should be present also on code generation.

Perhaps it could be also useful on Unit Tests when they require to instantiate the Entity, but must probably could be handled on code generation.

2 Likes

Being able to validate the descriptors while developing, but without having to actually run the service like with the integration tests or the local proxy, would be very nice and is something we have recently discussed providing out of the box to make it easier to build services. We have not decided exactly how that will work yet though.

I’m afraid it is not easily doable right now though. I think the best way until we provide something is making sure there is at least one integration test in a project, or using the proxy “dev mode” when developing (Run a service locally :: Akka Serverless Documentation).