From fba78e8982a1f6753d2d0578e030039d33070401 Mon Sep 17 00:00:00 2001 From: Sven Anderson Date: Thu, 9 Nov 2023 15:20:48 +0100 Subject: [PATCH] CI: enable and collect core dumps in tests Signed-off-by: Sven Anderson --- .github/workflows/main.yml | 5 +++++ entrypoint.sh | 15 ++++++++++++++- testing/containers/ceph/Dockerfile | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 46d2bf0..bbf828f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,11 +76,15 @@ jobs: go_version: ${{ needs.go-versions.outputs.unstable }} steps: - uses: actions/checkout@v4 + - name: Set cores to get stored as "core" + run: sudo bash -c 'echo "core" > /proc/sys/kernel/core_pattern' - name: Run tests run: make test-containers-test "CEPH_VERSION=${{ matrix.ceph_version }}" "GO_VERSION=${{ matrix.go_version }}" "RESULTS_DIR=$PWD/_results" - name: Clean up test containers + if: always() run: make test-containers-clean "CEPH_VERSION=${{ matrix.ceph_version }}" - name: Archive test results + if: always() uses: actions/upload-artifact@v3 with: name: "go-ceph-results-${{ matrix.ceph_version }}-${{ matrix.go_version }}" @@ -88,6 +92,7 @@ jobs: _results/ retention-days: 30 - name: Check API Versions and Aging + if: always() run: | if [ -f _results/implements.json ]; then ./contrib/apiage.py diff --git a/entrypoint.sh b/entrypoint.sh index 0f0aad8..c6d1741 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -257,8 +257,21 @@ test_pkg() { testargs+=("-memprofile" "${pkg}.mem.out") fi - show go test -v "${testargs[@]}" "./${pkg}" + ulimit -c unlimited + testbin="./${pkg}/${pkg##*/}.test" + show go test -v "${testargs[@]}" -o "${testbin}" "./${pkg}" ret=$(($?+ret)) + if ls "${pkg}"/core.* >/dev/null 2>&1; then + echo "Found coredump" + sleep 5 + coredump="./${pkg}/${pkg##*/}.core" + mv "${pkg}"/core.* "${coredump}" + chmod 644 "${coredump}" + echo "set auto-load safe-path /" >>/root/.gdbinit + gdb "${testbin}" "${coredump}" -ex bt -ex q | cat + mkdir -p "${RESULTS_DIR}" + mv "${testbin}" "${coredump}" "${RESULTS_DIR}/" + fi grep -v "^mode: count" "${pkg}.cover.out" >> "cover.out" return ${ret} } diff --git a/testing/containers/ceph/Dockerfile b/testing/containers/ceph/Dockerfile index c99c9d4..d6db6f2 100644 --- a/testing/containers/ceph/Dockerfile +++ b/testing/containers/ceph/Dockerfile @@ -16,7 +16,8 @@ RUN true && \ yum install -y \ git wget curl make \ /usr/bin/cc /usr/bin/c++ \ - "libcephfs-devel-${cv}" "librados-devel-${cv}" "librbd-devel-${cv}" && \ + "libcephfs-devel-${cv}" "librados-devel-${cv}" "librbd-devel-${cv}" \ + gdb libcephfs2-debuginfo librados2-debuginfo librbd1-debuginfo && \ yum clean all && \ true