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,73 +0,0 @@
1
- var _ = require('underscore');
2
- var f = require('../lib/functional');
3
-
4
- function div(n, d) { return n / d }
5
- function performSomeCalculation(a, b, c) {
6
- return (a + b) / c;
7
- }
8
-
9
- describe('Partial function application', function() {
10
- it('works with 2 parameters', function() {
11
- var div10By2 = f.partial2(div, 10, 2);
12
- expect(div10By2()).toBe(5);
13
- });
14
- it('works with 3 parameters', function() {
15
- var action = f.partial3(performSomeCalculation, 10, 2, 3);
16
- expect(action()).toBe(4);
17
- });
18
- });
19
-
20
- describe('Curried function application', function() {
21
- it('works with 2 parameters', function() {
22
- var div10By2 = f.curry2(div)(2)(10);
23
- expect(div10By2).toBe(5);
24
- });
25
- it('works with 3 parameters', function() {
26
- var action = f.curry3(performSomeCalculation)(3)(2)(10);
27
- expect(action).toBe(4);
28
- });
29
- });
30
-
31
- function sqr(n) { return n * n; }
32
- var mSqr = f.lift(sqr);
33
-
34
- var push = f.lift(function(stack, e) { return f.construct(e, stack) });
35
- var pop = f.lift(_.first, _.rest);
36
-
37
- describe('State-bearing action pipeline', function() {
38
- it('can pipeline calculating square twice', function() {
39
- var doubleSqr = f.actions([mSqr(), mSqr()],
40
- function(_, state) {
41
- return state;
42
- });
43
- expect(doubleSqr(10)).toBe(10000); // 10 * 10 -> 100; 100 * 100 -> 10000
44
- });
45
- it('can pipeline queue push and pop functions', function() {
46
- var stackAction = f.actions([push(1), push(2), pop()],
47
- function(values, state) {
48
- return values;
49
- });
50
- expect(stackAction([])).toEqual([[1], [2, 1], 2]);
51
- });
52
- });
53
-
54
- describe('Partial functions', function() {
55
- it('can be used to run preconditions for functions', function() {
56
- var sqrPre = f.condition1(
57
- f.validator('arg must be a number', _.isNumber));
58
- function uncheckedSqr(n) { return n * n }
59
- var checkedSqr = f.partial1(sqrPre, uncheckedSqr);
60
- expect(checkedSqr(10)).toBe(100);
61
- });
62
- });
63
-
64
- describe('Array concatenation', function() {
65
- it('can be used to concatenate arrays', function() {
66
- var a1 = [1,2,3];
67
- var a2 = [4,5,6];
68
- expect(f.cat(a1, a2)).toEqual([1,2,3,4,5,6]);
69
- });
70
- it('tests cat method if no parameter is passed', function() {
71
- expect(f.cat()).toEqual([]);
72
- });
73
- });
@@ -1,19 +0,0 @@
1
- var t = require('./utils/testing'); // Testing dependency
2
-
3
- describe('Infinispan local client', function () {
4
- [ 'SCRAM-SHA-1', 'SCRAM-SHA-256', 'SCRAM-SHA-384', 'SCRAM-SHA-512', 'PLAIN', 'DIGEST-MD5'].forEach(m =>
5
- it(m, function (done) {
6
- t.client(t.local, {
7
- authentication: {
8
- enabled: true,
9
- saslMechanism: m,
10
- userName: 'admin',
11
- password: 'pass'
12
- }
13
- })
14
- .then(t.assert(t.put('key', 'value')))
15
- .then(t.disconnect())
16
- .catch(t.failed(done))
17
- .finally(done);
18
- }));
19
- });
@@ -1,176 +0,0 @@
1
- var _ = require('underscore');
2
-
3
- var f = require('../lib/functional');
4
- var t = require('./utils/testing'); // Testing dependency
5
- var tests = require('./tests'); // Shared tests
6
-
7
- describe('Infinispan cluster client', function() {
8
- var client = t.client(t.cluster1, t.authOpts);
9
-
10
- // Since Jasmine 1.3 does not have beforeAll callback and stats resets is a
11
- // bit slow, execute it as first test so that it only gets executed once.
12
- // @TODO Uncomment and fix this method when ISPN-10777 is implemented and available in JDG server.
13
- /*it('resets statistics', function(done) { client
14
- .then(t.resetStats)
15
- .then(t.assert(t.clear()))
16
- .catch(t.failed(done)).finally(done);
17
- });*/
18
-
19
- it('can get cluster topology from a server node', function(done) { client
20
- .then(t.assert(t.getMembers(), t.toContain(t.cluster)))
21
- .catch(t.failed(done)).finally(done);
22
- });
23
-
24
- it('can use consistent hashing to direct key-based ops to owner nodes', function(done) { client
25
- .then(routeConsistentHash())
26
- .catch(t.failed(done)).finally(done);
27
- });
28
-
29
-
30
- it('can load balance key-less operations in round-robin fashion', function(done) { client
31
- .then(routeRoundRobin())
32
- .then(t.assert(t.clear()))
33
- .catch(t.failed(done)).finally(done);
34
- });
35
-
36
- it('can iterate over entries in a cluster, one entry at the time',
37
- tests.iterateEntries('cluster', 1, client)
38
- );
39
-
40
- it('can iterate over entries in a cluster, more than one entry at the time',
41
- tests.iterateEntries('cluster', 3, client)
42
- );
43
-
44
- it('can remove listener in cluster', function(done) { client
45
- .then(t.assert(t.clear()))
46
- .then(t.on('create', t.expectEvent('listen-distinct-1', done, false, 'v1')))
47
- .then(t.assert(t.putIfAbsent('listen-distinct-1', 'v1'), t.toBeTruthy))
48
- .then(t.on('create', t.expectEvent('listen-distinct-2', done, true, 'v2')))
49
- .then(t.assert(t.putIfAbsent('listen-distinct-2', 'v2'), t.toBeTruthy))
50
- .catch(t.failed(done));
51
- });
52
-
53
- it('can execute a script remotely to store and retrieve data in cluster mode',
54
- tests.execPutGet(
55
- 'spec/utils/typed-put-get.js', 'cluster', client, t.toBe('cluster-typed-value')
56
- )
57
- );
58
- it('can execute a script remotely to store and retrieve data in distributed mode',
59
- tests.execPutGet(
60
- 'spec/utils/typed-put-get-dist.js', 'dist-cluster', client
61
- , toEqualJson(_.range(t.clusterSize())
62
- .map(function() { return 'dist-cluster-typed-value'; }))
63
- )
64
- );
65
- it('can execute a distributed script remotely that returns undefined', function(done) {
66
- client
67
- .then(t.loadAndExec('spec/utils/typed-null-return-dist.js'))
68
- .then(t.assert(t.exec('typed-null-return-dist.js'),
69
- toEqualJson(_.range(t.clusterSize())
70
- .map(function() { return ''; }))))
71
- .catch(t.failed(done)).finally(done);
72
- });
73
-
74
- it('can get ignore topology updates with client configuration', function(done) {
75
- t.client(t.cluster1, {topologyUpdates: false})
76
- .then(t.assert(t.getMembers(), t.toEqual([t.cluster1])))
77
- .then(t.disconnect())
78
- .catch(t.failed(done)).finally(done);
79
- });
80
-
81
- function toEqualJson(value) {
82
- return function(actual) {
83
- expect(JSON.parse(actual)).toEqual(value);
84
- }
85
- }
86
-
87
- // Since Jasmine 1.3 does not have afterAll callback, this disconnect test must be last
88
- it('disconnects client', function(done) { client
89
- .then(t.disconnect())
90
- .catch(t.failed(done))
91
- .finally(done);
92
- });
93
-
94
- function routeRoundRobin() {
95
- // Key-less operations should be executed in round-robin fashion.
96
- // This test verifies that if two putAll operations are executed,
97
- // these calls end up in different nodes by checking that each only
98
- // affects one node's statistics
99
- return function(client) {
100
- var statsBefore = getStats(client, t.cluster);
101
-
102
- var data = _.map(_.range(t.clusterSize()), function(i) {
103
- return [{key: 'round-robin-' + i + '0', value: i + '0'},
104
- {key: 'round-robin-' + i + '1', value: i + '1'}]
105
- });
106
-
107
- var puts = statsBefore.then(function() {
108
- return pmap(data, function(pairs) {
109
- return client.putAll(pairs);
110
- });
111
- });
112
-
113
- var statsAfter = _.map(_.range(t.clusterSize()), function() {
114
- return puts.then(function() { return client.stats(); });
115
- });
116
-
117
- return Promise.all(f.cat([statsBefore], statsAfter)).then(function(stats) {
118
- _.forEach(_.tail(stats), function(stat) {
119
- expect(stat.stores).toBe(stats[0].stores + 2);
120
- });
121
- return client;
122
- });
123
- }
124
- }
125
-
126
- function routeConsistentHash() {
127
- return function(client) {
128
- var members = client.getTopologyInfo().getMembers();
129
- var ownerPairs = members.map(function (member, index) {
130
- if(index == members.length - 1)
131
- return [members[index], members[0]];
132
- return [members[index], members[index+1]];
133
- });
134
- var keys = _.map(ownerPairs, function(pair) {
135
- return t.findKeyForServers(client, pair);
136
- });
137
-
138
- var statsBefore = getStats(client, t.cluster);
139
-
140
- var puts = statsBefore.then(function() {
141
- return pmap(keys, function(key) {
142
- return client.put(key, "value");
143
- });
144
- });
145
-
146
- var statsAfter = _.map(t.cluster, function() {
147
- return puts.then(function() { return client.stats(); });
148
- });
149
-
150
- return Promise.all(f.cat([statsBefore], statsAfter)).then(function(stats) {
151
- _.forEach(_.tail(stats), function(stat) {
152
- expect(stat.stores).toBe(1);
153
- expect(stat.currentNumberOfEntries).toBe(2 * (stats[0].stores + 1));
154
- });
155
- return client;
156
- });
157
- }
158
- }
159
-
160
- function getStats(c, cluster) {
161
- var stats = pmap(cluster, function() {
162
- return c.stats();
163
- });
164
- return stats.then(function(stats) {
165
- _.forEach(stats, function(stat) {
166
- expect(stat.stores).toBe(stats[0].stores);
167
- });
168
- return stats[0];
169
- });
170
- }
171
-
172
- function pmap(obj, iteratee, context) {
173
- return Promise.all(_.map(obj, iteratee, context));
174
- }
175
-
176
- });
@@ -1,218 +0,0 @@
1
- var _ = require('underscore');
2
-
3
- var t = require('./utils/testing'); // Testing dependency
4
-
5
- describe('Infinispan local client working with expiry operations', function() {
6
- var client = t.client(t.local, t.authOpts);
7
- var client1 = t.client(t.cluster1, t.authOpts);
8
- var client2 = t.client(t.cluster2, t.authOpts);
9
- var client3 = t.client(t.cluster3, t.authOpts);
10
-
11
- beforeEach(function(done) { client
12
- .then(t.assert(t.clear()))
13
- .catch(t.failed(done)).finally(done);
14
- });
15
-
16
- it('can validate incorrect duration definitions', function(done) { client
17
- .then(assertError(t.put('_', '_', {lifespan: '1z'}), t.toContain('Unknown duration unit')))
18
- .then(assertError(t.putIfAbsent('_', '_', {lifespan: 'aa'}), t.toContain('Unknown duration format')))
19
- .then(assertError(t.replace('_', '_', {lifespan: 1}), t.toContain('Positive duration provided without time unit')))
20
- .then(assertError(t.putAll([{key: '_', value: '_'}], {lifespan: '1z'}), t.toContain('Unknown duration unit')))
21
- .then(assertError(t.replaceV('_', '_', '_', {lifespan: 1}), t.toContain('Positive duration provided without time unit')))
22
- .catch(t.failed(done))
23
- .finally(done);
24
- });
25
- it('removes keys when their lifespan has expired', function(done) { client
26
- .then(t.assert(t.put('life', 'value', {lifespan: '100ms'})))
27
- .then(t.assert(t.containsKey('life'), t.toBeTruthy))
28
- .then(waitLifespanExpire('life', 1000))
29
- .then(t.assert(t.putIfAbsent('life-absent', 'value', {lifespan: '100000μs'})))
30
- .then(t.assert(t.containsKey('life-absent'), t.toBeTruthy))
31
- .then(waitLifespanExpire('life-absent', 1000))
32
- .then(t.assert(t.putIfAbsent('life-replace', 'v0')))
33
- .then(t.assert(t.get('life-replace'), t.toBe('v0')))
34
- .then(t.assert(t.replace('life-replace', 'v1', {lifespan: '100000000ns'})))
35
- .then(t.assert(t.get('life-replace'), t.toBe('v1')))
36
- .then(waitLifespanExpire('life-replace', 1000))
37
- .catch(t.failed(done))
38
- .finally(done);
39
- });
40
- xit('removes keys when their lifespan has expired in cluster', function(done) { client1
41
- .then(t.assert(t.put('life', 'value', {lifespan: '100ms'})))
42
- .then(t.assert(t.containsKey('life'), t.toBeTruthy))
43
- .then(function(client) {
44
- return client2
45
- .then(t.assert(t.containsKey('life'), t.toBeTruthy))
46
- .then(waitLifespanExpire('life', 1000))
47
- .then(t.assert(t.putIfAbsent('life-absent', 'value', {lifespan: '100000μs'})))
48
- .then(t.assert(t.containsKey('life-absent'), t.toBeTruthy))
49
- .then(function() {
50
- return client;
51
- })
52
- })
53
- .then(function(client){
54
- return client3
55
- .then(t.assert(t.get('life-absent'), t.toBe('value')))
56
- .then(waitLifespanExpire('life-absent', 1000))
57
- .then(t.assert(t.putIfAbsent('life-replace', 'v0')))
58
- .then(t.assert(t.get('life-replace'), t.toBe('v0')))
59
- .then(t.assert(t.replace('life-replace', 'v1', {lifespan: '100000000ns'})))
60
- .then(function() {
61
- return client;
62
- })
63
- })
64
- .then(t.assert(t.get('life-replace'), t.toBe('v1')))
65
- .then(waitLifespanExpire('life-replace', 1000))
66
- .catch(t.failed(done))
67
- .finally(done);
68
- });
69
- it('removes keys when their max idle time has expired', function(done) {
70
- var pairs = [{key: 'idle-multi1', value: 'v1'}, {key: 'idle-multi2', value: 'v2'}];
71
- client
72
- .then(t.assert(t.put('idle-replace', 'v0')))
73
- .then(t.assert(t.conditional(t.replaceV, t.getM, 'idle-replace', 'v0', 'v1', {maxIdle: '100ms'}), t.toBeTruthy))
74
- .then(t.assert(t.get('idle-replace'), t.toBe('v1')))
75
- .then(waitIdleTimeExpire('idle-replace', 1000))
76
- .then(t.assert(t.putAll(pairs, {maxIdle: '100000μs'}), t.toBeUndefined))
77
- .then(t.assert(t.containsKey('idle-multi1'), t.toBeTruthy))
78
- .then(t.assert(t.containsKey('idle-multi2'), t.toBeTruthy))
79
- .then(waitIdleTimeExpire('idle-multi1', 1000))
80
- .then(waitIdleTimeExpire('idle-multi2', 1000))
81
- .catch(t.failed(done))
82
- .finally(done);
83
- });
84
- it('removes keys when their max idle time has expired in cluster', function(done) {
85
- var pairs = [{key: 'idle-multi1', value: 'v1'}, {key: 'idle-multi2', value: 'v2'}];
86
- client1
87
- .then(t.assert(t.put('idle-replace', 'v0')))
88
- .then(t.assert(t.conditional(t.replaceV, t.getM, 'idle-replace', 'v0', 'v1', {maxIdle: '100ms'}), t.toBeTruthy))
89
- .then(t.assert(t.get('idle-replace'), t.toBe('v1')))
90
- .then(function(client) {
91
- return client2
92
- .then(t.assert(t.get('idle-replace'), t.toBe('v1')))
93
- .then(waitIdleTimeExpire('idle-replace', 1000))
94
- .then(t.assert(t.containsKey('idle-replace'), t.toBeFalsy))
95
- .then(t.assert(t.putAll(pairs, {maxIdle: '100000μs'}), t.toBeUndefined))
96
- .then(function() {
97
- return client;
98
- });
99
- })
100
- .then(function(client) {
101
- return client3
102
- .then(t.assert(t.containsKey('idle-multi2'), t.toBeTruthy))
103
- .then(waitIdleTimeExpire('idle-multi2', 1000))
104
- .then(t.assert(t.containsKey('idle-multi2'), t.toBeFalsy))
105
- .then(function() {
106
- return client;
107
- });
108
- })
109
- .then(t.assert(t.containsKey('idle-multi2'), t.toBeFalsy))
110
- .catch(t.failed(done))
111
- .finally(done);
112
- });
113
- it('can listen for expired events', function(done) { client
114
- .then(t.on('expiry', t.expectEvent('listen-expiry', done, true)))
115
- .then(t.assert(t.putIfAbsent('listen-expiry', 'value', {lifespan: '100ms'})))
116
- .then(waitForExpiryEvent('listen-expiry'))
117
- .catch(t.failed(done));
118
- });
119
-
120
- it('can listen for custom expired events', function(done) {
121
- var expected = "KeyValueWithPrevious{key=listen-expiry, value=value, prev=null}";
122
- var opts = { converterFactory : { name: "key-value-with-previous-converter-factory" } };
123
- client.then(t.on('expiry', t.expectCustomEvent(expected, done), opts))
124
- .then(t.assert(t.putIfAbsent('listen-expiry', 'value', {lifespan: '100ms'})))
125
- .then(waitForExpiryEvent('listen-expiry'))
126
- .catch(t.failed(done));
127
- });
128
-
129
- it('can listen for expired events in cluster', function(done) { client1
130
- .then(t.on('expiry', t.expectEvent('listen-expiry', done, true)))
131
- .then(t.assert(t.putIfAbsent('listen-expiry', 'value', {lifespan: '100ms'})))
132
- .then(function(client) {
133
- return client2
134
- .then(t.assert(t.containsKey('listen-expiry'), t.toBeTruthy))
135
- .then(waitForExpiryEvent('listen-expiry'))
136
- .then(function() {
137
- return client;
138
- });
139
- })
140
- .then(t.assert(t.containsKey('listen-expiry'), t.toBeFalsy))
141
- .catch(t.failed(done));
142
- });
143
- // Since Jasmine 1.3 does not have afterAll callback, this disconnect test must be last
144
- it('disconnects client', function(done) {
145
- // Guarantee that even if one of the disconnect fails, all disconnects have been called
146
- Promise.all([client, client1, client2, client3])
147
- .then(function(clients) {
148
- return Promise.all(_.map(clients, function(client) {
149
- return client.disconnect();
150
- }));
151
- })
152
- .catch(t.failed(done))
153
- .finally(done);
154
- });
155
-
156
- });
157
-
158
- // timeout in ms
159
- function waitLifespanExpire(key, timeout) {
160
- return function(client) {
161
- var contains = true;
162
- waitsFor(function() {
163
- client.containsKey(key).then(function(success) {
164
- contains = success;
165
- });
166
-
167
- return !contains;
168
- }, '`' + key + '` key should be expired', timeout);
169
-
170
- return client;
171
- }
172
- }
173
-
174
- function waitForExpiryEvent(key) {
175
- return function(client) {
176
- t.sleepFor(200); // sleep required, waitFor() does not work with event
177
- client.containsKey(key).then(function(success) {
178
- expect(success).toBeFalsy();
179
- });
180
- return client;
181
- }
182
- }
183
-
184
- // timeout in ms
185
- function waitIdleTimeExpire(key, timeout) {
186
- return function(client) {
187
- var contains = true;
188
- t.sleepFor(200); // sleep required
189
- waitsFor(function() {
190
- client.containsKey(key).then(function(success) {
191
- contains = success;
192
- });
193
-
194
- return !contains;
195
- }, '`' + key + '` key should be expired', timeout);
196
-
197
- return client;
198
- }
199
- }
200
-
201
- function assertError(fun, expectErrorFun) {
202
- return function(client) {
203
- var failed = false;
204
- try {
205
- fun(client);
206
- } catch(error) {
207
- failed = true;
208
- expectErrorFun(error.message);
209
- }
210
-
211
- if (!failed)
212
- throw new Error('Expected function to fail');
213
-
214
- return client;
215
- }
216
- }
217
-
218
-
@@ -1,52 +0,0 @@
1
- var _ = require('underscore');
2
-
3
- var t = require('./utils/testing'); // Testing dependency
4
-
5
- describe('Infinispan clustered clients', function() {
6
- t.configureLogging();
7
-
8
- it('can failover when nodes crash', function(done) {
9
- var keys = ['before-failover-listener', 'middle-failover-listener', 'after-failover-listener'];
10
- t.launchClusterNodeAndWaitView('server-failover-one', t.failoverConfig, t.failover1['port'], t.failoverMCastAddr, 1, t.client)
11
- .then(function() {
12
- return t.client(t.failover1, t.authOpts);
13
- })
14
- .then(t.assert(t.getMembers(), t.toContain([t.failover1])))
15
- .then(t.assert(t.clear()))
16
- .then(t.on('create', t.expectEvents(keys, done, true)))
17
- .then(t.assert(t.putIfAbsent(keys[0], 'value'), t.toBeTruthy))
18
- .then(function(client) {return t.launchClusterNodeAndWaitView('server-failover-two', t.failoverConfig, t.failover2['port'], t.failoverMCastAddr, 2, client);}) //11432
19
- .then(expectClientView([t.failover1, t.failover2]))
20
- .then(t.assert(t.putIfAbsent(keys[1], 'value'), t.toBeTruthy))
21
- .then(withAll(t.stopAndWaitView(t.failover1['port'], 1, t.failover2['port'])))
22
- .then(expectClientView([t.failover2]))
23
- .then(t.assert(t.putIfAbsent(keys[2], 'value'), t.toBeTruthy))
24
- .then(withAll(t.stopClusterNode(t.failover2['port'], true)))
25
- .then(withAll(t.disconnect()))
26
- .catch(t.failed(done));
27
- }, 10000);
28
-
29
- });
30
-
31
- function withAll(fun) {
32
- return function(param) {
33
- return fun(param).then(function() { return param; })
34
- }
35
- }
36
-
37
- function keyPut(value) {
38
- return function(params) { return params[0].put(params[1], value) }
39
- }
40
-
41
- function keyGet(expectFun) {
42
- return function(params) {
43
- return params[0].get(params[1]).then(function(v) { expectFun(v); })
44
- }
45
- }
46
-
47
- function expectClientView(members) {
48
- return function(client) {
49
- return t.assert(t.ping(), t.toBeUndefined)(client)
50
- .then(t.assert(t.getMembers(), t.toContain(members)))
51
- }
52
- }
@@ -1,63 +0,0 @@
1
- var t = require('./utils/testing'); // Testing dependency
2
-
3
- describe('Infinispan clustered clients', function() {
4
-
5
- it('can failover when nodes crash', function(done) {
6
- t.launchClusterNodeAndWaitView('server-failover-one', t.failoverConfig, t.failover1['port'], t.failoverMCastAddr, 1)
7
- .then(function() {
8
- return t.client(t.failover1, t.authOpts);
9
- })
10
- .then(t.assert(t.getMembers(), t.toContain([t.failover1])))
11
- .then(function(client) {
12
- return t.launchClusterNodeAndWaitView('server-failover-two', t.failoverConfig, t.failover2['port'], t.failoverMCastAddr, 2, client);}) //11432
13
- .then(expectClientView([t.failover1, t.failover2]))
14
- .then(function(client) { return t.launchClusterNodeAndWaitView('server-failover-three', t.failoverConfig, t.failover3['port'], t.failoverMCastAddr, 3, client); }) //11442
15
- .then(expectClientView([t.failover1, t.failover2, t.failover3]))
16
- .then(keyGen([t.failover2, t.failover3]))
17
- .then(withAll(keyPut('failover-value')))
18
- .then(withAll(keyGet(t.toBe('failover-value'))))
19
- .then(withFirst(t.stopAndWaitView(t.failover3['port'], 2, t.failover1['port'])))
20
- .then(withFirst(expectClientView([t.failover1, t.failover2])))
21
- .then(withAll(keyGet(t.toBe('failover-value'))))
22
- .then(withFirst(t.stopAndWaitView(t.failover2['port'], 1, t.failover1['port'])))
23
- .then(withFirst(expectClientView([t.failover1])))
24
- .then(withAll(keyGet(t.toBe('failover-value'))))
25
- .then(withFirst(t.stopClusterNode(t.failover1['port'], false)))
26
- .then(withFirst(t.disconnect()))
27
- .catch(t.failed(done)).finally(done);
28
- }, 20000);
29
-
30
- });
31
-
32
- function keyGen(addrs) {
33
- return function(cl) { return [cl, t.findKeyForServers(cl, addrs)]; }
34
- }
35
-
36
- function withFirst(fun) {
37
- return function(params) {
38
- return fun(params[0]).then(function() { return params; })
39
- }
40
- }
41
-
42
- function withAll(fun) {
43
- return function(param) {
44
- return fun(param).then(function() { return param; })
45
- }
46
- }
47
-
48
- function keyPut(value) {
49
- return function(params) { return params[0].put(params[1], value) }
50
- }
51
-
52
- function keyGet(expectFun) {
53
- return function(params) {
54
- return params[0].get(params[1]).then(function(v) { expectFun(v); })
55
- }
56
- }
57
-
58
- function expectClientView(members) {
59
- return function(client) {
60
- return t.assert(t.ping(), t.toBeUndefined)(client)
61
- .then(t.assert(t.getMembers(), t.toContain(members)))
62
- }
63
- }