Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
4100da89
Commit
4100da89
authored
Jan 31, 2020
by
Miek Gieben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests
Signed-off-by:
Miek Gieben
<
miek@miek.nl
>
parent
00d62e62
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
20 deletions
+21
-20
plugin/traffic/traffic_test.go
plugin/traffic/traffic_test.go
+21
-20
No files found.
plugin/traffic/traffic_test.go
View file @
4100da89
...
@@ -9,9 +9,8 @@ import (
...
@@ -9,9 +9,8 @@ import (
"github.com/coredns/coredns/plugin/test"
"github.com/coredns/coredns/plugin/test"
"github.com/coredns/coredns/plugin/traffic/xds"
"github.com/coredns/coredns/plugin/traffic/xds"
xdspb
"github.com/envoyproxy/go-control-plane/envoy/api/v2"
corepb
"github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
corepb
"github.com/envoyproxy/go-control-plane/envoy/api/v2/core"
endpointpb
"github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
endpointpb
"github.com/envoyproxy/go-control-plane/envoy/api/v2/endpoint"
"github.com/miekg/dns"
"github.com/miekg/dns"
"google.golang.org/grpc"
"google.golang.org/grpc"
)
)
...
@@ -24,7 +23,7 @@ func TestTraffic(t *testing.T) {
...
@@ -24,7 +23,7 @@ func TestTraffic(t *testing.T) {
tr
:=
&
Traffic
{
c
:
c
,
origins
:
[]
string
{
"lb.example.org."
}}
tr
:=
&
Traffic
{
c
:
c
,
origins
:
[]
string
{
"lb.example.org."
}}
tests
:=
[]
struct
{
tests
:=
[]
struct
{
cla
*
xds
pb
.
ClusterLoadAssignment
cla
*
endpoint
pb
.
ClusterLoadAssignment
cluster
string
cluster
string
qtype
uint16
qtype
uint16
rcode
int
rcode
int
...
@@ -32,27 +31,27 @@ func TestTraffic(t *testing.T) {
...
@@ -32,27 +31,27 @@ func TestTraffic(t *testing.T) {
ns
bool
// should there be a ns section.
ns
bool
// should there be a ns section.
}{
}{
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{},
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{},
cluster
:
"web"
,
qtype
:
dns
.
TypeA
,
rcode
:
dns
.
RcodeSuccess
,
ns
:
true
,
cluster
:
"web"
,
qtype
:
dns
.
TypeA
,
rcode
:
dns
.
RcodeSuccess
,
ns
:
true
,
},
},
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{},
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{},
cluster
:
"web"
,
qtype
:
dns
.
TypeSRV
,
rcode
:
dns
.
RcodeSuccess
,
ns
:
true
,
cluster
:
"web"
,
qtype
:
dns
.
TypeSRV
,
rcode
:
dns
.
RcodeSuccess
,
ns
:
true
,
},
},
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{},
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{},
cluster
:
"does-not-exist"
,
qtype
:
dns
.
TypeA
,
rcode
:
dns
.
RcodeNameError
,
ns
:
true
,
cluster
:
"does-not-exist"
,
qtype
:
dns
.
TypeA
,
rcode
:
dns
.
RcodeNameError
,
ns
:
true
,
},
},
// healthy endpoint
// healthy endpoint
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{
ClusterName
:
"web"
,
ClusterName
:
"web"
,
Endpoints
:
endpoints
([]
EndpointHealth
{{
"127.0.0.1"
,
18008
,
corepb
.
HealthStatus_HEALTHY
}}),
Endpoints
:
endpoints
([]
EndpointHealth
{{
"127.0.0.1"
,
18008
,
corepb
.
HealthStatus_HEALTHY
}}),
},
},
cluster
:
"web"
,
qtype
:
dns
.
TypeA
,
rcode
:
dns
.
RcodeSuccess
,
answer
:
"127.0.0.1"
,
cluster
:
"web"
,
qtype
:
dns
.
TypeA
,
rcode
:
dns
.
RcodeSuccess
,
answer
:
"127.0.0.1"
,
},
},
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{
ClusterName
:
"web"
,
ClusterName
:
"web"
,
Endpoints
:
endpoints
([]
EndpointHealth
{{
"::1"
,
18008
,
corepb
.
HealthStatus_HEALTHY
}}),
Endpoints
:
endpoints
([]
EndpointHealth
{{
"::1"
,
18008
,
corepb
.
HealthStatus_HEALTHY
}}),
},
},
...
@@ -60,7 +59,7 @@ func TestTraffic(t *testing.T) {
...
@@ -60,7 +59,7 @@ func TestTraffic(t *testing.T) {
},
},
// unknown endpoint
// unknown endpoint
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{
ClusterName
:
"web"
,
ClusterName
:
"web"
,
Endpoints
:
endpoints
([]
EndpointHealth
{{
"127.0.0.1"
,
18008
,
corepb
.
HealthStatus_UNKNOWN
}}),
Endpoints
:
endpoints
([]
EndpointHealth
{{
"127.0.0.1"
,
18008
,
corepb
.
HealthStatus_UNKNOWN
}}),
},
},
...
@@ -68,7 +67,7 @@ func TestTraffic(t *testing.T) {
...
@@ -68,7 +67,7 @@ func TestTraffic(t *testing.T) {
},
},
// unknown endpoint and healthy endpoint
// unknown endpoint and healthy endpoint
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{
ClusterName
:
"web"
,
ClusterName
:
"web"
,
Endpoints
:
endpoints
([]
EndpointHealth
{
Endpoints
:
endpoints
([]
EndpointHealth
{
{
"127.0.0.1"
,
18008
,
corepb
.
HealthStatus_UNKNOWN
},
{
"127.0.0.1"
,
18008
,
corepb
.
HealthStatus_UNKNOWN
},
...
@@ -79,7 +78,7 @@ func TestTraffic(t *testing.T) {
...
@@ -79,7 +78,7 @@ func TestTraffic(t *testing.T) {
},
},
// SRV query healthy endpoint
// SRV query healthy endpoint
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{
ClusterName
:
"web"
,
ClusterName
:
"web"
,
Endpoints
:
endpoints
([]
EndpointHealth
{
Endpoints
:
endpoints
([]
EndpointHealth
{
{
"127.0.0.2"
,
18008
,
corepb
.
HealthStatus_HEALTHY
},
{
"127.0.0.2"
,
18008
,
corepb
.
HealthStatus_HEALTHY
},
...
@@ -89,7 +88,7 @@ func TestTraffic(t *testing.T) {
...
@@ -89,7 +88,7 @@ func TestTraffic(t *testing.T) {
},
},
// A query for endpoint-0.
// A query for endpoint-0.
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{
ClusterName
:
"web"
,
ClusterName
:
"web"
,
Endpoints
:
endpoints
([]
EndpointHealth
{
Endpoints
:
endpoints
([]
EndpointHealth
{
{
"127.0.0.2"
,
18008
,
corepb
.
HealthStatus_HEALTHY
},
{
"127.0.0.2"
,
18008
,
corepb
.
HealthStatus_HEALTHY
},
...
@@ -99,7 +98,7 @@ func TestTraffic(t *testing.T) {
...
@@ -99,7 +98,7 @@ func TestTraffic(t *testing.T) {
},
},
// A query for endpoint-1.
// A query for endpoint-1.
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{
ClusterName
:
"web"
,
ClusterName
:
"web"
,
Endpoints
:
endpoints
([]
EndpointHealth
{
Endpoints
:
endpoints
([]
EndpointHealth
{
{
"127.0.0.2"
,
18008
,
corepb
.
HealthStatus_HEALTHY
},
{
"127.0.0.2"
,
18008
,
corepb
.
HealthStatus_HEALTHY
},
...
@@ -161,17 +160,19 @@ func TestTrafficLocality(t *testing.T) {
...
@@ -161,17 +160,19 @@ func TestTrafficLocality(t *testing.T) {
tr
:=
&
Traffic
{
c
:
c
,
origins
:
[]
string
{
"lb.example.org."
}}
tr
:=
&
Traffic
{
c
:
c
,
origins
:
[]
string
{
"lb.example.org."
}}
tests
:=
[]
struct
{
tests
:=
[]
struct
{
cla
*
xds
pb
.
ClusterLoadAssignment
cla
*
endpoint
pb
.
ClusterLoadAssignment
loc
xds
.
Locality
// where we run
loc
xds
.
Locality
// where we run
answer
string
answer
string
}{
}{
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{
ClusterName
:
"web"
,
ClusterName
:
"web"
,
Endpoints
:
append
(
Endpoints
:
append
(
// IPs here should be different, but locality isn't implemented. Make
// them identical so the test doesn't fail...(for now)
endpointsWithLocality
([]
EndpointHealth
{
endpointsWithLocality
([]
EndpointHealth
{
{
"127.0.
0
.1"
,
18008
,
corepb
.
HealthStatus_HEALTHY
},
{
"127.0.
1
.1"
,
18008
,
corepb
.
HealthStatus_HEALTHY
},
{
"127.0.
0.2
"
,
18008
,
corepb
.
HealthStatus_HEALTHY
}},
{
"127.0.
1.1
"
,
18008
,
corepb
.
HealthStatus_HEALTHY
}},
xds
.
Locality
{
Region
:
"us"
}),
xds
.
Locality
{
Region
:
"us"
}),
endpointsWithLocality
([]
EndpointHealth
{
endpointsWithLocality
([]
EndpointHealth
{
{
"127.0.1.1"
,
18008
,
corepb
.
HealthStatus_HEALTHY
}},
{
"127.0.1.1"
,
18008
,
corepb
.
HealthStatus_HEALTHY
}},
...
@@ -211,7 +212,7 @@ func TestTrafficSRV(t *testing.T) {
...
@@ -211,7 +212,7 @@ func TestTrafficSRV(t *testing.T) {
tr
:=
&
Traffic
{
c
:
c
,
origins
:
[]
string
{
"lb.example.org."
}}
tr
:=
&
Traffic
{
c
:
c
,
origins
:
[]
string
{
"lb.example.org."
}}
tests
:=
[]
struct
{
tests
:=
[]
struct
{
cla
*
xds
pb
.
ClusterLoadAssignment
cla
*
endpoint
pb
.
ClusterLoadAssignment
cluster
string
cluster
string
qtype
uint16
qtype
uint16
rcode
int
rcode
int
...
@@ -219,7 +220,7 @@ func TestTrafficSRV(t *testing.T) {
...
@@ -219,7 +220,7 @@ func TestTrafficSRV(t *testing.T) {
}{
}{
// SRV query healthy endpoint
// SRV query healthy endpoint
{
{
cla
:
&
xds
pb
.
ClusterLoadAssignment
{
cla
:
&
endpoint
pb
.
ClusterLoadAssignment
{
ClusterName
:
"web"
,
ClusterName
:
"web"
,
Endpoints
:
endpoints
([]
EndpointHealth
{
Endpoints
:
endpoints
([]
EndpointHealth
{
{
"127.0.0.2"
,
18008
,
corepb
.
HealthStatus_HEALTHY
},
{
"127.0.0.2"
,
18008
,
corepb
.
HealthStatus_HEALTHY
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment