Skip to content

Commit b3a6680

Browse files
authored
Merge pull request #119 from rabbitmq/rabbitmq-perf-test-118-docker-image
Create Docker image
2 parents ce25d95 + 1de2b9e commit b3a6680

File tree

3 files changed

+66
-10
lines changed

3 files changed

+66
-10
lines changed

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM openjdk:8u181-jre-alpine3.8
2+
3+
ARG perf_test_version
4+
ENV URL=https://github.com/rabbitmq/rabbitmq-perf-test/releases/download/v$perf_test_version/rabbitmq-perf-test-$perf_test_version-bin.tar.gz
5+
6+
RUN apk add --no-cache bash curl ca-certificates
7+
8+
# Fail fast if URL is invalid
9+
RUN curl --verbose --head --fail $URL 1>/dev/null
10+
11+
# Download into /perf_test & ensure that it works correctly
12+
RUN mkdir -p /perf_test && cd /perf_test && curl --location --silent --fail --output - $URL | tar x -z -v -f - --strip-components 1 && bin/runjava com.rabbitmq.perf.PerfTest --help
13+
WORKDIR /perf_test
14+
15+
ENTRYPOINT ["bin/runjava", "com.rabbitmq.perf.PerfTest"]

Makefile

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,71 @@
1-
.ONESHELL:# single shell invocation for all lines in the recipe
1+
SHELL := bash# we want bash behaviour in all shell invocations
22

33
.DEFAULT_GOAL = help
44

55
### VARIABLES ###
66
#
7-
export PATH :=$(CURDIR):$(CURDIR)/scripts:$(PATH)
8-
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
9-
HARDWARE := $(shell uname -m | tr '[:upper:]' '[:lower:]')
10-
GPG_KEYNAME := $(shell cat pom.xml | grep -oPm1 "(?<=<gpg.keyname>)[^<]+")
7+
export PATH := $(CURDIR):$(CURDIR)/scripts:$(PATH)
8+
9+
OS := $$(uname -s | tr '[:upper:]' '[:lower:]')
10+
HARDWARE := $$(uname -m | tr '[:upper:]' '[:lower:]')
11+
12+
GPG_KEYNAME := $$(awk -F'[<>]' '/<gpg.keyname>/ { print $$3 }' pom.xml)
13+
14+
RELEASE_VERSION ?= 2.3.0
1115

1216
### TARGETS ###
1317
#
1418

19+
.PHONY: binary
1520
binary: clean ## Build the binary distribution
1621
@mvnw package -P assemblies -Dgpg.skip=true -Dmaven.test.skip
1722

23+
.PHONY: native-image
1824
native-image: clean ## Build the native image
1925
@mvnw -q package -DskipTests -P native-image -P '!java-packaging'
2026
native-image -jar target/perf-test.jar -H:Features="com.rabbitmq.perf.NativeImageFeature"
2127

28+
.PHONY: docker-image
29+
docker-image: ## Build Docker image
30+
@docker build \
31+
--tag pivotalrabbitmq/perf-test:$(RELEASE_VERSION) \
32+
--tag pivotalrabbitmq/perf-test:latest \
33+
--build-arg perf_test_version=$(RELEASE_VERSION) .
2234

35+
.PHONY: package-native-image
2336
package-native-image: native-image ## Package the native image
2437
cp perf-test target/perf-test_$(OS)_$(HARDWARE)
2538
@mvnw -q checksum:files -P native-image
2639
gpg --armor --local-user $(GPG_KEYNAME) --detach-sign target/perf-test_$(OS)_$(HARDWARE)
2740

41+
.PHONY: help
2842
help:
29-
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
43+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-24s\033[0m %s\n", $$1, $$2}'
3044

45+
.PHONY: clean
3146
clean: ## Clean all build artefacts
3247
@mvnw clean
3348

49+
.PHONY: compile
3450
compile: ## Compile the source code
3551
@mvnw compile
3652

53+
.PHONY: install
3754
install: clean ## Create and copy the binaries into the local Maven repository
3855
@mvnw install -Dmaven.test.skip
3956

57+
.PHONY: jar
4058
jar: clean ## Build the JAR file
4159
@mvnw package -Dmaven.test.skip
4260

61+
.PHONY: run
4362
run: compile ## Run PerfTest, pass exec arguments via ARGS, e.g. ARGS="-x 1 -y 1 -r 1"
4463
@mvnw exec:java -Dexec.mainClass="com.rabbitmq.perf.PerfTest" -Dexec.args="$(ARGS)"
4564

65+
.PHONY: signed-binary
4666
signed-binary: clean ## Build a GPG signed binary
4767
@mvnw package -P assemblies
4868

69+
.PHONY: doc
4970
doc: ## Generate PerfTest documentation
5071
@mvnw asciidoctor:process-asciidoc
51-
52-
.PHONY: binary help clean compile jar run signed-binary

src/docs/asciidoc/installation.adoc

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
== Installation
22

3-
=== From binary
3+
=== From Binary
44

55
PerfTest is distributed as a binary build archive
66
from https://github.com/rabbitmq/rabbitmq-perf-test/releases[GitHub releases] and
@@ -22,13 +22,35 @@ the `PerfTest` Java class.
2222

2323
To verify a PerfTest installation, use:
2424

25-
$ bin/runjava com.rabbitmq.perf.PerfTest --help
25+
bin/runjava com.rabbitmq.perf.PerfTest --help
2626

2727
=== From Native Executable
2828

2929
PerfTest is also distributed as a native executable binary. This is an experimental
3030
feature, see the link:#native-executable[dedicated section] for more information.
3131

32+
=== From Docker Image
33+
34+
PerfTest has a https://hub.docker.com/r/pivotalrabbitmq/perf-test/[Docker image] as well.
35+
To use it:
36+
37+
docker run -it --rm pivotalrabbitmq/perf-test:latest --help
38+
39+
Note that the Docker container needs to be able to connect to the host where
40+
the RabbitMQ broker runs. Find out more at
41+
https://docs.docker.com/network/[Docker network documentation]. Once the
42+
Docker container where PerfTest runs can connect to the RabbitMQ broker,
43+
PerfTest can be run with the regular options, e.g.:
44+
45+
docker run -it --rm pivotalrabbitmq/perf-test:latest -x 1 -y 2 -u "throughput-test-1" -a --id "test 1"
46+
47+
To run the RabbitMQ broker within Docker, and run PerfTest against it, run the
48+
following commands:
49+
50+
docker network create perf-test
51+
docker run -it --rm --network perf-test --name rabbitmq -p 15672:15672 rabbitmq:3.7.8-management
52+
docker run -it --rm --network perf-test pivotalrabbitmq/perf-test:latest --uri amqp://rabbitmq
53+
3254
=== For Cloud Foundry
3355

3456
There is a https://github.com/rabbitmq/rabbitmq-perf-test-for-cf[template project]

0 commit comments

Comments
 (0)