[perf] Move to a single installation of CockroachDB for all Perf instances.

The migration of the data has already been done by hand.

Change-Id: I323d69c3a4eada0914d8792ee49392054899f43e
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/303348
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
diff --git a/perf/COCKROACHDB.md b/perf/COCKROACHDB.md
index 0a0dff3..0234b69 100644
--- a/perf/COCKROACHDB.md
+++ b/perf/COCKROACHDB.md
@@ -2,18 +2,19 @@
 
 Perf supports using CockroachDB as a backend.
 
-There should be a `cockroachdb/connect-*-cockroachdb.sh` script for each
-instance in this directory. Run that script and you will be dropped into an SQL
-shell as root to send commands to the server. You can, for example, create a new
-database here:
+There is a single installation of CockroachDB for all the instances of Perf.
+
+There should be a `cockroachdb/connect.sh` script in this directory. Run that
+script and you will be dropped into an SQL shell as root to send commands to the
+server. You can, for example, create a new database here:
 
         CREATE DATABASE androidx;
 
 See also: https://www.cockroachlabs.com/docs/stable/authorization.html
 
 You can get to the admin interface for each by running the associated
-`cockroachdb/admin-*-cockroachdb.sh` script, which will set up a port-forward to
-the admin interface and launch chrome to load the interface.
+`cockroachdb/admin.sh` script, which will set up a port-forward to the admin
+interface and launch chrome to load the interface.
 
 ## Setup
 
@@ -27,14 +28,14 @@
 The file should be renamed to reflect the Perf instance that will use it, and the
 names and app labels in the file should be rename to also reflect the Perf instance, for example:
 
