# Running test-suite for postgresql module

**URL:** <https://discuss.elastic.co/t/running-test-suite-for-postgresql-module/134105>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [May 31, 2018, 7:59pm UTC](https://discuss.elastic.co/t/running-test-suite-for-postgresql-module/134105 "2018-05-31T19:59:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zinefer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zinefer/32/29368_2.png) [@zinefer](https://discuss.elastic.co/u/zinefer)\
**Post date:** [May 31, 2018, 7:59pm UTC](https://discuss.elastic.co/t/running-test-suite-for-postgresql-module/134105/1 "2018-05-31T19:59:52Z")

</div>

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

```auto
$ 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?

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

```

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [May 31, 2018, 10:23pm UTC](https://discuss.elastic.co/t/running-test-suite-for-postgresql-module/134105/2 "2018-05-31T22:23:51Z")

</div>

Hi @zinefer,

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

Best regards

---

<div class="post-metadata">

**Author:** ![zinefer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zinefer/32/29368_2.png) [@zinefer](https://discuss.elastic.co/u/zinefer)\
**Post date:** [June 1, 2018, 12:40am UTC](https://discuss.elastic.co/t/running-test-suite-for-postgresql-module/134105/3 "2018-06-01T00:40:38Z")

</div>

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`.

```auto
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:

```auto
=== 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

```

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [June 1, 2018, 6:00pm UTC](https://discuss.elastic.co/t/running-test-suite-for-postgresql-module/134105/4 "2018-06-01T18:00:52Z")

</div>

Hi again,

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

---

<div class="post-metadata">

**Author:** ![zinefer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zinefer/32/29368_2.png) [@zinefer](https://discuss.elastic.co/u/zinefer)\
**Post date:** [June 4, 2018, 5:23pm UTC](https://discuss.elastic.co/t/running-test-suite-for-postgresql-module/134105/5 "2018-06-04T17:23:15Z")

</div>

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

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

```

Thanks a ton!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 2, 2018, 5:23pm UTC](https://discuss.elastic.co/t/running-test-suite-for-postgresql-module/134105/6 "2018-07-02T17:23:20Z")

</div>

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