Etcd router bug fixing etcd path prefix matching name (#1899)
* add logging and don't get nodes where they exist in router * add more logging * Fix the etcd bug for name matching of keys and prefixes matching names
This commit is contained in:
		
							
								
								
									
										53
									
								
								registry/etcd/etcd_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								registry/etcd/etcd_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| package etcd | ||||
|  | ||||
| import ( | ||||
| 	"testing" | ||||
| ) | ||||
|  | ||||
| // test whether the name matches | ||||
| func TestEtcdHasName(t *testing.T) { | ||||
| 	testCases := []struct { | ||||
| 		key    string | ||||
| 		prefix string | ||||
| 		name   string | ||||
| 		expect bool | ||||
| 	}{ | ||||
| 		{ | ||||
| 			"/micro/registry/micro/registry", | ||||
| 			"/micro/registry", | ||||
| 			"registry", | ||||
| 			true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			"/micro/registry/micro/store", | ||||
| 			"/micro/registry", | ||||
| 			"registry", | ||||
| 			false, | ||||
| 		}, | ||||
| 		{ | ||||
| 			"/prefix/baz/*/registry", | ||||
| 			"/prefix/baz", | ||||
| 			"registry", | ||||
| 			true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			"/prefix/baz/micro/registry", | ||||
| 			"/prefix/baz", | ||||
| 			"store", | ||||
| 			false, | ||||
| 		}, | ||||
| 		{ | ||||
| 			"/prefix/baz/micro/registry", | ||||
| 			"/prefix/baz", | ||||
| 			"registry", | ||||
| 			true, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	for _, c := range testCases { | ||||
| 		v := hasName(c.key, c.prefix, c.name) | ||||
| 		if v != c.expect { | ||||
| 			t.Fatalf("Expected %t for %v got: %t", c.expect, c, v) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user