Skip to content

Commit

Permalink
Add supported versions to nats tests (elastic#16317)
Browse files Browse the repository at this point in the history
Add a common entry point to nats docker images so we
can use the same docker compose and Dockerfile.
Add supported-versions.yml for nats service.
Add support for 2.1.4.
  • Loading branch information
jsoriano authored and kvch committed Feb 20, 2020
1 parent aeb09bc commit e20c943
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Reuse connections in SQL module. {pull}16001[16001]
- Improve the `logstash` module (when `xpack.enabled` is set to `true`) to use the override `cluster_uuid` returned by Logstash APIs. {issue}15772[15772] {pull}15795[15795]
- Add kubernetes storage class support via kube-state-metrics. {pull}16145[16145]
- Add support for NATS 2.1. {pull}16317[16317]
- Add Load Balancing metricset to GCP {pull}15559[15559]

*Packetbeat*
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/docs/modules/nats.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The default metricsets are `stats`, `connections`, `routes` and `subscriptions`.
[float]
=== Compatibility

The Nats module is tested with Nats 1.3.0 and 2.0.4
The Nats module is tested with Nats 1.3.0, 2.0.4 and 2.1.4


[float]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ FROM nats:$NATS_VERSION
# create an enhanced container with nc command available since nats is based
# on scratch image making healthcheck impossible
FROM alpine:latest
COPY --from=0 /nats-server /nats-server
COPY --from=0 nats-server.conf nats-server.conf
COPY --from=0 / /opt/nats
COPY run.sh /run.sh
# Expose client, management, and cluster ports
EXPOSE 4222 8222 6222
HEALTHCHECK --interval=1s --retries=10 CMD nc -w 1 0.0.0.0 8222 </dev/null
# Run via the configuration file
ENTRYPOINT ["/nats-server"]
CMD ["-c", "nats-server.conf"]
CMD ["/run.sh"]
14 changes: 0 additions & 14 deletions metricbeat/module/nats/_meta/Dockerfile.1.3

This file was deleted.

2 changes: 1 addition & 1 deletion metricbeat/module/nats/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The default metricsets are `stats`, `connections`, `routes` and `subscriptions`.
[float]
=== Compatibility

The Nats module is tested with Nats 1.3.0 and 2.0.4
The Nats module is tested with Nats 1.3.0, 2.0.4 and 2.1.4


[float]
Expand Down
18 changes: 18 additions & 0 deletions metricbeat/module/nats/_meta/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# This script is used with old and new versions of nats,
# and they use different names for their binaries, detect
# which one is used and run it.

# NATS 2.X
if [ -x /opt/nats/nats-server ]; then
exec /opt/nats/nats-server -c /opt/nats/nats-server.conf
fi

# NATS 1.X
if [ -x /opt/nats/gnatsd ]; then
exec /opt/nats/gnatsd -c /opt/nats/gnatsd.conf
fi

echo "Couldn't find the nats server binary"
exit 1
4 changes: 4 additions & 0 deletions metricbeat/module/nats/_meta/supported-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variants:
- NATS_VERSION: 2.1.4
- NATS_VERSION: 2.0.4
- NATS_VERSION: 1.3.0
13 changes: 1 addition & 12 deletions metricbeat/module/nats/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,8 @@ services:
image: docker.elastic.co/integrations-ci/beats-nats:${NATS_VERSION:-2.0.4}-1
build:
context: ./_meta
dockerfile: Dockerfile.2.0.X
dockerfile: Dockerfile
args:
NATS_VERSION: ${NATS_VERSION:-2.0.4}
ports:
- 8222

nats_1_3:
image: docker.elastic.co/integrations-ci/beats-nats:${NATS_VERSION:-1.3.0}-1
build:
context: ./_meta
dockerfile: Dockerfile.1.3
args:
NATS_VERSION: ${NATS_VERSION:-1.3.0}
ports:
- 8222

6 changes: 1 addition & 5 deletions metricbeat/module/nats/test_nats.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
NATS_FIELDS = metricbeat.COMMON_FIELDS + ["nats"]


@metricbeat.parameterized_with_supported_versions
class TestNats(metricbeat.BaseTest):

COMPOSE_SERVICES = ['nats']

@unittest.skipUnless(metricbeat.INTEGRATION_TESTS, "integration test")
Expand Down Expand Up @@ -112,7 +112,3 @@ def test_subscriptions(self):
self.assertCountEqual(self.de_dot(NATS_FIELDS), evt.keys(), evt)

self.assert_fields_are_documented(evt)


class TestNats1_3(TestNats):
COMPOSE_SERVICES = ['nats_1_3']

0 comments on commit e20c943

Please sign in to comment.