Skip to content

Commit

Permalink
Metricbeat: Integration tests for haproxy 1.7 and 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoriano committed Apr 6, 2018
1 parent 61cadda commit 53e5ef7
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
- Set `pool` as default metricset for php_fpm module. {pull}6768[6768]
- Set `status` as default metricset for mysql module. {pull} 6769[6769]
- Set `stubstatus` as default metricset for nginx module. {pull}6770[6770]
- Added support for haproxy 1.7 and 1.8. {pull}6793[6793]

*Packetbeat*

Expand Down
13 changes: 13 additions & 0 deletions libbeat/tests/system/beat/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ def compose_down(cls):
if INTEGRATION_TESTS and cls.COMPOSE_SERVICES:
cls.compose_project().kill(service_names=cls.COMPOSE_SERVICES)

@classmethod
def compose_hosts(cls):
if not INTEGRATION_TESTS or not cls.COMPOSE_SERVICES:
return []

hosts = []
for container in cls.compose_project().containers(service_names=cls.COMPOSE_SERVICES):
network_settings = container.inspect()['NetworkSettings']
for network in network_settings['Networks'].values():
if network['IPAddress']:
hosts.append(network['IPAddress'])
return hosts

@classmethod
def compose_project(cls):
return get_project(cls.COMPOSE_PROJECT_DIR, project_name=os.environ.get('DOCKER_COMPOSE_PROJECT_NAME'))
10 changes: 10 additions & 0 deletions metricbeat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ services:
haproxy:
build: ./module/haproxy/_meta

haproxy_1_6:
build:
context: ./module/haproxy/_meta
dockerfile: Dockerfile.1.6

haproxy_1_7:
build:
context: ./module/haproxy/_meta
dockerfile: Dockerfile.1.7

http:
build: ./module/http/_meta

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/docs/modules/haproxy.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The default metricsets are `info`and `stat`.
[float]
=== Compatibility

The HAProxy metricsets were tested with HAProxy 1.6 and are expected to work with all 1.6 versions.
The HAProxy metricsets are tested with HAProxy versions from 1.6, 1.7 to 1.8.


[float]
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/haproxy/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM haproxy:1.6
FROM haproxy:1.8
RUN apt-get update && apt-get install -y netcat
HEALTHCHECK --interval=1s --retries=90 CMD nc -z localhost 14567
COPY ./haproxy.conf /usr/local/etc/haproxy/haproxy.cfg
Expand Down
5 changes: 5 additions & 0 deletions metricbeat/module/haproxy/_meta/Dockerfile.1.6
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM haproxy:1.6
RUN apt-get update && apt-get install -y netcat
HEALTHCHECK --interval=1s --retries=90 CMD nc -z localhost 14567
COPY ./haproxy.conf /usr/local/etc/haproxy/haproxy.cfg
EXPOSE 14567
5 changes: 5 additions & 0 deletions metricbeat/module/haproxy/_meta/Dockerfile.1.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM haproxy:1.7
RUN apt-get update && apt-get install -y netcat
HEALTHCHECK --interval=1s --retries=90 CMD nc -z localhost 14567
COPY ./haproxy.conf /usr/local/etc/haproxy/haproxy.cfg
EXPOSE 14567
2 changes: 1 addition & 1 deletion metricbeat/module/haproxy/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ The default metricsets are `info`and `stat`.
[float]
=== Compatibility

The HAProxy metricsets were tested with HAProxy 1.6 and are expected to work with all 1.6 versions.
The HAProxy metricsets are tested with HAProxy versions from 1.6, 1.7 to 1.8.
2 changes: 2 additions & 0 deletions metricbeat/module/haproxy/_meta/env
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
HAPROXY_1_6_HOST=haproxy_1_6
HAPROXY_1_7_HOST=haproxy_1_7
HAPROXY_HOST=haproxy
HAPROXY_PORT=14567
18 changes: 13 additions & 5 deletions metricbeat/tests/system/test_haproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
HAPROXY_FIELDS = metricbeat.COMMON_FIELDS + ["haproxy"]


class Test(metricbeat.BaseTest):
class HaproxyTest(metricbeat.BaseTest):

COMPOSE_SERVICES = ['haproxy']

Expand All @@ -32,7 +32,7 @@ def test_info_socket(self):
self.render_config_template(modules=[{
"name": "haproxy",
"metricsets": ["info"],
"hosts": ["tcp://%s:%d" % (os.getenv('HAPROXY_HOST', 'localhost'), 14567)],
"hosts": ["tcp://%s:%d" % (self.compose_hosts()[0], 14567)],
"period": "5s"
}])
self._test_info()
Expand All @@ -59,7 +59,7 @@ def test_stat_socket(self):
self.render_config_template(modules=[{
"name": "haproxy",
"metricsets": ["stat"],
"hosts": ["tcp://%s:%d" % (os.getenv('HAPROXY_HOST', 'localhost'), 14567)],
"hosts": ["tcp://%s:%d" % (self.compose_hosts()[0], 14567)],
"period": "5s"
}])
self._test_stat()
Expand All @@ -72,7 +72,7 @@ def test_stat_http(self):
self.render_config_template(modules=[{
"name": "haproxy",
"metricsets": ["stat"],
"hosts": ["http://%s:%d/stats" % (os.getenv('HAPROXY_HOST', 'localhost'), 14568)],
"hosts": ["http://%s:%d/stats" % (self.compose_hosts()[0], 14568)],
"period": "5s"
}])
self._test_stat()
Expand All @@ -87,7 +87,15 @@ def test_stat_http_auth(self):
"metricsets": ["stat"],
"username": "admin",
"password": "admin",
"hosts": ["http://%s:%d/stats" % (os.getenv('HAPROXY_HOST', 'localhost'), 14569)],
"hosts": ["http://%s:%d/stats" % (self.compose_hosts()[0], 14569)],
"period": "5s"
}])
self._test_stat()


class Haproxy_1_6_Test(HaproxyTest):
COMPOSE_SERVICES = ['haproxy_1_6']


class Haproxy_1_7_Test(HaproxyTest):
COMPOSE_SERVICES = ['haproxy_1_7']

0 comments on commit 53e5ef7

Please sign in to comment.