vayacondios-server 0.2.11 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/.travis.yml +2 -0
- data/Gemfile +15 -9
- data/LICENSE.md +2 -6
- data/Procfile +1 -1
- data/README.md +656 -111
- data/Rakefile +89 -6
- data/bin/vcd +10 -0
- data/bin/vcd-server +8 -0
- data/config/database.yml +6 -0
- data/config/spec.example.yml +18 -0
- data/config/vayacondios.example.yml +15 -0
- data/config/vcd-server.rb +37 -0
- data/examples/configuration.rb +56 -0
- data/examples/event_stream.rb +19 -0
- data/examples/simple.rb +61 -0
- data/features/event.feature +319 -0
- data/features/events.feature +208 -0
- data/features/stash.feature +840 -0
- data/features/stashes.feature +492 -0
- data/features/step_definitions/stash_steps.rb +113 -0
- data/features/stream.feature +30 -0
- data/features/support/em.rb +14 -0
- data/features/support/env.rb +13 -0
- data/lib/vayacondios/configuration.rb +63 -0
- data/lib/vayacondios/server/api.rb +126 -0
- data/lib/vayacondios/server/api_options.rb +56 -0
- data/lib/vayacondios/server/configuration.rb +23 -0
- data/lib/vayacondios/server/driver.rb +71 -0
- data/lib/vayacondios/server/drivers/mongo.rb +126 -0
- data/lib/vayacondios/server/handlers/document_handler.rb +81 -0
- data/lib/vayacondios/server/handlers/event_handler.rb +31 -26
- data/lib/vayacondios/server/handlers/events_handler.rb +31 -0
- data/lib/vayacondios/server/handlers/stash_handler.rb +69 -0
- data/lib/vayacondios/server/handlers/stashes_handler.rb +49 -0
- data/lib/vayacondios/server/handlers/stream_handler.rb +39 -0
- data/lib/vayacondios/server/models/document.rb +87 -0
- data/lib/vayacondios/server/models/event.rb +198 -0
- data/lib/vayacondios/server/models/stash.rb +100 -0
- data/lib/vayacondios/server.rb +35 -0
- data/lib/vayacondios-server.rb +19 -13
- data/lib/vayacondios.rb +22 -0
- data/pom.xml +124 -4
- data/spec/configuration_spec.rb +41 -0
- data/spec/server/api_options_spec.rb +32 -0
- data/spec/server/api_spec.rb +279 -0
- data/spec/server/configuration_spec.rb +27 -0
- data/spec/server/drivers/mongo_spec.rb +107 -0
- data/spec/server/handlers/event_handler_spec.rb +62 -0
- data/spec/server/handlers/events_handler_spec.rb +51 -0
- data/spec/server/handlers/stash_handler_spec.rb +68 -0
- data/spec/server/handlers/stashes_handler_spec.rb +50 -0
- data/spec/server/handlers/stream_handler_spec.rb +5 -0
- data/spec/server/models/document_spec.rb +9 -0
- data/spec/server/models/event_spec.rb +185 -0
- data/spec/server/models/stash_spec.rb +95 -0
- data/spec/spec_helper.rb +23 -3
- data/spec/support/database_helper.rb +42 -0
- data/spec/support/log_helper.rb +19 -0
- data/spec/support/shared_context_for_events.rb +22 -0
- data/spec/support/shared_context_for_stashes.rb +24 -0
- data/spec/support/shared_examples_for_handlers.rb +32 -0
- data/src/main/java/com/infochimps/vayacondios/BaseClient.java +342 -0
- data/src/main/java/com/infochimps/vayacondios/HTTPClient.java +426 -0
- data/src/main/java/com/infochimps/vayacondios/VayacondiosClient.java +487 -65
- data/src/main/java/com/infochimps/vayacondios/test/IntegrationTest.java +3 -0
- data/src/test/java/com/infochimps/vayacondios/BaseClientTest.java +50 -0
- data/src/test/java/com/infochimps/vayacondios/HTTPClientIT.java +267 -0
- data/vayacondios-server.gemspec +9 -9
- metadata +127 -122
- checksums.yaml +0 -15
- data/.rspec +0 -2
- data/.yardopts +0 -10
- data/Guardfile +0 -41
- data/app/http_shim.rb +0 -71
- data/bin/vcd.sh +0 -27
- data/config/http_shim.rb +0 -43
- data/config/vayacondios.example.yaml +0 -7
- data/config/vayacondios.yaml +0 -7
- data/examples/java/ItemSetTest.java +0 -76
- data/lib/tasks/publish.rake +0 -23
- data/lib/tasks/spec.rake +0 -11
- data/lib/tasks/yard.rake +0 -2
- data/lib/vayacondios/client/config.rb +0 -7
- data/lib/vayacondios/client/configliere.rb +0 -38
- data/lib/vayacondios/client/cube_client.rb +0 -39
- data/lib/vayacondios/client/http_client.rb +0 -49
- data/lib/vayacondios/client/itemset.rb +0 -130
- data/lib/vayacondios/client/legacy_switch.rb +0 -43
- data/lib/vayacondios/client/notifier.rb +0 -123
- data/lib/vayacondios/client/zabbix_client.rb +0 -148
- data/lib/vayacondios/legacy_switch.rb +0 -43
- data/lib/vayacondios/server/errors/bad_request.rb +0 -6
- data/lib/vayacondios/server/errors/not_found.rb +0 -6
- data/lib/vayacondios/server/handlers/config_handler.rb +0 -32
- data/lib/vayacondios/server/handlers/itemset_handler.rb +0 -60
- data/lib/vayacondios/server/legacy_switch.rb +0 -43
- data/lib/vayacondios/server/model/config_document.rb +0 -89
- data/lib/vayacondios/server/model/document.rb +0 -25
- data/lib/vayacondios/server/model/event_document.rb +0 -94
- data/lib/vayacondios/server/model/itemset_document.rb +0 -126
- data/lib/vayacondios/server/rack/extract_methods.rb +0 -35
- data/lib/vayacondios/server/rack/jsonize.rb +0 -43
- data/lib/vayacondios/server/rack/params.rb +0 -50
- data/lib/vayacondios/server/rack/path.rb +0 -23
- data/lib/vayacondios/server/rack/path_validation.rb +0 -22
- data/lib/vayacondios/version.rb +0 -3
- data/lib/vayacondios-client.rb +0 -22
- data/scripts/hadoop_monitor/configurable.rb +0 -66
- data/scripts/hadoop_monitor/hadoop_attempt_scraper.rb +0 -45
- data/scripts/hadoop_monitor/hadoop_client.rb +0 -273
- data/scripts/hadoop_monitor/hadoop_monitor.rb +0 -101
- data/scripts/hadoop_monitor/hadoopable.rb +0 -65
- data/scripts/hadoop_monitor/machine_monitor.rb +0 -115
- data/scripts/s3_cataloger/buckets +0 -33
- data/scripts/s3_cataloger/foreach_bucket +0 -88
- data/scripts/s3_cataloger/parse_ls.py +0 -391
- data/spec/client/itemset_legacy_spec.rb +0 -55
- data/spec/client/itemset_spec.rb +0 -60
- data/spec/client/notifier_spec.rb +0 -120
- data/spec/server/config_spec.rb +0 -113
- data/spec/server/event_spec.rb +0 -103
- data/spec/server/itemset_legacy_spec.rb +0 -320
- data/spec/server/itemset_spec.rb +0 -317
- data/spec/server/rack/extract_methods_spec.rb +0 -60
- data/spec/server/rack/path_spec.rb +0 -36
- data/spec/server/rack/path_validation_spec.rb +0 -22
- data/spec/server/server_spec.rb +0 -20
- data/spec/support/mongo_cleaner.rb +0 -32
- data/src/main/java/ItemSetTest.java +0 -76
- data/src/main/java/com/infochimps/util/CurrentClass.java +0 -26
- data/src/main/java/com/infochimps/util/DebugUtil.java +0 -38
- data/src/main/java/com/infochimps/util/HttpHelper.java +0 -181
- data/src/main/java/com/infochimps/vayacondios/ItemSets.java +0 -373
- data/src/main/java/com/infochimps/vayacondios/LinkToVCD.java +0 -18
- data/src/main/java/com/infochimps/vayacondios/MemoryVCDShim.java +0 -84
- data/src/main/java/com/infochimps/vayacondios/Organization.java +0 -62
- data/src/main/java/com/infochimps/vayacondios/PathBuilder.java +0 -13
- data/src/main/java/com/infochimps/vayacondios/StandardVCDLink.java +0 -218
- data/src/main/java/com/infochimps/vayacondios/VCDIntegrationTest.java +0 -108
- data/src/test/java/com/infochimps/vayacondios/TestVayacondiosInMemory.java +0 -78
- data/vayacondios-client.gemspec +0 -25
@@ -0,0 +1,492 @@
|
|
1
|
+
Feature: Stashes
|
2
|
+
In order to provide functionality
|
3
|
+
As a user of the Vayacondios Api
|
4
|
+
I want to document how Stashes work
|
5
|
+
|
6
|
+
Scenario: Retrieving Missing Stashes
|
7
|
+
Given there are no matching Stashes in the database
|
8
|
+
When the client sends a GET request to "/v3/organization/stashes" with no body
|
9
|
+
Then the response status should be 200
|
10
|
+
And the response body should be:
|
11
|
+
"""
|
12
|
+
[
|
13
|
+
]
|
14
|
+
"""
|
15
|
+
|
16
|
+
Scenario: Retrieving Existing Stashes
|
17
|
+
Given the following Stash exists in the database:
|
18
|
+
"""
|
19
|
+
{
|
20
|
+
"_id": "topic",
|
21
|
+
"foo": "bar"
|
22
|
+
}
|
23
|
+
"""
|
24
|
+
And the following Stash exists in the database:
|
25
|
+
"""
|
26
|
+
{
|
27
|
+
"_id": "un_topic",
|
28
|
+
"baz": "qix"
|
29
|
+
}
|
30
|
+
"""
|
31
|
+
When the client sends a GET request to "/v3/organization/stashes" with no body
|
32
|
+
Then the response status should be 200
|
33
|
+
And the response body should be:
|
34
|
+
"""
|
35
|
+
[
|
36
|
+
{
|
37
|
+
"topic": "topic",
|
38
|
+
"foo":"bar"
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"topic": "un_topic",
|
42
|
+
"baz": "qix"
|
43
|
+
}
|
44
|
+
]
|
45
|
+
"""
|
46
|
+
|
47
|
+
Scenario: Retrieving Nested Stashes
|
48
|
+
Given the following Stash exists in the database:
|
49
|
+
"""
|
50
|
+
{
|
51
|
+
"_id": "topic",
|
52
|
+
"root": {
|
53
|
+
"b": 1
|
54
|
+
}
|
55
|
+
}
|
56
|
+
"""
|
57
|
+
When the client sends a GET request to "/v3/organization/stashes" with the following body:
|
58
|
+
"""
|
59
|
+
{
|
60
|
+
"root.b": 1
|
61
|
+
}
|
62
|
+
"""
|
63
|
+
Then the response status should be 200
|
64
|
+
And the response body should be:
|
65
|
+
"""
|
66
|
+
[
|
67
|
+
{
|
68
|
+
"topic": "topic",
|
69
|
+
"root": {
|
70
|
+
"b": 1
|
71
|
+
}
|
72
|
+
}
|
73
|
+
]
|
74
|
+
"""
|
75
|
+
|
76
|
+
Scenario: Retrieving Nested Stashes using Projection
|
77
|
+
Given the following Stash exists in the database:
|
78
|
+
"""
|
79
|
+
{
|
80
|
+
"_id": "topic",
|
81
|
+
"root": {
|
82
|
+
"a": {
|
83
|
+
"foo": "bar"
|
84
|
+
},
|
85
|
+
"b": 1
|
86
|
+
}
|
87
|
+
}
|
88
|
+
"""
|
89
|
+
When the client sends a GET request to "/v3/organization/stashes" with the following body:
|
90
|
+
"""
|
91
|
+
{
|
92
|
+
"root.b": 1,
|
93
|
+
"fields": ["root.a"]
|
94
|
+
}
|
95
|
+
"""
|
96
|
+
Then the response status should be 200
|
97
|
+
And the response body should be:
|
98
|
+
"""
|
99
|
+
[
|
100
|
+
{
|
101
|
+
"topic": "topic",
|
102
|
+
"root": {
|
103
|
+
"a": {
|
104
|
+
"foo": "bar"
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
]
|
109
|
+
"""
|
110
|
+
|
111
|
+
Scenario: Creating Stashes without a Query
|
112
|
+
Given there are no matching Stashes in the database
|
113
|
+
When the client sends a POST request to "/v3/organization/stashes" with no body
|
114
|
+
Then the response status should be 405
|
115
|
+
And the response body should be:
|
116
|
+
"""
|
117
|
+
{
|
118
|
+
"error": "Operation create not allowed for Vayacondios::Server::StashesHandler. Valid operations are [\"retrieve\", \"delete\"]"
|
119
|
+
}
|
120
|
+
"""
|
121
|
+
And there are no Stashes in the database
|
122
|
+
# Then the response status should be 400
|
123
|
+
# And the response body should be:
|
124
|
+
# """
|
125
|
+
# {
|
126
|
+
# "error": "Query cannot be empty"
|
127
|
+
# }
|
128
|
+
# """
|
129
|
+
# And there are no Stashes in the database
|
130
|
+
|
131
|
+
Scenario: Creating Stashes with a Malformed Query
|
132
|
+
Given there are no matching Stashes in the database
|
133
|
+
When the client sends a POST request to "/v3/organization/stashes" with the following body:
|
134
|
+
"""
|
135
|
+
{
|
136
|
+
"query": "busted"
|
137
|
+
}
|
138
|
+
"""
|
139
|
+
Then the response status should be 405
|
140
|
+
And the response body should be:
|
141
|
+
"""
|
142
|
+
{
|
143
|
+
"error": "Operation create not allowed for Vayacondios::Server::StashesHandler. Valid operations are [\"retrieve\", \"delete\"]"
|
144
|
+
}
|
145
|
+
"""
|
146
|
+
And there are no Stashes in the database
|
147
|
+
# Then the response status should be 400
|
148
|
+
# And the response body should be:
|
149
|
+
# """
|
150
|
+
# {
|
151
|
+
# "error": "Query must be a Hash"
|
152
|
+
# }
|
153
|
+
# """
|
154
|
+
# And there are no Stashes in the database
|
155
|
+
|
156
|
+
Scenario: Creating Stashes with an Empty Query
|
157
|
+
Given there are no matching Stashes in the database
|
158
|
+
When the client sends a POST request to "/v3/organization/stashes" with the following body:
|
159
|
+
"""
|
160
|
+
{
|
161
|
+
"query": { }
|
162
|
+
}
|
163
|
+
"""
|
164
|
+
Then the response status should be 405
|
165
|
+
And the response body should be:
|
166
|
+
"""
|
167
|
+
{
|
168
|
+
"error": "Operation create not allowed for Vayacondios::Server::StashesHandler. Valid operations are [\"retrieve\", \"delete\"]"
|
169
|
+
}
|
170
|
+
"""
|
171
|
+
And there are no Stashes in the database
|
172
|
+
# Then the response status should be 400
|
173
|
+
# And the response body should be:
|
174
|
+
# """
|
175
|
+
# {
|
176
|
+
# "error": "Query cannot be empty"
|
177
|
+
# }
|
178
|
+
# """
|
179
|
+
# And there are no Stashes in the database
|
180
|
+
|
181
|
+
Scenario: Creating Stashes when the Query does not Match
|
182
|
+
Given the following Stash exists in the database:
|
183
|
+
"""
|
184
|
+
{
|
185
|
+
"_id": "topic",
|
186
|
+
"foo": "bar"
|
187
|
+
}
|
188
|
+
"""
|
189
|
+
When the client sends a POST request to "/v3/organization/stashes" with the following body:
|
190
|
+
"""
|
191
|
+
{
|
192
|
+
"query": {
|
193
|
+
"foo": "baz"
|
194
|
+
},
|
195
|
+
"update": {
|
196
|
+
"foo": "qix"
|
197
|
+
}
|
198
|
+
}
|
199
|
+
"""
|
200
|
+
Then the response status should be 405
|
201
|
+
And the response body should be:
|
202
|
+
"""
|
203
|
+
{
|
204
|
+
"error": "Operation create not allowed for Vayacondios::Server::StashesHandler. Valid operations are [\"retrieve\", \"delete\"]"
|
205
|
+
}
|
206
|
+
"""
|
207
|
+
# Then the response status should be 200
|
208
|
+
# And the response body should be:
|
209
|
+
# """
|
210
|
+
# {
|
211
|
+
# }
|
212
|
+
# """
|
213
|
+
# And the database should have the following Stash:
|
214
|
+
# """
|
215
|
+
# {
|
216
|
+
# "_id": "topic"
|
217
|
+
# "foo": "bar"
|
218
|
+
# }
|
219
|
+
# """
|
220
|
+
|
221
|
+
Scenario: Creating Stashes when the Query does Match
|
222
|
+
Given the following Stash exists in the database:
|
223
|
+
"""
|
224
|
+
{
|
225
|
+
"_id": "topic",
|
226
|
+
"foo": "bar"
|
227
|
+
}
|
228
|
+
"""
|
229
|
+
When the client sends a POST request to "/v3/organization/stashes" with the following body:
|
230
|
+
"""
|
231
|
+
{
|
232
|
+
"query": {
|
233
|
+
"foo": "bar"
|
234
|
+
},
|
235
|
+
"update": {
|
236
|
+
"foo": "qix"
|
237
|
+
}
|
238
|
+
}
|
239
|
+
"""
|
240
|
+
Then the response status should be 405
|
241
|
+
And the response body should be:
|
242
|
+
"""
|
243
|
+
{
|
244
|
+
"error": "Operation create not allowed for Vayacondios::Server::StashesHandler. Valid operations are [\"retrieve\", \"delete\"]"
|
245
|
+
}
|
246
|
+
"""
|
247
|
+
# Then the response status should be 200
|
248
|
+
# And the response body should be:
|
249
|
+
# """
|
250
|
+
# {
|
251
|
+
# }
|
252
|
+
# """
|
253
|
+
# And the database should have the following Stash:
|
254
|
+
# """
|
255
|
+
# {
|
256
|
+
# "_id": "topic"
|
257
|
+
# "foo": "qix"
|
258
|
+
# }
|
259
|
+
# """
|
260
|
+
|
261
|
+
Scenario: Updating a non-Existent Stash with an Empty Hash
|
262
|
+
Given there are no matching Stashes in the database
|
263
|
+
When the client sends a PUT request to "/v3/organization/stashes" with no body
|
264
|
+
Then the response status should be 405
|
265
|
+
And the response body should be:
|
266
|
+
"""
|
267
|
+
{
|
268
|
+
"error": "Operation update not allowed for Vayacondios::Server::StashesHandler. Valid operations are [\"retrieve\", \"delete\"]"
|
269
|
+
}
|
270
|
+
"""
|
271
|
+
# Then the response status should be 200
|
272
|
+
# And the response body should be:
|
273
|
+
# """
|
274
|
+
# {
|
275
|
+
# }
|
276
|
+
# """
|
277
|
+
# And the database should have the following Stash:
|
278
|
+
# """
|
279
|
+
# {
|
280
|
+
# "_id": "topic"
|
281
|
+
# }
|
282
|
+
# """
|
283
|
+
|
284
|
+
Scenario: Updating non-Existent Stashes without a Query
|
285
|
+
Given there are no matching Stashes in the database
|
286
|
+
When the client sends a PUT request to "/v3/organization/stashes" with no body
|
287
|
+
Then the response status should be 405
|
288
|
+
And the response body should be:
|
289
|
+
"""
|
290
|
+
{
|
291
|
+
"error": "Operation update not allowed for Vayacondios::Server::StashesHandler. Valid operations are [\"retrieve\", \"delete\"]"
|
292
|
+
}
|
293
|
+
"""
|
294
|
+
# Then the response status should be 400
|
295
|
+
# And the response body should be:
|
296
|
+
# """
|
297
|
+
# {
|
298
|
+
# "error": "Query cannot be empty"
|
299
|
+
# }
|
300
|
+
# """
|
301
|
+
# And there are no Stashes in the database
|
302
|
+
|
303
|
+
Scenario: Updating non-Existent Stashes with a Malformed Query
|
304
|
+
Given there are no matching Stashes in the database
|
305
|
+
When the client sends a PUT request to "/v3/organization/stashes" with the following body:
|
306
|
+
"""
|
307
|
+
{
|
308
|
+
"query": "busted"
|
309
|
+
}
|
310
|
+
"""
|
311
|
+
Then the response status should be 405
|
312
|
+
And the response body should be:
|
313
|
+
"""
|
314
|
+
{
|
315
|
+
"error": "Operation update not allowed for Vayacondios::Server::StashesHandler. Valid operations are [\"retrieve\", \"delete\"]"
|
316
|
+
}
|
317
|
+
"""
|
318
|
+
# Then the response status should be 400
|
319
|
+
# And the response body should be:
|
320
|
+
# """
|
321
|
+
# {
|
322
|
+
# "error": "Query must be a Hash"
|
323
|
+
# }
|
324
|
+
# """
|
325
|
+
# And there are no Stashes in the database
|
326
|
+
|
327
|
+
Scenario: Updating non-Existent Stashes with an Empty Query
|
328
|
+
Given there are no matching Stashes in the database
|
329
|
+
When the client sends a PUT request to "/v3/organization/stashes" with the following body:
|
330
|
+
"""
|
331
|
+
{
|
332
|
+
"query": { }
|
333
|
+
}
|
334
|
+
"""
|
335
|
+
Then the response status should be 405
|
336
|
+
And the response body should be:
|
337
|
+
"""
|
338
|
+
{
|
339
|
+
"error": "Operation update not allowed for Vayacondios::Server::StashesHandler. Valid operations are [\"retrieve\", \"delete\"]"
|
340
|
+
}
|
341
|
+
"""
|
342
|
+
# Then the response status should be 400
|
343
|
+
# And the response body should be:
|
344
|
+
# """
|
345
|
+
# {
|
346
|
+
# "error": "Query cannot be empty"
|
347
|
+
# }
|
348
|
+
# """
|
349
|
+
# And there are no Stashes in the database
|
350
|
+
|
351
|
+
Scenario: Updating Existent Stashes when the Query does not Match
|
352
|
+
Given the following Stash exists in the database:
|
353
|
+
"""
|
354
|
+
{
|
355
|
+
"_id": "topic",
|
356
|
+
"foo": "bar"
|
357
|
+
}
|
358
|
+
"""
|
359
|
+
When the client sends a PUT request to "/v3/organization/stashes" with the following body:
|
360
|
+
"""
|
361
|
+
{
|
362
|
+
"query": {
|
363
|
+
"foo": "baz"
|
364
|
+
},
|
365
|
+
"update": {
|
366
|
+
"foo": "qix"
|
367
|
+
}
|
368
|
+
}
|
369
|
+
"""
|
370
|
+
Then the response status should be 405
|
371
|
+
And the response body should be:
|
372
|
+
"""
|
373
|
+
{
|
374
|
+
"error": "Operation update not allowed for Vayacondios::Server::StashesHandler. Valid operations are [\"retrieve\", \"delete\"]"
|
375
|
+
}
|
376
|
+
"""
|
377
|
+
# Then the response status should be 200
|
378
|
+
# And the response body should be:
|
379
|
+
# """
|
380
|
+
# {
|
381
|
+
# }
|
382
|
+
# """
|
383
|
+
# And the database should have the following Stash:
|
384
|
+
# """
|
385
|
+
# {
|
386
|
+
# "_id": "topic"
|
387
|
+
# "foo": "bar"
|
388
|
+
# }
|
389
|
+
# """
|
390
|
+
|
391
|
+
Scenario: Updating Existing Stashes when the Query does Match
|
392
|
+
Given the following Stash exists in the database:
|
393
|
+
"""
|
394
|
+
{
|
395
|
+
"_id": "topic",
|
396
|
+
"foo": "bar"
|
397
|
+
}
|
398
|
+
"""
|
399
|
+
When the client sends a PUT request to "/v3/organization/stashes" with the following body:
|
400
|
+
"""
|
401
|
+
{
|
402
|
+
"query": {
|
403
|
+
"foo": "bar"
|
404
|
+
},
|
405
|
+
"update": {
|
406
|
+
"foo": "qix"
|
407
|
+
}
|
408
|
+
}
|
409
|
+
"""
|
410
|
+
Then the response status should be 405
|
411
|
+
And the response body should be:
|
412
|
+
"""
|
413
|
+
{
|
414
|
+
"error": "Operation update not allowed for Vayacondios::Server::StashesHandler. Valid operations are [\"retrieve\", \"delete\"]"
|
415
|
+
}
|
416
|
+
"""
|
417
|
+
# Then the response status should be 200
|
418
|
+
# And the response body should be:
|
419
|
+
# """
|
420
|
+
# {
|
421
|
+
# }
|
422
|
+
# """
|
423
|
+
# And the database should have the following Stash:
|
424
|
+
# """
|
425
|
+
# {
|
426
|
+
# "_id": "topic"
|
427
|
+
# "foo": "qix"
|
428
|
+
# }
|
429
|
+
# """
|
430
|
+
|
431
|
+
Scenario: Deleting Stashes with an Empty Query
|
432
|
+
Given there are no matching Stashes in the database
|
433
|
+
When the client sends a DELETE request to "/v3/organization/stashes" with no body
|
434
|
+
Then the response status should be 400
|
435
|
+
And the response body should be:
|
436
|
+
"""
|
437
|
+
{
|
438
|
+
"error": "Query cannot be empty"
|
439
|
+
}
|
440
|
+
"""
|
441
|
+
|
442
|
+
Scenario: Deleting Stashes when the Query Does Not Match
|
443
|
+
Given the following Stash exists in the database:
|
444
|
+
"""
|
445
|
+
{
|
446
|
+
"_id": "topic",
|
447
|
+
"foo": "bar"
|
448
|
+
}
|
449
|
+
"""
|
450
|
+
When the client sends a DELETE request to "/v3/organization/stashes" with the following body:
|
451
|
+
"""
|
452
|
+
{
|
453
|
+
"foo": "baz"
|
454
|
+
}
|
455
|
+
"""
|
456
|
+
Then the response status should be 200
|
457
|
+
And the response body should be:
|
458
|
+
"""
|
459
|
+
{
|
460
|
+
"ok": true
|
461
|
+
}
|
462
|
+
"""
|
463
|
+
And the database should have the following Stash:
|
464
|
+
"""
|
465
|
+
{
|
466
|
+
"_id": "topic",
|
467
|
+
"foo": "bar"
|
468
|
+
}
|
469
|
+
"""
|
470
|
+
|
471
|
+
Scenario: Deleting Stashes when the Query Does Match
|
472
|
+
Given the following Stash exists in the database:
|
473
|
+
"""
|
474
|
+
{
|
475
|
+
"_id": "topic",
|
476
|
+
"foo": "bar"
|
477
|
+
}
|
478
|
+
"""
|
479
|
+
When the client sends a DELETE request to "/v3/organization/stashes" with the following body:
|
480
|
+
"""
|
481
|
+
{
|
482
|
+
"foo": "bar"
|
483
|
+
}
|
484
|
+
"""
|
485
|
+
Then the response status should be 200
|
486
|
+
And the response body should be:
|
487
|
+
"""
|
488
|
+
{
|
489
|
+
"ok": true
|
490
|
+
}
|
491
|
+
"""
|
492
|
+
And there are no Stashes in the database
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require_relative '../../spec/support/database_helper'
|
2
|
+
require_relative '../../spec/support/log_helper'
|
3
|
+
require 'em-synchrony/em-http'
|
4
|
+
|
5
|
+
include DatabaseHelper
|
6
|
+
include LogHelper
|
7
|
+
|
8
|
+
def make_request(verb, path, body = nil)
|
9
|
+
EM::Synchrony.sleep(0.1) # Make sure the db call is complete
|
10
|
+
params = { path: path }
|
11
|
+
params[:body] = MultiJson.dump(body) if body
|
12
|
+
EM::HttpRequest.new('http://localhost:3467').send(verb.to_s.downcase, params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def stash_location() 'organization.stash' ; end
|
16
|
+
def event_location(topic) "organization.#{topic}.events" ; end
|
17
|
+
|
18
|
+
Before do
|
19
|
+
db_reset!
|
20
|
+
end
|
21
|
+
|
22
|
+
Given(/^there are no matching Stashes in the database$/) do
|
23
|
+
database_count(stash_location).should == 0
|
24
|
+
end
|
25
|
+
|
26
|
+
Given(/^the following Stash exists in the database:$/) do |json|
|
27
|
+
insert_record(stash_location, MultiJson.load(json))
|
28
|
+
end
|
29
|
+
|
30
|
+
Given(/^there are no Events under topic "(.*?)" in the database$/) do |topic|
|
31
|
+
database_count(event_location topic).should == 0
|
32
|
+
end
|
33
|
+
|
34
|
+
Given(/^the following Event exists under topic "(.*?)" in the database:$/) do |topic, json|
|
35
|
+
event = MultiJson.load json
|
36
|
+
event['_t'] = Time.parse(event['_t']).round(3).utc if event.has_key?('_t')
|
37
|
+
insert_record(event_location(topic), event)
|
38
|
+
end
|
39
|
+
|
40
|
+
When(/^the client sends a (GET|POST|PUT|DELETE) request to "(.*?)" with no body$/) do |verb, path|
|
41
|
+
@response = make_request(verb, path)
|
42
|
+
end
|
43
|
+
|
44
|
+
When(/^the client sends a (GET|POST|PUT|DELETE) request to "(.*?)" with the following body:$/) do |verb, path, json|
|
45
|
+
@response = make_request(verb, path, MultiJson.load(json))
|
46
|
+
end
|
47
|
+
|
48
|
+
When(/^the client open a stream request to "(.*?)" with the following body:$/) do |path, json|
|
49
|
+
@queue = []
|
50
|
+
@response = make_request('GET', path, MultiJson.load(json))
|
51
|
+
@response.stream{ |chunk| @queue << chunk }
|
52
|
+
end
|
53
|
+
|
54
|
+
Then(/^the response status should be (\d+)$/) do |status|
|
55
|
+
@response.response_header.status.to_s.should == status
|
56
|
+
end
|
57
|
+
|
58
|
+
Then(/^the response body should be:$/) do |json|
|
59
|
+
MultiJson.load(@response.response).should == MultiJson.load(json)
|
60
|
+
end
|
61
|
+
|
62
|
+
Then(/^the response body should contain:$/) do |json|
|
63
|
+
MultiJson.load(@response.response).should include(MultiJson.load json)
|
64
|
+
end
|
65
|
+
|
66
|
+
Then(/^the response body should contain a randomly assigned Id$/) do
|
67
|
+
body = MultiJson.load @response.response
|
68
|
+
body.should have_key('id')
|
69
|
+
body['id'].should be_a(String)
|
70
|
+
body['id'].size.should_not be_zero
|
71
|
+
end
|
72
|
+
|
73
|
+
Then(/^the response body should contain a generated timestamp$/) do
|
74
|
+
body = MultiJson.load @response.response
|
75
|
+
body.should have_key('time')
|
76
|
+
body['time'].should be_a(String)
|
77
|
+
Time.parse(body['time']).should be_within(1).of(Time.now)
|
78
|
+
end
|
79
|
+
|
80
|
+
Then(/^the stream response body should be:$/) do |json|
|
81
|
+
MultiJson.load(@queue.shift).should eq(MultiJson.load json)
|
82
|
+
end
|
83
|
+
|
84
|
+
Then(/^the database should have the following Stash:$/) do |json|
|
85
|
+
retrieve_record(stash_location).should == MultiJson.load(json)
|
86
|
+
end
|
87
|
+
|
88
|
+
Then(/^there are no Stashes in the database$/) do
|
89
|
+
database_count('organization.stash').should == 0
|
90
|
+
end
|
91
|
+
|
92
|
+
Then(/^there is exactly one Event under topic "(.*?)" in the database$/) do |topic|
|
93
|
+
database_count(event_location topic).should == 1
|
94
|
+
end
|
95
|
+
|
96
|
+
Then(/^the database should have the following Event under topic "(.*?)":$/) do |topic, json|
|
97
|
+
db_event = retrieve_record(event_location topic)
|
98
|
+
db_event["_t"] = db_event["_t"].iso8601(3)
|
99
|
+
db_event.should == MultiJson.load(json)
|
100
|
+
end
|
101
|
+
|
102
|
+
Then(/^there (should|should not) be an Event with Id "(.*?)" under topic "(.*?)" in the database$/) do |assert, id, topic|
|
103
|
+
result = retrieve_record(event_location(topic), { _id: id })
|
104
|
+
if assert =~ /not/
|
105
|
+
result.should be_nil
|
106
|
+
else
|
107
|
+
result.should_not be_nil
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
After do
|
112
|
+
db_reset!
|
113
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: Stash
|
2
|
+
In order to provide functionality
|
3
|
+
As a user of the Vayacondios Api
|
4
|
+
I want to document how the Stream works
|
5
|
+
|
6
|
+
Scenario: Retrieving Events as a stream
|
7
|
+
Given the following Event exists under topic "topic" in the database:
|
8
|
+
"""
|
9
|
+
{
|
10
|
+
"_id": "id1",
|
11
|
+
"_t": "2012-02-13T12:34:42.452Z",
|
12
|
+
"_d": {
|
13
|
+
"time": "2012-02-13T12:34:42.452Z"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
"""
|
17
|
+
# When the client open a stream request to "/v2/organization/stream/topic" with the following body:
|
18
|
+
# """
|
19
|
+
# {
|
20
|
+
# "from":"2012-01-01T00:00:00.000Z"
|
21
|
+
# }
|
22
|
+
# """
|
23
|
+
# Then the response status should be 200
|
24
|
+
# And the stream response body should be:
|
25
|
+
# """
|
26
|
+
# {
|
27
|
+
# "id":"id1",
|
28
|
+
# "time": "2012-02-13T12:34:42.452Z"
|
29
|
+
# }
|
30
|
+
# """
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'vayacondios-server'
|
2
|
+
# can automate the server start if necessary
|
3
|
+
# start the vayacondios server
|
4
|
+
# api = spawn 'bundle exec vcd-server -e test'
|
5
|
+
# puts 'Waiting for Vayacondios Server to start'
|
6
|
+
# sleep 2
|
7
|
+
|
8
|
+
# # stop the vayacondios server
|
9
|
+
# at_exit do
|
10
|
+
# Process.kill('KILL', api)
|
11
|
+
# Process.wait api
|
12
|
+
# end
|
13
|
+
|