Skip to content

Commit 0e23396

Browse files
authored
Update README and other doc. (#269)
1 parent 2bdd8fb commit 0e23396

File tree

7 files changed

+115
-34
lines changed

7 files changed

+115
-34
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*.so
66
*.dylib
77
bin/*
8+
dashboard/containers/**
9+
dashboard/bin/*
810
**/main
911
**/*.out
1012

README.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,29 @@ The main executable is a [custom controller] that manages resources of kind
1515
[LoadTest]. This controller must be deployed to the cluster before load tests
1616
can be run on it. The controller is implemented with [kubebuilder].
1717

18-
There is also a set of tools used to prepare prebuilt images and run batches of
19-
tests. These tools are used to generate the dashboard linked from the [gRPC
20-
performance benchmarking] page. For more information, see
21-
[tools](tools/README.md).
18+
There is also a set of [tools](tools/README.md) used to generate load test
19+
configurations, prepare prebuilt images and run batches of tests. These tools
20+
are used to run batches of tests for continuous integration.
2221

2322
[Examples](config/samples/README.md) of load test configurations in the
2423
supported languages are also provided.
2524

2625
[custom controller]: cmd/controller/main.go
27-
[grpc performance benchmarking]: https://grpc.io/docs/guides/benchmarking/
2826
[kubebuilder]: https://kubebuilder.io
2927
[loadtest]: config/crd/bases/e2etest.grpc.io_loadtests.yaml
3028

31-
## Contributing
29+
## Dashboard
3230

33-
Welcome! Please read [how to contribute](CONTRIBUTING.md) before proceeding.
31+
The data generated in continuous integration are saved to [BigQuery], and
32+
displayed on a public dashboard linked from the [gRPC performance benchmarking]
33+
page.
3434

35-
This project includes third party dependencies as git submodules. Be sure to
36-
initialize and update them when setting up a development environment:
35+
For more information, and to build your own dashboard, see
36+
[dashboard](dashboard/README.md).
3737

38-
```shell
39-
# Init/update during the clone
40-
git clone --recursive https://github.com/grpc/test-infra.git # HTTPS
41-
git clone --recursive git@github.com:grpc/test-infra.git # SSH
38+
[bigquery]: https://cloud.google.com/bigquery
39+
[grpc performance benchmarking]: https://grpc.io/docs/guides/benchmarking/
4240

43-
# (or) Init/update after the clone
44-
git submodule update --init
45-
```
41+
## Contributing
42+
43+
Welcome! Please read [how to contribute](CONTRIBUTING.md) before proceeding.

dashboard/Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
GOCMD ?= go
2-
GOARGS= -trimpath
3-
REPLICATOR_OUTPUT_DIR ?= bin
2+
GOARGS = -trimpath
43
CONFIG_TEMPLATE_DIR ?= config
4+
DASHBOARDS_CONFIG_DIR ?= $(CONFIG_TEMPLATE_DIR)/grafana/dashboards/default
5+
REPLICATOR_CONFIG_TEMPLATE ?= $(CONFIG_TEMPLATE_DIR)/postgres_replicator/default/config.yaml
6+
REPLICATOR_OUTPUT_DIR ?= bin
57
GRAFANA_CONTAINER_OUTPUT_DIR ?= containers/grafana
68
REPLICATOR_CONTAINER_OUTPUT_DIR ?= containers/replicator
79

810
configure-grafana:
911
scripts/check_env.sh GCP_GRAFANA_SERVICE PG_USER PG_PASS PG_DATABASE GRAFANA_ADMIN_PASS CLOUD_SQL_INSTANCE
1012
mkdir -p $(GRAFANA_CONTAINER_OUTPUT_DIR)
11-
cp -r $(CONFIG_TEMPLATE_DIR)/grafana/dashboards/default $(GRAFANA_CONTAINER_OUTPUT_DIR)/dashboards
13+
cp -r $(DASHBOARDS_CONFIG_DIR) $(GRAFANA_CONTAINER_OUTPUT_DIR)/dashboards
1214
cp -r grafana/* $(GRAFANA_CONTAINER_OUTPUT_DIR)
1315
cp $(CONFIG_TEMPLATE_DIR)/grafana/Dockerfile $(GRAFANA_CONTAINER_OUTPUT_DIR)/Dockerfile
1416
envsubst < $(CONFIG_TEMPLATE_DIR)/grafana/app.yaml > $(GRAFANA_CONTAINER_OUTPUT_DIR)/app.yaml
1517

1618
configure-replicator:
1719
scripts/check_env.sh GCP_PROJECT_ID GCP_DATA_TRANSFER_SERVICE BQ_PROJECT_ID PG_USER PG_PASS PG_DATABASE CLOUD_SQL_INSTANCE
18-
mkdir -p containers/replicator
20+
mkdir -p $(REPLICATOR_CONTAINER_OUTPUT_DIR)
21+
envsubst < $(REPLICATOR_CONFIG_TEMPLATE) > $(REPLICATOR_CONTAINER_OUTPUT_DIR)/config.yaml
1922
cp $(CONFIG_TEMPLATE_DIR)/postgres_replicator/Dockerfile $(REPLICATOR_CONTAINER_OUTPUT_DIR)/Dockerfile
2023
envsubst < $(CONFIG_TEMPLATE_DIR)/postgres_replicator/app.yaml > $(REPLICATOR_CONTAINER_OUTPUT_DIR)/app.yaml
21-
envsubst < $(CONFIG_TEMPLATE_DIR)/postgres_replicator/default/config.yaml > $(REPLICATOR_CONTAINER_OUTPUT_DIR)/config.yaml
2224

25+
# Replicator target is for testing only. Production binary is built by Docker.
2326
replicator: fmt vet
2427
$(GOCMD) build $(GOARGS) -o $(REPLICATOR_OUTPUT_DIR)/replicator cmd/postgres_replicator/main.go
2528

dashboard/README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Dashboard
2+
3+
This folder contains the components necessary to build and deploy a dashboard to
4+
visualize gRPC OSS benchmarking results.
5+
6+
gRPC OSS benchmarks save results to [BigQuery]. The dashboard consists of two
7+
components:
8+
9+
1. A [Postgres replicator], to transfer the results to a Postgres database.
10+
1. A Grafana dashboard, to displays the results from the Postgres database.
11+
12+
These components can be built and deployed manually using the
13+
[Makefile](Makefile) (see [manual build](#manual-build)).
14+
15+
Notice that the dashboard build is independent from the top-level build.
16+
17+
## Configuration
18+
19+
The configuration of the Postgres replicator is defined in a YAML file. The
20+
default configuration is defined here, in template form:
21+
22+
- [config/postgres_replicator/default/config.yaml][postgres replicator config]
23+
24+
For more information, see [Postgres replicator].
25+
26+
The configuration of the Grafana dashboard is defined in a set of dashboards
27+
specified in JSON files. The default configuration is defined here:
28+
29+
- [config/grafana/dashboards/default/][grafana dashboard config]
30+
31+
The continuous integration dashboard linked from the [gRPC performance
32+
benchmarking] page uses the default configuration. The variables
33+
`REPLICATOR_CONFIG_TEMPLATE` and `DASHBOARDS_CONFIG_DIR` can be set to build
34+
dashboards with different configurations.
35+
36+
[bigquery]: https://cloud.google.com/bigquery
37+
[grafana dashboard config]: config/grafana/dashboards/default/
38+
[grpc performance benchmarking]: https://grpc.io/docs/guides/benchmarking/
39+
[postgres replicator]: cmd/postgres_replicator/README.md
40+
[postgres replicator config]: config/postgres_replicator/default/config.yaml
41+
42+
## Manual build
43+
44+
Several environment variables must be set before building and deploying. The
45+
table below shows the names and values of the variables in our main dashboard:
46+
47+
| Variable | Value |
48+
| --------------------------- | --------------------------------------------- |
49+
| `BQ_PROJECT_ID` | `grpc-testing` |
50+
| `CLOUD_SQL_INSTANCE` | `grpc-testing:us-central1:grafana-datasource` |
51+
| `GCP_DATA_TRANSFER_SERVICE` | `postgres-replicator` |
52+
| `GCP_GRAFANA_SERVICE` | `grafana` |
53+
| `GCP_PROJECT_ID` | `grpc-testing` |
54+
| `GRAFANA_ADMIN_PASS` | \*\*\* |
55+
| `PG_DATABASE` | `datasource` |
56+
| `PG_PASS` | \*\*\* |
57+
| `PG_USER` | `grafana-user` |
58+
59+
Docker files that can be used to build and deploy the Postgres replicator and
60+
Grafana dashboard are then created with the following commands:
61+
62+
```shell
63+
make configure-replicator
64+
make configure-dashboard
65+
```
66+
67+
## Cloud build
68+
69+
The continuous integration dashboard is built and deployed with [Cloud Build],
70+
using the configuration specified in [cloudbuild.yaml](cloudbuild.yaml).
71+
72+
The use of Cloud Build allows the dashboard to be redeployed automatically on
73+
configuration changes. In addition, it allows passwords such as `PG_PASS` and
74+
`GRAFANA_ADMIN_PASS` to be stored as secrets in the cloud project.
75+
76+
[cloud build]: https://cloud.google.com/build

dashboard/cmd/postgres_replicator/README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This tool replicates streaming data from BigQuery into PostgreSQL.
44

55
## Configuration
66

7-
It is configured with a YAML file. Here is an example configuration file:
7+
The tool is configured with a YAML file. Here is an example configuration file:
88

99
```yaml
1010
# Source database settings
@@ -52,7 +52,7 @@ This port number can be overridden via the `PORT` environment variable.
5252

5353
## Running
5454

55-
From the test-infra project root, run `make replicator`, then
55+
From the dashboard project root, run `make replicator`, then
5656
`bin/replicator -c <config_file>`.
5757

5858
When the replicator receives a `GET` request for `/run`, it will transfer new
@@ -64,8 +64,8 @@ ignore additional requests to `/run` (but still return `200`).
6464
1. The data in the database must be sequentially ordered by time. Specifically,
6565
there must be a column of BigQuery datatype TIMESTAMP. This timestamp should
6666
strictly increase for new data.
67-
2. Configuration only allows for one GCP project at a time.
68-
3. All table names must be unique, even across multiple BigQuery datasets
67+
1. Configuration only allows for one GCP project at a time.
68+
1. All table names must be unique, even across multiple BigQuery datasets
6969

7070
## How it works
7171

@@ -87,13 +87,14 @@ BigQuery table.
8787

8888
For non-nested columns, the replicator currently supports
8989

90-
- FLOAT
91-
- STRING
92-
- TIMESTAMP
90+
- `FLOAT`
91+
- `STRING`
92+
- `TIMESTAMP`
9393

9494
BigQuery table fields that are of the `RECORD`/`REPEATED`/`STRUCT`/`ARRAY` type
9595
are converted to JSON and stored in Postgres as the JSON datatype. To retrieve
96-
values from the Postgres table, see the [JSON Functions and Operators] page.
96+
values from the Postgres table, see the documentation on [JSON Functions and
97+
Operators].
9798

9899
For example, if your BigQuery table has the FLOAT field `stats.client1.latency`,
99100
this could then be queried and typecast with the following in Postgres:

dashboard/config/postgres_replicator/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ ARG REPOSITORY=grpc/test-infra
2121
ARG GITREF=master
2222

2323
RUN git clone https://github.com/$REPOSITORY.git src \
24-
&& cd src/dashboard && git checkout $GITREF \
25-
&& make replicator REPLICATOR_OUTPUT_DIR=/
24+
&& cd src/dashboard && git checkout $GITREF \
25+
&& make replicator REPLICATOR_OUTPUT_DIR=/
2626

2727
# Copy replicator binary and run it
2828
FROM golang:1.16

dashboard/scripts/check_env.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
# check_env checks that all required environment variables are set
44
check_env () {
5-
env_vars=("$@")
6-
missing_var=0
5+
local -a env_vars=( "$@" )
6+
local missing_var=0
7+
local var
78
for var in "${env_vars[@]}"; do
89
if [ -z "${!var}" ]; then
910
echo "${var} not set"
1011
missing_var=1
1112
fi
1213
done
13-
return $missing_var
14+
return ${missing_var}
1415
}
1516

1617
check_env "$@"

0 commit comments

Comments
 (0)