commit | 68ed48d975175d5109a7b3b60d4c1501af6fde41 | [log] [tgz] |
---|---|---|
author | Jacek Centkowski <jcentkowski@collab.net> | Thu Apr 26 08:36:25 2018 +0200 |
committer | Jacek Centkowski <jcentkowski@collab.net> | Thu Apr 26 08:36:25 2018 +0200 |
tree | 9d3548cbfc29d8f1c55939eeb409a9255142475d | |
parent | 19c94bce1139cb014837c7a06917b4b940505689 [diff] |
Add HowTo create Docker based test setup README.md contains step (with necessary gerrit.config changes) for setting up Postgres Docker based setup. Change-Id: I550dc16e61bb398b179d31fb5592e88724d17575 Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
Gerrit lib module to swap existing persistent cache implementation (that is H2 based) with implementation that stores data in Postgres. Note that is uses INSERT INTO ... ON CONFLICT DO UPDATE ... upsert syntax therefore it is Postgres 9.5+ compatible.
Build this module similarly to standalone build for any other, bazel based Gerrit plugin:
bazel build cache-postgres
cache-postgres.jar
module is generated under /bazel-genfiles/cache-postgres.jar
Copy cache-postgres.jar
library to Gerrit /lib
and add the following two extra settings to gerrit.config
:
[gerrit] installModule = com.googlesource.gerrit.modules.cache.pg.CacheModule [cache] url = jdbc:postgresql://localhost:5432/gerrit_caches?user=gerrit&password=gerrit
cache
cache.url : URI that specifies connection to existing DB (including both username and passwword).
cache.poolLimit : Maximum number of open database connections. If the server needs more than this number, request processing threads will wait up to cache.poolMaxWait
seconds for a connection to be released before they abort with an exception. Default value is taken from database.poolLimit
.
cache.poolMinIdle : Minimum number of connections to keep idle in the pool. Default is 4
.
cache.poolMaxIdle : Maximum number of connections to keep idle in the pool. If there are more idle connections, connections will be closed instead of being returned back to the pool. Default is min(cache.poolLimit
, 16
).
cache.poolMaxWait Maximum amount of time a request processing thread will wait to acquire a database connection from the pool. If no connection is released within this time period, the processing thread will abort its current operations and return an error to the client. Values should use common unit suffixes to express their setting:
If a unit suffix is not specified, milliseconds
is assumed. Default is 30 seconds
.
One can start test Postgres server that contains both gerrit_review
(Gerrit db) and gerrit_caches
(db for caches) with the following command
docker-compose -f docker/gerrit-caches-compose.yaml up
One nedds to add the following parameters to gerrit.config
git config --file ${GERRIT_ETC_DIR}/gerrit.config database.type POSTGRESQL git config --file ${GERRIT_ETC_DIR}/gerrit.config database.hostname localhost git config --file ${GERRIT_ETC_DIR}/gerrit.config database.port 5432 git config --file ${GERRIT_ETC_DIR}/gerrit.config database.database gerrit_review git config --file ${GERRIT_ETC_DIR}/gerrit.config database.username gerrit git config --file ${GERRIT_ETC_DIR}/gerrit.config database.password gerrit git config --file ${GERRIT_ETC_DIR}/gerrit.config cache.url "jdbc:postgresql://localhost:5432/gerrit_caches?user=gerrit&password=gerrit"
where GERRIT_ETC_DIR
is GERRIT_SITE/etc
;
Notes
gerrit-pg
docker_gerrit-db-data
volume therefore restarting it preserves datadocker/create-gerrit-dbs.sh
docker/gerrit-caches-compose.yaml