Skip to content

Commit 38b36e6

Browse files
committed
Connect to search db hosts directly
1 parent a619adc commit 38b36e6

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

.github/workflows/ci.yml

+5-10
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ jobs:
66
test:
77
name: Test
88
runs-on: ubuntu-latest
9+
container:
10+
image: node:18
911
strategy:
1012
matrix:
11-
searchdb-port: [9207, 9208, 9201]
13+
searchdb-host: [elastic7, elastic8, opensearch1]
1214
fail-fast: false
1315

1416
services:
@@ -18,26 +20,18 @@ jobs:
1820
POSTGRES_DB: indexer_test
1921
POSTGRES_USER: indexer_test
2022
POSTGRES_PASSWORD: temba
21-
ports:
22-
- 5432:5432
2323
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
2424
elastic7:
2525
image: elasticsearch:7.17.9
26-
ports:
27-
- 9207:9200
2826
env:
2927
discovery.type: single-node
3028
elastic8:
3129
image: elasticsearch:8.13.4
32-
ports:
33-
- 9208:9200
3430
env:
3531
discovery.type: single-node
3632
xpack.security.enabled: false
3733
opensearch1:
3834
image: opensearchproject/opensearch:1.3.16
39-
ports:
40-
- 9201:9200
4135
env:
4236
discovery.type: single-node
4337
plugins.security.disabled: true
@@ -53,7 +47,8 @@ jobs:
5347

5448
- name: Setup environment
5549
run: |
56-
echo "INDEXER_ELASTIC_URL=http://localhost:${{ matrix.searchdb-port }}" >> "$GITHUB_ENV"
50+
echo "INDEXER_DB=postgres://indexer_test:temba@postgres:5432/indexer_test?sslmode=disable" >> "$GITHUB_ENV"
51+
echo "INDEXER_ELASTIC_URL=http://${{ matrix.searchdb-host }}:9200" >> "$GITHUB_ENV"
5752
5853
- name: Run tests
5954
run: go test -p=1 -coverprofile=coverage.text -covermode=atomic ./...

indexers/base_test.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ import (
2323

2424
const aliasName = "indexer_test"
2525

26+
func getenv(key, def string) string {
27+
val := os.Getenv(key)
28+
if val == "" {
29+
return def
30+
}
31+
return val
32+
}
33+
2634
func setup(t *testing.T) (*indexer.Config, *sql.DB) {
2735
cfg := indexer.NewDefaultConfig()
28-
cfg.DB = "postgres://indexer_test:temba@localhost:5432/indexer_test?sslmode=disable"
29-
cfg.ElasticURL = os.Getenv("INDEXER_ELASTIC_URL")
30-
if cfg.ElasticURL == "" {
31-
cfg.ElasticURL = "http://localhost:9200"
32-
}
36+
cfg.DB = getenv("INDEXER_DB", "postgres://indexer_test:temba@localhost:5432/indexer_test?sslmode=disable")
37+
cfg.ElasticURL = getenv("INDEXER_ELASTIC_URL", "http://localhost:9200")
3338

3439
testDB, err := os.ReadFile("../testdb.sql")
3540
require.NoError(t, err)

0 commit comments

Comments
 (0)