forked from mhart/kinesalite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for DescribeStreamSummary
- Loading branch information
Showing
4 changed files
with
117 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
module.exports = function describeStreamSummary(store, data, cb) { | ||
|
||
store.getStream(data.StreamName, function(err, stream) { | ||
if (err) return cb(err) | ||
|
||
stream.OpenShardCount = stream.Shards.filter(function(shard) { | ||
return shard.SequenceNumberRange.EndingSequenceNumber == null | ||
}).length | ||
|
||
delete stream._seqIx | ||
delete stream._tags | ||
delete stream.Shards | ||
delete stream.HasMoreShards | ||
|
||
cb(null, {StreamDescriptionSummary: stream}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
var helpers = require('./helpers') | ||
|
||
var target = 'DescribeStreamSummary', | ||
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('describeStreamSummary', function() { | ||
|
||
describe('serializations', function() { | ||
|
||
it('should return SerializationException when StreamName is not a String', function(done) { | ||
assertType('StreamName', '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: ''}, [ | ||
'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}, [ | ||
'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 summary', function(done) { | ||
request(opts({StreamName: helpers.testStream}), function(err, res) { | ||
if (err) return done(err) | ||
res.statusCode.should.equal(200) | ||
var createTime = Date.now() / 1000 | ||
|
||
res.body.StreamDescriptionSummary.StreamCreationTimestamp.should.be.above(createTime - 10) | ||
res.body.StreamDescriptionSummary.StreamCreationTimestamp.should.be.below(createTime + 10) | ||
delete res.body.StreamDescriptionSummary.StreamCreationTimestamp | ||
|
||
res.body.should.eql({ | ||
StreamDescriptionSummary: { | ||
StreamStatus: 'ACTIVE', | ||
StreamName: helpers.testStream, | ||
StreamARN: 'arn:aws:kinesis:' + helpers.awsRegion + ':' + helpers.awsAccountId + | ||
':stream/' + helpers.testStream, | ||
RetentionPeriodHours: 24, | ||
EncryptionType: 'NONE', | ||
EnhancedMonitoring: [{ShardLevelMetrics: []}], | ||
OpenShardCount: 3, | ||
}, | ||
}) | ||
|
||
done() | ||
}) | ||
}) | ||
|
||
}) | ||
|
||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
exports.types = { | ||
StreamName: { | ||
type: 'String', | ||
notNull: true, | ||
regex: '[a-zA-Z0-9_.-]+', | ||
lengthGreaterThanOrEqual: 1, | ||
lengthLessThanOrEqual: 128, | ||
}, | ||
} |