Created
November 17, 2018 17:38
-
-
Save varlal/18267423351714a73af2008f140d68bb to your computer and use it in GitHub Desktop.
Relax... CouchDB compaction test.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import couchdb.client | |
# config | |
COUCH_HOST = "http://admin:password@localhost:5984" | |
DB = "test_db" | |
# connect server and create db | |
server = couchdb.client.Server(COUCH_HOST) | |
try: | |
db = server.create(DB) | |
except couchdb.http.PreconditionFailed as e: | |
if 'The database could not be created, the file already exists.' in str(e): | |
print("'"+DB+"' is already exsis. Continue test.") | |
db = server[DB] | |
else: | |
print(e.args) | |
exit() | |
# all docs deleted flag true | |
all_docs = db.view('_all_docs') | |
documentsToDelete = [couchdb.client.Document(_id=entry['id'],_rev=entry['value']['rev'],_deleted=True) for entry in all_docs] | |
db.update(documentsToDelete) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import couchdb.client | |
# config | |
COUCH_HOST = "http://admin:password@localhost:5984" | |
DB = "test_db" | |
# create dummy.json | |
dummy_json = {} | |
for i in range(10000): | |
dummy_json["test"+str(i).zfill(8)] = random.random() | |
# connect server and create db | |
server = couchdb.client.Server(COUCH_HOST) | |
try: | |
db = server.create(DB) | |
except couchdb.http.PreconditionFailed as e: | |
if 'The database could not be created, the file already exists.' in str(e): | |
print("'"+DB+"' is already exsis. Continue test.") | |
db = server[DB] | |
else: | |
print(e.args) | |
exit() | |
# create docs | |
for i in range(100): | |
print(i) | |
db.create(dummy_json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# CleanUP log | |
echo "" > test.log | |
# function : Check disk usage of couch volume | |
check(){ | |
echo $1 >> test.log | |
echo "#du -h ~/date" >> test.log | |
du -h ~/data | tee -a test.log | |
} | |
check "--- State1: Start ---" | |
python create_test.py | |
sleep 10s | |
check "--- State2: After create db and docs ---" | |
curl -X POST -H "Content-Type:application/json" http://admin:password@localhost:5984/test_db/_compact | |
sleep 10s | |
check "--- State3: compaction1 ---" | |
python add_deleted_test.py | |
sleep 10s | |
check "--- State4: After deleted True for all docs ---" | |
curl -X POST -H "Content-Type:application/json" http://admin:password@localhost:5984/test_db/_compact | |
sleep 10s | |
check "--- State5: compaction2 ---" | |
curl -X DELETE http://admin:password@localhost:5984/test_db | |
sleep 10s | |
check "--- Last State: After delete DB ---" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- State1: Start --- | |
#du -h ~/date | |
12K /home/varlal/data/shards/40000000-5fffffff | |
8.0K /home/varlal/data/shards/00000000-1fffffff | |
8.0K /home/varlal/data/shards/80000000-9fffffff | |
8.0K /home/varlal/data/shards/60000000-7fffffff | |
8.0K /home/varlal/data/shards/c0000000-dfffffff | |
8.0K /home/varlal/data/shards/20000000-3fffffff | |
8.0K /home/varlal/data/shards/a0000000-bfffffff | |
8.0K /home/varlal/data/shards/e0000000-ffffffff | |
72K /home/varlal/data/shards | |
4.0K /home/varlal/data/.delete | |
8.0K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design/mrview | |
12K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design | |
16K /home/varlal/data/.shards/40000000-5fffffff | |
20K /home/varlal/data/.shards | |
8.0K /home/varlal/data/._users_design/mrview | |
12K /home/varlal/data/._users_design | |
8.0K /home/varlal/data/._replicator_design/mrview | |
12K /home/varlal/data/._replicator_design | |
220K /home/varlal/data | |
--- State2: After create db and docs --- | |
#du -h ~/date | |
1.8M /home/varlal/data/shards/40000000-5fffffff | |
1.9M /home/varlal/data/shards/00000000-1fffffff | |
1.5M /home/varlal/data/shards/80000000-9fffffff | |
3.0M /home/varlal/data/shards/60000000-7fffffff | |
2.0M /home/varlal/data/shards/c0000000-dfffffff | |
1.5M /home/varlal/data/shards/20000000-3fffffff | |
1.2M /home/varlal/data/shards/a0000000-bfffffff | |
1.8M /home/varlal/data/shards/e0000000-ffffffff | |
15M /home/varlal/data/shards | |
4.0K /home/varlal/data/.delete | |
8.0K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design/mrview | |
12K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design | |
16K /home/varlal/data/.shards/40000000-5fffffff | |
20K /home/varlal/data/.shards | |
8.0K /home/varlal/data/._users_design/mrview | |
12K /home/varlal/data/._users_design | |
8.0K /home/varlal/data/._replicator_design/mrview | |
12K /home/varlal/data/._replicator_design | |
15M /home/varlal/data | |
--- State3: compaction1 --- | |
#du -h ~/date | |
1.7M /home/varlal/data/shards/40000000-5fffffff | |
1.8M /home/varlal/data/shards/00000000-1fffffff | |
1.4M /home/varlal/data/shards/80000000-9fffffff | |
2.9M /home/varlal/data/shards/60000000-7fffffff | |
2.0M /home/varlal/data/shards/c0000000-dfffffff | |
1.4M /home/varlal/data/shards/20000000-3fffffff | |
1.2M /home/varlal/data/shards/a0000000-bfffffff | |
1.7M /home/varlal/data/shards/e0000000-ffffffff | |
14M /home/varlal/data/shards | |
4.0K /home/varlal/data/.delete | |
8.0K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design/mrview | |
12K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design | |
16K /home/varlal/data/.shards/40000000-5fffffff | |
20K /home/varlal/data/.shards | |
8.0K /home/varlal/data/._users_design/mrview | |
12K /home/varlal/data/._users_design | |
8.0K /home/varlal/data/._replicator_design/mrview | |
12K /home/varlal/data/._replicator_design | |
14M /home/varlal/data | |
--- State4: After deleted True for all docs --- | |
#du -h ~/date | |
1.7M /home/varlal/data/shards/40000000-5fffffff | |
1.9M /home/varlal/data/shards/00000000-1fffffff | |
1.4M /home/varlal/data/shards/80000000-9fffffff | |
2.9M /home/varlal/data/shards/60000000-7fffffff | |
2.0M /home/varlal/data/shards/c0000000-dfffffff | |
1.4M /home/varlal/data/shards/20000000-3fffffff | |
1.2M /home/varlal/data/shards/a0000000-bfffffff | |
1.7M /home/varlal/data/shards/e0000000-ffffffff | |
14M /home/varlal/data/shards | |
4.0K /home/varlal/data/.delete | |
8.0K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design/mrview | |
12K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design | |
16K /home/varlal/data/.shards/40000000-5fffffff | |
20K /home/varlal/data/.shards | |
8.0K /home/varlal/data/._users_design/mrview | |
12K /home/varlal/data/._users_design | |
8.0K /home/varlal/data/._replicator_design/mrview | |
12K /home/varlal/data/._replicator_design | |
15M /home/varlal/data | |
--- State5: compaction2 --- | |
#du -h ~/date | |
28K /home/varlal/data/shards/40000000-5fffffff | |
24K /home/varlal/data/shards/00000000-1fffffff | |
24K /home/varlal/data/shards/80000000-9fffffff | |
24K /home/varlal/data/shards/60000000-7fffffff | |
24K /home/varlal/data/shards/c0000000-dfffffff | |
24K /home/varlal/data/shards/20000000-3fffffff | |
24K /home/varlal/data/shards/a0000000-bfffffff | |
24K /home/varlal/data/shards/e0000000-ffffffff | |
200K /home/varlal/data/shards | |
4.0K /home/varlal/data/.delete | |
8.0K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design/mrview | |
12K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design | |
16K /home/varlal/data/.shards/40000000-5fffffff | |
20K /home/varlal/data/.shards | |
8.0K /home/varlal/data/._users_design/mrview | |
12K /home/varlal/data/._users_design | |
8.0K /home/varlal/data/._replicator_design/mrview | |
12K /home/varlal/data/._replicator_design | |
352K /home/varlal/data | |
--- Last State: After delete DB --- | |
#du -h ~/date | |
12K /home/varlal/data/shards/40000000-5fffffff | |
8.0K /home/varlal/data/shards/00000000-1fffffff | |
8.0K /home/varlal/data/shards/80000000-9fffffff | |
8.0K /home/varlal/data/shards/60000000-7fffffff | |
8.0K /home/varlal/data/shards/c0000000-dfffffff | |
8.0K /home/varlal/data/shards/20000000-3fffffff | |
8.0K /home/varlal/data/shards/a0000000-bfffffff | |
8.0K /home/varlal/data/shards/e0000000-ffffffff | |
72K /home/varlal/data/shards | |
4.0K /home/varlal/data/.delete | |
8.0K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design/mrview | |
12K /home/varlal/data/.shards/40000000-5fffffff/_users.1542460350_design | |
16K /home/varlal/data/.shards/40000000-5fffffff | |
20K /home/varlal/data/.shards | |
8.0K /home/varlal/data/._users_design/mrview | |
12K /home/varlal/data/._users_design | |
8.0K /home/varlal/data/._replicator_design/mrview | |
12K /home/varlal/data/._replicator_design | |
228K /home/varlal/data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment