spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
704 stars 694 forks source link

FR - More consistent emulator support #2589

Closed saturnism closed 3 years ago

saturnism commented 3 years ago

Is your feature request related to a problem? Please describe. I created examples for testing w/ emulators using testcontainers for datastore, firestore, pubsub, and spanner.

https://github.com/saturnism/testcontainers-gcloud-examples/tree/main/springboot

It took sometimes to figure out how to configure each starter to use the emulator correctly, mostly due to inconsistencies. This issue tracks the inconsistencies and proposed for a more consistent configuration for all emulators.

Starter Emulator host Host Format Additional Properties
Datastore spring.cloud.gcp.datastore.host http://host:port
Firestore spring.cloud.gcp.firestore.host-port host:port spring.cloud.gcp.firestore.emulator.enabled=true
Spanner spring.cloud.gcp.spanner.emulator-host host:port spring.cloud.gcp.spanner.emulator.enabled=true
PubSub spring.cloud.gcp.pubsub.emulator-host host:port

Describe the solution you'd like It'd be great to make all the emulator host configuration, host format, and additional properties requirement consistent.

Starter Emulator host Host Format Additional Properties
Datastore spring.cloud.gcp.datastore.emulator-host host:port
Firestore spring.cloud.gcp.firestore.emulator-host host:port
Spanner spring.cloud.gcp.spanner.emulator-host host:port
PubSub spring.cloud.gcp.pubsub.emulator-host host:port

Or...

Starter Emulator host Host Format Additional Properties
Datastore spring.cloud.gcp.datastore.host-port host:port spring.cloud.gcp.datastore.emulator.enabled=true
Firestore spring.cloud.gcp.firestore.host-port host:port spring.cloud.gcp.datastore.emulator.enabled=true
Spanner spring.cloud.gcp.spanner.host-port host:port spring.cloud.gcp.datastore.emulator.enabled=true
PubSub spring.cloud.gcp.pubsub.host-port host:port spring.cloud.gcp.datastore.emulator.enabled=true

This would conflict w/ the existing datastore emulator support, however. But that also means if we keep "emulator.enabled", it should only mean it if Spring Cloud GCP launches the emulator automatically (like Datastore)

However, I think the challenge is mostly in the underlying client libraries as well. There are some significant inconsistencies for client libraries regarding the use of EmualtorCredentials vs NoCredentials, where to configure plaintext for managed channel, and the host name, etc.

Describe alternatives you've considered N/A

Additional context https://github.com/saturnism/testcontainers-gcloud-examples/tree/main/springboot

meltsufin commented 3 years ago

Migrated to: https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/159