infinispan 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +1 -1
  2. package/package.json +7 -6
  3. package/.eslintrc +0 -25
  4. package/.flowconfig +0 -6
  5. package/Jenkinsfile +0 -50
  6. package/Jenkinsfile-release +0 -63
  7. package/documentation/asciidoc/stories/assembly_client_usage_examples.adoc +0 -10
  8. package/documentation/asciidoc/stories/assembly_installation_configuration.adoc +0 -20
  9. package/documentation/asciidoc/titles/js_client.asciidoc +0 -28
  10. package/documentation/asciidoc/titles/stories.adoc +0 -5
  11. package/documentation/asciidoc/topics/attributes/community-attributes.adoc +0 -9
  12. package/documentation/asciidoc/topics/attributes/downstream-attributes.adoc +0 -2
  13. package/documentation/asciidoc/topics/code_examples/authentication-digest.js +0 -12
  14. package/documentation/asciidoc/topics/code_examples/authentication-external.js +0 -15
  15. package/documentation/asciidoc/topics/code_examples/authentication-oauthbearer.js +0 -10
  16. package/documentation/asciidoc/topics/code_examples/authentication-plain.js +0 -11
  17. package/documentation/asciidoc/topics/code_examples/authentication-scram.js +0 -11
  18. package/documentation/asciidoc/topics/code_examples/await-multiple-entries.js +0 -36
  19. package/documentation/asciidoc/topics/code_examples/await-single-entries.js +0 -29
  20. package/documentation/asciidoc/topics/code_examples/conditional-operations.js +0 -57
  21. package/documentation/asciidoc/topics/code_examples/connection-multiple-servers.js +0 -23
  22. package/documentation/asciidoc/topics/code_examples/connection-xsite-cluster-switch.js +0 -39
  23. package/documentation/asciidoc/topics/code_examples/connection-xsite.js +0 -13
  24. package/documentation/asciidoc/topics/code_examples/data-types.js +0 -30
  25. package/documentation/asciidoc/topics/code_examples/encryption-crypto-store.js +0 -11
  26. package/documentation/asciidoc/topics/code_examples/encryption-private-key.js +0 -13
  27. package/documentation/asciidoc/topics/code_examples/encryption-sni-hostname.js +0 -9
  28. package/documentation/asciidoc/topics/code_examples/encryption-trust-certs.js +0 -8
  29. package/documentation/asciidoc/topics/code_examples/ephemeral-data.js +0 -52
  30. package/documentation/asciidoc/topics/code_examples/hello-world.js +0 -42
  31. package/documentation/asciidoc/topics/code_examples/key-value-converter.js +0 -67
  32. package/documentation/asciidoc/topics/code_examples/logging-configuration.js +0 -2
  33. package/documentation/asciidoc/topics/code_examples/multiple-entries.js +0 -64
  34. package/documentation/asciidoc/topics/code_examples/queries.js +0 -92
  35. package/documentation/asciidoc/topics/code_examples/register-event-listener.js +0 -64
  36. package/documentation/asciidoc/topics/code_examples/sample-script-execute.js +0 -33
  37. package/documentation/asciidoc/topics/code_examples/sample-script.js +0 -3
  38. package/documentation/asciidoc/topics/code_examples/single-entries.js +0 -49
  39. package/documentation/asciidoc/topics/config_examples/logging.json +0 -14
  40. package/documentation/asciidoc/topics/proc_configuring_authentication.adoc +0 -16
  41. package/documentation/asciidoc/topics/proc_configuring_connections.adoc +0 -25
  42. package/documentation/asciidoc/topics/proc_configuring_connections_xsite.adoc +0 -18
  43. package/documentation/asciidoc/topics/proc_configuring_data_formats.adoc +0 -30
  44. package/documentation/asciidoc/topics/proc_configuring_encryption.adoc +0 -15
  45. package/documentation/asciidoc/topics/proc_configuring_logging.adoc +0 -28
  46. package/documentation/asciidoc/topics/proc_installing_clients.adoc +0 -58
  47. package/documentation/asciidoc/topics/proc_switching_clusters.adoc +0 -17
  48. package/documentation/asciidoc/topics/ref_authentication_mechanisms.adoc +0 -68
  49. package/documentation/asciidoc/topics/ref_client_usage.adoc +0 -128
  50. package/documentation/asciidoc/topics/ref_encryption.adoc +0 -71
  51. package/gen-jsdoc.sh +0 -6
  52. package/make-ssl.sh +0 -335
  53. package/memory-profiling/helper.js +0 -9
  54. package/memory-profiling/infinispan_memory_many_get.js +0 -50
  55. package/memory-profiling/infinispan_memory_one_get.js +0 -56
  56. package/release.sh +0 -19
  57. package/run-servers.sh +0 -171
  58. package/run-testsuite.sh +0 -6
  59. package/server/.keep +0 -0
  60. package/set-npm-auth-token.sh +0 -4
  61. package/smoke-tests.sh +0 -21
  62. package/spec/codec_spec.js +0 -224
  63. package/spec/configs/clean/infinispan.xml +0 -55
  64. package/spec/configs/infinispan-clustered.xml +0 -63
  65. package/spec/configs/infinispan-ssl.xml +0 -115
  66. package/spec/configs/infinispan-xsite-EARTH.xml +0 -187
  67. package/spec/configs/infinispan-xsite-MOON.xml +0 -189
  68. package/spec/configs/infinispan.xml +0 -77
  69. package/spec/functional_spec.js +0 -73
  70. package/spec/infinispan_auth_spec.js +0 -19
  71. package/spec/infinispan_cluster_spec.js +0 -176
  72. package/spec/infinispan_expiry_spec.js +0 -218
  73. package/spec/infinispan_failover_listener_spec.js +0 -52
  74. package/spec/infinispan_failover_spec.js +0 -63
  75. package/spec/infinispan_json_spec.js +0 -182
  76. package/spec/infinispan_local_spec.js +0 -354
  77. package/spec/infinispan_ssl_spec.js +0 -442
  78. package/spec/infinispan_stress_spec.js +0 -32
  79. package/spec/infinispan_xsite_spec.js +0 -99
  80. package/spec/protocols_spec.js +0 -82
  81. package/spec/protostream_spec.js +0 -237
  82. package/spec/tests.js +0 -28
  83. package/spec/utils/test-log4js.json +0 -14
  84. package/spec/utils/testing.js +0 -762
  85. package/spec/utils/typed-cachemanager-put-get.js +0 -3
  86. package/spec/utils/typed-null-return-dist.js +0 -2
  87. package/spec/utils/typed-null-return.js +0 -2
  88. package/spec/utils/typed-put-get-dist.js +0 -3
  89. package/spec/utils/typed-put-get-unicode.js +0 -3
  90. package/spec/utils/typed-put-get.js +0 -3
  91. package/spec/utils/typed-size.js +0 -2
  92. package/spec/utils_spec.js +0 -154
  93. package/spec-manual/infinispan_manual_stress_get_spec.js +0 -50
  94. package/spec-manual/infinispan_manual_stress_iterate_spec.js +0 -86
