@@ -29,59 +29,8 @@ import (
29
29
"google.golang.org/grpc/internal/testutils"
30
30
"google.golang.org/grpc/xds/internal/testutils/fakeclient"
31
31
"google.golang.org/grpc/xds/internal/xdsclient/xdsresource"
32
- "google.golang.org/protobuf/proto"
33
32
)
34
33
35
- func (s ) TestFindBestMatchingVirtualHost (t * testing.T ) {
36
- var (
37
- oneExactMatch = & xdsresource.VirtualHost {
38
- Domains : []string {"foo.bar.com" },
39
- }
40
- oneSuffixMatch = & xdsresource.VirtualHost {
41
- Domains : []string {"*.bar.com" },
42
- }
43
- onePrefixMatch = & xdsresource.VirtualHost {
44
- Domains : []string {"foo.bar.*" },
45
- }
46
- oneUniversalMatch = & xdsresource.VirtualHost {
47
- Domains : []string {"*" },
48
- }
49
- longExactMatch = & xdsresource.VirtualHost {
50
- Domains : []string {"v2.foo.bar.com" },
51
- }
52
- multipleMatch = & xdsresource.VirtualHost {
53
- Domains : []string {"pi.foo.bar.com" , "314.*" , "*.159" },
54
- }
55
- vhs = []* xdsresource.VirtualHost {oneExactMatch , oneSuffixMatch , onePrefixMatch , oneUniversalMatch , longExactMatch , multipleMatch }
56
- )
57
-
58
- tests := []struct {
59
- name string
60
- host string
61
- vHosts []* xdsresource.VirtualHost
62
- want * xdsresource.VirtualHost
63
- }{
64
- {name : "exact-match" , host : "foo.bar.com" , vHosts : vhs , want : oneExactMatch },
65
- {name : "suffix-match" , host : "123.bar.com" , vHosts : vhs , want : oneSuffixMatch },
66
- {name : "prefix-match" , host : "foo.bar.org" , vHosts : vhs , want : onePrefixMatch },
67
- {name : "universal-match" , host : "abc.123" , vHosts : vhs , want : oneUniversalMatch },
68
- {name : "long-exact-match" , host : "v2.foo.bar.com" , vHosts : vhs , want : longExactMatch },
69
- // Matches suffix "*.bar.com" and exact "pi.foo.bar.com". Takes exact.
70
- {name : "multiple-match-exact" , host : "pi.foo.bar.com" , vHosts : vhs , want : multipleMatch },
71
- // Matches suffix "*.159" and prefix "foo.bar.*". Takes suffix.
72
- {name : "multiple-match-suffix" , host : "foo.bar.159" , vHosts : vhs , want : multipleMatch },
73
- // Matches suffix "*.bar.com" and prefix "314.*". Takes suffix.
74
- {name : "multiple-match-prefix" , host : "314.bar.com" , vHosts : vhs , want : oneSuffixMatch },
75
- }
76
- for _ , tt := range tests {
77
- t .Run (tt .name , func (t * testing.T ) {
78
- if got := xdsresource .FindBestMatchingVirtualHost (tt .host , tt .vHosts ); ! cmp .Equal (got , tt .want , cmp .Comparer (proto .Equal )) {
79
- t .Errorf ("findBestMatchingxdsclient.VirtualHost() = %v, want %v" , got , tt .want )
80
- }
81
- })
82
- }
83
- }
84
-
85
34
type serviceUpdateErr struct {
86
35
u serviceUpdate
87
36
err error
0 commit comments