Imported Upstream version 1.3.0
[platform/upstream/augeas.git] / lenses / tests / test_redis.aug
1 (*
2 Module: Test_Redis
3   Provides unit tests and examples for the <Redis> lens.
4 *)
5
6 module Test_Redis =
7
8 let standard_entry = "dir /var/lib/redis\n"
9 test Redis.lns get standard_entry = { "dir" = "/var/lib/redis" }
10
11 let double_quoted_entry = "dir \"/var/lib/redis\"\n"
12 test Redis.lns get double_quoted_entry = { "dir" = "/var/lib/redis" }
13
14 let single_quoted_entry = "dir '/var/lib/redis'\n"
15 test Redis.lns get single_quoted_entry = { "dir" = "/var/lib/redis" }
16
17 let extra_whitespace_entry = "   dir    /var/lib/redis     \n"
18 test Redis.lns get extra_whitespace_entry = { "dir" = "/var/lib/redis" }
19
20 let save_entry = "save 60 10000\n"
21 test Redis.lns get save_entry =
22 { "save"
23   { "seconds" = "60" }
24   { "keys" = "10000" }
25 }
26
27 let save_entry_quotes = "save '60' \"10000\"\n"
28 test Redis.lns get save_entry_quotes =
29 { "save"
30   { "seconds" = "60" }
31   { "keys" = "10000" }
32 }
33
34 let slaveof_entry = "slaveof 192.168.0.10 6379\n"
35 test Redis.lns get slaveof_entry =
36 { "slaveof"
37   { "ip" = "192.168.0.10" }
38   { "port" = "6379" }
39 }
40
41 let rename_command_entry = "rename-command CONFIG CONFIG2\n"
42 test Redis.lns get rename_command_entry =
43 { "rename-command"
44   { "from" = "CONFIG" }
45   { "to" = "CONFIG2" }
46 }
47
48 let client_output_buffer_limit_entry_1 = "client-output-buffer-limit normal 0 0 0\n"
49 test Redis.lns get client_output_buffer_limit_entry_1 =
50 { "client-output-buffer-limit"
51   { "class" = "normal" }
52   { "hard_limit" = "0" }
53   { "soft_limit" = "0" }
54   { "soft_seconds" = "0" }
55 }
56
57 let client_output_buffer_limit_entry_2 = "client-output-buffer-limit slave 256mb 64mb 60\n"
58 test Redis.lns get client_output_buffer_limit_entry_2 =
59 { "client-output-buffer-limit"
60   { "class" = "slave" }
61   { "hard_limit" = "256mb" }
62   { "soft_limit" = "64mb" }
63   { "soft_seconds" = "60" }
64 }
65
66 let include_entry = "include /foo/redis.conf\ninclude /bar/redis.conf\n"
67 test Redis.lns get include_entry =
68 { "include" = "/foo/redis.conf" }
69 { "include" = "/bar/redis.conf" }
70
71 let standard_comment = "# a comment\n"
72 test Redis.lns get standard_comment = { "#comment" = "a comment" }
73
74 let extra_whitespace_comment = "   #     another comment        \n"
75 test Redis.lns get extra_whitespace_comment = { "#comment" = "another comment" }
76
77 let redis_conf = "# Redis configuration file example
78
79 # Note on units: when memory size is needed, it is possible to specifiy
80 # it in the usual form of 1k 5GB 4M and so forth:
81 #
82 # 1k => 1000 bytes
83 # 1kb => 1024 bytes
84 # 1m => 1000000 bytes
85 # 1mb => 1024*1024 bytes
86 # 1g => 1000000000 bytes
87 # 1gb => 1024*1024*1024 bytes
88 #
89 # units are case insensitive so 1GB 1Gb 1gB are all the same.
90
91 # By default Redis does not run as a daemon. Use 'yes' if you need it.
92 # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
93 daemonize yes
94
95 # When running daemonized, Redis writes a pid file in /var/run/redis.pid by
96 # default. You can specify a custom pid file location here.
97 pidfile /var/run/redis/redis-server.pid
98
99 # Accept connections on the specified port, default is 6379.
100 # If port 0 is specified Redis will not listen on a TCP socket.
101 port 6379
102
103 # If you want you can bind a single interface, if the bind option is not
104 # specified all the interfaces will listen for incoming connections.
105 #
106 bind 127.0.0.1
107
108 #   Note: you can disable saving at all commenting all the \"save\" lines.
109
110 save 900 1
111 save 300 10
112 save 60 10000
113
114 # Include one or more other config files here.  This is useful if you
115 # have a standard template that goes to all redis server but also need
116 # to customize a few per-server settings.  Include files can include
117 # other files, so use this wisely.
118 #
119 include /path/to/local.conf
120 include /path/to/other.conf
121 "
122
123 test Redis.lns get redis_conf =
124   { "#comment" = "Redis configuration file example" }
125   { }
126   { "#comment" = "Note on units: when memory size is needed, it is possible to specifiy" }
127   { "#comment" = "it in the usual form of 1k 5GB 4M and so forth:" }
128   { }
129   { "#comment" = "1k => 1000 bytes" }
130   { "#comment" = "1kb => 1024 bytes" }
131   { "#comment" = "1m => 1000000 bytes" }
132   { "#comment" = "1mb => 1024*1024 bytes" }
133   { "#comment" = "1g => 1000000000 bytes" }
134   { "#comment" = "1gb => 1024*1024*1024 bytes" }
135   { }
136   { "#comment" = "units are case insensitive so 1GB 1Gb 1gB are all the same." }
137   { }
138   { "#comment" = "By default Redis does not run as a daemon. Use 'yes' if you need it." }
139   { "#comment" = "Note that Redis will write a pid file in /var/run/redis.pid when daemonized." }
140   { "daemonize" = "yes" }
141   { }
142   { "#comment" = "When running daemonized, Redis writes a pid file in /var/run/redis.pid by" }
143   { "#comment" = "default. You can specify a custom pid file location here." }
144   { "pidfile" = "/var/run/redis/redis-server.pid" }
145   { }
146   { "#comment" = "Accept connections on the specified port, default is 6379." }
147   { "#comment" = "If port 0 is specified Redis will not listen on a TCP socket." }
148   { "port" = "6379" }
149   { }
150   { "#comment" = "If you want you can bind a single interface, if the bind option is not" }
151   { "#comment" = "specified all the interfaces will listen for incoming connections." }
152   { }
153   { "bind" = "127.0.0.1" }
154   { }
155   { "#comment" = "Note: you can disable saving at all commenting all the \"save\" lines." }
156   { }
157   { "save"
158     { "seconds" = "900" }
159     { "keys" = "1" }
160   }
161   { "save"
162     { "seconds" = "300" }
163     { "keys" = "10" }
164   }
165   { "save"
166     { "seconds" = "60" }
167     { "keys" = "10000" }
168   }
169   { }
170   { "#comment" = "Include one or more other config files here.  This is useful if you" }
171   { "#comment" = "have a standard template that goes to all redis server but also need" }
172   { "#comment" = "to customize a few per-server settings.  Include files can include" }
173   { "#comment" = "other files, so use this wisely." }
174   { }
175   { "include" = "/path/to/local.conf" }
176   { "include" = "/path/to/other.conf" }
177
178 (* Test: Redis.lns
179      Empty value (GH issue #115) *)
180 test Redis.lns get "notify-keyspace-events \"\"\n" =
181   { "notify-keyspace-events" = "" }