YUKI Hiroshi
null+****@clear*****
Tue Dec 4 15:39:04 JST 2012
YUKI Hiroshi 2012-12-04 15:39:04 +0900 (Tue, 04 Dec 2012) New Revision: 041e5b4ddf5cbb4c98de5bab8c78799c6468bb44 https://github.com/groonga/gcs/commit/041e5b4ddf5cbb4c98de5bab8c78799c6468bb44 Log: Remove features to build endpoint hostname Modified files: bin/gcs-describe-domain lib/database/domain.js test/database-domain.test.js test/gcs-commands.test.js Modified: bin/gcs-describe-domain (+5 -4) =================================================================== --- bin/gcs-describe-domain 2012-12-04 15:10:23 +0900 (7e07bf2) +++ bin/gcs-describe-domain 2012-12-04 15:39:04 +0900 (b608a39) @@ -25,15 +25,16 @@ function toValidHostAndPort(hostAndPort) { return hostAndPort.join(':'); } -function arnToEndpoint(arn, prefix) { - var match = arn.match(/^arn:aws:cs:[^:]+:([^:]+):(?:doc|search)\/(.+)$/); +function arnToEndpoint(arn) { + var match = arn.match(/^arn:aws:cs:[^:]+:([^:]+):([^\/]+)\/(.+)$/); if (!match) client.raiseFatalError('invalid arn: ' + arn); - var name = match[2]; var id = match[1]; + var type = match[2]; + var name = match[3]; var hostAndPort = client.host + ':' + client.port; - return prefix + '-' + name + '-' + id + '.' + toValidHostAndPort(hostAndPort); + return type + '-' + name + '-' + id + '.' + toValidHostAndPort(hostAndPort); } function reportStatus(domain, indexFields, defaultSearchField) { Modified: lib/database/domain.js (+0 -19) =================================================================== --- lib/database/domain.js 2012-12-04 15:10:23 +0900 (5f28c7d) +++ lib/database/domain.js 2012-12-04 15:39:04 +0900 (e697639) @@ -94,15 +94,6 @@ function assertValidDomainName(domain) { } -function toValidHostAndPort(hostAndPort) { - hostAndPort = hostAndPort.split(':'); - if (hostAndPort[0] == 'localhost') - hostAndPort[0] = '127.0.0.1'; - if (hostAndPort[0].match(/^\d+\.\d+\.\d+\.\d+$/)) - hostAndPort[0] += '.xip.io'; - return hostAndPort.join(':'); -} - // Accepts two arguments: source and context. // You can give them in the reversed order, like: // new Domain("source", context) or new Domain(context, "source") @@ -349,19 +340,9 @@ Domain.prototype = { return false; }, - getDocumentsEndpoint: function(hostname) { - hostname = hostname.replace(/^\./, ''); - hostname = toValidHostAndPort(hostname); - return 'doc-' + this.name + '-' + this.id + '.' + hostname; - }, get documentsArn() { return 'arn:aws:cs:us-east-1:' + this.id + ':doc/' + this.name; }, - getSearchEndpoint: function(hostname) { - hostname = hostname.replace(/^\./, ''); - hostname = toValidHostAndPort(hostname); - return 'search-' + this.name + '-' + this.id + '.' + hostname; - }, get searchArn() { return 'arn:aws:cs:us-east-1:' + this.id + ':search/' + this.name; }, Modified: test/database-domain.test.js (+0 -60) =================================================================== --- test/database-domain.test.js 2012-12-04 15:10:23 +0900 (0f6c3a3) +++ test/database-domain.test.js 2012-12-04 15:39:04 +0900 (bf6ec24) @@ -249,36 +249,6 @@ suite('database', function() { domain = new Domain('valid').setId(Domain.DEFAULT_ID).validate(); }); - test('regular domain, with port', function() { - assert.equal(domain.getDocumentsEndpoint('my.domain:0123'), - 'doc-valid-' + Domain.DEFAULT_ID + '.my.domain:0123'); - }); - - test('regular domain, without port', function() { - assert.equal(domain.getDocumentsEndpoint('my.domain'), - 'doc-valid-' + Domain.DEFAULT_ID + '.my.domain'); - }); - - test('IP address, with port', function() { - assert.equal(domain.getDocumentsEndpoint('192.168.0.1:4567'), - 'doc-valid-' + Domain.DEFAULT_ID + '.192.168.0.1.xip.io:4567'); - }); - - test('IP address, without port', function() { - assert.equal(domain.getDocumentsEndpoint('192.168.0.1'), - 'doc-valid-' + Domain.DEFAULT_ID + '.192.168.0.1.xip.io'); - }); - - test('localhost, with port', function() { - assert.equal(domain.getDocumentsEndpoint('localhost:4567'), - 'doc-valid-' + Domain.DEFAULT_ID + '.127.0.0.1.xip.io:4567'); - }); - - test('localhost, without port', function() { - assert.equal(domain.getDocumentsEndpoint('localhost'), - 'doc-valid-' + Domain.DEFAULT_ID + '.127.0.0.1.xip.io'); - }); - test('arn', function() { assert.equal(domain.documentsArn, 'arn:aws:cs:us-east-1:' + Domain.DEFAULT_ID + ':doc/valid'); @@ -291,36 +261,6 @@ suite('database', function() { domain = new Domain('valid').setId(Domain.DEFAULT_ID).validate(); }); - test('regular domain, with port', function() { - assert.equal(domain.getSearchEndpoint('my.domain:0123'), - 'search-valid-' + Domain.DEFAULT_ID + '.my.domain:0123'); - }); - - test('regular domain, without port', function() { - assert.equal(domain.getSearchEndpoint('my.domain'), - 'search-valid-' + Domain.DEFAULT_ID + '.my.domain'); - }); - - test('IP address, with port', function() { - assert.equal(domain.getSearchEndpoint('192.168.0.1:4567'), - 'search-valid-' + Domain.DEFAULT_ID + '.192.168.0.1.xip.io:4567'); - }); - - test('IP address, without port', function() { - assert.equal(domain.getSearchEndpoint('192.168.0.1'), - 'search-valid-' + Domain.DEFAULT_ID + '.192.168.0.1.xip.io'); - }); - - test('localhost, with port', function() { - assert.equal(domain.getSearchEndpoint('localhost:4567'), - 'search-valid-' + Domain.DEFAULT_ID + '.127.0.0.1.xip.io:4567'); - }); - - test('localhost, without port', function() { - assert.equal(domain.getSearchEndpoint('localhost'), - 'search-valid-' + Domain.DEFAULT_ID + '.127.0.0.1.xip.io'); - }); - test('arn', function() { assert.equal(domain.searchArn, 'arn:aws:cs:us-east-1:' + Domain.DEFAULT_ID + ':search/valid'); Modified: test/gcs-commands.test.js (+15 -7) =================================================================== --- test/gcs-commands.test.js 2012-12-04 15:10:23 +0900 (24f8d08) +++ test/gcs-commands.test.js 2012-12-04 15:39:04 +0900 (267a2e1) @@ -167,6 +167,14 @@ suite('gcs-delete-domain', function() { }); }); +function arnToEndpoint(arn, hostPort) { + var match = arn.match(/^arn:aws:cs:[^:]+:([^:]+):([^\/]+)\/(.+)$/); + var id = match[1]; + var type = match[2]; + var name = match[3]; + return type + '-' + name + '-' + id + '.' + hostPort; +} + suite('gcs-describe-domain', function() { setup(commonSetup); teardown(commonTeardown); @@ -190,9 +198,9 @@ suite('gcs-describe-domain', function() { '=== Domain Summary ===\n' + 'Domain Name: domain1\n' + 'Document Service endpoint: ' + - domain.getDocumentsEndpoint(hostPort) + '\n' + + arnToEndpoint(domain.documentsArn, hostPort) + '\n' + 'Search Service endpoint: ' + - domain.getSearchEndpoint(hostPort) + '\n' + + arnToEndpoint(domain.searchArn, hostPort) + '\n' + 'SearchInstanceType: null\n' + 'SearchPartitionCount: 0\n' + 'SearchInstanceCount: 0\n' + @@ -231,9 +239,9 @@ suite('gcs-describe-domain', function() { '=== Domain Summary ===\n' + 'Domain Name: domain2\n' + 'Document Service endpoint: ' + - domain2.getDocumentsEndpoint(hostPort) + '\n' + + arnToEndpoint(domain2.documentsArn, hostPort) + '\n' + 'Search Service endpoint: ' + - domain2.getSearchEndpoint(hostPort) + '\n' + + arnToEndpoint(domain2.searchArn, hostPort) + '\n' + 'SearchInstanceType: null\n' + 'SearchPartitionCount: 0\n' + 'SearchInstanceCount: 0\n' + @@ -250,9 +258,9 @@ suite('gcs-describe-domain', function() { '=== Domain Summary ===\n' + 'Domain Name: domain1\n' + 'Document Service endpoint: ' + - domain1.getDocumentsEndpoint(hostPort) + '\n' + + arnToEndpoint(domain.documentsArn, hostPort) + '\n' + 'Search Service endpoint: ' + - domain1.getSearchEndpoint(hostPort) + '\n' + + arnToEndpoint(domain.searchArn, hostPort) + '\n' + 'SearchInstanceType: null\n' + 'SearchPartitionCount: 0\n' + 'SearchInstanceCount: 0\n' + @@ -912,7 +920,7 @@ suite('gcs-post-sdf', function() { domain.getIndexField('description').setType('text').createSync(); domain.getIndexField('age').setType('uint').createSync(); domain.getIndexField('product').setType('literal').createSync(); - endpoint = domain.getDocumentsEndpoint('localhost:' + utils.testPort); + endpoint = arnToEndpoint(domain.documentsArn, 'localhost:' + utils.testPort); } test('post add sdf json', function(done) { -------------- next part -------------- HTML����������������������������... ダウンロード