Add healthcheck plugin

Use healthcheck plugin instead of version endpoint

Feature: Issue 12828
Change-Id: Iee0f76b10571525cd3b2775af98009cb3412c481
diff --git a/dual-master/haproxy/haproxy.cfg.template b/dual-master/haproxy/haproxy.cfg.template
index 844b2e6..ba04013 100644
--- a/dual-master/haproxy/haproxy.cfg.template
+++ b/dual-master/haproxy/haproxy.cfg.template
@@ -39,7 +39,7 @@
     balance roundrobin
     option forwardfor
     default-server inter 10s fall 3 rise 2
-    option httpchk GET /config/server/version HTTP/1.0
+    option httpchk GET /config/server/healthcheck~status HTTP/1.0
     http-check expect status 200
     server gerrit-1 $GERRIT_MASTER_1_URL:$GERRIT_MASTER_1_HTTP_PORT check inter 10s
     server gerrit-2 $GERRIT_MASTER_2_URL:$GERRIT_MASTER_2_HTTP_PORT check inter 10s backup
@@ -57,7 +57,7 @@
 backend ssh
     mode tcp
     option redispatch
-    option httpchk GET /config/server/version HTTP/1.0
+    option httpchk GET /config/server/healthcheck~status HTTP/1.0
     http-check expect status 200
     balance source
     timeout connect 10s
diff --git a/gerrit/Makefile b/gerrit/Makefile
index 6b71a07..902e93a 100644
--- a/gerrit/Makefile
+++ b/gerrit/Makefile
@@ -24,6 +24,11 @@
 	-O ./plugins/high-availability.jar \
 	|| { echo >&2 "Cannot download high-availability plugin: Check internet connection. Aborting"; exit 1; }
 
+	@echo "Downloading Health Check plugin $(GERRIT_BRANCH)"
+	wget $(GERRIT_CI)/plugin-healthcheck-bazel-$(GERRIT_BRANCH)/$(LAST_BUILD)/healthcheck/healthcheck.jar \
+	-O ./plugins/healthcheck.jar \
+	|| { echo >&2 "Cannot download healthcheck plugin: Check internet connection. Aborting"; exit 1; }
+
 gerrit-build:
 	cat Dockerfile | \
 		GERRIT_VERSION=$(GERRIT_VERSION) GERRIT_PATCH=$(GERRIT_PATCH) envsubst | \
diff --git a/gerrit/etc/healthcheck.config b/gerrit/etc/healthcheck.config
new file mode 100644
index 0000000..ddea5f1
--- /dev/null
+++ b/gerrit/etc/healthcheck.config
@@ -0,0 +1,9 @@
+[healthcheck]
+  timeout = 10s
+
+[healthcheck "querychanges"]
+  query = status:open OR status:merged OR status:abandoned
+  limit = 0
+
+[healthcheck "auth"]
+  enabled =  false