Skip to content

Commit

Permalink
Merge pull request #286 from murgatroid99/cross_impl_perf_tests
Browse files Browse the repository at this point in the history
Update benchmark code to handle both implementations
  • Loading branch information
murgatroid99 authored Apr 20, 2018
2 parents 7667741 + 0b075f1 commit a237967
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 21 deletions.
1 change: 1 addition & 0 deletions packages/grpc-js-core/src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export class Http2Channel extends EventEmitter implements Channel {
ConnectivityState.TRANSIENT_FAILURE);
};
subChannel.once('close', this.subChannelCloseCallback);
subChannel.once('error', this.subChannelCloseCallback);
}

constructor(
Expand Down
5 changes: 5 additions & 0 deletions packages/grpc-js-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,8 @@ export {
* @param client The client to close.
*/
export const closeClient = (client: Client) => client.close();

export const waitForClientReady =
(client: Client, deadline: Date|number,
callback: (error: Error|null) => void) =>
client.waitForReady(deadline, callback);
4 changes: 3 additions & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
}
],
"dependencies": {
"express": "^4.16.3",
"google-auth-library": "^0.9.2",
"lodash": "^4.17.4"
"lodash": "^4.17.4",
"poisson-process": "^1.0.0"
}
}
16 changes: 11 additions & 5 deletions test/performance/benchmark_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ var Histogram = require('./histogram');
var genericService = require('./generic_service');

// TODO(murgatroid99): use multiple grpc implementations
var grpc = require('grpc');
var serviceProto = grpc.load({
root: __dirname + '/../packages/grpc-native-core/ext/grpc',
file: 'src/proto/grpc/testing/services.proto'}).grpc.testing;
var grpc = require('../any_grpc').client;
var protoLoader = require('../../packages/grpc-protobufjs');
var protoPackage = protoLoader.loadSync(
'src/proto/grpc/testing/services.proto',
{keepCase: true,
defaults: true,
enums: String,
oneofs: true,
include: [__dirname + '/../../packages/grpc-native-core/deps/grpc']});
var serviceProto = grpc.loadPackageDefinition(protoPackage).grpc.testing;

/**
* Create a buffer filled with size zeroes
Expand Down Expand Up @@ -82,7 +88,7 @@ function BenchmarkClient(server_targets, channels, histogram_params,
if (security_params) {
var ca_path;
if (security_params.use_test_ca) {
ca_path = path.join(__dirname, '../test/data/ca.pem');
ca_path = path.join(__dirname, '../data/ca.pem');
var ca_data = fs.readFileSync(ca_path);
creds = grpc.credentials.createSsl(ca_data);
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/performance/benchmark_client_express.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function BenchmarkClient(server_targets, channels, histogram_params,
protocol = https;
this.request = _.bind(https.request, https);
if (security_params.use_test_ca) {
ca_path = path.join(__dirname, '../test/data/ca.pem');
ca_path = path.join(__dirname, '../data/ca.pem');
var ca_data = fs.readFileSync(ca_path);
options.ca = ca_data;
}
Expand Down
19 changes: 12 additions & 7 deletions test/performance/benchmark_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ var util = require('util');

var genericService = require('./generic_service');

// TODO(murgatroid99): use multiple grpc implementations
var grpc = require('grpc');
var serviceProto = grpc.load({
root: __dirname + '/../packages/grpc-native-core/ext/grpc',
file: 'src/proto/grpc/testing/services.proto'}).grpc.testing;
var grpc = require('../any_grpc').server;
var protoLoader = require('../../packages/grpc-protobufjs');
var protoPackage = protoLoader.loadSync(
'src/proto/grpc/testing/services.proto',
{keepCase: true,
defaults: true,
enums: String,
oneofs: true,
include: [__dirname + '/../../packages/grpc-native-core/deps/grpc']});
var serviceProto = grpc.loadPackageDefinition(protoPackage).grpc.testing;

/**
* Create a buffer filled with size zeroes
Expand Down Expand Up @@ -106,8 +111,8 @@ function BenchmarkServer(host, port, tls, generic, response_size) {
var server_creds;
var host_override;
if (tls) {
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);
Expand Down
4 changes: 2 additions & 2 deletions test/performance/benchmark_server_express.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function BenchmarkServer(host, port, tls, generic, response_size) {
this.input_port = port;
if (tls) {
var credentials = {};
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);
Expand Down
15 changes: 10 additions & 5 deletions test/performance/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@
var console = require('console');
var WorkerServiceImpl = require('./worker_service_impl');

// TODO(murgatroid99): use multiple grpc implementations
var grpc = require('grpc');
var serviceProto = grpc.load({
root: __dirname + '/../packages/grpc-native-core/ext/grpc',
file: 'src/proto/grpc/testing/services.proto'}).grpc.testing;
var grpc = require('../any_grpc').server;
var protoLoader = require('../../packages/grpc-protobufjs');
var protoPackage = protoLoader.loadSync(
'src/proto/grpc/testing/services.proto',
{keepCase: true,
defaults: true,
enums: String,
oneofs: true,
include: [__dirname + '/../../packages/grpc-native-core/deps/grpc']});
var serviceProto = grpc.loadPackageDefinition(protoPackage).grpc.testing;

function runServer(port, benchmark_impl) {
var server_creds = grpc.ServerCredentials.createInsecure();
Expand Down

0 comments on commit a237967

Please sign in to comment.