Skip to content

Commit fa27a57

Browse files
authored
NR-180723: update integration tests to support postgres-16 (#146)
1 parent 21734ce commit fa27a57

File tree

8 files changed

+24942
-49327
lines changed

8 files changed

+24942
-49327
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test:
3131
integration-test:
3232
@echo "=== $(INTEGRATION) === [ test ]: running integration tests..."
3333
@docker-compose -f tests/docker-compose.yml pull
34-
@go test -v -tags=integration ./tests/. || (ret=$$?; docker-compose -f tests/docker-compose.yml down && exit $$ret)
34+
@go test -v -tags=integration -count 1 ./tests/. || (ret=$$?; docker-compose -f tests/docker-compose.yml down && exit $$ret)
3535
@docker-compose -f tests/docker-compose.yml down
3636

3737
install: compile

tests/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Integration tests
2+
3+
Steps to update the integration tests for the latest supported version:
4+
5+
1. Update the postgres image in the `postgres-latest-supported` of the [docker-compose](./docker-compose.yml).
6+
2. Execute the integration tests
7+
* If the JSON-schema validation fails:
8+
- Check the inventory, some server settings might have been removed.
9+
- Check the number of entities: the number of internal tables and or indexes may vary (metrics failures).
10+
- Check the release notes ([Postgres 16 example](https://www.postgresql.org/docs/release/16.0/))
11+
3. Once the failures are understood (if any), update the corresponding JSON-schema files, you may need to generate it
12+
using the integration output, specially if there is any metric failure.

tests/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ services:
1818
POSTGRES_PASSWORD: example
1919
POSTGRES_DB: demo
2020

21-
postgres-9-2-onwards:
22-
image: postgres:13
21+
postgres-latest-supported:
22+
image: postgres:16
2323
restart: always
2424
environment:
2525
POSTGRES_USER: postgres
@@ -33,7 +33,7 @@ services:
3333
depends_on:
3434
- postgres-9-0
3535
- postgres-9-1
36-
- postgres-9-2-onwards
36+
- postgres-latest-supported
3737
volumes:
3838
- ../:/code
3939
entrypoint: go run /code/src/main.go

tests/postgresql_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import (
2020

2121
const (
2222
// docker-compose service names
23-
serviceNameNRI = "nri-postgresql"
24-
serviceNamePostgres90 = "postgres-9-0"
25-
serviceNamePostgres91 = "postgres-9-1"
26-
serviceNamePostgres92Onwards = "postgres-9-2-onwards"
23+
serviceNameNRI = "nri-postgresql"
24+
serviceNamePostgres90 = "postgres-9-0"
25+
serviceNamePostgres91 = "postgres-9-1"
26+
serviceNamePostgresLatest = "postgres-latest-supported"
2727
)
2828

2929
func executeDockerCompose(serviceName string, envVars []string) (string, string, error) {
@@ -66,27 +66,27 @@ func TestSuccessConnection(t *testing.T) {
6666
EnvVars []string
6767
}{
6868
{
69-
Name: "Testing Metrics for Postgres v9.0x",
69+
Name: "Testing Metrics and inventory for Postgres v9.0x",
7070
Hostname: serviceNamePostgres90,
7171
Schema: "jsonschema90.json",
72-
EnvVars: []string{"METRIC=true"},
72+
EnvVars: []string{},
7373
},
7474
{
75-
Name: "Testing Metrics for Postgres v9.1x",
75+
Name: "Testing Metrics and inventory for Postgres v9.1x",
7676
Hostname: serviceNamePostgres91,
7777
Schema: "jsonschema91.json",
78-
EnvVars: []string{"METRIC=true"},
78+
EnvVars: []string{},
7979
},
8080
{
81-
Name: "Testing Metrics for Postgres v9.2x +",
82-
Hostname: serviceNamePostgres92Onwards,
83-
Schema: "jsonschema92.json",
84-
EnvVars: []string{"METRIC=true"},
81+
Name: "Testing Metrics and inventory for latest Postgres supported version",
82+
Hostname: serviceNamePostgresLatest,
83+
Schema: "jsonschema-latest.json",
84+
EnvVars: []string{},
8585
},
8686
{
87-
Name: "Testing Postgres Inventory",
88-
Hostname: serviceNamePostgres92Onwards,
89-
Schema: "jsonschema-inventory.json",
87+
Name: "Inventory only for latest Postgres supported version",
88+
Hostname: serviceNamePostgresLatest,
89+
Schema: "jsonschema-inventory-latest.json",
9090
EnvVars: []string{"INVENTORY=true"},
9191
},
9292
}
@@ -111,7 +111,7 @@ func TestSuccessConnection(t *testing.T) {
111111

112112
func TestMissingRequiredVars(t *testing.T) {
113113
envVars := []string{
114-
"HOSTNAME=" + serviceNamePostgres92Onwards,
114+
"HOSTNAME=" + serviceNamePostgresLatest,
115115
"DATABASE=demo",
116116
}
117117
_, stderr, err := executeDockerCompose(serviceNameNRI, envVars)
@@ -121,7 +121,7 @@ func TestMissingRequiredVars(t *testing.T) {
121121

122122
func TestIgnoringDB(t *testing.T) {
123123
envVars := []string{
124-
"HOSTNAME=" + serviceNamePostgres92Onwards,
124+
"HOSTNAME=" + serviceNamePostgresLatest,
125125
"USERNAME=postgres",
126126
"PASSWORD=example",
127127
"DATABASE=demo",

0 commit comments

Comments
 (0)