Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #16317 to 7.x: Add supported versions to nats tests #16379

Merged
merged 1 commit into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add collecting AuroraDB metrics in rds metricset. {issue}14142[14142] {pull}16004[16004]
- 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 support for NATS 2.1. {pull}16317[16317]

*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']