I am using kuberntes runner for CICD. I want to connect cockroach database from stage container to run test cases, I have tried to configured it in CI but not working,. Here is sample of my gitlab-ci.yml file.
test:
image: cockroachdb/cockroach:v20.2.3
stage: test
variables:
DATABASE_URL: "postgresql://test_db:password@cockroachdb-cockroach:26257/test_db?sslmode=require"
FF_NETWORK_PER_BUILD: 1
services:
- name: cockroachdb/cockroach:v20.2.3
entrypoint:
- "bash"
command:
- -c
- >
mkdir certs my-safe-directory
cockroach cert create-ca --certs-dir=certs --ca-key=my-safe-directory/ca.key
cockroach cert create-node localhost 127.0.0.1 cockroachdb cockroachdb-cockroach cockroach $(hostname) --certs-dir=certs --ca-key=my-safe-directory/ca.key
cockroach cert create-client root --certs-dir=certs --ca-key=my-safe-directory/ca.key
cockroach start-single-node --certs-dir=certs --advertise-addr=cockroachdb-cockroach --background
cockroach sql --certs-dir=certs --execute="CREATE DATABASE test_db; CREATE USER test_db WITH PASSWORD 'password'; GRANT ALL ON DATABASE test_db TO test_db;"
tail -f /dev/null
cache: {}
script: |
#curl http://cockroachdb-cockroach:8080
cockroach sql --certs-dir=certs --execute="show databases;" --url=$DATABASE_URL
Error :
ERROR: cannot dial server.
Is the server running?
If the server is running, check --host client-side and --advertise server-side.
dial tcp 127.0.0.1:26257: connect: connection refused
Is there anything wrong in my ci file or does cockroach db database supports in gitlab ci services ?