Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some utility scripts to tools/ #178

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"