Skip to content

Commit 9d19298

Browse files
committed
Add cluster tests
1 parent d8bdf7f commit 9d19298

File tree

10 files changed

+155
-1
lines changed

10 files changed

+155
-1
lines changed

Diff for: .github/workflows/test-pr.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@ jobs:
3333
-Dclient.key=./tls-gen/basic/result/client_$(hostname)_key.pem
3434
- name: Test (dynamic-batch publishing)
3535
run: |
36-
./mvnw verify -Drabbitmqctl.bin=DOCKER:rabbitmq \
36+
./mvnw test -Drabbitmqctl.bin=DOCKER:rabbitmq \
3737
-Drabbitmq.stream.producer.dynamic.batch=true \
3838
-Dca.certificate=./tls-gen/basic/result/ca_certificate.pem \
3939
-Dclient.certificate=./tls-gen/basic/result/client_$(hostname)_certificate.pem \
4040
-Dclient.key=./tls-gen/basic/result/client_$(hostname)_key.pem
4141
- name: Stop broker
4242
run: docker stop rabbitmq && docker rm rabbitmq
43+
- name: Start cluster
44+
run: ci/start-cluster.sh
45+
- name: Test against cluster
46+
run: ./mvnw test -Dtest="*ClusterTest" -Drabbitmqctl.bin=DOCKER:rabbitmq0
47+
- name: Stop cluster
48+
run: docker compose --file ci/cluster/docker-compose.yml down

Diff for: ci/cluster/configuration-0/enabled_plugins

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[rabbitmq_stream_management].

Diff for: ci/cluster/configuration-0/rabbitmq.conf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
2+
cluster_formation.classic_config.nodes.1 = rabbit@node0
3+
cluster_formation.classic_config.nodes.2 = rabbit@node1
4+
cluster_formation.classic_config.nodes.3 = rabbit@node2
5+
loopback_users = none
6+
7+
stream.advertised_host = localhost
8+
stream.advertised_port = 5552

Diff for: ci/cluster/configuration-1/enabled_plugins

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[rabbitmq_stream_management].

Diff for: ci/cluster/configuration-1/rabbitmq.conf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
2+
cluster_formation.classic_config.nodes.1 = rabbit@node0
3+
cluster_formation.classic_config.nodes.2 = rabbit@node1
4+
cluster_formation.classic_config.nodes.3 = rabbit@node2
5+
loopback_users = none
6+
7+
stream.advertised_host = localhost
8+
stream.advertised_port = 5553

Diff for: ci/cluster/configuration-2/enabled_plugins

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[rabbitmq_stream_management].

Diff for: ci/cluster/configuration-2/rabbitmq.conf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
2+
cluster_formation.classic_config.nodes.1 = rabbit@node0
3+
cluster_formation.classic_config.nodes.2 = rabbit@node1
4+
cluster_formation.classic_config.nodes.3 = rabbit@node2
5+
loopback_users = none
6+
7+
stream.advertised_host = localhost
8+
stream.advertised_port = 5554

Diff for: ci/cluster/docker-compose.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
services:
2+
node0:
3+
environment:
4+
- RABBITMQ_ERLANG_COOKIE='secret_cookie'
5+
networks:
6+
- rabbitmq-cluster
7+
hostname: node0
8+
container_name: rabbitmq0
9+
image: ${RABBITMQ_IMAGE:-rabbitmq:4.0}
10+
pull_policy: always
11+
ports:
12+
- "5672:5672"
13+
- "5552:5552"
14+
- "15672:15672"
15+
tty: true
16+
volumes:
17+
- ./configuration-0/:/etc/rabbitmq/
18+
node1:
19+
environment:
20+
- RABBITMQ_ERLANG_COOKIE='secret_cookie'
21+
networks:
22+
- rabbitmq-cluster
23+
hostname: node1
24+
container_name: rabbitmq1
25+
image: ${RABBITMQ_IMAGE:-rabbitmq:4.0}
26+
pull_policy: always
27+
ports:
28+
- "5673:5672"
29+
- "5553:5552"
30+
- "15673:15672"
31+
tty: true
32+
volumes:
33+
- ./configuration-1/:/etc/rabbitmq/
34+
node2:
35+
environment:
36+
- RABBITMQ_ERLANG_COOKIE='secret_cookie'
37+
networks:
38+
- rabbitmq-cluster
39+
hostname: node2
40+
container_name: rabbitmq2
41+
image: ${RABBITMQ_IMAGE:-rabbitmq:4.0}
42+
pull_policy: always
43+
ports:
44+
- "5674:5672"
45+
- "5554:5552"
46+
- "15674:15672"
47+
tty: true
48+
volumes:
49+
- ./configuration-2/:/etc/rabbitmq/
50+
load-balander:
51+
networks:
52+
- rabbitmq-cluster
53+
hostname: load-balancer
54+
container_name: haproxy
55+
image: haproxy:3.0
56+
pull_policy: always
57+
ports:
58+
- "5555:5555"
59+
- "8100:8100"
60+
tty: true
61+
volumes:
62+
- ./load-balancer/:/usr/local/etc/haproxy:ro
63+
networks:
64+
rabbitmq-cluster:

Diff for: ci/cluster/load-balancer/haproxy.cfg

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
global
2+
log 127.0.0.1 local0 info
3+
maxconn 512
4+
5+
defaults
6+
log global
7+
mode tcp
8+
option tcplog
9+
option dontlognull
10+
retries 3
11+
option redispatch
12+
maxconn 512
13+
timeout connect 5s
14+
timeout client 120s
15+
timeout server 120s
16+
17+
listen stream
18+
bind :5555
19+
mode tcp
20+
balance roundrobin
21+
server rabbitmq-0 node0:5552
22+
server rabbitmq-1 node1:5552
23+
server rabbitmq-2 node2:5552
24+
25+
listen stats
26+
bind :8100
27+
mode http
28+
option httplog
29+
stats enable
30+
stats uri /stats
31+
stats refresh 5s

Diff for: ci/start-cluster.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
export RABBITMQ_IMAGE=${RABBITMQ_IMAGE:-rabbitmq:4.0}
4+
5+
wait_for_message() {
6+
while ! docker logs "$1" | grep -q "$2";
7+
do
8+
sleep 2
9+
echo "Waiting 2 seconds for $1 to start..."
10+
done
11+
}
12+
13+
docker compose --file ci/cluster/docker-compose.yml down
14+
docker compose --file ci/cluster/docker-compose.yml up --detach
15+
16+
wait_for_message rabbitmq0 "completed with"
17+
18+
docker exec rabbitmq0 rabbitmqctl await_online_nodes 3
19+
20+
docker exec rabbitmq0 rabbitmqctl enable_feature_flag --opt-in khepri_db
21+
docker exec rabbitmq1 rabbitmqctl enable_feature_flag --opt-in khepri_db
22+
docker exec rabbitmq2 rabbitmqctl enable_feature_flag --opt-in khepri_db
23+
24+
docker exec rabbitmq0 rabbitmqctl cluster_status
25+
26+
docker compose --file ci/cluster/docker-compose.yml ps

0 commit comments

Comments
 (0)