This repository contains a sample banking application built using Cloud Spanner.
NOTE: Requires gcloud, mvn, grpc_cli installed.
-
Create a database locally using cloud-spanner-emulator and export spanner host for client libraries to work.
$ gcloud emulators spanner start $ gcloud config configurations create emulator $ gcloud config set auth/disable_credentials true $ gcloud config set project test-project $ gcloud config set api_endpoint_overrides/spanner http://localhost:9020/ $ gcloud spanner instances create test-instance \ --config=emulator-config --description="Test Instance" --nodes=1 $ gcloud config set spanner/instance test-instance $ gcloud spanner databases create test-database \ --ddl-file src/main/java/com/google/finapp/schema.sdl $ export SPANNER_EMULATOR_HOST="localhost:9010"
-
Bring up the FinAppServer hosting a grpc service.
$ mvn verify $ mvn exec:java -Dexec.mainClass=com.google.finapp.ServerMain
-
Call RPCs using grpc_cli.
$ grpc_cli call localhost:8080 CreateCustomer \ "name: 'google' address: 'amphitheatre pkwy'"
-
Run the application in a separate terminal.
-
In the
cloud-spanner-samples/workload
directory, run$ mvn clean compile assembly:single $ java -jar target/workload-1.0-SNAPSHOT-jar-with-dependencies.jar --address-name localhost --port 8080 --num-accounts 200
- Set up the emulator as described in #1 above.
- Run
mvn integration-test
.
To run the tests using the JDBC implementation of the application instead of the Java client implementation, run
mvn integration-test -DSPANNER_USE_JDBC=true