mirror of https://github.com/grpc/grpc-node.git
Revert 2c625fe^..b192adf
Revert "use client's user agent; small changes in test gulpfile; add TODO" This reverts commit2c625feb9f. Revert "use merged gRPC object in api tests" This reverts commit9d9404615e. Revert "add packageJson to any-grpc" This reverts commit6a6b4eb56c. Revert "change grpc refs in math api test" This reverts commit689d4d0c61. Revert "test: add requiring fixtures to specify implementation to test" This reverts commitb192adf2a1.
This commit is contained in:
parent
046a333a9c
commit
6e569b76f1
|
|
@ -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'
|
||||
]));
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
var Metadata = require('../any_grpc').Metadata;
|
||||
var Metadata = require('grpc').Metadata;
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
global._server_implementation = 'native';
|
||||
global._client_implementation = 'js';
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
global._server_implementation = 'js';
|
||||
global._client_implementation = 'native';
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
global._server_implementation = 'js';
|
||||
global._client_implementation = 'native';
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
global._server_implementation = 'native';
|
||||
global._client_implementation = 'native';
|
||||
|
|
@ -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'}));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue