Skip to content

Commit d5c3c81

Browse files
committed
Use GitHub Actions for CI
1 parent ee1ed69 commit d5c3c81

File tree

4 files changed

+69
-59
lines changed

4 files changed

+69
-59
lines changed

.github/workflows/test-linux.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build (Linux)
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-18.04
14+
15+
services:
16+
rabbitmq:
17+
image: rabbitmq:3.8
18+
ports:
19+
- 5672:5672
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Set up JDK 1.8
25+
uses: actions/setup-java@v1
26+
with:
27+
java-version: 1.8
28+
29+
- name: Test
30+
run: ./mvnw check -Drabbitmqctl.bin=DOCKER:${{job.services.rabbitmq.id}}

.travis.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## RabbitMQ Performance Testing Tool
22

3-
[![Travis CI](https://travis-ci.org/rabbitmq/rabbitmq-jms-client.svg?branch=master)](https://travis-ci.org/rabbitmq/rabbitmq-perf-test)
3+
[![Build Status](https://github.com/rabbitmq/rabbitmq-perf-test/workflows/Build%20(Linux)/badge.svg?branch=master)](https://github.com/rabbitmq/rabbitmq-perf-test/actions?query=workflow%3A%22Build+%28Linux%29%22+branch%3Amaster)
44

55
This repository contains source code of the RabbitMQ Performance Testing Tool.
66
The client is maintained by the [RabbitMQ team at VMware](https://github.com/rabbitmq/).
@@ -56,17 +56,36 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for an overview of the development proc
5656
To build the JAR file:
5757

5858
```
59-
./mvnw clean package
59+
./mvnw clean package -Dmaven.test.skip
6060
```
6161

6262
Files are then in the `target` directory.
6363

6464
To build the JAR file, source and binary distributions:
6565

6666
```
67-
./mvnw clean package -P assemblies -Dgpg.skip=true
67+
./mvnw clean package -P assemblies -Dgpg.skip=true -Dmaven.test.skip
6868
```
6969

70+
### Running tests
71+
72+
The test suite needs to execute `rabbitmqctl` to test connection recovery. You
73+
can specify the path to `rabbitmqctl` like the following:
74+
75+
./mvnw clean verify -Drabbitmqctl.bin=/path/to/rabbitmqctl
76+
77+
You need a local running RabbitMQ instance.
78+
79+
### Running tests with Docker
80+
81+
Start a RabbitMQ container:
82+
83+
docker run -it --rm --name rabbitmq -p 5672:5672 rabbitmq:3.8
84+
85+
Run the test suite:
86+
87+
./mvnw clean verify -Drabbitmqctl.bin=DOCKER:rabbitmq
88+
7089
Files are then in the `target` directory.
7190

7291
## Maven Artifact

src/test/java/com/rabbitmq/perf/it/Host.java

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
package com.rabbitmq.perf.it;
1717

18-
import com.rabbitmq.client.impl.NetworkConnection;
19-
2018
import java.io.BufferedReader;
2119
import java.io.IOException;
2220
import java.io.InputStream;
@@ -96,10 +94,21 @@ public static void startBrokerApp() throws IOException {
9694
}
9795

9896
public static String rabbitmqctlCommand() {
99-
return System.getProperty("rabbitmqctl.bin");
97+
String rabbitmqCtl = System.getProperty("rabbitmqctl.bin");
98+
if (rabbitmqCtl == null) {
99+
throw new IllegalStateException("Please define the rabbitmqctl.bin system property");
100+
}
101+
if (rabbitmqCtl.startsWith("DOCKER:")) {
102+
String containerId = rabbitmqCtl.split(":")[1];
103+
return "docker exec " + containerId + " rabbitmqctl";
104+
} else if ("sudo_rabbitmqctl".equals(rabbitmqCtl)) {
105+
return "sudo rabbitmqctl";
106+
} else {
107+
return rabbitmqCtl;
108+
}
100109
}
101110

102-
public static void closeConnection(String pid) throws IOException {
111+
private static void closeConnection(String pid) throws IOException {
103112
rabbitmqctl("close_connection '" + pid + "' 'Closed via rabbitmqctl'");
104113
}
105114

@@ -109,24 +118,21 @@ public static void closeAllConnections(List<ConnectionInfo> connectionInfos) thr
109118
}
110119
}
111120

112-
public static void closeAllConnections() throws IOException {
113-
closeAllConnections(listConnections());
114-
}
115-
116121
public static List<ConnectionInfo> listConnections() throws IOException {
117122
String output = capture(rabbitmqctl("list_connections -q pid peer_port").getInputStream());
118123
// output (header line presence depends on broker version):
119124
// pid peer_port
120125
// <[email protected]> 58713
121126
String[] allLines = output.split("\n");
122127

123-
List<ConnectionInfo> result = new ArrayList<ConnectionInfo>();
128+
List<ConnectionInfo> result = new ArrayList<>();
124129
for (String line : allLines) {
125130
// line: <[email protected]> 58713
126131
String[] columns = line.split("\t");
127132
// can be also header line, so ignoring NumberFormatException
128133
try {
129-
result.add(new ConnectionInfo(columns[0], Integer.valueOf(columns[1])));
134+
Integer.valueOf(columns[1]);
135+
result.add(new ConnectionInfo(columns[0]));
130136
} catch (NumberFormatException e) {
131137
// OK
132138
}
@@ -160,33 +166,17 @@ public static List<String> listQueues() throws IOException {
160166
.collect(Collectors.toList());
161167
}
162168

163-
private static Host.ConnectionInfo findConnectionInfoFor(List<ConnectionInfo> xs, NetworkConnection c) {
164-
Host.ConnectionInfo result = null;
165-
for (Host.ConnectionInfo ci : xs) {
166-
if (c.getLocalPort() == ci.getPeerPort()) {
167-
result = ci;
168-
break;
169-
}
170-
}
171-
return result;
172-
}
173-
174169
public static class ConnectionInfo {
175170

176171
private final String pid;
177-
private final int peerPort;
178172

179-
public ConnectionInfo(String pid, int peerPort) {
173+
public ConnectionInfo(String pid) {
180174
this.pid = pid;
181-
this.peerPort = peerPort;
182175
}
183176

184177
public String getPid() {
185178
return pid;
186179
}
187180

188-
public int getPeerPort() {
189-
return peerPort;
190-
}
191181
}
192182
}

0 commit comments

Comments
 (0)