Merge pull request #199 from kjin/move-tests-back

Move API tests back to grpc-native-core
This commit is contained in:
Kelvin Jin 2018-03-02 09:53:39 -08:00 committed by GitHub
commit 02e4121a36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 78 additions and 326 deletions

View File

@ -34,8 +34,16 @@
"protobufjs": "^5.0.0"
},
"devDependencies": {
"async": "^2.0.1",
"body-parser": "^1.15.2",
"electron-mocha": "^3.1.1",
"istanbul": "^0.4.4"
"express": "^4.14.0",
"google-auth-library": "^0.9.2",
"google-protobuf": "^3.0.0",
"istanbul": "^0.4.4",
"lodash": "^4.17.4",
"minimist": "^1.1.0",
"poisson-process": "^0.2.1"
},
"engines": {
"node": ">=4"

View File

@ -20,9 +20,9 @@
var assert = require('assert');
var grpc = require('../any_grpc');
var grpc = require('..');
var math = grpc.load(
__dirname + '/../../packages/grpc-native-core/deps/grpc/src/proto/math/math.proto').math;
__dirname + '/../deps/grpc/src/proto/math/math.proto').math;
/**

View File

@ -22,7 +22,7 @@ var assert = require('assert');
var fs = require('fs');
var path = require('path');
var grpc = require('../any_grpc');
var grpc = require('..');
/**
* This is used for testing functions with multiple asynchronous calls that
@ -67,9 +67,9 @@ var fakeFailingGoogleCredentials = {
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');
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);

View File

@ -0,0 +1 @@
CONFIRMEDTESTKEY

View File

@ -0,0 +1,15 @@
-----BEGIN CERTIFICATE-----
MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
BAYTAkFVMRMwEQYDVQQIEwpTb21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WF+slf3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd
9N8YwbBYAckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAGjazBpMAkGA1UdEwQCMAAw
CwYDVR0PBAQDAgXgME8GA1UdEQRIMEaCECoudGVzdC5nb29nbGUuZnKCGHdhdGVy
em9vaS50ZXN0Lmdvb2dsZS5iZYISKi50ZXN0LnlvdXR1YmUuY29thwTAqAEDMA0G
CSqGSIb3DQEBCwUAA4GBAJFXVifQNub1LUP4JlnX5lXNlo8FxZ2a12AFQs+bzoJ6
hM044EDjqyxUqSbVePK0ni3w1fHQB5rY9yYC5f8G7aqqTY1QOhoUk8ZTSTRpnkTh
y4jjdvTZeLDVBlueZUTDRmy2feY5aZIU18vFDK08dTG0A87pppuv1LNIR3loveU8
-----END CERTIFICATE-----

View File

@ -18,8 +18,9 @@
'use strict';
var interop_server = require('../interop/interop_server.js');
var interop_client = require('../interop/interop_client.js');
require('../../../test/fixtures/native_native.js');
var interop_server = require('../../../test/interop/interop_server.js');
var interop_client = require('../../../test/interop/interop_client.js');
var server;

View File

@ -16,8 +16,8 @@
// limitations under the License.
//
'use strict';
var grpc = require('../../any_grpc.js');
var math_math_pb = require('../math/math_pb.js');
var grpc = require('../..');
var math_math_pb = require('./math_pb.js');
function serialize_DivArgs(arg) {
if (!(arg instanceof math_math_pb.DivArgs)) {

View File

@ -18,7 +18,7 @@
'use strict';
var grpc = require('../../any_grpc.js');
var grpc = require('../..');
var grpcMath = require('./math_grpc_pb');
var math = require('./math_pb');

View File

@ -20,7 +20,7 @@
var assert = require('assert');
var grpc = require('../any_grpc');
var grpc = require('..');
var math = require('./math/math_pb');
var MathClient = require('./math/math_grpc_pb').MathClient;

View File

@ -18,7 +18,7 @@
'use strict';
var Metadata = require('../any_grpc').Metadata;
var Metadata = require('..').Metadata;
var assert = require('assert');

View File

@ -72,8 +72,8 @@ describe('server', function() {
});
it('should bind to an unused port with ssl credentials', function() {
var port;
var key_path = path.join(__dirname, '../../../test/data/server1.key');
var pem_path = path.join(__dirname, '../../../test/data/server1.pem');
var key_path = path.join(__dirname, '/data/server1.key');
var pem_path = path.join(__dirname, '/data/server1.pem');
var key_data = fs.readFileSync(key_path);
var pem_data = fs.readFileSync(pem_path);
var creds = grpc.ServerCredentials.createSsl(null,

View File

@ -21,10 +21,10 @@
var assert = require('assert');
var _ = require('lodash');
var grpc = require('../any_grpc');
var grpc = require('..');
var MathClient = grpc.load(
__dirname + '/../../packages/grpc-native-core/deps/grpc/src/proto/math/math.proto').math.Math;
__dirname + '/../deps/grpc/src/proto/math/math.proto').math.Math;
var mathServiceAttrs = MathClient.service;
/**
@ -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('../package.json').version;
var call = client.unary({}, metadata,
function(err, data) { assert.ifError(err); });
call.on('metadata', function(metadata) {

View File

@ -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);
});
});
});

View File

@ -1,24 +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.
syntax = "proto3";
message EchoMessage {
string value = 1;
int32 value2 = 2;
}
service EchoService {
rpc Echo (EchoMessage) returns (EchoMessage);
}

View File

@ -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');
});
});
});

View File

@ -1,45 +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.
syntax = "proto3";
message LongValues {
int64 int_64 = 1;
uint64 uint_64 = 2;
sint64 sint_64 = 3;
fixed64 fixed_64 = 4;
sfixed64 sfixed_64 = 5;
}
message SequenceValues {
bytes bytes_field = 1;
repeated int32 repeated_field = 2;
}
message OneOfValues {
oneof oneof_choice {
int32 int_choice = 1;
string string_choice = 2;
}
}
enum TestEnum {
ZERO = 0;
ONE = 1;
TWO = 2;
}
message EnumValues {
TestEnum enum_value = 1;
}

View File

@ -35,29 +35,4 @@ 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());
});
gulp.task('test', 'Run API-level tests', () => {});

View File

@ -14,13 +14,7 @@
}
],
"dependencies": {
"async": "^2.0.1",
"body-parser": "^1.15.2",
"express": "^4.14.0",
"google-auth-library": "^0.9.2",
"google-protobuf": "^3.0.0",
"lodash": "^4.17.4",
"minimist": "^1.1.0",
"poisson-process": "^0.2.1"
"lodash": "^4.17.4"
}
}