@cryptotaxi247 / kubo / commits / 7b5027f08

add basic tests for Spec config change

License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>

Kevin Atkinson committed Jul 6, 2017 at 04:43 UTC 7b5027f084756e1cdab09bc11fa1d2e792c078b9
1 file changed +114
test/sharness/t0024-datastore-config.sh new
+114
@@ -0,0 +1,114 @@
1 +#!/bin/sh
2 +
3 +test_description="Test datastore config"
4 +
5 +. lib/test-lib.sh
6 +
7 +test_init_ipfs
8 +
9 +test_launch_ipfs_daemon
10 +test_kill_ipfs_daemon
11 +
12 +SPEC_ORIG=$(cat <<EOF)
13 +{
14 + "mounts": [
15 + {
16 + "child": {
17 + "path": "blocks",
18 + "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
19 + "sync": true,
20 + "type": "flatfs"
21 + },
22 + "mountpoint": "/blocks",
23 + "prefix": "flatfs.datastore",
24 + "type": "measure"
25 + },
26 + {
27 + "child": {
28 + "compression": "none",
29 + "path": "datastore",
30 + "type": "levelds"
31 + },
32 + "mountpoint": "/",
33 + "prefix": "leveldb.datastore",
34 + "type": "measure"
35 + }
36 + ],
37 + "type": "mount"
38 +}
39 +EOF
40 +
41 +SPEC_NOSYNC=$(cat <<'EOF')
42 +{
43 + "mounts": [
44 + {
45 + "child": {
46 + "path": "blocks",
47 + "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
48 + "sync": false,
49 + "type": "flatfs"
50 + },
51 + "mountpoint": "/blocks",
52 + "prefix": "flatfs.datastore",
53 + "type": "measure"
54 + },
55 + {
56 + "child": {
57 + "compression": "none",
58 + "path": "datastore",
59 + "type": "levelds"
60 + },
61 + "mountpoint": "/",
62 + "prefix": "leveldb.datastore",
63 + "type": "measure"
64 + }
65 + ],
66 + "type": "mount"
67 +}
68 +EOF
69 +
70 +SPEC_NEWSHARDFUN=$(cat <<'EOF')
71 +{
72 + "mounts": [
73 + {
74 + "child": {
75 + "path": "blocks",
76 + "shardFunc": "/repo/flatfs/shard/v1/next-to-last/3",
77 + "sync": true,
78 + "type": "flatfs"
79 + },
80 + "mountpoint": "/blocks",
81 + "prefix": "flatfs.datastore",
82 + "type": "measure"
83 + },
84 + {
85 + "child": {
86 + "compression": "none",
87 + "path": "datastore",
88 + "type": "levelds"
89 + },
90 + "mountpoint": "/",
91 + "prefix": "leveldb.datastore",
92 + "type": "measure"
93 + }
94 + ],
95 + "type": "mount"
96 +}
97 +EOF
98 +
99 +test_expect_success "change runtime value in spec config" '
100 + ipfs config --json Datastore.Spec "$SPEC_NOSYNC"
101 +'
102 +
103 +test_launch_ipfs_daemon
104 +test_kill_ipfs_daemon
105 +
106 +test_expect_success "change on-disk value in spec config" '
107 + ipfs config --json Datastore.Spec "$SPEC_NEWSHARDFUN"
108 +'
109 +
110 +test_expect_success "can not launch daemon after on-disk value change" '
111 + test_must_fail ipfs daemon
112 +'
113 +
114 +test_done