Running test-suite for postgresql module

I'm getting an error when I try to run integration tests for postgresql...

$ MODULE=postgresql make run-module

TESTING_ENVIRONMENT=snapshot ES_BEATS=.. docker-compose -p metricbeatf1c1aec6a75b69c6e95228873a2b9e3f66c240b4  -f docker-compose.yml run -p : postgresql
Creating network "metricbeatf1c1aec6a75b69c6e95228873a2b9e3f66c240b4_default" with the default driver
Traceback (most recent call last):
  File "bin/docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 88, in main
  File "compose/cli/main.py", line 140, in perform_command
  File "compose/cli/main.py", line 736, in run
  File "compose/cli/main.py", line 1028, in run_one_off_container
  File "compose/service.py", line 292, in create_container
  File "compose/service.py", line 686, in _get_container_create_options
  File "compose/service.py", line 1212, in build_container_ports
  File "site-packages/docker/utils/ports.py", line 75, in split_port
  File "site-packages/docker/utils/ports.py", line 56, in _raise_invalid_port
ValueError: Invalid port ":", should be [[remote_ip:]remote_port[-remote_port]:]port[/protocol]
Failed to execute script docker-compose
Makefile:79: recipe for target 'run-module' failed
make: *** [run-module] Error 255

Could this be an issue with my docker version?

$ docker --version
Docker version 18.03.1-ce, build 9ee9f40
$ docker-compose --version
docker-compose version 1.11.1, build 7c5d5e4

Hi @zinefer,

Apart from module, you need to pass an env variable for the postgresql port

Best regards

Heh... Dunno why I didn't try that. I figured that env file was getting picked up but of course it isn't. Thanks!!

I had to remove the POSTGRESQL_ prefix from all of the vars in env.

MODULE=postgresql DSN=postgres://postgresql:5432?sslmode=disable HOST=postgresql PORT=5432 USERNAME=postgres make run-module

Now I have a new problem ... When I run MODULE=postgresql make test-module All the modules are failing with the same error:

=== RUN   TestParseUrl
--- PASS: TestParseUrl (0.00s)
PASS
ok      github.com/elastic/beats/metricbeat/module/postgresql   0.006s
=== RUN   TestFetch
--- FAIL: TestFetch (1.39s)
        modules.go:77: failed to create new MetricSet empty field accessing 'hosts.0'
=== RUN   TestData
--- FAIL: TestData (1.10s)
        modules.go:77: failed to create new MetricSet empty field accessing 'hosts.0'
FAIL
exit status 1
FAIL    github.com/elastic/beats/metricbeat/module/postgresql/activity  2.505s
=== RUN   TestFetch
--- FAIL: TestFetch (1.06s)
        modules.go:77: failed to create new MetricSet empty field accessing 'hosts.0'
=== RUN   TestData
--- FAIL: TestData (1.13s)
        modules.go:77: failed to create new MetricSet empty field accessing 'hosts.0'
FAIL
exit status 1
FAIL    github.com/elastic/beats/metricbeat/module/postgresql/bgwriter  2.202s
=== RUN   TestFetch
--- FAIL: TestFetch (1.07s)
        modules.go:77: failed to create new MetricSet empty field accessing 'hosts.0'
=== RUN   TestData
--- FAIL: TestData (1.09s)
        modules.go:77: failed to create new MetricSet empty field accessing 'hosts.0'
FAIL
exit status 1
FAIL    github.com/elastic/beats/metricbeat/module/postgresql/database  2.167s
=== RUN   TestFetch
--- FAIL: TestFetch (1.06s)
        modules.go:77: failed to create new MetricSet empty field accessing 'hosts.0'
=== RUN   TestData
--- FAIL: TestData (1.14s)
        modules.go:77: failed to create new MetricSet empty field accessing 'hosts.0'
FAIL
exit status 1
FAIL    github.com/elastic/beats/metricbeat/module/postgresql/statement 2.216s
Makefile:85: recipe for target 'test-module' failed
make: *** [test-module] Error 1

Hi again,

I think DSN env var should be POSTGRESQL_DSN, could you try that?

Yep! I also needed POSTGRESQL_USER to get it to run. Incase any one else lands here, my final command looked like this:

 MODULE=postgresql POSTGRESQL_DSN=postgres://localhost:5432?sslmode=disable POSTGRESQL_USERNAME=postgres make test-module

Thanks a ton!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.