diff --git a/test/any_grpc.js b/test/any_grpc.js deleted file mode 100644 index d6d008c2..00000000 --- a/test/any_grpc.js +++ /dev/null @@ -1,39 +0,0 @@ -// TODO: Instead of attempting to expose both implementations of gRPC in -// a single object, the tests should be re-written in a way that makes it clear -// that two separate implementations are being tested against one another. - -const _ = require('lodash'); - -function getImplementation(globalField) { - if (global[globalField] !== 'js' && global[globalField] !== 'native') { - throw new Error([ - `Invalid value for global.${globalField}: ${global.globalField}.`, - 'If running from the command line, please --require a fixture first.' - ].join(' ')); - } - const impl = global[globalField]; - return { - surface: require(`../packages/grpc-${impl}`), - pjson: require(`../packages/grpc-${impl}/package.json`), - core: require(`../packages/grpc-${impl}-core`), - corePjson: require(`../packages/grpc-${impl}-core/package.json`) - }; -} - -const clientImpl = getImplementation('_client_implementation'); -const serverImpl = getImplementation('_server_implementation'); - -// We export a "merged" gRPC API by merging client and server specified -// APIs together. Any function that is unspecific to client/server defaults -// to client-side implementation. -// This object also has a test-only field from which details about the -// modules may be read. -module.exports = Object.assign({ - '$implementationInfo': { - client: clientImpl, - server: serverImpl - } -}, clientImpl.surface, _.pick(serverImpl.surface, [ - 'Server', - 'ServerCredentials' -])); diff --git a/test/api/async_test.js b/test/api/async_test.js index 86cd62e2..e899da56 100644 --- a/test/api/async_test.js +++ b/test/api/async_test.js @@ -20,7 +20,7 @@ var assert = require('assert'); -var grpc = require('../any_grpc'); +var grpc = require('grpc'); var math = grpc.load( __dirname + '/../../packages/grpc-native-core/deps/grpc/src/proto/math/math.proto').math; diff --git a/test/api/credentials_api_test.js b/test/api/credentials_api_test.js deleted file mode 100644 index e79fca07..00000000 --- a/test/api/credentials_api_test.js +++ /dev/null @@ -1,165 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -'use strict'; - -var assert = require('assert'); -var fs = require('fs'); -var path = require('path'); - -var grpc = require('../any_grpc'); - -var key_data, pem_data, ca_data; - -before(function() { - var key_path = path.join(__dirname, '../data/server1.key'); - var pem_path = path.join(__dirname, '../data/server1.pem'); - var ca_path = path.join(__dirname, '../data/ca.pem'); - key_data = fs.readFileSync(key_path); - pem_data = fs.readFileSync(pem_path); - ca_data = fs.readFileSync(ca_path); -}); - -describe('channel credentials', function() { - describe('#createSsl', function() { - it('works with no arguments', function() { - var creds; - assert.doesNotThrow(function() { - creds = grpc.credentials.createSsl(); - }); - assert.notEqual(creds, null); - }); - it('works with just one Buffer argument', function() { - var creds; - assert.doesNotThrow(function() { - creds = grpc.credentials.createSsl(ca_data); - }); - assert.notEqual(creds, null); - }); - it('works with 3 Buffer arguments', function() { - var creds; - assert.doesNotThrow(function() { - creds = grpc.credentials.createSsl(ca_data, key_data, pem_data); - }); - assert.notEqual(creds, null); - }); - it('works if the first argument is null', function() { - var creds; - assert.doesNotThrow(function() { - creds = grpc.credentials.createSsl(null, key_data, pem_data); - }); - assert.notEqual(creds, null); - }); - it('fails if the first argument is a non-Buffer value', function() { - assert.throws(function() { - grpc.credentials.createSsl('test'); - }, TypeError); - }); - it('fails if the second argument is a non-Buffer value', function() { - assert.throws(function() { - grpc.credentials.createSsl(null, 'test', pem_data); - }, TypeError); - }); - it('fails if the third argument is a non-Buffer value', function() { - assert.throws(function() { - grpc.credentials.createSsl(null, key_data, 'test'); - }, TypeError); - }); - it('fails if only 1 of the last 2 arguments is provided', function() { - assert.throws(function() { - grpc.credentials.createSsl(null, key_data); - }); - assert.throws(function() { - grpc.credentials.createSsl(null, null, pem_data); - }); - }); - }); -}); - -describe('server credentials', function() { - describe('#createSsl', function() { - it('accepts a buffer and array as the first 2 arguments', function() { - var creds; - assert.doesNotThrow(function() { - creds = grpc.ServerCredentials.createSsl(ca_data, []); - }); - assert.notEqual(creds, null); - }); - it('accepts a boolean as the third argument', function() { - var creds; - assert.doesNotThrow(function() { - creds = grpc.ServerCredentials.createSsl(ca_data, [], true); - }); - assert.notEqual(creds, null); - }); - it('accepts an object with two buffers in the second argument', function() { - var creds; - assert.doesNotThrow(function() { - creds = grpc.ServerCredentials.createSsl(null, - [{private_key: key_data, - cert_chain: pem_data}]); - }); - assert.notEqual(creds, null); - }); - it('accepts multiple objects in the second argument', function() { - var creds; - assert.doesNotThrow(function() { - creds = grpc.ServerCredentials.createSsl(null, - [{private_key: key_data, - cert_chain: pem_data}, - {private_key: key_data, - cert_chain: pem_data}]); - }); - assert.notEqual(creds, null); - }); - it('fails if the second argument is not an Array', function() { - assert.throws(function() { - grpc.ServerCredentials.createSsl(ca_data, 'test'); - }, TypeError); - }); - it('fails if the first argument is a non-Buffer value', function() { - assert.throws(function() { - grpc.ServerCredentials.createSsl('test', []); - }, TypeError); - }); - it('fails if the third argument is a non-boolean value', function() { - assert.throws(function() { - grpc.ServerCredentials.createSsl(ca_data, [], 'test'); - }, TypeError); - }); - it('fails if the array elements are not objects', function() { - assert.throws(function() { - grpc.ServerCredentials.createSsl(ca_data, 'test'); - }, TypeError); - }); - it('fails if the object does not have a Buffer private_key', function() { - assert.throws(function() { - grpc.ServerCredentials.createSsl(null, - [{private_key: 'test', - cert_chain: pem_data}]); - }, TypeError); - }); - it('fails if the object does not have a Buffer cert_chain', function() { - assert.throws(function() { - grpc.ServerCredentials.createSsl(null, - [{private_key: key_data, - cert_chain: 'test'}]); - }, TypeError); - }); - }); -}); \ No newline at end of file diff --git a/test/api/credentials_test.js b/test/api/credentials_test.js index f9bdefaf..2f101134 100644 --- a/test/api/credentials_test.js +++ b/test/api/credentials_test.js @@ -22,7 +22,7 @@ var assert = require('assert'); var fs = require('fs'); var path = require('path'); -var grpc = require('../any_grpc'); +var grpc = require('grpc'); /** * This is used for testing functions with multiple asynchronous calls that diff --git a/test/api/file_load_test.js b/test/api/file_load_test.js deleted file mode 100644 index c24a1100..00000000 --- a/test/api/file_load_test.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -'use strict'; - -var assert = require('assert'); -var grpc = require('../any_grpc'); - -describe('File loader', function() { - it('Should load a proto file by default', function() { - assert.doesNotThrow(function() { - grpc.load(__dirname + '/test_service.proto'); - }); - }); - it('Should load a proto file with the proto format', function() { - assert.doesNotThrow(function() { - grpc.load(__dirname + '/test_service.proto', 'proto'); - }); - }); - it('Should load a json file with the json format', function() { - assert.doesNotThrow(function() { - grpc.load(__dirname + '/test_service.json', 'json'); - }); - }); -}); diff --git a/test/api/math/math_grpc_pb.js b/test/api/math/math_grpc_pb.js index 68001847..afd08a34 100644 --- a/test/api/math/math_grpc_pb.js +++ b/test/api/math/math_grpc_pb.js @@ -16,7 +16,7 @@ // limitations under the License. // 'use strict'; -var grpc = require('../../any_grpc.js'); +var grpc = require('grpc'); var math_math_pb = require('../math/math_pb.js'); function serialize_DivArgs(arg) { diff --git a/test/api/math/math_server.js b/test/api/math/math_server.js index 70ad2dc5..05e30f72 100644 --- a/test/api/math/math_server.js +++ b/test/api/math/math_server.js @@ -18,7 +18,7 @@ 'use strict'; -var grpc = require('../../any_grpc.js'); +var grpc = require('grpc'); var grpcMath = require('./math_grpc_pb'); var math = require('./math_pb'); diff --git a/test/api/math_client_test.js b/test/api/math_client_test.js index f4ba0951..09265abf 100644 --- a/test/api/math_client_test.js +++ b/test/api/math_client_test.js @@ -20,7 +20,7 @@ var assert = require('assert'); -var grpc = require('../any_grpc'); +var grpc = require('grpc'); var math = require('./math/math_pb'); var MathClient = require('./math/math_grpc_pb').MathClient; diff --git a/test/api/metadata_test.js b/test/api/metadata_test.js index 7825383d..5e24f7ac 100644 --- a/test/api/metadata_test.js +++ b/test/api/metadata_test.js @@ -18,7 +18,7 @@ 'use strict'; -var Metadata = require('../any_grpc').Metadata; +var Metadata = require('grpc').Metadata; var assert = require('assert'); diff --git a/test/api/surface_test.js b/test/api/surface_test.js index 92802435..2a1bf5bf 100644 --- a/test/api/surface_test.js +++ b/test/api/surface_test.js @@ -21,7 +21,7 @@ var assert = require('assert'); var _ = require('lodash'); -var grpc = require('../any_grpc'); +var grpc = require('grpc'); var MathClient = grpc.load( __dirname + '/../../packages/grpc-native-core/deps/grpc/src/proto/math/math.proto').math.Math; @@ -485,7 +485,7 @@ describe('Echo metadata', function() { call.end(); }); it('shows the correct user-agent string', function(done) { - var version = require('../any_grpc')['$implementationInfo'].client.corePjson.version; + var version = require('grpc/package.json').version; var call = client.unary({}, metadata, function(err, data) { assert.ifError(err); }); call.on('metadata', function(metadata) { diff --git a/test/fixtures/js_js.js b/test/fixtures/js_js.js deleted file mode 100644 index e0ca3c58..00000000 --- a/test/fixtures/js_js.js +++ /dev/null @@ -1,2 +0,0 @@ -global._server_implementation = 'native'; -global._client_implementation = 'js'; \ No newline at end of file diff --git a/test/fixtures/js_native.js b/test/fixtures/js_native.js deleted file mode 100644 index 5088df96..00000000 --- a/test/fixtures/js_native.js +++ /dev/null @@ -1,2 +0,0 @@ -global._server_implementation = 'js'; -global._client_implementation = 'native'; \ No newline at end of file diff --git a/test/fixtures/native_js.js b/test/fixtures/native_js.js deleted file mode 100644 index 5088df96..00000000 --- a/test/fixtures/native_js.js +++ /dev/null @@ -1,2 +0,0 @@ -global._server_implementation = 'js'; -global._client_implementation = 'native'; \ No newline at end of file diff --git a/test/fixtures/native_native.js b/test/fixtures/native_native.js deleted file mode 100644 index 5b005e48..00000000 --- a/test/fixtures/native_native.js +++ /dev/null @@ -1,2 +0,0 @@ -global._server_implementation = 'native'; -global._client_implementation = 'native'; \ No newline at end of file diff --git a/test/gulpfile.js b/test/gulpfile.js index 70e05796..25e5e7b6 100644 --- a/test/gulpfile.js +++ b/test/gulpfile.js @@ -36,28 +36,5 @@ gulp.task('install', 'Install test dependencies', () => { gulp.task('clean.all', 'Delete all files created by tasks', () => {}); gulp.task('test', 'Run API-level tests', () => { - // run mocha tests matching a glob with a pre-required fixture, - // returning the associated gulp stream - const apiTestGlob = `${apiTestDir}/*.js`; - const runTestsWithFixture = (server, client) => new Promise((resolve, reject) => { - const fixture = `${server}_${client}`; - console.log(`Running ${apiTestGlob} with ${server} server + ${client} client`); - gulp.src(apiTestGlob) - .pipe(mocha({ - reporter: 'mocha-jenkins-reporter', - require: `${testDir}/fixtures/${fixture}.js` - })) - .resume() // put the stream in flowing mode - .on('end', resolve) - .on('error', reject); - }); - const runTestsArgPairs = [ - ['native', 'native'], - // ['native', 'js'], - // ['js', 'native'], - // ['js', 'js'] - ]; - return runTestsArgPairs.reduce((previousPromise, argPair) => { - return previousPromise.then(runTestsWithFixture.bind(null, argPair[0], argPair[1])); - }, Promise.resolve()); + return gulp.src(`${apiTestDir}/*.js`).pipe(mocha({reporter: 'mocha-jenkins-reporter'})); }); diff --git a/test/interop/interop_client.js b/test/interop/interop_client.js index 83890bca..66a46a44 100644 --- a/test/interop/interop_client.js +++ b/test/interop/interop_client.js @@ -20,7 +20,8 @@ var fs = require('fs'); var path = require('path'); -var grpc = require('../any_grpc')['$implementationInfo'].client.surface; +// TODO(murgatroid99): use multiple grpc implementations +var grpc = require('grpc'); var testProto = grpc.load({ root: __dirname + '/../../packages/grpc-native-core/deps/grpc', file: 'src/proto/grpc/testing/test.proto'}).grpc.testing; diff --git a/test/interop/interop_server.js b/test/interop/interop_server.js index fe1222dd..65bb088d 100644 --- a/test/interop/interop_server.js +++ b/test/interop/interop_server.js @@ -22,7 +22,8 @@ var fs = require('fs'); var path = require('path'); var _ = require('lodash'); var AsyncDelayQueue = require('./async_delay_queue'); -var grpc = require('../any_grpc')['$implementationInfo'].server.surface; +// TODO(murgatroid99): use multiple grpc implementations +var grpc = require('grpc'); var testProto = grpc.load({ root: __dirname + '/../../packages/grpc-native-core/deps/grpc', file: 'src/proto/grpc/testing/test.proto'}).grpc.testing;