nickva commented on PR #6165:
URL: https://github.com/apache/couchdb/pull/6165#issuecomment-6221344977
A test script to play around with
```shell
#!/bin/sh
set -eu
DB=${DB:-http://adm:[email protected]:15984}
NDOCS=1000
req() {
if [ $# -gt 2 ]; then
curl -s -X "$1" -H content-type:application/json -d "$3" "$DB$2"
else
curl -s -X "$1" "$DB$2"
fi
}
req DELETE "/hbseq" > /dev/null
req PUT "/hbseq?q=1" > /dev/null
FLT="function(doc, req) {var t=Date.now(); while (Date.now()-t < 20) {};
return doc.bad; }"
req PUT "/hbseq/_design/slow" "{\"filters\": {\"f\": \"$FLT\"}}" > /dev/null
docs=""
for ((i = 1; i <= 1000; i++)); do
printf -v id '%05d' "$i"
if (( i == 300 || i == 600)); then
docs="$docs{\"_id\":\"$id\",\"bad\":true},"
else
docs="$docs{\"_id\":\"$id\",\"bad\":false},"
fi
done
req POST "/hbseq/_bulk_docs" "{\"docs\":[${docs%,}]}" > /dev/null
echo
echo "Created $NDOCS in $DB"
echo
echo "Try running these commands"
cat <<'EOF'
curl -N
$DB/hbseq/_changes'?feed=continuous&filter=slow/f&heartbeat=2000&heartbeat_seq=true'
curl -N
$DB/hbseq/_changes'?feed=continuous&filter=slow/f&timeout=5000&heartbeat_seq=true'
curl -N
$DB/hbseq/_changes'?feed=normal&filter=slow/f&heartbeat=2000&heartbeat_seq=true'
curl -N
$DB/hbseq/_changes'?feed=eventsource&filter=slow/f&heartbeat=2000&heartbeat_seq=true'
EOF
echo
echo "Then can periodically create new passing/failing docs"
cat <<'EOF'
curl -XPOST -H'content-type:application/json' $DB/hbseq -d '{"bad":true}'
curl -XPOST -H'content-type:application/json' $DB/hbseq -d '{}'
EOF
echo
```
Example
```
Created 1000 in http://adm:[email protected]:15984
curl -N
$DB/hbseq/_changes'?feed=continuous&filter=slow/f&timeout=5000&heartbeat_seq=true'
{"seq":"249-g1AAAABLeJzLYWBgYMxgTmHgz8tPSTV0MDQy1zMAQsMcoARTIkMeC8N_IMjKYE78mQsUYk9NTE5JMjHC1JAFAM5VE_Y","id":null,"changes":[]}
{"seq":"301-g1AAAABOeJzLYWBgYMxgTmHgz8tPSTV0MDQy1zMAQsMcoARTIkMeC8N_IMjKYE4CKtTNBYqypyYmpySZGGHqyQIA17sTLA","id":"00300","changes":[{"rev":"1-95d23cf29761e3415e35bc22506984e8"}]}
{"seq":"498-g1AAAABOeJzLYWBgYMxgTmHgz8tPSTV0MDQy1zMAQsMcoARTIkMeC8N_IMjKYE4CKvyUCxRlT01MTkkyMcLUkwUA8FsT8Q","id":null,"changes":[]}
{"seq":"601-g1AAAABOeJzLYWBgYMxgTmHgz8tPSTV0MDQy1zMAQsMcoARTIkMeC8N_IMjKYE4C8iNzgaLsqYnJKUkmRph6sgDdXBNZ","id":"00600","changes":[{"rev":"1-95d23cf29761e3415e35bc22506984e8"}]}
{"seq":"739-g1AAAABOeJzLYWBgYMxgTmHgz8tPSTV0MDQy1zMAQsMcoARTIkMeC8N_IMjKYE4C8h_nAkXZUxOTU5JMjDD1ZAEA7pwT4w","id":null,"changes":[]}
{"seq":"975-g1AAAABOeJzLYWBgYMxgTmHgz8tPSTV0MDQy1zMAQsMcoARTIkMeC8N_IMjKYE5iYGA-nwsUZU9NTE5JMjHC1JMFAOw9E9A","id":null,"changes":[]}
{"last_seq":"1001-g1AAAABOeJzLYWBgYMxgTmHgz8tPSTV0MDQy1zMAQsMcoARTIkMeC8N_IMjKYE5iYGB-mQsUZU9NTE5JMjHC1JMFAO99E-o","pending":0}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]