This repository has been archived by the owner on Jun 25, 2019. It is now read-only.
forked from mhart/kinesalite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdescribeStream.js
134 lines (111 loc) · 5.47 KB
/
describeStream.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
var helpers = require('./helpers')
var target = 'DescribeStream',
request = helpers.request,
randomName = helpers.randomName,
opts = helpers.opts.bind(null, target),
assertType = helpers.assertType.bind(null, target),
assertValidation = helpers.assertValidation.bind(null, target),
assertNotFound = helpers.assertNotFound.bind(null, target)
describe('describeStream', function() {
describe('serializations', function() {
it('should return SerializationException when StreamName is not a String', function(done) {
assertType('StreamName', 'String', done)
})
it('should return SerializationException when Limit is not an Integer', function(done) {
assertType('Limit', 'Integer', done)
})
it('should return SerializationException when ExclusiveStartShardId is not a String', function(done) {
assertType('ExclusiveStartShardId', 'String', done)
})
})
describe('validations', function() {
it('should return ValidationException for no StreamName', function(done) {
assertValidation({}, [
'Value null at \'streamName\' failed to satisfy constraint: ' +
'Member must not be null',
], done)
})
it('should return ValidationException for empty StreamName', function(done) {
assertValidation({StreamName: '', Limit: 0, ExclusiveStartShardId: ''}, [
'Value \'0\' at \'limit\' failed to satisfy constraint: ' +
'Member must have value greater than or equal to 1',
'Value \'\' at \'exclusiveStartShardId\' failed to satisfy constraint: ' +
'Member must satisfy regular expression pattern: [a-zA-Z0-9_.-]+',
'Value \'\' at \'exclusiveStartShardId\' failed to satisfy constraint: ' +
'Member must have length greater than or equal to 1',
'Value \'\' at \'streamName\' failed to satisfy constraint: ' +
'Member must satisfy regular expression pattern: [a-zA-Z0-9_.-]+',
'Value \'\' at \'streamName\' failed to satisfy constraint: ' +
'Member must have length greater than or equal to 1',
], done)
})
it('should return ValidationException for long StreamName', function(done) {
var name = new Array(129 + 1).join('a')
assertValidation({StreamName: name, Limit: 100000, ExclusiveStartShardId: name}, [
'Value \'100000\' at \'limit\' failed to satisfy constraint: ' +
'Member must have value less than or equal to 10000',
'Value \'' + name + '\' at \'exclusiveStartShardId\' failed to satisfy constraint: ' +
'Member must have length less than or equal to 128',
'Value \'' + name + '\' at \'streamName\' failed to satisfy constraint: ' +
'Member must have length less than or equal to 128',
], done)
})
it('should return ResourceNotFoundException if stream does not exist', function(done) {
var name = randomName()
assertNotFound({StreamName: name}, 'Stream ' + name + ' under account ' +
helpers.awsAccountId + ' not found.', done)
})
})
describe('functionality', function() {
it('should return stream description', function(done) {
request(opts({StreamName: helpers.testStream}), function(err, res) {
if (err) return done(err)
res.statusCode.should.equal(200)
res.body.StreamDescription.Shards[0].SequenceNumberRange.StartingSequenceNumber.should.match(/^\d{56}$/)
res.body.StreamDescription.Shards[1].SequenceNumberRange.StartingSequenceNumber.should.match(/^\d{56}$/)
res.body.StreamDescription.Shards[2].SequenceNumberRange.StartingSequenceNumber.should.match(/^\d{56}$/)
delete res.body.StreamDescription.Shards[0].SequenceNumberRange.StartingSequenceNumber
delete res.body.StreamDescription.Shards[1].SequenceNumberRange.StartingSequenceNumber
delete res.body.StreamDescription.Shards[2].SequenceNumberRange.StartingSequenceNumber
res.body.StreamDescription.StreamCreationTimestamp.should.be.above(new Date('2018-01-01') / 1000)
res.body.StreamDescription.StreamCreationTimestamp.should.be.below(new Date('2118-01-01') / 1000)
delete res.body.StreamDescription.StreamCreationTimestamp
res.body.should.eql({
StreamDescription: {
StreamStatus: 'ACTIVE',
StreamName: helpers.testStream,
StreamARN: 'arn:aws:kinesis:' + helpers.awsRegion + ':' + helpers.awsAccountId +
':stream/' + helpers.testStream,
RetentionPeriodHours: 24,
EncryptionType: 'NONE',
EnhancedMonitoring: [{ShardLevelMetrics: []}],
HasMoreShards: false,
Shards: [{
ShardId: 'shardId-000000000000',
SequenceNumberRange: {},
HashKeyRange: {
StartingHashKey: '0',
EndingHashKey: '113427455640312821154458202477256070484',
},
}, {
ShardId: 'shardId-000000000001',
SequenceNumberRange: {},
HashKeyRange: {
StartingHashKey: '113427455640312821154458202477256070485',
EndingHashKey: '226854911280625642308916404954512140969',
},
}, {
ShardId: 'shardId-000000000002',
SequenceNumberRange: {},
HashKeyRange: {
StartingHashKey: '226854911280625642308916404954512140970',
EndingHashKey: '340282366920938463463374607431768211455',
},
}],
},
})
done()
})
})
})
})