Skip to content

Commit

Permalink
[CLIENT-2239] CI/CD: Run memory profiler test (#513)
Browse files Browse the repository at this point in the history
* Allow pytest-memray to save dumps for tests with long names
* Ignore ZeroDivisionError thrown by pytest-memray
  • Loading branch information
juliannguyen4 authored Sep 22, 2023
1 parent ac80c4d commit f5f736e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,45 @@ 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: Wait for database to be ready
# Should be ready after 3 seconds
run: sleep 3

- 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

test-coverage:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions test/new_tests/test_key_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def test_validate_digest_ints(pk, expected):
("-" * 10000, "b42e64afbfccb05912a609179228d9249ea1c1a0"),
("+" * 100000, "0a3e888c20bb8958537ddd4ba835e4070bd51740"),
),
ids=["empty", "s", "10 a's", "100 m's", "1000 t's", "10000 -'s", "100000 +'s"]
)
def test_validate_digest_str(pk, expected):
digest = aerospike.calc_digest(NAMESPACE, SET, pk)
Expand All @@ -90,6 +91,7 @@ def test_validate_digest_str(pk, expected):
("-" * 10000, "ed65c63f7a1f8c6697eb3894b6409a95461fd982"),
("+" * 100000, "fe19770c371774ba1a1532438d4851b8a773a9e6"),
),
ids=["s", "10 a's", "100 m's", "1000 t's", "10000 -'s", "100000 +'s"]
)
def test_validate_digest_bytes(pk, expected):
# encode the primary key as bytes
Expand Down
2 changes: 2 additions & 0 deletions test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
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
# TODO: these should be removed since we are not using them
psutil

0 comments on commit f5f736e

Please sign in to comment.