Skip to content

Commit

Permalink
Collect core dumps
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitrii Petukhov <[email protected]>
  • Loading branch information
bbpetukhov committed Dec 6, 2024
1 parent e468717 commit 4a21edb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Tests
on:
push:
branches:
- main
- '**'
pull_request:
branches:
- main
Expand Down Expand Up @@ -81,17 +81,35 @@ jobs:
working-directory: bmq-sdk/src/test/docker
run: docker build --tag bmq-broker-java-it --build-arg "image=bmqbrkr:latest" .

- name: Setup Core Dumps config
run: |
sudo mkdir /tmp/cores
sudo chmod 777 /tmp/cores
echo "/tmp/cores/%e.%p.%s.%t" | sudo tee /proc/sys/kernel/core_pattern
- name: Build and run integration tests with Maven
timeout-minutes: 120
run: mvn --batch-mode -DskipUnitTests=true -Dspotbugs.skip=true -Dit.dockerImage=bmqbrkr:latest verify
run: |
# Allow core dumps
ulimit -c unlimited
mvn --batch-mode -DskipUnitTests=true -Dspotbugs.skip=true -Dit.dockerImage=bmqbrkr:latest verify
- name: Upload broker core dump as artifacts
# if: failure()
uses: actions/upload-artifact@v4
with:
name: core_dumps
path: /cores
retention-days: 5

- name: Compress collected broker logs
if: failure()
# if: failure()
working-directory: /tmp/bmq-broker
run: tar -zcvf broker_logs.tar.gz /tmp/bmq-broker/bmq-broker-java-it*

- name: Upload broker logs as artifacts
if: failure()
# if: failure()
uses: actions/upload-artifact@v3
with:
name: broker_logs_${{ matrix.java }}
Expand Down
2 changes: 2 additions & 0 deletions bmq-sdk/src/test/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ FROM ${image}

ENV BMQ_DOCKER_TMPDIR=/tmp/bmq-broker

RUN mkdir -p /tmp/cores

COPY config/ /etc/local/bmq/

EXPOSE 30114
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class BmqBrokerContainer implements BmqBroker {
private static final Logger logger =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final String CONTAINER_TMP_LOGS = "/tmp/logs";
private static final String CONTAINER_CORES = "/tmp/cores";
private static final String IMAGE_NAME = "bmq-broker-java-it";
private static final String OUTPUT_FILENAME = "output.log";

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

final Path tmpDir = makeTempDir(name);
final Path logsPath = tmpDir.resolve("logs");
final Path hostLogsPath = tmpDir.resolve("logs");
final Path hostCoresPath = Paths.get("/tmp/cores");

logger.info("Use '{}' directory for broker logs", logsPath);
logger.info("Use '{}' directory for broker logs", hostLogsPath);
logger.info("Use '{}' directory for broker cores", hostCoresPath);

final PortBinding portBinding =
PortBinding.parse(opts.brokerUri().getPort() + ":" + BROKER_DEFAULT_PORT);
Expand All @@ -97,7 +100,8 @@ public static BmqBrokerContainer createContainer(int port) throws IOException {
final HostConfig hostConfig =
new HostConfig()
.withPortBindings(portBinding)
.withBinds(Bind.parse(logsPath + ":" + CONTAINER_TMP_LOGS));
.withBinds(Bind.parse(hostLogsPath + ":" + CONTAINER_TMP_LOGS))
.withBinds(Bind.parse(hostCoresPath + ":" + CONTAINER_CORES));

final String id =
client.createContainerCmd(IMAGE_NAME)
Expand Down

0 comments on commit 4a21edb

Please sign in to comment.