| 
									
										
										
										
											2016-04-26 20:45:29 +01:00
										 |  |  | package test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"testing" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-14 09:36:06 +01:00
										 |  |  | 	"github.com/coredns/coredns/plugin/test" | 
					
						
							| 
									
										
										
										
											2016-04-26 20:45:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/miekg/dns" | 
					
						
							| 
									
										
										
										
											2018-01-15 13:54:10 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Load all managed plugins in github.com/coredns/coredns | 
					
						
							|  |  |  | 	_ "github.com/coredns/coredns/core/plugin" | 
					
						
							| 
									
										
										
										
											2016-04-26 20:45:29 +01:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-19 17:14:17 -07:00
										 |  |  | func benchmarkLookupBalanceRewriteCache(b *testing.B) { | 
					
						
							| 
									
										
										
										
											2016-04-26 20:45:29 +01:00
										 |  |  | 	t := new(testing.T) | 
					
						
							| 
									
										
										
										
											2016-10-02 15:58:01 +01:00
										 |  |  | 	name, rm, err := test.TempFile(".", exampleOrg) | 
					
						
							| 
									
										
										
										
											2016-04-26 20:45:29 +01:00
										 |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2018-06-01 15:12:49 +01:00
										 |  |  | 		t.Fatalf("Failed to create zone: %s", err) | 
					
						
							| 
									
										
										
										
											2016-04-26 20:45:29 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	defer rm() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	corefile := `example.org:0 { | 
					
						
							|  |  |  |     file ` + name + ` | 
					
						
							| 
									
										
										
										
											2017-03-06 16:32:17 -05:00
										 |  |  |     rewrite type ANY HINFO | 
					
						
							| 
									
										
										
										
											2016-04-26 20:45:29 +01:00
										 |  |  |     loadbalance | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ` | 
					
						
							| 
									
										
										
										
											2016-08-19 17:14:17 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-24 11:35:14 +01:00
										 |  |  | 	ex, udp, _, err := CoreDNSServerAndPorts(corefile) | 
					
						
							| 
									
										
										
										
											2016-04-26 20:45:29 +01:00
										 |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2016-10-02 08:31:44 +01:00
										 |  |  | 		t.Fatalf("Could not get CoreDNS serving instance: %s", err) | 
					
						
							| 
									
										
										
										
											2016-04-26 20:45:29 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	defer ex.Stop() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	c := new(dns.Client) | 
					
						
							|  |  |  | 	m := new(dns.Msg) | 
					
						
							|  |  |  | 	m.SetQuestion("example.org.", dns.TypeA) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	b.ResetTimer() | 
					
						
							|  |  |  | 	for i := 0; i < b.N; i++ { | 
					
						
							|  |  |  | 		c.Exchange(m, udp) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |