Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(851)

Side by Side Diff: third_party/grpc/src/node/test/health_test.js

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 *
3 * Copyright 2015, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34 'use strict';
35
36 var assert = require('assert');
37
38 var health = require('../health_check/health.js');
39
40 var grpc = require('../');
41
42 describe('Health Checking', function() {
43 var statusMap = {
44 '': 'SERVING',
45 'grpc.test.TestServiceNotServing': 'NOT_SERVING',
46 'grpc.test.TestServiceServing': 'SERVING'
47 };
48 var healthServer;
49 var healthImpl;
50 var healthClient;
51 before(function() {
52 healthServer = new grpc.Server();
53 healthImpl = new health.Implementation(statusMap);
54 healthServer.addProtoService(health.service, healthImpl);
55 var port_num = healthServer.bind('0.0.0.0:0',
56 grpc.ServerCredentials.createInsecure());
57 healthServer.start();
58 healthClient = new health.Client('localhost:' + port_num,
59 grpc.credentials.createInsecure());
60 });
61 after(function() {
62 healthServer.forceShutdown();
63 });
64 it('should say an enabled service is SERVING', function(done) {
65 healthClient.check({service: ''}, function(err, response) {
66 assert.ifError(err);
67 assert.strictEqual(response.status, 'SERVING');
68 done();
69 });
70 });
71 it('should say that a disabled service is NOT_SERVING', function(done) {
72 healthClient.check({service: 'grpc.test.TestServiceNotServing'},
73 function(err, response) {
74 assert.ifError(err);
75 assert.strictEqual(response.status, 'NOT_SERVING');
76 done();
77 });
78 });
79 it('should say that an enabled service is SERVING', function(done) {
80 healthClient.check({service: 'grpc.test.TestServiceServing'},
81 function(err, response) {
82 assert.ifError(err);
83 assert.strictEqual(response.status, 'SERVING');
84 done();
85 });
86 });
87 it('should get NOT_FOUND if the service is not registered', function(done) {
88 healthClient.check({service: 'not_registered'}, function(err, response) {
89 assert(err);
90 assert.strictEqual(err.code, grpc.status.NOT_FOUND);
91 done();
92 });
93 });
94 it('should get a different response if the status changes', function(done) {
95 healthClient.check({service: 'transient'}, function(err, response) {
96 assert(err);
97 assert.strictEqual(err.code, grpc.status.NOT_FOUND);
98 healthImpl.setStatus('transient', 'SERVING');
99 healthClient.check({service: 'transient'}, function(err, response) {
100 assert.ifError(err);
101 assert.strictEqual(response.status, 'SERVING');
102 done();
103 });
104 });
105 });
106 });
OLDNEW
« no previous file with comments | « third_party/grpc/src/node/test/end_to_end_test.js ('k') | third_party/grpc/src/node/test/interop_sanity_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698