Skip to content

Commit

Permalink
NR-180723: update integration tests to support postgres-16 (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigilioso authored Dec 29, 2023
1 parent 21734ce commit fa27a57
Show file tree
Hide file tree
Showing 8 changed files with 24,942 additions and 49,327 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test:
integration-test:
@echo "=== $(INTEGRATION) === [ test ]: running integration tests..."
@docker-compose -f tests/docker-compose.yml pull
@go test -v -tags=integration ./tests/. || (ret=$$?; docker-compose -f tests/docker-compose.yml down && exit $$ret)
@go test -v -tags=integration -count 1 ./tests/. || (ret=$$?; docker-compose -f tests/docker-compose.yml down && exit $$ret)
@docker-compose -f tests/docker-compose.yml down

install: compile
Expand Down
12 changes: 12 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Integration tests

Steps to update the integration tests for the latest supported version:

1. Update the postgres image in the `postgres-latest-supported` of the [docker-compose](./docker-compose.yml).
2. Execute the integration tests
* If the JSON-schema validation fails:
- Check the inventory, some server settings might have been removed.
- Check the number of entities: the number of internal tables and or indexes may vary (metrics failures).
- Check the release notes ([Postgres 16 example](https://www.postgresql.org/docs/release/16.0/))
3. Once the failures are understood (if any), update the corresponding JSON-schema files, you may need to generate it
using the integration output, specially if there is any metric failure.
6 changes: 3 additions & 3 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ services:
POSTGRES_PASSWORD: example
POSTGRES_DB: demo

postgres-9-2-onwards:
image: postgres:13
postgres-latest-supported:
image: postgres:16
restart: always
environment:
POSTGRES_USER: postgres
Expand All @@ -33,7 +33,7 @@ services:
depends_on:
- postgres-9-0
- postgres-9-1
- postgres-9-2-onwards
- postgres-latest-supported
volumes:
- ../:/code
entrypoint: go run /code/src/main.go
34 changes: 17 additions & 17 deletions tests/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (

const (
// docker-compose service names
serviceNameNRI = "nri-postgresql"
serviceNamePostgres90 = "postgres-9-0"
serviceNamePostgres91 = "postgres-9-1"
serviceNamePostgres92Onwards = "postgres-9-2-onwards"
serviceNameNRI = "nri-postgresql"
serviceNamePostgres90 = "postgres-9-0"
serviceNamePostgres91 = "postgres-9-1"
serviceNamePostgresLatest = "postgres-latest-supported"
)

func executeDockerCompose(serviceName string, envVars []string) (string, string, error) {
Expand Down Expand Up @@ -66,27 +66,27 @@ func TestSuccessConnection(t *testing.T) {
EnvVars []string
}{
{
Name: "Testing Metrics for Postgres v9.0x",
Name: "Testing Metrics and inventory for Postgres v9.0x",
Hostname: serviceNamePostgres90,
Schema: "jsonschema90.json",
EnvVars: []string{"METRIC=true"},
EnvVars: []string{},
},
{
Name: "Testing Metrics for Postgres v9.1x",
Name: "Testing Metrics and inventory for Postgres v9.1x",
Hostname: serviceNamePostgres91,
Schema: "jsonschema91.json",
EnvVars: []string{"METRIC=true"},
EnvVars: []string{},
},
{
Name: "Testing Metrics for Postgres v9.2x +",
Hostname: serviceNamePostgres92Onwards,
Schema: "jsonschema92.json",
EnvVars: []string{"METRIC=true"},
Name: "Testing Metrics and inventory for latest Postgres supported version",
Hostname: serviceNamePostgresLatest,
Schema: "jsonschema-latest.json",
EnvVars: []string{},
},
{
Name: "Testing Postgres Inventory",
Hostname: serviceNamePostgres92Onwards,
Schema: "jsonschema-inventory.json",
Name: "Inventory only for latest Postgres supported version",
Hostname: serviceNamePostgresLatest,
Schema: "jsonschema-inventory-latest.json",
EnvVars: []string{"INVENTORY=true"},
},
}
Expand All @@ -111,7 +111,7 @@ func TestSuccessConnection(t *testing.T) {

func TestMissingRequiredVars(t *testing.T) {
envVars := []string{
"HOSTNAME=" + serviceNamePostgres92Onwards,
"HOSTNAME=" + serviceNamePostgresLatest,
"DATABASE=demo",
}
_, stderr, err := executeDockerCompose(serviceNameNRI, envVars)
Expand All @@ -121,7 +121,7 @@ func TestMissingRequiredVars(t *testing.T) {

func TestIgnoringDB(t *testing.T) {
envVars := []string{
"HOSTNAME=" + serviceNamePostgres92Onwards,
"HOSTNAME=" + serviceNamePostgresLatest,
"USERNAME=postgres",
"PASSWORD=example",
"DATABASE=demo",
Expand Down
Loading

0 comments on commit fa27a57

Please sign in to comment.