Skip to content

Commit

Permalink
Verify that we can query Postgres and Sybase or fail the build.
Browse files Browse the repository at this point in the history
Right now there's a hack where we sleep, since
https://hub.docker.com/r/datagrip/sybase/ says it needs about 30s for
initialization.  We ought to handle this by retrying instead, but until
I figure out why the login failure is causing a segfault this will do.
  • Loading branch information
ncabatoff committed May 12, 2019
1 parent 6516e25 commit 8a75b22
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 19 deletions.
66 changes: 62 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,55 @@ jobs:
steps:
- checkout
- run: make vet test dbms_exporter
- persist_to_workspace:
root: .
paths:
- dbms_exporter
- sybase-short.yaml
- postgres.yaml

testpg:
docker:
- image: docker:stable-git
steps:
- attach_workspace:
at: workspace
- setup_remote_docker
- run: docker run -d --name pg -e 'POSTGRES_PASSWORD=pgpass' postgres:11
- run: |
docker create -v /de --name de debian:stretch /bin/true
docker cp workspace/. de:/de
- run: >
docker run --network container:pg -d
--volumes-from de
-e DATA_SOURCE_NAME='postgresql://postgres:pgpass@localhost:5432/?sslmode=disable'
debian:stretch
/de/dbms_exporter -queryfile /de/postgres.yaml -driver postgres
- run: |
test 0 -lt $(docker run --network container:pg byrnedo/alpine-curl --retry 10 --retry-connrefused localhost:9113/metrics |
awk '/postgres_pg_stat_activity_count[{]datname="postgres",state="active"[}]/{ print $2 }')
testsyb:
docker:
- image: docker:stable-git
steps:
- attach_workspace:
at: workspace
- setup_remote_docker
- run: docker run -d --name syb -e 'SYBASE_USER=guest' -h dksybase datagrip/sybase:16.0
- run: |
docker create -v /de --name de debian:stretch /bin/true
docker cp workspace/. de:/de
sleep 60
- run: >
docker run --name sybde --network container:syb -d
--volumes-from de
-e DATA_SOURCE_NAME='compatibility_mode=sybase;user=guest;pwd=guest1234;server=localhost:5000'
debian:stretch
/de/dbms_exporter -queryfile /de/sybase-short.yaml -driver sybase -persistent.connection=true
- run: |
test 0 -lt $(docker run --network container:syb byrnedo/alpine-curl --retry 10 --retry-connrefused localhost:9113/metrics |
awk '/sybase_spid_count_by_user_conns[{]dbuser="guest"[}]/{ print $2 }')
image:
environment:
Expand All @@ -30,9 +79,9 @@ jobs:
- image: ncabatoff/dbms_exporter_builder:1.1.5
steps:
- checkout
# - run: sudo apt-get -qq update
# - run: sudo apt-get install -y rpm
- run: curl -sL https://git.io/goreleaser | bash
- run: curl -LO https://github.com/goreleaser/goreleaser/releases/latest/download/goreleaser_amd64.deb
- run: dpkg -i goreleaser_amd64.deb
- run: goreleaser release

release_image:
environment:
Expand All @@ -53,7 +102,16 @@ workflows:
build_and_image:
jobs:
- build
- image
- testpg:
requires:
- build
- testsyb:
requires:
- build
- image:
requires:
- testpg
- testsyb
release:
jobs:
- release:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ See the [github.com/lib/pq](http://github.com/lib/pq) module for other ways to f
### FreeTDS/Sybase

You can use "sybase" as an alias for the freetds driver; it behaves the same
except that metrics start with `sybase_` isntead of `freetds_`.
except that metrics start with `sybase_` instead of `freetds_`.

```
DATA_SOURCE_NAME="compatibility_mode=sybase;user=myuser;pwd=mypassword;server=myhostname" \
Expand Down
32 changes: 18 additions & 14 deletions postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,24 @@ pg_locks:
usage: "GAUGE"
description: "Number of locks"

pg_stat_replication:
query: "SELECT client_addr, state,
pg_xlog_location_diff(pg_current_xlog_location(), replay_location)::float
FROM pg_stat_replication"
metrics:
- client_addr:
usage: "LABEL"
description: "IP address of the client connected to this WAL sender. If this field is null, it indicates that the client is connected via a Unix socket on the server machine."
- state:
usage: "LABEL"
description: "Current WAL sender state"
- pg_xlog_location_diff:
usage: "GAUGE"
description: "Lag in bytes between master and slave"
# pg_xlog_location_diff is gone in recent PG versions, need to figure out the
# right modern equiv, and if there isn't a common way to do it, how to manage
# multiple versions.

#pg_stat_replication:
# query: "SELECT client_addr, state,
# pg_xlog_location_diff(pg_current_xlog_location(), replay_location)::float
# FROM pg_stat_replication"
# metrics:
# - client_addr:
# usage: "LABEL"
# description: "IP address of the client connected to this WAL sender. If this field is null, it indicates that the client is connected via a Unix socket on the server machine."
# - state:
# usage: "LABEL"
# description: "Current WAL sender state"
# - pg_xlog_location_diff:
# usage: "GAUGE"
# description: "Lag in bytes between master and slave"

pg_stat_activity:
query: "SELECT pg_database.datname,
Expand Down

0 comments on commit 8a75b22

Please sign in to comment.