From e0737219b37c8a1c6339b49fb92005f2e6d184f7 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 4 Sep 2024 11:47:59 -0700 Subject: [PATCH] [CLIENT-2239] CI/CD: Use massif to get Python client memory usage over time while running integration tests (#664) - CI/CD: Removed pytest-memray test, since it's not used for CI/CD regression testing; only for debugging. I rarely check the results of this test on Github Actions and I can just run it locally when I need to debug the memory usage of the Python client code. --- .github/workflows/tests.yml | 43 ---------------------------------- .github/workflows/valgrind.yml | 20 +++++++++++++++- test/requirements.txt | 2 -- 3 files changed, 19 insertions(+), 46 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5aa87602d..c8bb7801a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -75,49 +75,6 @@ jobs: name: wheel-${{ matrix.py-version }} path: ./dist/*.whl - test-memray: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-python@v2 - with: - python-version: "3.8" - architecture: 'x64' - - - uses: actions/download-artifact@v3 - with: - name: wheel-3.8 - - - name: Install client - run: pip install *.whl - - - name: Install test dependencies - run: pip install -r test/requirements.txt - - - name: Run Aerospike server - run: docker run -d --name aerospike -p 3000-3002:3000-3002 aerospike/aerospike-server - - - name: Create config.conf - run: cp config.conf.template config.conf - working-directory: test - - - uses: ./.github/actions/wait-for-as-server-to-start - with: - container-name: aerospike - - - name: Get number of tests - run: echo "NUM_TESTS=$(python3 -m pytest new_tests/ --collect-only -q | tail -n 1 | awk '{print $1;}')" >> $GITHUB_ENV - working-directory: test - - - name: Run tests - # Get number of tests since setting to 0 doesn't work properly - # pytest-memray currently throws a ZeroDivision error due to having a bug - # We ignore this for now - run: python -m pytest ./new_tests --memray --memray-bin-path=./ --most-allocations=${{ env.NUM_TESTS }} || true - working-directory: test - generate-coverage-report: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index f79dea4a3..15de27cee 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -12,6 +12,11 @@ on: description: 'Use server release candidate?' required: true default: false + massif: + type: boolean + description: 'Use massif for testing memory usage' + required: false + default: false jobs: build-manylinux-wheel: @@ -23,6 +28,8 @@ jobs: secrets: inherit valgrind: + env: + MASSIF_REPORT_FILE_NAME: massif.out needs: build-manylinux-wheel runs-on: ubuntu-22.04 steps: @@ -55,5 +62,16 @@ jobs: - run: sudo apt update - run: sudo apt install valgrind -y - - run: PYTHONMALLOC=malloc valgrind --leak-check=full --error-exitcode=1 python3 -m pytest -v new_tests/${{ github.event.inputs.test-file }} + + - run: echo VALGRIND_ARGS="--tool=massif --massif-out-file=./${{ env.MASSIF_REPORT_FILE_NAME }}" >> $GITHUB_ENV + if: ${{ inputs.massif }} + + - run: echo VALGRIND_ARGS="--leak-check=full" >> $GITHUB_ENV + if: ${{ !inputs.massif }} + + - run: PYTHONMALLOC=malloc valgrind --error-exitcode=1 ${{ env.VALGRIND_ARGS }} python3 -m pytest -v new_tests/${{ github.event.inputs.test-file }} + working-directory: test + + - run: ms_print ./${{ env.MASSIF_REPORT_FILE_NAME }} + if: ${{ !cancelled() && inputs.massif }} working-directory: test diff --git a/test/requirements.txt b/test/requirements.txt index 7e1acd0ec..e9043f2e7 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -1,5 +1,3 @@ pytest==7.4.0 # To generate coverage reports in the Github Actions pipeline pytest-cov==4.1.0 -# Memory profiling -pytest-memray==1.5.0