mirror of https://github.com/grpc/grpc-node.git
				
				
				
			Add resolver tests
This commit is contained in:
		
							parent
							
								
									454b4183b5
								
							
						
					
					
						commit
						fefc4dbba7
					
				|  | @ -62,7 +62,7 @@ | |||
|     "all": true | ||||
|   }, | ||||
|   "scripts": { | ||||
|     "test": "nyc gulp test", | ||||
|     "test": "nyc gulp test && GRPC_DNS_RESOLVER=ares nyc gulp nativeTestOnly", | ||||
|     "coverage": "nyc report --reporter=text-lcov | coveralls" | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -0,0 +1,69 @@ | |||
| /* | ||||
|  * | ||||
|  * Copyright 2019 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 _ = require('lodash'); | ||||
| 
 | ||||
| var grpc = require('..'); | ||||
| 
 | ||||
| const insecureCreds = grpc.credentials.createInsecure(); | ||||
| 
 | ||||
| describe('Name resolver', function() { | ||||
|   let server; | ||||
|   let port; | ||||
|   before(function(done) { | ||||
|     const insecureServerCreds = grpc.ServerCredentials.createInsecure(); | ||||
|     server = new grpc.Server(); | ||||
|     server.bindAsync('localhost:0', insecureServerCreds, (error, portVal) => { | ||||
|       port = portVal; | ||||
|       done(error); | ||||
|     }); | ||||
|   }); | ||||
|   after(function() { | ||||
|     server.forceShutdown(); | ||||
|   }); | ||||
|   it('Should resolve a target to IPv4 addresses', function(done) { | ||||
|     const client = new grpc.Client(`loopback4.unittest.grpc.io:${port}`, insecureCreds); | ||||
|     let deadline = new Date(); | ||||
|     deadline.setSeconds(deadline.getSeconds() + 1); | ||||
|     client.waitForReady(deadline, (error) => { | ||||
|       assert.ifError(error); | ||||
|       done(); | ||||
|     }); | ||||
|   }); | ||||
|   it('Should resolve a target to IPv6 addresses', function(done) { | ||||
|     const client = new grpc.Client(`loopback6.unittest.grpc.io:${port}`, insecureCreds); | ||||
|     let deadline = new Date(); | ||||
|     deadline.setSeconds(deadline.getSeconds() + 1); | ||||
|     client.waitForReady(deadline, (error) => { | ||||
|       assert.ifError(error); | ||||
|       done(); | ||||
|     }); | ||||
|   }); | ||||
|   it('Should resolve a target to IPv4 and IPv6 addresses', function(done) { | ||||
|     const client = new grpc.Client(`loopback46.unittest.grpc.io:${port}`, insecureCreds); | ||||
|     let deadline = new Date(); | ||||
|     deadline.setSeconds(deadline.getSeconds() + 1); | ||||
|     client.waitForReady(deadline, (error) => { | ||||
|       assert.ifError(error); | ||||
|       done(); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
|  | @ -56,6 +56,7 @@ for %%v in (6 7 8 9 10 11 12) do ( | |||
|   call .\node_modules\.bin\gulp cleanAll || SET FAILED=1 | ||||
|   call .\node_modules\.bin\gulp setupWindows || SET FAILED=1 | ||||
|   call .\node_modules\.bin\gulp test || SET FAILED=1 | ||||
|   cmd.exe /c "SET GRPC_DNS_RESOLVER=ares& call .\node_modules\.bin\gulp nativeTestOnly" || SET FAILED=1 | ||||
| ) | ||||
| 
 | ||||
| node merge_kokoro_logs.js | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue