commit | 0bba8a72685f85d943eaef9e76899c6616117187 | [log] [tgz] |
---|---|---|
author | Matthias Sohn <matthias.sohn@sap.com> | Fri Jul 28 21:34:12 2023 +0200 |
committer | Matthias Sohn <matthias.sohn@sap.com> | Tue Aug 01 23:11:09 2023 +0200 |
tree | a7119d9a9f566d55b067eb21579e804b1e167087 | |
parent | f102d2fc0f42f4673ccb05d2057e0a52a40c1219 [diff] |
Test spanner-refdb using spanner emulator testcontainer Implement a SpannerEmulatorContainer for running the upstream Spanner emulator container for tests: - start the emulator container - create a Spanner instance - create a Spanner database - use a separate plugin config file spanner-refdb.config to configure the plugin - mock the PluginConfigFactory so that we can start the plugin from test code without loading the plugin in a running Gerrit server - create the SpannerRefDatabase schema - implement first tests Change-Id: I9290c4458299aa27bcf6e1d036b2c2245d948ba3
This plugin provides an implementation of the Gerrit global refdb backed by Cloud Spanner.
Requirements for using this plugin are:
A global refdb implementation is a requirement for a Gerrit multi-master scenario in a multi-site setup to ensure refs are updated consistently across multiple Gerrit primary sites.
Refer to the Gerrit multi-site plugin for more details on the high level architecture.
The in-memory Cloud Spanner emulator can be used during development. There are several limitations of the emulator that differ from the production service.
An easy way to run the emulator is to use gcloud CLI and Docker. Following the install instructions here will provide a local instance that the plugin can access. The gcloud CLI commands will be sent to the emulator instead of the production service. A test spanner instance and database will need to be created.
gcloud spanner instances create test-instance --config=emulator-config --description="Test Instance" --nodes=1 gcloud spanner databases create global-refdb --instance=test-instance
There are several limitations of the emulator which differ from the production service.
In order to easily set up and begin testing the spanner-refdb plugin, the multi-site plugin's local environment setup can be used.
This simulates a multi-site setup using two local gerrit instances. Build the release.war to include spanner-refdb and follow the linked example setup.
Configuration details can be found in the spanner-refdb config documentation.