-    s/cockroachdb/perf-androidx-cockroachdb/g
+    s/cockroachdb/perf-cockroachdb/g
 
 The service name and user account are then used in the connection string in the config file, for example:
 
     {
       "data_store_config": {
       "datastore_type": "cockroachdb",
-      "connection_string": "postgresql://root@perf-androidx-cockroachdb-public:26257/androidx?sslmode=disable",
+      "connection_string": "postgresql://root@perf-cockroachdb-public:26257/androidx?sslmode=disable",
       ...
     }
 
@@ -56,3 +57,16 @@
 Then run the migrations:
 
     migrate -verbose -path ./migrations/cockroachdb/ -database cockroachdb://root@localhost:26257/skia?sslmode=disable up
+
+## Backups
+
+Migrating between cockroachdb instances can be done by using the 'dump' and
+'sql' commands:
+
+    $ cockroach dump --url postgresql://root@perf-flutter-flutter-cockroachdb-public:26257?sslmode=disable flutter  > flutter_flutter.sql
+
+    $ cockroach sql --url postgresql://root@localhost:26257/?sslmode=disable --database flutter_flutter < flutter_flutter.sql
+
+Note that you should run this from one of the cockroachdb instances in the
+cluster since they have local SSD and the bandwidth is much higher than to your
+workstation.
diff --git a/perf/cockroachdb/admin.sh b/perf/cockroachdb/admin.sh
new file mode 100755
index 0000000..38999ac
--- /dev/null
+++ b/perf/cockroachdb/admin.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+# Sets up a port-forward to the CockroachDB admin web site and launches
+# Chrome.
+
+google-chrome http://localhost:8080
+kubectl port-forward perf-cockroachdb-0 8080
diff --git a/perf/cockroachdb/connect.sh b/perf/cockroachdb/connect.sh
new file mode 100755
index 0000000..4375473
--- /dev/null
+++ b/perf/cockroachdb/connect.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+kubectl run androidx-cockroachdb -it \
+--image=cockroachdb/cockroach:v19.2.5 \
+--rm \
+--restart=Never \
+-- sql \
+--insecure \
+--host=perf-cockroachdb-public
\ No newline at end of file
diff --git a/perf/configs/android-prod.json b/perf/configs/android-prod.json
index dbc0099..dfeaf6c 100644
--- a/perf/configs/android-prod.json
+++ b/perf/configs/android-prod.json
@@ -2,7 +2,7 @@
   "URL": "https://android-master-perf.skia.org",
   "data_store_config": {
     "datastore_type": "gcp",
-    "connection_string": "postgresql://root@perf-android-cockroachdb-public:26257/android?sslmode=disable",
+    "connection_string": "postgresql://root@perf-cockroachdb-public:26257/android?sslmode=disable",
     "tile_size": 8192,
     "project": "skia-public",
     "instance": "production",
diff --git a/perf/configs/android-x.json b/perf/configs/android-x.json
index 2f5d1e8..3a591ca 100644
--- a/perf/configs/android-x.json
+++ b/perf/configs/android-x.json
@@ -2,7 +2,7 @@
   "URL": "https://androidx-perf.skia.org/",
   "data_store_config": {
     "datastore_type": "gcp",
-    "connection_string": "postgresql://root@perf-androidx-cockroachdb-public:26257/androidx?sslmode=disable",
+    "connection_string": "postgresql://root@perf-cockroachdb-public:26257/android_x?sslmode=disable",
     "tile_size": 512,
     "project": "skia-public",
     "instance": "production",
diff --git a/perf/configs/ct-prod.json b/perf/configs/ct-prod.json
index ddeefd5..2cd6d1f 100644
--- a/perf/configs/ct-prod.json
+++ b/perf/configs/ct-prod.json
@@ -2,7 +2,7 @@
   "URL": "https://ct-perf.skia.org",
   "data_store_config": {
     "datastore_type": "gcp",
-    "connection_string": "postgresql://root@perf-ct-cockroachdb-public:26257/ct?sslmode=disable",
+    "connection_string": "postgresql://root@perf-cockroachdb-public:26257/ct?sslmode=disable",
     "tile_size": 256,
     "project": "skia-public",
     "instance": "production",
diff --git a/perf/configs/flutter-flutter.json b/perf/configs/flutter-flutter.json
index 2fed0da..acdfd29 100644
--- a/perf/configs/flutter-flutter.json
+++ b/perf/configs/flutter-flutter.json
@@ -2,7 +2,7 @@
   "URL": "https://flutter-flutter-perf.skia.org/",
   "data_store_config": {
     "datastore_type": "cockroachdb",
-    "connection_string": "postgresql://root@perf-flutter-flutter-cockroachdb-public:26257/flutter?sslmode=disable",
+    "connection_string": "postgresql://root@perf-cockroachdb-public:26257/flutter_flutter?sslmode=disable",
     "tile_size": 4096,
     "shards": 8
   },
diff --git a/perf/configs/flutter.json b/perf/configs/flutter.json
index ea2a9a7..801f649 100644
--- a/perf/configs/flutter.json
+++ b/perf/configs/flutter.json
@@ -2,7 +2,7 @@
   "URL": "https://flutter-engine-perf.skia.org/",
   "data_store_config": {
     "datastore_type": "gcp",
-    "connection_string": "postgresql://root@perf-flutter-cockroachdb-public:26257/flutter?sslmode=disable",
+    "connection_string": "postgresql://root@perf-cockroachdb-public:26257/flutter_engine?sslmode=disable",
     "tile_size": 256,
     "project": "skia-public",
     "instance": "production",
diff --git a/perf/configs/nano.json b/perf/configs/nano.json
index 35383f1..11792a0 100644
--- a/perf/configs/nano.json
+++ b/perf/configs/nano.json
@@ -2,7 +2,7 @@
   "URL": "https://perf.skia.org",
   "data_store_config": {
     "datastore_type": "gcp",
-    "connection_string": "postgresql://root@perf-skia-cockroachdb-public:26257/skia?sslmode=disable",
+    "connection_string": "postgresql://root@perf-cockroachdb-public:26257/skia?sslmode=disable",
     "tile_size": 256,
     "project": "skia-public",
     "instance": "production",