Skip to content

Commit

Permalink
Merge pull request #178 from dandi/more-tools
Browse files Browse the repository at this point in the history
Add some utility scripts to `tools/`
  • Loading branch information
jwodder authored Aug 19, 2024
2 parents 38b59ef + e78ce36 commit 66c94eb
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tools/test-propfind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# Make a number of test PROPFIND queries to dandidav and save the output
set -eux

# dandidav server root:
endpoint=http://127.0.0.1:8080
#endpoint=https://webdav.dandiarchive.org

# Path to a collection resource to query:
collection=dandisets/000108/draft
#collection=zarrs/0d5/b9b/0d5b9be5-e626-4f6a-96da-b6b602954899/0395d0a3767524377b58da3945b3c063-48379--27115470.zarr

# Path to a non-collection resource to query:
item=dandisets/000027/draft/sub-RAT123/sub-RAT123.nwb

# Directory in which to store responses:
outdir=propfind

mkdir -p "$outdir"

curl -fsSL -X PROPFIND -H "Depth: 0" "$endpoint" > "$outdir"/root-depth0.xml
curl -fsSL -X PROPFIND -H "Depth: 1" "$endpoint" > "$outdir"/root-depth1.xml

curl -fsSL -X PROPFIND -H "Depth: 0" "$endpoint/$collection" > "$outdir"/collection-depth0.xml
curl -fsSL -X PROPFIND -H "Depth: 1" "$endpoint/$collection" > "$outdir"/collection-depth1.xml

curl -fsSL \
-X PROPFIND \
-H "Depth: 1" \
-d '<propfind xmlns="DAV:"><propname/></propfind>' \
"$endpoint/$collection" > "$outdir"/propname.xml

curl -fsSL \
-X PROPFIND \
-H "Depth: 1" \
-d '<propfind xmlns="DAV:"><prop><resourcetype/></prop></propfind>' \
"$endpoint/$collection" > "$outdir"/resourcetype.xml

curl -fsSL \
-X PROPFIND \
-H "Depth: 0" \
-d '
<propfind xmlns="DAV:">
<prop>
<getcontentlength/>
<resourcetype/>
<unknown/>
<extension xmlns="https://dav.example.com"/>
<displayname/>
</prop>
</propfind>
' "$endpoint/$item" > "$outdir"/prop.xml

# No -f:
curl -sSL -X PROPFIND -H "Depth: 1" "$endpoint/does-not-exist" > "$outdir"/nonexistent.txt
22 changes: 22 additions & 0 deletions tools/type-sizes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# Produces a listing of the types defined by dandidav (including anonymous
# types like futures returned by async functions) along with their sizes,
# ordered by decreasing size
#
# Requires:
#
# - nightly Rust
# - top-type-sizes <https://crates.io/crates/top-type-sizes>

set -eux -o pipefail

outfile="${1:?Usage: $0 outfile}"

cargo clean -p dandidav

RUSTFLAGS=-Zprint-type-sizes cargo +nightly build -j 1 | top-type-sizes \
--sort-fields \
--filter '@src/|\b(dandi|dav|httputil|paths|s3|streamutil|zarrman)::' \
--remove-wrappers \
--hide-less 8 \
> "$outfile"

0 comments on commit 66c94eb

Please sign in to comment.