For another test besides the unit test can try this script
```
#!/bin/bash
S=localhost:15984
SA=adm:pass@${S}
JSON="Content-Type: application/json"
curl -s -XDELETE $SA/db > /dev/null
curl -s -XDELETE $SA/srcdb > /dev/null
curl -s -XDELETE $SA/_replicator > /dev/null
curl -s -XPUT $SA/db > /dev/null
curl -s -XPUT $SA/srcdb > /dev/null
echo "Setting [couch_httpd_auth] timeout = 5"
curl -s -XPUT adm:pass@localhost:15986/_config/couch_httpd_auth/timeout -d
'"5"' > /dev/null
curl -s -XPUT adm:pass@localhost:25986/_config/couch_httpd_auth/timeout -d
'"5"' > /dev/null
curl -s -XPUT adm:pass@localhost:35986/_config/couch_httpd_auth/timeout -d
'"5"' > /dev/null
echo "Set session force refresh = 4"
curl -s -XPUT
adm:pass@localhost:15986/_config/replicator/session_force_refresh_interval_sec
-d '"4"' > /dev/null
curl -s -XPUT
adm:pass@localhost:25986/_config/replicator/session_force_refresh_interval_sec
-d '"4"' > /dev/null
curl -s -XPUT
adm:pass@localhost:35986/_config/replicator/session_force_refresh_interval_sec
-d '"4"' > /dev/null
echo "Adding VDU to target"
cat <<EOF > /tmp/vdu.json
{
"_id": "_design/vdu",
"validate_doc_update":"function(newDoc, oldDoc, userCtx) { log(userCtx); if
(newDoc.name != userCtx.name) { throw({'forbidden': 'VDU failed'}); } }"
}
EOF
curl -s -XPUT $SA/db/_design/vdu -H "$JSON" -T /tmp/vdu.json > /dev/null
echo "Replicating from srcdb to db"
curl -s XDELETE $SA/_replicate -H "$JSON" -d
'{"source":"http://adm:pass@localhost:15984/srcdb",
"target":"http://adm:pass@localhost:15984/db", "worker_proceses":1,
"continuous":true}' > /dev/null
curl -s XPOST $SA/_replicate -H "$JSON" -d
'{"source":"http://adm:pass@localhost:15984/srcdb",
"target":"http://adm:pass@localhost:15984/db", "worker_proceses":1,
"continuous":true}' > /dev/null
sleep 3
DOCID=0
echo "With frequent enough updates, session is getting refreshed"
while [ $DOCID -lt 2 ]; do
let DOCID++
echo ""
echo "DocID: $DOCID"
curl -s -XPUT $SA/srcdb/$DOCID -H "$JSON" -d '{"name":"adm"}' > /dev/null
echo "Doc added to source, sleeping 2 seconds"
sleep 2
echo "Getting doc from target:"
curl $SA/db/$DOCID
done
echo "Now trying with longer sleeps"
sleep 10
while [ $DOCID -lt 10 ]; do
let DOCID++
echo ""
echo "DocID: $DOCID"
curl -s -XPUT $SA/srcdb/$DOCID -H "$JSON" -d '{"name":"adm"}' > /dev/null
echo "Doc added to source, sleeping 7 seconds"
sleep 7
echo "Getting doc from target:"
curl $SA/db/$DOCID
done
```
Comment the part where the force refresh setting is set to 4 seconds and docs
5,6,7... etc should fail with
```
DocID: 5
Doc added to source, sleeping 7 seconds
Getting doc from target:
{"error":"not_found","reason":"missing"}
DocID: 6
Doc added to source, sleeping 7 seconds
Getting doc from target:
{"error":"not_found","reason":"missing"}
```
Uncomment the setting and they should be replicating
```
DocID: 5
Doc added to source, sleeping 7 seconds
Getting doc from target:
{"_id":"5","_rev":"1-66e95cbbe626e928747ecc225341b2d6","name":"adm"}
DocID: 6
Doc added to source, sleeping 7 seconds
Getting doc from target:
{"_id":"6","_rev":"1-66e95cbbe626e928747ecc225341b2d6","name":"adm"}
DocID: 7
Doc added to source, sleeping 7 seconds
Getting doc from target:
{"_id":"7","_rev":"1-66e95cbbe626e928747ecc225341b2d6","name":"adm"}
```
[ Full content available at: https://github.com/apache/couchdb/pull/1619 ]
This message was relayed via gitbox.apache.org for [email protected]