Skip to content

Commit 9300ea8

Browse files
valentin-pinkaunormanrz
authored andcommitted
Refactor tests (#56)
* use test scripts * make executable * add local test script
1 parent 7f982a2 commit 9300ea8

16 files changed

+198
-178
lines changed

.circleci/config.yml

Lines changed: 14 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,23 @@ jobs:
1313
1414
- run:
1515
name: Build docker image
16-
command: docker build -t "scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM}" .
16+
command: tests/scripts/build_docker_image.sh
1717

1818
- run:
1919
name: Decompress test data
20-
command: tar -xzvf testdata/WT1_wkw.tar.gz
20+
command: tests/scripts/decompress_test_data.sh
2121

2222
- run:
2323
name: Check formatting
24-
command: |
25-
set -x
26-
docker run \
27-
--rm \
28-
--entrypoint "/bin/bash" \
29-
-w "/" \
30-
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
31-
-c "black --check /app/wkcuber"
24+
command: tests/scripts/check_formatting.sh
3225

3326
- run:
3427
name: Python tests
35-
command: |
36-
set -x
37-
mkdir -p testoutput
38-
docker run \
39-
-v "${PWD}/testdata:/testdata" \
40-
-v "${PWD}/testoutput:/testoutput" \
41-
--rm \
42-
--entrypoint "/bin/bash" \
43-
-w "/" \
44-
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
45-
-c "py.test /app/tests"
28+
command: tests/scripts/python_tests.sh
4629

4730
- run:
4831
name: Test tiff cubing
49-
command: |
50-
set -x
51-
mkdir -p testoutput/tiff
52-
docker run \
53-
-v "${PWD}/testdata:/testdata" \
54-
-v "${PWD}/testoutput:/testoutput" \
55-
--rm \
56-
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
57-
wkcuber.cubing \
58-
--verbose \
59-
--jobs 2 \
60-
--batch_size 8 \
61-
--layer_name color \
62-
/testdata/tiff /testoutput/tiff
63-
[ -d testoutput/tiff/color ]
64-
[ -d testoutput/tiff/color/1 ]
65-
[ $(find testoutput/tiff/color/1 -mindepth 3 -name "*.wkw" | wc -l) -eq 1 ]
32+
command: tests/scripts/tiff_cubing.sh
6633

6734
# - run:
6835
# name: Test DM3 cubing
@@ -88,170 +55,39 @@ jobs:
8855

8956
- run:
9057
name: Test tile cubing
91-
command: |
92-
set -x
93-
mkdir -p testoutput/temca2
94-
docker run \
95-
-v "${PWD}/testdata:/testdata" \
96-
-v "${PWD}/testoutput:/testoutput" \
97-
--rm \
98-
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
99-
wkcuber.tile_cubing \
100-
--verbose \
101-
--jobs 2 \
102-
--batch_size 8 \
103-
--layer_name color \
104-
/testdata/temca2 /testoutput/temca2
105-
[ -d testoutput/temca2/color ]
106-
[ -d testoutput/temca2/color/1 ]
107-
[ $(find testoutput/temca2/color/1 -mindepth 3 -name "*.wkw" | wc -l) -eq 8 ]
58+
command: tests/scripts/tile_cubing.sh
10859

10960
- run:
11061
name: Test simple tiff cubing
111-
command: |
112-
set -x
113-
mkdir -p testoutput/tiff2
114-
docker run \
115-
-v "${PWD}/testdata:/testdata" \
116-
-v "${PWD}/testoutput:/testoutput" \
117-
--rm \
118-
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
119-
wkcuber \
120-
--verbose \
121-
--jobs 2 \
122-
--batch_size 8 \
123-
--layer_name color \
124-
--max_mag 4 \
125-
--scale 11.24,11.24,25 \
126-
--name awesome_data \
127-
/testdata/tiff /testoutput/tiff2
128-
[ -d testoutput/tiff2/color ]
129-
[ -d testoutput/tiff2/color/1 ]
130-
[ $(find testoutput/tiff2/color/1 -mindepth 3 -name "*.wkw" | wc -l) -eq 1 ]
131-
[ -e testoutput/tiff2/datasource-properties.json ]
62+
command: tests/scripts/simple_tiff_cubing.sh
13263

13364
- run:
13465
name: Test simple tiff cubing (no compression)
135-
command: |
136-
set -x
137-
mkdir -p testoutput/tiff3
138-
docker run \
139-
-v "${PWD}/testdata:/testdata" \
140-
-v "${PWD}/testoutput:/testoutput" \
141-
--rm \
142-
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
143-
wkcuber \
144-
--verbose \
145-
--jobs 2 \
146-
--batch_size 8 \
147-
--layer_name color \
148-
--max_mag 4 \
149-
--no_compress \
150-
--scale 11.24,11.24,25 \
151-
--name awesome_data \
152-
/testdata/tiff /testoutput/tiff3
153-
[ -d testoutput/tiff3/color ]
154-
[ -d testoutput/tiff3/color/1 ]
155-
[ $(find testoutput/tiff3/color/1 -mindepth 3 -name "*.wkw" | wc -l) -eq 1 ]
156-
[ -e testoutput/tiff3/datasource-properties.json ]
66+
command: tests/scripts/simple_tiff_cubing_no_compression.sh
15767

15868
- run:
15969
name: Test KNOSSOS conversion
160-
command: |
161-
set -x
162-
mkdir -p testoutput/knossos
163-
docker run \
164-
-v "${PWD}/testdata:/testdata" \
165-
-v "${PWD}/testoutput:/testoutput" \
166-
--rm \
167-
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
168-
wkcuber.convert_knossos \
169-
--verbose \
170-
--jobs 2 \
171-
--dtype uint8 \
172-
--layer_name color \
173-
--mag 1 \
174-
/testdata/knossos/color/1 /testoutput/knossos
175-
[ -d testoutput/knossos/color ]
176-
[ -d testoutput/knossos/color/1 ]
177-
[ $(find testoutput/knossos/color/1 -mindepth 3 -name "*.wkw" | wc -l) -eq 1 ]
70+
command: tests/scripts/knossos_conversion.sh
17871

17972
- run:
18073
name: Decompress reference magnification data
181-
command: mkdir -p testdata/tiff_mag_2_reference && tar -xzvf testdata/tiff_mag_2_reference.tar.gz -C testdata/tiff_mag_2_reference
74+
command: tests/scripts/decompress_reference_mag.sh
18275

18376
- run:
18477
name: Test downsampling
185-
command: |
186-
set -x
187-
docker run \
188-
-v "${PWD}/testoutput:/testoutput" \
189-
--rm \
190-
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
191-
wkcuber.downsampling \
192-
--verbose \
193-
--jobs 2 \
194-
--max 8 \
195-
--buffer_cube_size 128 \
196-
--layer_name color \
197-
/testoutput/tiff
198-
[ -d testoutput/tiff/color/2 ]
199-
[ -d testoutput/tiff/color/4 ]
200-
[ -d testoutput/tiff/color/8 ]
201-
[ -n testoutput/tiff/color/16 ]
202-
[ $(find testoutput/tiff/color/2 -mindepth 3 -name "*.wkw" | wc -l) -eq 1 ]
203-
[ $(find testoutput/tiff/color/4 -mindepth 3 -name "*.wkw" | wc -l) -eq 1 ]
204-
[ $(find testoutput/tiff/color/8 -mindepth 3 -name "*.wkw" | wc -l) -eq 1 ]
205-
cmp --silent testoutput/tiff/color/2/z0/y0/x0.wkw testdata/tiff_mag_2_reference/color/2/z0/y0/x0.wkw
78+
command: tests/scripts/downsampling.sh
20679

20780
- run:
20881
name: Test compression
209-
command: |
210-
set -x
211-
docker run \
212-
-v "${PWD}/testoutput:/testoutput" \
213-
--rm \
214-
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
215-
wkcuber.compress \
216-
--verbose \
217-
--jobs 2 \
218-
--layer_name color \
219-
/testoutput/tiff /testoutput/tiff_compress
220-
[ -d testoutput/tiff_compress/color/1 ]
221-
[ -d testoutput/tiff_compress/color/2 ]
222-
[ -d testoutput/tiff_compress/color/4 ]
223-
[ -d testoutput/tiff_compress/color/8 ]
82+
command: tests/scripts/compression.sh
22483

22584
- run:
22685
name: Test in-place compression
227-
command: |
228-
set -x
229-
cp -r testoutput/tiff testoutput/tiff_compress2
230-
docker run \
231-
-v "${PWD}/testoutput:/testoutput" \
232-
--rm \
233-
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
234-
wkcuber.compress \
235-
--verbose \
236-
--jobs 2 \
237-
--layer_name color \
238-
/testoutput/tiff_compress2
86+
command: tests/scripts/in_place_compression.sh
23987

24088
- run:
24189
name: Test metadata generation
242-
command: |
243-
set -x
244-
docker run \
245-
-v "${PWD}/testoutput:/testoutput" \
246-
--rm \
247-
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
248-
wkcuber.metadata \
249-
--name test_dataset \
250-
--scale 11.24,11.24,25 \
251-
/testoutput/tiff
252-
[ -e testoutput/tiff/datasource-properties.json ]
253-
jq --argfile a testdata/tiff/datasource-properties.fixture.json --argfile b testoutput/tiff/datasource-properties.json -n '$a == $b'
254-
# diff testdata/tiff/datasource-properties.fixture.json testoutput/tiff/datasource-properties.json
90+
command: tests/scripts/meta_generation.sh
25591

25692
- run:
25793
name: Push docker images

test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export CIRCLE_BUILD_NUM=latest
2+
tests/scripts/build_docker_image.sh
3+
tests/scripts/decompress_test_data.sh
4+
tests/scripts/check_formatting.sh
5+
tests/scripts/python_tests.sh
6+
tests/scripts/tiff_cubing.sh
7+
tests/scripts/tile_cubing.sh
8+
tests/scripts/simple_tiff_cubing.sh
9+
tests/scripts/simple_tiff_cubing_no_compression.sh
10+
tests/scripts/knossos_conversion.sh
11+
tests/scripts/decompress_reference_mag.sh
12+
tests/scripts/downsampling.sh
13+
tests/scripts/compression.sh
14+
tests/scripts/in_place_compression.sh
15+
tests/scripts/meta_generation.sh
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
set -xe
2+
docker build -t "scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM}" .

tests/scripts/check_formatting.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set -xe
2+
docker run \
3+
--rm \
4+
--entrypoint "/bin/bash" \
5+
-w "/" \
6+
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
7+
-c "black --check /app/wkcuber"

tests/scripts/compression.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
set -xe
2+
docker run \
3+
-v "${PWD}/testoutput:/testoutput" \
4+
--rm \
5+
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
6+
wkcuber.compress \
7+
--verbose \
8+
--jobs 2 \
9+
--layer_name color \
10+
/testoutput/tiff /testoutput/tiff_compress
11+
[ -d testoutput/tiff_compress/color/1 ]
12+
[ -d testoutput/tiff_compress/color/2 ]
13+
[ -d testoutput/tiff_compress/color/4 ]
14+
[ -d testoutput/tiff_compress/color/8 ]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
set -xe
2+
mkdir -p testdata/tiff_mag_2_reference && tar -xzvf testdata/tiff_mag_2_reference.tar.gz -C testdata/tiff_mag_2_reference
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tar -xzvf testdata/WT1_wkw.tar.gz

tests/scripts/downsampling.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
set -xe
2+
docker run \
3+
-v "${PWD}/testoutput:/testoutput" \
4+
--rm \
5+
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
6+
wkcuber.downsampling \
7+
--verbose \
8+
--jobs 2 \
9+
--max 8 \
10+
--buffer_cube_size 128 \
11+
--layer_name color \
12+
/testoutput/tiff
13+
[ -d testoutput/tiff/color/2 ]
14+
[ -d testoutput/tiff/color/4 ]
15+
[ -d testoutput/tiff/color/8 ]
16+
[ -n testoutput/tiff/color/16 ]
17+
[ $(find testoutput/tiff/color/2 -mindepth 3 -name "*.wkw" | wc -l) -eq 1 ]
18+
[ $(find testoutput/tiff/color/4 -mindepth 3 -name "*.wkw" | wc -l) -eq 1 ]
19+
[ $(find testoutput/tiff/color/8 -mindepth 3 -name "*.wkw" | wc -l) -eq 1 ]
20+
cmp --silent testoutput/tiff/color/2/z0/y0/x0.wkw testdata/tiff_mag_2_reference/color/2/z0/y0/x0.wkw
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set -xe
2+
cp -r testoutput/tiff testoutput/tiff_compress2
3+
docker run \
4+
-v "${PWD}/testoutput:/testoutput" \
5+
--rm \
6+
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
7+
wkcuber.compress \
8+
--verbose \
9+
--jobs 2 \
10+
--layer_name color \
11+
/testoutput/tiff_compress2
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
set -xe
2+
mkdir -p testoutput/knossos
3+
docker run \
4+
-v "${PWD}/testdata:/testdata" \
5+
-v "${PWD}/testoutput:/testoutput" \
6+
--rm \
7+
scalableminds/webknossos-cuber:${CIRCLE_BUILD_NUM} \
8+
wkcuber.convert_knossos \
9+
--verbose \
10+
--jobs 2 \
11+
--dtype uint8 \
12+
--layer_name color \
13+
--mag 1 \
14+
/testdata/knossos/color/1 /testoutput/knossos
15+
[ -d testoutput/knossos/color ]
16+
[ -d testoutput/knossos/color/1 ]
17+
[ $(find testoutput/knossos/color/1 -mindepth 3 -name "*.wkw" | wc -l) -eq 1 ]

0 commit comments

Comments
 (0)