Skip to content

Commit

Permalink
Enable Leak Detection in CI Pipeline (#242)
Browse files Browse the repository at this point in the history
Motivation:
Address lack of ByteBuffer leak detection during development to prevent
potential production issues.

Modifications:
Added leak detection feature to CI pipeline for automatic detection
during testing.

Result:
Better CI
Resolves #241

---------

Signed-off-by: jchrys <jchrys@me.com>
  • Loading branch information
jchrys authored Feb 22, 2024
1 parent 98741f2 commit 068c0e3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
30 changes: 30 additions & 0 deletions .github/scripts/ensure_no_leak.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#
# Copyright 2024 asyncer.io projects
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e

if [ "$#" -ne 1 ] || [ "${1##*.}" != "log" ]; then
echo "Please provide a single log file with a .log extension."
exit 1
fi

if grep -q 'LEAK' "$1" ; then
echo "LEAK FOUND: The log file $1 contains a memory leak."
exit 1
fi

echo "No Leak: The log file $1 does not contain any memory leaks."
exit 0
7 changes: 6 additions & 1 deletion .github/workflows/ci-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ jobs:
-Dmaven.surefire.skip=true \
-Dtest.mysql.password=r2dbc-password!@ \
-Dtest.mysql.version=${{ matrix.mysql-version }} \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN \
-Dio.netty.leakDetectionLevel=paranoid \
-Dio.netty.leakDetection.targetRecords=32 \
| tee test.log
- name: ensure no leaks
run: ./.github/scripts/ensure_no_leak.sh test.log
8 changes: 7 additions & 1 deletion .github/workflows/ci-mariadb-intergration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ jobs:
-Dtest.mysql.password=r2dbc-password!@ \
-Dtest.mysql.version=${{ matrix.mariadb-version }} \
-Dtest.db.type=mariadb \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN \
-Dio.netty.leakDetectionLevel=paranoid \
-Dio.netty.leakDetection.targetRecords=32 \
| tee test.log
- name: ensure no leaks
run: ./.github/scripts/ensure_no_leak.sh test.log
8 changes: 7 additions & 1 deletion .github/workflows/ci-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ jobs:
java-version: ${{ matrix.java-version }}
cache: maven
- name: Unit test with Maven
run: ./mvnw -B test -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN
run: |
./mvnw -B test -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN \
-Dio.netty.leakDetectionLevel=paranoid \
-Dio.netty.leakDetection.targetRecords=32 \
| tee test.log
- name: ensure no leaks
run: ./.github/scripts/ensure_no_leak.sh test.log
1 change: 1 addition & 0 deletions r2dbc-mysql/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<logger name="org.testcontainers" level="INFO"/>
<logger name="reactor.netty" level="INFO"/>
<logger name="com.zaxxer.hikari" level="WARN"/>
<logger name="io.netty" level="WARN"/>

<root level="INFO">
<appender-ref ref="STDOUT"/>
Expand Down

0 comments on commit 068c0e3

Please sign in to comment.