-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump sdk to last version and Integration tests added (#129)
- integration tests covering bootstrap and zookeeper - Add new SDK 3.6.8 and get the JMX Host and Port when a query fails
- Loading branch information
1 parent
460eb62
commit 45b6885
Showing
16 changed files
with
20,432 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM golang:1.16 as builder | ||
ARG CGO_ENABLED=0 | ||
ARG NRJMX_VERSION | ||
WORKDIR /go/src/github.com/newrelic/nri-kafka | ||
COPY . . | ||
RUN make clean compile | ||
WORKDIR / | ||
ADD http://download.newrelic.com/infrastructure_agent/binaries/linux/noarch/nrjmx_linux_${NRJMX_VERSION}_noarch.tar.gz ./ | ||
RUN tar -xzf nrjmx_linux_${NRJMX_VERSION}_noarch.tar.gz | ||
|
||
FROM alpine:latest | ||
RUN apk --update add openjdk8-jre | ||
COPY --from=builder /usr/bin/nrjmx /usr/bin/nrjmx | ||
COPY --from=builder /usr/bin/nrjmx.jar /usr/bin/nrjmx.jar | ||
COPY --from=builder /usr/bin/jmxterm.jar /usr/bin/jmxterm.jar | ||
COPY --from=builder /go/src/github.com/newrelic/nri-kafka/bin / | ||
CMD ["sleep", "1h"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
version: '2' | ||
services: | ||
zookeeper: | ||
image: wurstmeister/zookeeper | ||
ports: | ||
- "2181:2181" | ||
networks: | ||
- kfk | ||
|
||
kafka1: | ||
image: wurstmeister/kafka | ||
ports: | ||
- "19092:9092" | ||
- "1099" | ||
environment: | ||
KAFKA_ADVERTISED_HOST_NAME: kafka1 | ||
KAFKA_ADVERTISED_PORT: 9092 | ||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 | ||
KAFKA_LOG_DIRS: /kafka/logs | ||
KAFKA_BROKER_ID: 500 | ||
KAFKA_offsets_topic_replication_factor: 3 | ||
KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka1 -Dcom.sun.management.jmxremote.rmi.port=1099" | ||
JMX_PORT: 1099 | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
networks: | ||
- kfk | ||
|
||
kafka2: | ||
image: wurstmeister/kafka | ||
ports: | ||
- "9092" | ||
- "1099" | ||
environment: | ||
KAFKA_ADVERTISED_HOST_NAME: kafka2 | ||
KAFKA_ADVERTISED_PORT: 9092 | ||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 | ||
KAFKA_LOG_DIRS: /kafka/logs | ||
KAFKA_BROKER_ID: 501 | ||
KAFKA_offsets_topic_replication_factor: 3 | ||
KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka2 -Dcom.sun.management.jmxremote.rmi.port=1099" | ||
JMX_PORT: 1099 | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
networks: | ||
- kfk | ||
|
||
kafka3: | ||
image: wurstmeister/kafka | ||
ports: | ||
- "9092" | ||
- "1099" | ||
environment: | ||
KAFKA_ADVERTISED_HOST_NAME: kafka3 | ||
KAFKA_ADVERTISED_PORT: 9092 | ||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 | ||
KAFKA_LOG_DIRS: /kafka/logs | ||
KAFKA_BROKER_ID: 502 | ||
KAFKA_offsets_topic_replication_factor: 3 | ||
KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka3 -Dcom.sun.management.jmxremote.rmi.port=1099" | ||
JMX_PORT: 1099 | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
networks: | ||
- kfk | ||
|
||
nri-kafka: | ||
container_name: integration_nri_kafka_1 | ||
build: | ||
context: ../../ | ||
dockerfile: tests/integration/Dockerfile | ||
args: | ||
- NRJMX_VERSION=${NRJMX_VERSION} | ||
dns: | ||
- 8.8.8.8 | ||
networks: | ||
- kfk | ||
|
||
networks: | ||
kfk: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package helpers | ||
|
||
import ( | ||
"bytes" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/newrelic/infra-integrations-sdk/log" | ||
) | ||
|
||
const cmdMinLength = 3 | ||
|
||
// ExecInContainer executes the given command inside the specified container. It returns three values: | ||
// 1st - Standard Output | ||
// 2nd - Standard Error | ||
// 3rd - Runtime error, if any | ||
func ExecInContainer(container string, command []string) (string, string, error) { | ||
cmdLine := make([]string, 0, cmdMinLength+len(command)) | ||
cmdLine = append(cmdLine, "exec", "-i") | ||
cmdLine = append(cmdLine, container) | ||
cmdLine = append(cmdLine, command...) | ||
|
||
log.Debug("executing: docker %s", strings.Join(cmdLine, " ")) | ||
|
||
cmd := exec.Command("docker", cmdLine...) | ||
|
||
var outbuf, errbuf bytes.Buffer | ||
cmd.Stdout = &outbuf | ||
cmd.Stderr = &errbuf | ||
|
||
err := cmd.Run() | ||
stdout := outbuf.String() | ||
stderr := errbuf.String() | ||
|
||
return stdout, stderr, err | ||
} |
Oops, something went wrong.