Skip to content

Commit edb4e28

Browse files
committed
Collect core dumps
Signed-off-by: Dmitrii Petukhov <[email protected]>
1 parent e468717 commit edb4e28

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

.github/workflows/build.yaml

+22-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Tests
33
on:
44
push:
55
branches:
6-
- main
6+
- '**'
77
pull_request:
88
branches:
99
- main
@@ -81,17 +81,35 @@ jobs:
8181
working-directory: bmq-sdk/src/test/docker
8282
run: docker build --tag bmq-broker-java-it --build-arg "image=bmqbrkr:latest" .
8383

84+
- name: Setup Core Dumps config
85+
run: |
86+
sudo mkdir /tmp/cores
87+
sudo chmod 777 /tmp/cores
88+
echo "/tmp/cores/%e.%p.%s.%t" | sudo tee /proc/sys/kernel/core_pattern
89+
8490
- name: Build and run integration tests with Maven
8591
timeout-minutes: 120
86-
run: mvn --batch-mode -DskipUnitTests=true -Dspotbugs.skip=true -Dit.dockerImage=bmqbrkr:latest verify
92+
run: |
93+
# Allow core dumps
94+
ulimit -c unlimited
95+
96+
mvn --batch-mode -DskipUnitTests=true -Dspotbugs.skip=true -Dit.dockerImage=bmqbrkr:latest verify
97+
98+
- name: Upload broker core dump as artifacts
99+
# if: failure()
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: core_dumps
103+
path: /cores
104+
retention-days: 5
87105

88106
- name: Compress collected broker logs
89-
if: failure()
107+
# if: failure()
90108
working-directory: /tmp/bmq-broker
91109
run: tar -zcvf broker_logs.tar.gz /tmp/bmq-broker/bmq-broker-java-it*
92110

93111
- name: Upload broker logs as artifacts
94-
if: failure()
112+
# if: failure()
95113
uses: actions/upload-artifact@v3
96114
with:
97115
name: broker_logs_${{ matrix.java }}

bmq-sdk/src/test/docker/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ FROM ${image}
33

44
ENV BMQ_DOCKER_TMPDIR=/tmp/bmq-broker
55

6+
RUN mkdir -p /tmp/cores
7+
68
COPY config/ /etc/local/bmq/
79

810
EXPOSE 30114

bmq-sdk/src/test/java/com/bloomberg/bmq/it/util/BmqBrokerContainer.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class BmqBrokerContainer implements BmqBroker {
4848
private static final Logger logger =
4949
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
5050
private static final String CONTAINER_TMP_LOGS = "/tmp/logs";
51+
private static final String CONTAINER_CORES = "/tmp/cores";
5152
private static final String IMAGE_NAME = "bmq-broker-java-it";
5253
private static final String OUTPUT_FILENAME = "output.log";
5354

@@ -86,9 +87,11 @@ public static BmqBrokerContainer createContainer(int port) throws IOException {
8687
logger.info("Create '{}' container", name);
8788

8889
final Path tmpDir = makeTempDir(name);
89-
final Path logsPath = tmpDir.resolve("logs");
90+
final Path hostLogsPath = tmpDir.resolve("logs");
91+
final Path hostCoresPath = Paths.get("/tmp/cores");
9092

91-
logger.info("Use '{}' directory for broker logs", logsPath);
93+
logger.info("Use '{}' directory for broker logs", hostLogsPath);
94+
logger.info("Use '{}' directory for broker cores", hostCoresPath);
9295

9396
final PortBinding portBinding =
9497
PortBinding.parse(opts.brokerUri().getPort() + ":" + BROKER_DEFAULT_PORT);
@@ -97,7 +100,8 @@ public static BmqBrokerContainer createContainer(int port) throws IOException {
97100
final HostConfig hostConfig =
98101
new HostConfig()
99102
.withPortBindings(portBinding)
100-
.withBinds(Bind.parse(logsPath + ":" + CONTAINER_TMP_LOGS));
103+
.withBinds(Bind.parse(hostlogsPath + ":" + CONTAINER_TMP_LOGS))
104+
.withBinds(Bind.parse(hostCoresPath + ":" + CONTAINER_CORES));
101105

102106
final String id =
103107
client.createContainerCmd(IMAGE_NAME)

0 commit comments

Comments
 (0)