Adding postgres docker to jenkins test (#2225)

* wip

* file rename

* Adding postgres docker to jenkins test

* update and fix to jenkins file

* More fixing

* tinker

* more tinkering

* agent in stage

* agent in stage fix

* Integrated Andrea's Docker compose work

* Rework to include dockerfile into jenkins unit test

* Customer dockerfile agent

* Change to ENTRYPOINT

* No dir() in Unit Tests

* Removal dir property of dockerfile

* Added lable to agent.dockerfile

* agent set only at stage level

* Added Jakub's suggestion

* removed stage level agent

* replaced docker host name with default 127.0.0.1

* Fix of old NewWhisperEnvelope

* removed user and password settings from postgres connection

* Set explicit postgres user and password

* Change postgres creds to be more generic

* Removed unneeded docker files

* POSTGRES_HOST_AUTH_METHOD because we hate passwords

* chicken chicken chicken

* indents 2 spaces
This commit is contained in:
Samuel Hawksby-Robinson 2021-06-09 11:16:04 +01:00 committed by GitHub
parent f80b5e66a2
commit cab6281dc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 10 deletions

View File

@ -42,7 +42,7 @@ pipeline {
} } } } } }
stage('Vendoring check') { steps { dir(env.STATUS_PATH) { stage('Vendoring check') { steps { dir(env.STATUS_PATH) {
/* fail build if vendoring hasn't been done */ // fail build if vendoring hasn't been done
sh 'GO111MODULE=on make vendor && git diff --exit-code --no-color --stat vendor/' sh 'GO111MODULE=on make vendor && git diff --exit-code --no-color --stat vendor/'
} } } } } }
@ -54,9 +54,13 @@ pipeline {
sh 'make canary-test' sh 'make canary-test'
} } } } } }
stage('Unit Tests') { steps { dir(env.STATUS_PATH) { stage('Unit Tests') { steps { script { dir(env.STATUS_PATH) {
docker.image('postgres:9.6-alpine').withRun(
'-e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432'
) { c ->
sh 'make test-unit' sh 'make test-unit'
} } } }
} } } }
stage('Race E2E Tests') { steps { dir(env.STATUS_PATH) { stage('Race E2E Tests') { steps { dir(env.STATUS_PATH) {
sh 'make test-e2e-race' sh 'make test-e2e-race'

View File

@ -1,9 +1,7 @@
// +build postgres
// In order to run these tests, you must run a PostgreSQL database. // In order to run these tests, you must run a PostgreSQL database.
// //
// Using Docker: // Using Docker:
// docker run --name mailserver-db -e POSTGRES_USER=whisper -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_DB=whisper -d -p 5432:5432 postgres:9.6-alpine // docker run --name mailserver-db -e POSTGRES_HOST_AUTH_METHOD=trust -d -p 5432:5432 postgres:9.6-alpine
// //
package mailserver package mailserver
@ -24,7 +22,7 @@ import (
func TestPostgresDB_BuildIteratorWithBloomFilter(t *testing.T) { func TestPostgresDB_BuildIteratorWithBloomFilter(t *testing.T) {
topic := []byte{0xaa, 0xbb, 0xcc, 0xdd} topic := []byte{0xaa, 0xbb, 0xcc, 0xdd}
db, err := NewPostgresDB("postgres://whisper:mysecretpassword@127.0.0.1:5432/whisper?sslmode=disable") db, err := NewPostgresDB("postgres://postgres@127.0.0.1:5432/postgres?sslmode=disable")
require.NoError(t, err) require.NoError(t, err)
envelope, err := newTestEnvelope(topic) envelope, err := newTestEnvelope(topic)
@ -57,7 +55,7 @@ func TestPostgresDB_BuildIteratorWithBloomFilter(t *testing.T) {
func TestPostgresDB_BuildIteratorWithTopic(t *testing.T) { func TestPostgresDB_BuildIteratorWithTopic(t *testing.T) {
topic := []byte{0x01, 0x02, 0x03, 0x04} topic := []byte{0x01, 0x02, 0x03, 0x04}
db, err := NewPostgresDB("postgres://whisper:mysecretpassword@127.0.0.1:5432/whisper?sslmode=disable") db, err := NewPostgresDB("postgres://postgres@127.0.0.1:5432/postgres?sslmode=disable")
require.NoError(t, err) require.NoError(t, err)
envelope, err := newTestEnvelope(topic) envelope, err := newTestEnvelope(topic)
@ -109,5 +107,5 @@ func newTestEnvelope(topic []byte) (types.Envelope, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return gethbridge.NewWhisperEnvelope(envelope), nil return gethbridge.NewWakuEnvelope(envelope), nil
} }