-
Notifications
You must be signed in to change notification settings - Fork 73
Using Spanner Emulator for Testing
Devrim edited this page Aug 26, 2022
·
1 revision
Obtain your ip address and assign a hostname for spanner emulator.
In this case my ip address is 10.146.197.203
and I will assging spanner.localdomain
echo "10.146.197.203 spanner.localdomain" >> /etc/hosts
VERSION=1.4.2
wget https://storage.googleapis.com/cloud-spanner-emulator/releases/${VERSION}/cloud-spanner-emulator_linux_amd64-${VERSION}.tar.gz
tar zxvf cloud-spanner-emulator_linux_amd64-${VERSION}.tar.gz
chmod u+x gateway_main emulator_main
You can start Spanner Emulator Server as
./gateway_main --hostname 0.0.0.0 --grpc_port 9010 --http_port 9020
Note! Remember this is emulator and data is stored in RAM. When emulator is stopped your data will gone.
On another terminal
wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-399.0.0-linux-x86_64.tar.gz
tar -zxf google-cloud-cli-399.0.0-linux-x86_64.tar.gz
Change to directory
cd google-cloud-sdk/bin
Create project, instance and db
export SPANNER_EMULATOR_HOST="spanner.localdomain:9010"
./gcloud config set api_endpoint_overrides/spanner http://spanner.localdomain:9020/
./gcloud config set auth/disable_credentials true
./gcloud config set project jans-project
./gcloud spanner instances create jans-instance --config=emulator-config --description="Jans Instance" --nodes=1
./gcloud spanner databases create jansdb --instance jans-instance
When Jans installer prompts Backend Type, select Cloud Spanner, and type y
for question Is it emulator?.
Emulator Host is spanner.localdomain
, and you can leave other options as empty for default values:
Chose Backend Type:
1 Local OpenDj
2 Remote OpenDj
3 Local MySQL
4 Remote MySQL
5 Remote Couchbase
6 Cloud Spanner
Selection [1]: 6
Is it emulator? [N|y] : y
Emulator host : spanner.localdomain
Spanner project [jans-project] :
Spanner instance [jans-instance] :
Spanner database [jansdb] :
Checking spanner connection