@@ -148,6 +148,38 @@ describe('Bigtable', () => {
148
148
assert . deepStrictEqual ( bigtable . api , { } ) ;
149
149
} ) ;
150
150
151
+ it ( 'should set grpc keepalive options' , ( ) => {
152
+ const bigtable = Bigtable ( ) ;
153
+ assert . strictEqual (
154
+ bigtable . options . BigtableClient [ 'grpc.keepalive_time_ms' ] ,
155
+ 30000
156
+ ) ;
157
+ assert . strictEqual (
158
+ bigtable . options . BigtableClient [ 'grpc.keepalive_timeout_ms' ] ,
159
+ 10000
160
+ ) ;
161
+
162
+ assert . strictEqual (
163
+ bigtable . options . BigtableInstanceAdminClient [ 'grpc.keepalive_time_ms' ] ,
164
+ 30000
165
+ ) ;
166
+ assert . strictEqual (
167
+ bigtable . options . BigtableInstanceAdminClient [
168
+ 'grpc.keepalive_timeout_ms'
169
+ ] ,
170
+ 10000
171
+ ) ;
172
+
173
+ assert . strictEqual (
174
+ bigtable . options . BigtableTableAdminClient [ 'grpc.keepalive_time_ms' ] ,
175
+ 30000
176
+ ) ;
177
+ assert . strictEqual (
178
+ bigtable . options . BigtableTableAdminClient [ 'grpc.keepalive_timeout_ms' ] ,
179
+ 10000
180
+ ) ;
181
+ } ) ;
182
+
151
183
it ( 'should cache a local google-auth-library instance' , ( ) => {
152
184
const fakeGoogleAuthInstance = { } ;
153
185
const options = {
@@ -163,6 +195,8 @@ describe('Bigtable', () => {
163
195
libName : 'gccl' ,
164
196
libVersion : PKG . version ,
165
197
scopes : EXPECTED_SCOPES ,
198
+ 'grpc.keepalive_time_ms' : 30000 ,
199
+ 'grpc.keepalive_timeout_ms' : 10000 ,
166
200
} ,
167
201
options
168
202
)
@@ -185,38 +219,37 @@ describe('Bigtable', () => {
185
219
} ;
186
220
187
221
const bigtable = new Bigtable ( options ) ;
188
- const defaultOptions = {
189
- a : 'b' ,
190
- c : 'd' ,
191
- libName : 'gccl' ,
192
- libVersion : PKG . version ,
193
- scopes : EXPECTED_SCOPES ,
194
- } ;
222
+ const expectedOptions = Object . assign (
223
+ {
224
+ port : 443 ,
225
+ sslCreds : undefined ,
226
+ libName : 'gccl' ,
227
+ libVersion : PKG . version ,
228
+ scopes : EXPECTED_SCOPES ,
229
+ 'grpc.keepalive_time_ms' : 30000 ,
230
+ 'grpc.keepalive_timeout_ms' : 10000 ,
231
+ } ,
232
+ options
233
+ ) ;
195
234
196
235
assert . deepStrictEqual ( bigtable . options , {
197
236
BigtableClient : Object . assign (
198
237
{
199
238
servicePath : 'bigtable.googleapis.com' ,
200
- port : 443 ,
201
- sslCreds : undefined ,
202
239
} ,
203
- defaultOptions
240
+ expectedOptions
204
241
) ,
205
242
BigtableInstanceAdminClient : Object . assign (
206
243
{
207
244
servicePath : 'bigtableadmin.googleapis.com' ,
208
- port : 443 ,
209
- sslCreds : undefined ,
210
245
} ,
211
- defaultOptions
246
+ expectedOptions
212
247
) ,
213
248
BigtableTableAdminClient : Object . assign (
214
249
{
215
250
servicePath : 'bigtableadmin.googleapis.com' ,
216
- port : 443 ,
217
- sslCreds : undefined ,
218
251
} ,
219
- defaultOptions
252
+ expectedOptions
220
253
) ,
221
254
} ) ;
222
255
} ) ;
@@ -227,11 +260,22 @@ describe('Bigtable', () => {
227
260
const options = {
228
261
a : 'b' ,
229
262
c : 'd' ,
230
- libName : 'gccl' ,
231
- libVersion : PKG . version ,
232
- scopes : EXPECTED_SCOPES ,
233
263
} ;
234
264
265
+ const expectedOptions = Object . assign (
266
+ {
267
+ servicePath : 'override' ,
268
+ port : 8080 ,
269
+ sslCreds : grpc . credentials . createInsecure ( ) ,
270
+ libName : 'gccl' ,
271
+ libVersion : PKG . version ,
272
+ scopes : EXPECTED_SCOPES ,
273
+ 'grpc.keepalive_time_ms' : 30000 ,
274
+ 'grpc.keepalive_timeout_ms' : 10000 ,
275
+ } ,
276
+ options
277
+ ) ;
278
+
235
279
const bigtable = new Bigtable ( options ) ;
236
280
237
281
assert . strictEqual (
@@ -240,30 +284,9 @@ describe('Bigtable', () => {
240
284
) ;
241
285
242
286
assert . deepStrictEqual ( bigtable . options , {
243
- BigtableClient : Object . assign (
244
- {
245
- servicePath : 'override' ,
246
- port : 8080 ,
247
- sslCreds : grpc . credentials . createInsecure ( ) ,
248
- } ,
249
- options
250
- ) ,
251
- BigtableInstanceAdminClient : Object . assign (
252
- {
253
- servicePath : 'override' ,
254
- port : 8080 ,
255
- sslCreds : grpc . credentials . createInsecure ( ) ,
256
- } ,
257
- options
258
- ) ,
259
- BigtableTableAdminClient : Object . assign (
260
- {
261
- servicePath : 'override' ,
262
- port : 8080 ,
263
- sslCreds : grpc . credentials . createInsecure ( ) ,
264
- } ,
265
- options
266
- ) ,
287
+ BigtableClient : expectedOptions ,
288
+ BigtableInstanceAdminClient : expectedOptions ,
289
+ BigtableTableAdminClient : expectedOptions ,
267
290
} ) ;
268
291
} ) ;
269
292
@@ -272,40 +295,30 @@ describe('Bigtable', () => {
272
295
apiEndpoint : 'customEndpoint:9090' ,
273
296
a : 'b' ,
274
297
c : 'd' ,
275
- libName : 'gccl' ,
276
- libVersion : PKG . version ,
277
- scopes : EXPECTED_SCOPES ,
278
298
} ;
279
299
300
+ const expectedOptions = Object . assign (
301
+ {
302
+ servicePath : 'customEndpoint' ,
303
+ port : 9090 ,
304
+ sslCreds : grpc . credentials . createInsecure ( ) ,
305
+ libName : 'gccl' ,
306
+ libVersion : PKG . version ,
307
+ scopes : EXPECTED_SCOPES ,
308
+ 'grpc.keepalive_time_ms' : 30000 ,
309
+ 'grpc.keepalive_timeout_ms' : 10000 ,
310
+ } ,
311
+ options
312
+ ) ;
313
+
280
314
const bigtable = new Bigtable ( options ) ;
281
315
282
316
assert . strictEqual ( bigtable . customEndpoint , options . apiEndpoint ) ;
283
317
284
318
assert . deepStrictEqual ( bigtable . options , {
285
- BigtableClient : Object . assign (
286
- {
287
- servicePath : 'customEndpoint' ,
288
- port : 9090 ,
289
- sslCreds : grpc . credentials . createInsecure ( ) ,
290
- } ,
291
- options
292
- ) ,
293
- BigtableInstanceAdminClient : Object . assign (
294
- {
295
- servicePath : 'customEndpoint' ,
296
- port : 9090 ,
297
- sslCreds : grpc . credentials . createInsecure ( ) ,
298
- } ,
299
- options
300
- ) ,
301
- BigtableTableAdminClient : Object . assign (
302
- {
303
- servicePath : 'customEndpoint' ,
304
- port : 9090 ,
305
- sslCreds : grpc . credentials . createInsecure ( ) ,
306
- } ,
307
- options
308
- ) ,
319
+ BigtableClient : expectedOptions ,
320
+ BigtableInstanceAdminClient : expectedOptions ,
321
+ BigtableTableAdminClient : expectedOptions ,
309
322
} ) ;
310
323
} ) ;
311
324
0 commit comments