@@ -1,442 +0,0 @@
1
- var _ = require('underscore');
2
-
3
- var util = require('util');
4
-
5
- var t = require('./utils/testing'); // Testing dependency
6
-
7
- describe('Infinispan TLS/SSL client', function() {
8
-
9
- it('can operate on data via trusted encrypted transport',
10
- testSsl('trust', t.ssl, sslTrust())
11
- );
12
-
13
- it('can operate on data via crypto store trusted encrypted transport',
14
- testSsl('trust-cryptostore', t.ssl, sslTrustCryptoStore())
15
- );
16
-
17
- it('can operate on data via authenticated encrypted transport',
18
- testSsl('auth', t.ssl, sslAuth())
19
- );
20
-
21
- it('can operate on data via SNI trusted encrypted transport',
22
- testSsl('sni-trusted', t.ssl, sslSniTrusted())
23
- );
24
-
25
- it('can operate on data via SNI trusted encrypted transport while having multiple identities',
26
- testSsl('sni-trusted', t.ssl, sslSniTrustedInCaseOfMultipleTrustedSni())
27
- );
28
-
29
- it('fails to operate if default server name (SNI) does not match default server realm',
30
- testError(expectContainsAnyErrors(["self signed certificate in certificate chain", "self-signed certificate in certificate chain"]),
31
- sslSniDefault())
32
- );
33
-
34
- it('fails to operate if server name (SNI) and trusted certificate are incorrect',
35
- testError(
36
- expectAnyExactErrors(
37
- ['CERT_SIGNATURE_FAILURE'
38
- , 'certificate signature failure'
39
- , 'self signed certificate in certificate chain'
40
- , 'self-signed certificate in certificate chain'
41
- ])
42
- , sslSniUntrusted()
43
- )
44
- );
45
-
46
- it('fails to operate if no passphrase provided for crypto store',
47
- testError(expectAnyExactErrors(['No passphrase defined for crypto store']),
48
- sslStoreNoPassphrase())
49
- );
50
-
51
- it('fails to operate if no path provided for crypto store',
52
- testError(expectAnyExactErrors(['No path defined for crypto store']),
53
- sslStoreNoPath())
54
- );
55
-
56
- it('fails to operate if no encrypted transport is provided',
57
- testError(expectAnyExactErrors(['self signed certificate in certificate chain', 'self-signed certificate in certificate chain']),
58
- sslStoreNoCryptoStore())
59
- );
60
-
61
- // it('fails to operate if key for authenticated encrypted transport is missing',
62
- // testError(expectAnyExactErrors(['CERT_SIGNATURE_FAILURE', 'self signed certificate']),
63
- // sslAuthWithMissingKey())
64
- // );
65
- //
66
- // it('fails to operate if passphrase for authenticated encrypted transport is missing',
67
- // testError(expectAnyExactErrors(['CERT_SIGNATURE_FAILURE', 'self signed certificate']),
68
- // sslAuthWithMissingPassphrase())
69
- // );
70
-
71
- // it('fails to operate if cert path for authenticated encrypted transport is missing',
72
- // testError(expectAnyExactErrors(['CERT_SIGNATURE_FAILURE', 'self signed certificate']),
73
- // sslAuthWithMissingCert())
74
- // );
75
-
76
- // it('fails to operate if authenticated encrypted transport is missing',
77
- // testError(expectAnyExactErrors(['CERT_SIGNATURE_FAILURE', 'self signed certificate']),
78
- // sslAuthWithMissingInfo())
79
- // );
80
-
81
- it('fails to operate if trusted certificate is missing for authenticated encrypted transport',
82
- testError(expectAnyExactErrors(['self signed certificate in certificate chain', 'self-signed certificate in certificate chain']),
83
- sslAuthWithMissingTrustCertificate())
84
- );
85
-
86
- function testSsl(infix, addr, sslOpts) {
87
- var k = util.format('ssl-%s-key', infix);
88
- var v = util.format('ssl-%s-value', infix);
89
- return function(done) {
90
- t.client(addr, sslOpts)
91
- .then(t.assert(t.put(k, v)))
92
- .then(t.assert(t.get(k), t.toBe(v)))
93
- .then(t.disconnect())
94
- .catch(t.failed(done))
95
- .finally(done);
96
- }
97
- }
98
-
99
- function sslTrust() {
100
- return {
101
- ssl: {
102
- enabled: true,
103
- secureProtocol: 'TLS_client_method',
104
- trustCerts: ['out/ssl/ca/ca.pem']
105
- },
106
- authentication: {
107
- enabled: true,
108
- saslMechanism: 'PLAIN',
109
- userName: 'admin',
110
- password: 'pass'
111
- }
112
- }
113
- }
114
-
115
- function sslTrustCryptoStore() {
116
- return {
117
- ssl: {
118
- enabled: true,
119
- secureProtocol: 'TLS_client_method',
120
- cryptoStore: {
121
- path: 'out/ssl/client/client.p12',
122
- passphrase: 'secret'
123
- }
124
- },
125
- authentication: {
126
- enabled: true,
127
- saslMechanism: 'PLAIN',
128
- userName: 'admin',
129
- password: 'pass'
130
- }
131
- }
132
- }
133
-
134
- function sslAuth() {
135
- return {
136
- ssl: {
137
- enabled: true,
138
- trustCerts: ['out/ssl/ca/ca.pem'],
139
- clientAuth: {
140
- key: 'out/ssl/client/client.pk',
141
- passphrase: 'secret',
142
- cert: 'out/ssl/client/client.pem'
143
- }
144
- },
145
- authentication: {
146
- enabled: true,
147
- saslMechanism: 'PLAIN',
148
- userName: 'admin',
149
- password: 'pass'
150
- }
151
- }
152
- }
153
-
154
- function sslSniTrusted() {
155
- return {
156
- ssl: {
157
- enabled: true,
158
- trustCerts: ['out/ssl/ca/ca.pem'],
159
- sniHostName: 'localhost'
160
- },
161
- authentication: {
162
- enabled: true,
163
- saslMechanism: 'PLAIN',
164
- userName: 'admin',
165
- password: 'pass'
166
- }
167
- }
168
- }
169
-
170
- function sslSniTrustedInCaseOfMultipleTrustedSni() {
171
- return {
172
- ssl: {
173
- enabled: true,
174
- trustCerts: ['out/ssl/ca/ca.pem'],
175
- sniHostName: 'localhost'
176
- },
177
- authentication: {
178
- enabled: true,
179
- saslMechanism: 'PLAIN',
180
- userName: 'admin',
181
- password: 'pass'
182
- }
183
- }
184
- }
185
-
186
- function sslSniDefault() {
187
- return {
188
- ssl: {
189
- enabled: true,
190
- trustCerts: ['out/ssl/untrust-ca/untrust-ca.pem'],
191
- sniHostName: 'trustfail'
192
- },
193
- authentication: {
194
- enabled: true,
195
- saslMechanism: 'PLAIN',
196
- userName: 'admin',
197
- password: 'pass'
198
- }
199
- }
200
- }
201
-
202
- function sslSniDefaultWithTrustedCertificate() {
203
- return {
204
- ssl: {
205
- enabled: true,
206
- trustCerts: ['out/ssl/ca/ca.pem'],
207
- },
208
- authentication: {
209
- enabled: true,
210
- saslMechanism: 'PLAIN',
211
- userName: 'admin',
212
- password: 'pass'
213
- }
214
- }
215
- }
216
-
217
- function sslSniUntrusted() {
218
- return {
219
- ssl: {
220
- enabled: true,
221
- trustCerts: ['out/ssl/untrust-ca/untrust-ca.pem'],
222
- sniHostName: "untrust"
223
- },
224
- authentication: {
225
- enabled: true,
226
- saslMechanism: 'PLAIN',
227
- userName: 'admin',
228
- password: 'pass'
229
- }
230
- }
231
- }
232
-
233
- function testError(errF, sslOpts) {
234
- return function(done) {
235
- t.client(t.ssl, sslOpts)
236
- .then(shouldFail())
237
- .catch(errF(done))
238
- .finally(done);
239
- }
240
- }
241
-
242
- function shouldFail() {
243
- return function(client) {
244
- var disconnect = client.disconnect();
245
- return disconnect.finally(function() {
246
- throw Error('Expected operation to fail');
247
- });
248
- }
249
- }
250
-
251
- function expectError(msg) {
252
- return function(err) {
253
- expect(err.message).toBe(msg);
254
- }
255
- }
256
-
257
- function expectContainsAnyErrors(msg) {
258
- return function(done) {
259
- return function(err) {
260
- toContainAnyOf(msg, err, done);
261
- }
262
- }
263
- }
264
-
265
- function expectAnyExactErrors(msgs) {
266
- return function(done) {
267
- return function(err) {
268
- toBeAnyOf(msgs, err, done);
269
- }
270
- }
271
- }
272
-
273
- function sslStoreNoPassphrase() {
274
- return {
275
- ssl: {
276
- enabled: true,
277
- cryptoStore: {
278
- path: 'out/ssl/client/client.p12'
279
- }
280
- },
281
- authentication: {
282
- enabled: true,
283
- saslMechanism: 'PLAIN',
284
- userName: 'admin',
285
- password: 'pass'
286
- }
287
- }
288
- }
289
-
290
- function sslStoreNoPath() {
291
- return {
292
- ssl: {
293
- enabled: true,
294
- cryptoStore: {}
295
- },
296
- authentication: {
297
- enabled: true,
298
- saslMechanism: 'PLAIN',
299
- userName: 'admin',
300
- password: 'pass'
301
- }
302
- }
303
- }
304
-
305
- function sslStoreNoCryptoStore() {
306
- return {
307
- ssl: {
308
- enabled: true
309
- },
310
- authentication: {
311
- enabled: true,
312
- saslMechanism: 'PLAIN',
313
- userName: 'admin',
314
- password: 'pass'
315
- }
316
- }
317
- }
318
-
319
- function sslSniWithNoCert() {
320
- return {
321
- ssl: {
322
- enabled: true,
323
- sniHostName: "untrust"
324
- },
325
- authentication: {
326
- enabled: true,
327
- saslMechanism: 'PLAIN',
328
- userName: 'admin',
329
- password: 'pass'
330
- }
331
- }
332
- }
333
-
334
- function sslAuthWithMissingKey() {
335
- return {
336
- ssl: {
337
- enabled: true,
338
- trustCerts: ['out/ssl/ca/ca.pem'],
339
- clientAuth: {
340
- passphrase: 'secret',
341
- cert: 'out/ssl/client/client.pem'
342
- },
343
- authentication: {
344
- enabled: true,
345
- saslMechanism: 'PLAIN',
346
- userName: 'admin',
347
- password: 'pass'
348
- }
349
- }
350
- }
351
- }
352
-
353
- function sslAuthWithMissingPassphrase() {
354
- return {
355
- ssl: {
356
- enabled: true,
357
- trustCerts: ['out/ssl/ca/ca.pem'],
358
- clientAuth: {
359
- key: 'out/ssl/client/client.pk',
360
- cert: 'out/ssl/client/client.pem'
361
- },
362
- authentication: {
363
- enabled: true,
364
- saslMechanism: 'PLAIN',
365
- userName: 'admin',
366
- password: 'pass'
367
- }
368
- }
369
- }
370
- }
371
-
372
- function sslAuthWithMissingCert() {
373
- return {
374
- ssl: {
375
- enabled: true,
376
- trustCerts: ['out/ssl/ca/ca.pem'],
377
- clientAuth: {
378
- key: 'out/ssl/client/client.pk',
379
- passphrase: 'secret'
380
- }
381
- },
382
- authentication: {
383
- enabled: true,
384
- saslMechanism: 'PLAIN',
385
- userName: 'admin',
386
- password: 'pass'
387
- }
388
- }
389
- }
390
-
391
- function sslAuthWithMissingInfo() {
392
- return {
393
- ssl: {
394
- enabled: true,
395
- trustCerts: ['out/ssl/ca/ca.pem'],
396
- clientAuth: {}
397
- },
398
- authentication: {
399
- enabled: true,
400
- saslMechanism: 'PLAIN',
401
- userName: 'admin',
402
- password: 'pass'
403
- }
404
- }
405
- }
406
-
407
- function sslAuthWithMissingTrustCertificate() {
408
- return {
409
- ssl: {
410
- enabled: true,
411
- clientAuth: {
412
- key: 'out/ssl/client/client.pk',
413
- passphrase: 'secret',
414
- cert: 'out/ssl/client/client.pem'
415
- }
416
- },
417
- authentication: {
418
- enabled: true,
419
- saslMechanism: 'PLAIN',
420
- userName: 'admin',
421
- password: 'pass'
422
- }
423
- }
424
- }
425
-
426
- function toBeAnyOf(expecteds, actual, done) {
427
- for (var i = 0, l = expecteds.length; i < l; i++) {
428
- if (_.isEqual(actual.message, expecteds[i]))
429
- return;
430
- }
431
- done(new Error('[' + actual.message + '] is not any of: [' + expecteds + ']'));
432
- }
433
-
434
- function toContainAnyOf(expecteds, actual, done) {
435
- for (var i = 0, l = expecteds.length; i < l; i++) {
436
- if (actual.message.includes(expecteds[i]))
437
- return;
438
- }
439
- done(new Error('[' + actual.message + '] does not contain any of: [' + expecteds + ']'));
440
- }
441
-
442
- });
@@ -1,32 +0,0 @@
1
- var _ = require('underscore');
2
-
3
- var t = require('./utils/testing'); // Testing dependency
4
-
5
- describe('Infinispan local client under stress load', function() {
6
- var client = t.client(t.local, t.authOpts);
7
-
8
- beforeEach(function(done) { client
9
- .then(t.assert(t.clear()))
10
- .catch(t.failed(done)).finally(done);
11
- });
12
-
13
- it('can do multiple puts continuously and only wait at the end', function(done) {
14
- client.then(function(cl) {
15
- var puts = _.map(_.range(1000), function(i) {
16
- return cl.put(i + '', i + '');
17
- });
18
-
19
- return Promise.all(puts)
20
- .catch(t.failed(done))
21
- .finally(done);
22
- })
23
- });
24
-
25
- // Since Jasmine 1.3 does not have afterAll callback, this disconnect test must be last
26
- it('disconnects client', function(done) { client
27
- .then(t.disconnect())
28
- .catch(t.failed(done))
29
- .finally(done);
30
- });
31
-
32
- });
@@ -1,99 +0,0 @@
1
- var _ = require('underscore');
2
-
3
- var t = require('./utils/testing'); // Testing dependency
4
- var u = require('../lib/utils');
5
-
6
- var logger = u.logger('xsite-test');
7
-
8
- describe('Infinispan xsite cluster client', function() {
9
-
10
- // Since Jasmine 1.3 does not have beforeAll callback, execute
11
- // any cleanup as first test so that it only gets executed once.
12
- it('start sites', function(done) {
13
- logger.debugf("Starting servers for xsite replication tests.");
14
- t.launchClusterNodeAndWaitView('server-earth', t.earth1Config, t.earth1['port'], t.earth1MCastAddr, 1, t.client)
15
- .then(function(client) {return t.launchClusterNodeAndWaitView('server-moon', t.moon1Config, t.moon1['port'], t.moon1MCastAddr, 1, client);})
16
- .then(function () {
17
- logger.debugf("Both moon and earth servers started");
18
- }).catch(t.failed(done)).finally(done);
19
- }, 15000);
20
-
21
- it('can manually switch and fail over sites', function(done) {
22
- siteClients().then(function(cs) {
23
- expect(cs[0].getTopologyInfo().getMembers()).toEqual([t.earth1]);
24
- expect(cs[1].getTopologyInfo().getMembers()).toEqual([t.moon1]);
25
- return cs[0].getTopologyInfo().switchToCluster('server-moon')
26
- .then(function() {
27
- expect(cs[0].getTopologyInfo().getMembers()).toEqual([t.moon1]);
28
- return cs[0].getTopologyInfo().switchToDefaultCluster();
29
- })
30
- .then(function() {
31
- expect(cs[0].getTopologyInfo().getMembers()).toEqual([t.earth1]);
32
- return cs[0].put('xsite-key', 'xsite-value');
33
- })
34
- .then(assertGet('xsite-key', 'xsite-value', cs[0]))
35
- .then(assertGet('xsite-key', 'xsite-value', cs[1]))
36
- .then(t.stopClusterNode(t.earth1['port'], true))
37
- // Client connected to surviving site should find data
38
- .then(assertGet('xsite-key', 'xsite-value', cs[1]))
39
- // Client connected to crashed site should failover
40
- .then(assertGet('xsite-key', 'xsite-value', cs[0]))
41
- .then(function() {
42
- expect(cs[0].getTopologyInfo().getMembers()).toEqual([t.moon1]);
43
- expect(cs[1].getTopologyInfo().getMembers()).toEqual([t.moon1]);
44
- })
45
- // Re-launch site stopped site and stop alive site
46
- .then(assertGet('xsite-key', 'xsite-value', cs[0]))
47
- .then(function(client) { return t.launchClusterNodeAndWaitView('server-earth', t.earth1Config, t.earth1['port'], t.earth1MCastAddr, 1, client); })
48
- .then(t.stopClusterNode(t.moon1['port'], true))
49
- // Client connected to failed over site should come back to original site
50
- .then(assertGet('xsite-key', undefined, cs[0]))
51
- .then(function() {
52
- expect(cs[0].getTopologyInfo().getMembers()).toEqual([t.earth1]);
53
- })
54
- .then(function() {
55
- return cs[0].put('xsite-key-2', 'xsite-value-2');
56
- })
57
- .then(assertGet('xsite-key-2', 'xsite-value-2', cs[0]))
58
- //Stopping the rest of the servers to finish the test
59
- .then(t.stopClusterNode(t.earth1['port'], true))
60
- .finally(function() {
61
- return Promise.all(_.map(cs, function(c) { return c.disconnect(); }));
62
- });
63
- })
64
- .catch(t.failed(done)).finally(done);
65
- }, 15000);
66
-
67
- });
68
-
69
- function assertGet(k, expected, client) {
70
- return function() {
71
- return client.get(k)
72
- .then(function(v) {
73
- expect(v).toBe(expected);
74
- })
75
- }
76
- }
77
-
78
- function clusterSiteMoon() {
79
- return {
80
- cacheName: t.xsiteCacheName,
81
- authentication: t.authOpts.authentication,
82
- clusters: [
83
- {
84
- name: 'server-moon',
85
- servers: [t.moon1]
86
- }
87
- ]
88
- };
89
- }
90
-
91
- function siteClients() {
92
- return Promise.all([
93
- t.client(t.earth1, clusterSiteMoon()),
94
- t.client(t.moon1, {cacheName:
95
- t.xsiteCacheName,
96
- authentication: t.authOpts.authentication
97
- })
98
- ]);
99
- }
@@ -1,82 +0,0 @@
1
- 'use strict';
2
-
3
- var _ = require('underscore');
4
- var f = require('../lib/functional');
5
- var codec = require('../lib/codec');
6
-
7
- var t = require('./utils/testing'); // Testing dependency
8
-
9
- var singleExpiryDecode = f.actions([codec.decodeUByte(), codec.decodeVLong()], codec.allDecoded(2));
10
- var constantExpiryDecode = f.actions([codec.decodeUByte()], codec.allDecoded(1));
11
-
12
- function lifespan(unit) { return unit << 4 | 0x07; }
13
- function maxIdle(unit) { return 0x70 | unit; }
14
-
15
- function object(name) {
16
- return function(value) {
17
- return _.object([name], [value]);
18
- }
19
- }
20
-
21
- describe('Protocols', function() {
22
- var p = t.protocol25();
23
-
24
- it('can encode/decode lifespan', function() {
25
- encodeDecodeUnits('lifespan', lifespan);
26
- });
27
- it('can encode/decode max idle', function() {
28
- encodeDecodeUnits('maxIdle', maxIdle);
29
- });
30
- it('connects with undefined HotRod Protocol', function (done) {
31
- t.expectToThrow(function () {
32
- t.client(t.local_notsecured, {version: '1.1'});
33
- }, 'Unknown protocol version: 1.1', done);
34
- });
35
- it('can handle different protocols at the same time', function() {
36
- var p1 = t.protocol29({
37
- dataFormat : {
38
- keyType: 'text/plain',
39
- valueType: 'text/plain'
40
- }
41
- });
42
- var p2 = t.protocol29({
43
- dataFormat : {
44
- keyType: 'application/json',
45
- valueType: 'application/json'
46
- }
47
- });
48
-
49
- expect(p1.clientOpts.dataFormat.keyType).toEqual('text/plain');
50
- expect(p1.getKeyMediaType()).toEqual('text/plain');
51
- expect(p1.getValueMediaType()).toEqual('text/plain');
52
-
53
- expect(p2.clientOpts.dataFormat.keyType).toEqual('application/json');
54
- expect(p2.getKeyMediaType()).toEqual('application/json');
55
- expect(p2.getValueMediaType()).toEqual('application/json');
56
- });
57
-
58
- function encodeDecodeUnits(name, converter) {
59
- var exp = object(name);
60
- encodeDecodeSingleNumericExpiry(exp('777777777d'), 777777777, converter(0x06));
61
- encodeDecodeSingleNumericExpiry(exp('66666666h'), 66666666, converter(0x05));
62
- encodeDecodeSingleNumericExpiry(exp('5555555m'), 5555555, converter(0x04));
63
- encodeDecodeSingleNumericExpiry(exp('444444s'), 444444, converter(0x00));
64
- encodeDecodeSingleNumericExpiry(exp('33333ms'), 33333, converter(0x01));
65
- encodeDecodeSingleNumericExpiry(exp('2222μs'), 2222, converter(0x03));
66
- encodeDecodeSingleNumericExpiry(exp('111ns'), 111, converter(0x02));
67
- encodeDecodeSingleConstantExpiry(exp(0), converter(0x07));
68
- encodeDecodeSingleConstantExpiry(exp(-1), converter(0x08));
69
- }
70
-
71
- function encodeDecodeSingleNumericExpiry(expiry, duration, unit) {
72
- var encoder = f.actions(p.encodeExpiry(expiry), codec.bytesEncoded);
73
- var bytebuf = t.assertEncode(t.newByteBuf(), encoder, t.vNumSize(duration) + 1);
74
- expect(singleExpiryDecode({buf: bytebuf.buf, offset: 0})).toEqual([unit, duration]);
75
- }
76
-
77
- function encodeDecodeSingleConstantExpiry(expiry, unit) {
78
- var encoder = f.actions(p.encodeExpiry(expiry), codec.bytesEncoded);
79
- var bytebuf = t.assertEncode(t.newByteBuf(), encoder, 1);
80
- expect(constantExpiryDecode({buf: bytebuf.buf, offset: 0})).toEqual([unit]);
81
- }
82
- });