Skip to content

Commit cba0105

Browse files
authored
readme: add testing section (#323)
1 parent e483f07 commit cba0105

File tree

6 files changed

+117
-7
lines changed

6 files changed

+117
-7
lines changed

.github/scripts/clear-dump.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash -eu
2+
3+
DATA_DIR="tests/integration/data"
4+
5+
echo "checking folder structure ..."
6+
if [ ! -d $DATA_DIR ]; then
7+
exit 1
8+
fi
9+
10+
echo "removing current crash dump if any ..."
11+
rm -f $DATA_DIR/dump.*
12+
13+
echo "removing any extracted vmlinux ..."
14+
rm -f $DATA_DIR/vmlinux*
15+
16+
echo "removing any extracted modules ..."
17+
rm -rf $DATA_DIR/mods
18+
rm -rf $DATA_DIR/usr
19+
20+
echo "removing any savedump scripts ..."
21+
rm -rf $DATA_DIR/run-*.sh
22+
23+
echo "Done"

.github/scripts/download-dump-from-s3.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,24 @@
2222

2323
DATA_DIR="tests/integration/data"
2424

25+
if [ $# -eq 0 ]; then
26+
echo "error: no crash dump archive argument supplied"
27+
exit 1
28+
fi
29+
2530
echo "checking folder structure ..."
2631
if [ ! -d $DATA_DIR ]; then
32+
echo "error: please cd to the root of the git repo"
2733
exit 1
2834
fi
2935

30-
echo "initiating download of $1 from S3 ..."
31-
wget https://sdb-testing-bucket.s3.us-west-2.amazonaws.com/$1
32-
[ $? -eq 0 ] || exit 1
36+
if [ -f "$1" ]; then
37+
echo "Found $1 locally, skip download ..."
38+
else
39+
echo "downloading of $1 from S3 ..."
40+
wget https://sdb-testing-bucket.s3.us-west-2.amazonaws.com/$1
41+
[ $? -eq 0 ] || exit 1
42+
fi
3343

3444
if [[ $1 == *.lzma ]]; then
3545
# Profile A

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
strategy:
5757
matrix:
5858
python-version: [3.8, 3.9]
59-
dump: [dump-201912060006.tar.lzma, dump.202303131823.tar.gz]
59+
dump: [dump.201912060006.tar.lzma, dump.202303131823.tar.gz]
6060
env:
6161
AWS_DEFAULT_REGION: 'us-west-2'
6262
steps:

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,7 @@ tests/integration/data/mods/
110110

111111
# vim
112112
*.swp
113+
114+
# zipped folders - usually crash dumps
115+
*.lzma
116+
*.tar.gz

README.md

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,79 @@ sdb> addr modules | lxlist "struct module" list | member name ! sort | head -n 3
5050
(char [56])"async_pq"
5151
```
5252

53-
### Resources
53+
### Developer Testing
5454

55-
User and developer resources for sdb can be found in the [project's wiki](https://github.com/delphix/sdb/wiki).
55+
#### Linting
56+
57+
```
58+
$ python3 -m pip install pylint pytest
59+
$ python3 -m pylint -d duplicate-code -d invalid-name sdb
60+
$ python3 -m pylint -d duplicate-code -d invalid-name tests
61+
```
62+
63+
#### Type Checking
64+
65+
```
66+
$ python3 -m pip install mypy==0.730
67+
$ python3 -m mypy --strict --show-error-codes -p sdb
68+
$ python3 -m mypy --strict --ignore-missing-imports --show-error-codes -p tests
69+
```
70+
71+
#### Style Checks
72+
73+
```
74+
$ python3 -m pip install yapf
75+
$ python3 -m yapf --diff --style google --recursive sdb
76+
$ python3 -m yapf --diff --style google --recursive tests
77+
```
78+
79+
If `yapf` has suggestions you can apply them automatically by substituting
80+
`--diff` with `-i` like this:
81+
```
82+
$ python3 -m yapf -i --style google --recursive sdb
83+
$ python3 -m yapf -i --style google --recursive tests
84+
```
85+
86+
#### Regression Testing
87+
88+
Regression testing is currently done by downloading a refererence crash/core
89+
dump and running a predetermined set of commads on it, ensuring that they
90+
return the same reference output before and after your changes. To see the list
91+
of reference crash dumps refer to the testing matrix of the `pytest` Github
92+
action in `.github/workflows/main.yml`. Here is an example of running the
93+
regression test commands against `dump.201912060006.tar.lzma` with code
94+
coverage and verbose output:
95+
96+
```
97+
$ python3 -m pip install python-config pytest pytest-cov
98+
$ .github/scripts/download-dump-from-s3.sh dump.201912060006.tar.lzma
99+
$ python3 -m pytest -v --cov sdb --cov-report xml tests
100+
```
101+
102+
If you want `pytest` to stop on the first failure it encounters add
103+
`-x/--exitfirst` in the command above.
104+
105+
If you've added new test commands or found mistakes in the current reference
106+
output and you want (re)generate reference output for a crash dump - let's say
107+
`dump.201912060006` from above:
108+
```
109+
$ PYTHONPATH=$(pwd) python3 tests/integration/gen_regression_output.py dump.201912060006
110+
```
111+
112+
or more generically:
113+
```
114+
$ PYTHONPATH=$(pwd) python3 tests/integration/gen_regression_output.py <dump name>
115+
```
116+
117+
For the time being, the test suite is not smart enought to handle the testing
118+
of multiple crash dumps at the same time. Until that happens, developers that
119+
want to test multiple crash dumps need to delete their current crash dump
120+
before downloading the next to run `pytest`. Here is a sequence of commands to
121+
run `pytest` against two crash dumps:
122+
```
123+
$ .github/scripts/download-dump-from-s3.sh dump.201912060006.tar.lzma
124+
$ python3 -m pytest -v --cov sdb --cov-report xml tests
125+
$ .github/scripts/clear-dump.sh
126+
$ .github/scripts/download-dump-from-s3.sh dump.202303131823.tar.gz
127+
$ python3 -m pytest -v --cov sdb --cov-report xml tests
128+
```

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
author_email='serapheim@delphix.com',
2828
description='The Slick/Simple Debugger',
2929
license='Apache-2.0',
30-
url='https://github.com/sdimitro/sdb',
30+
url='https://github.com/delphix/sdb',
3131
)

0 commit comments

Comments
 (0)