forked from joeholley/supergloo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
routing_rule_2.go
129 lines (119 loc) · 3.13 KB
/
routing_rule_2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package scenarios
import (
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"
v1 "github.com/solo-io/supergloo/pkg/api/v1"
"github.com/solo-io/supergloo/pkg/translator/appmesh"
appmeshInputs "github.com/solo-io/supergloo/test/inputs/appmesh"
gloov1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"
)
type routingRuleScenario2 struct {
meshName string
allResources appmeshInputs.TestResourceSet
}
// In this scenario, we have two routing rules that:
// - have the same traffic shifting configuration (same targets, same weights)
// - have same source and destination selectors
// - match different path prefixes
// the result should be the same a applying a single rule with two matchers
func RoutingRule2() AppMeshTestScenario {
return &routingRuleScenario2{
meshName: MeshName,
allResources: GetAllResources(),
}
}
func (s *routingRuleScenario2) GetMeshName() string {
return s.meshName
}
func (s *routingRuleScenario2) GetResources() appmeshInputs.TestResourceSet {
return s.allResources
}
func (s *routingRuleScenario2) GetRoutingRules() v1.RoutingRuleList {
return s.getRoutingRules()
}
func (s *routingRuleScenario2) VerifyExpectations(configuration appmesh.AwsAppMeshConfiguration) {
// This is expected to produce the same result as the routing_rule_1 scenario
routingRuleScenario1Expectations(configuration)
}
func (s *routingRuleScenario2) getRoutingRules() v1.RoutingRuleList {
spec := &v1.RoutingRuleSpec{
RuleType: &v1.RoutingRuleSpec_TrafficShifting{
TrafficShifting: &v1.TrafficShifting{
Destinations: &gloov1.MultiDestination{
Destinations: []*gloov1.WeightedDestination{
{
Weight: 80,
Destination: &gloov1.Destination{
Upstream: core.ResourceRef{
Namespace: "gloo-system",
Name: "default-reviews-9080",
},
},
},
{
Weight: 10,
Destination: &gloov1.Destination{
Upstream: core.ResourceRef{
Namespace: "gloo-system",
Name: "default-reviews-v2-9080",
},
},
},
{
Weight: 10,
Destination: &gloov1.Destination{
Upstream: core.ResourceRef{
Namespace: "gloo-system",
Name: "default-reviews-v3-9080",
},
},
},
},
},
},
},
}
dest := &v1.PodSelector{
SelectorType: &v1.PodSelector_UpstreamSelector_{
UpstreamSelector: &v1.PodSelector_UpstreamSelector{
Upstreams: []core.ResourceRef{
{
Namespace: "gloo-system",
Name: "default-reviews-9080",
},
},
},
},
}
return v1.RoutingRuleList{
{
Metadata: core.Metadata{
Name: "reviews-test-path",
Namespace: "supergloo-system",
},
Spec: spec,
RequestMatchers: []*gloov1.Matcher{
{
PathSpecifier: &gloov1.Matcher_Prefix{
Prefix: "/test",
},
},
},
DestinationSelector: dest,
},
{
Metadata: core.Metadata{
Name: "reviews-base-path",
Namespace: "supergloo-system",
},
Spec: spec,
RequestMatchers: []*gloov1.Matcher{
{
PathSpecifier: &gloov1.Matcher_Prefix{
Prefix: "/",
},
},
},
DestinationSelector: dest,
},
}
}