diff --git a/pkg/catalog/debugger_test.go b/pkg/catalog/debugger_test.go index 42b4c3fba9..54ee3ff99e 100644 --- a/pkg/catalog/debugger_test.go +++ b/pkg/catalog/debugger_test.go @@ -97,7 +97,7 @@ var _ = Describe("Test catalog proxy register/unregister", func() { Expect(trafficSplits[0].Spec.Service).To(Equal("bookstore-apex")) Expect(weightedServices[0]).To(Equal(service.WeightedService{ Service: tests.BookstoreV1Service, - Weight: 100, + Weight: tests.Weight90, RootService: "bookstore-apex"})) Expect(serviceAccounts[0].String()).To(Equal("default/bookstore")) Expect(routeGroups[0].Name).To(Equal("bookstore-service-routes")) diff --git a/pkg/catalog/routes_test.go b/pkg/catalog/routes_test.go index 782cb169df..49c7b18478 100644 --- a/pkg/catalog/routes_test.go +++ b/pkg/catalog/routes_test.go @@ -192,7 +192,7 @@ func TestGetWeightedClusterForService(t *testing.T) { expected := service.WeightedCluster{ ClusterName: "default/bookstore-v1", - Weight: 100, + Weight: tests.Weight90, } assert.Equal(weightedCluster, expected) } diff --git a/pkg/debugger/policy_test.go b/pkg/debugger/policy_test.go index ff0fd8e398..712268e301 100644 --- a/pkg/debugger/policy_test.go +++ b/pkg/debugger/policy_test.go @@ -53,6 +53,6 @@ func TestGetSMIPolicies(t *testing.T) { responseRecorder := httptest.NewRecorder() smiPoliciesHandler.ServeHTTP(responseRecorder, nil) actualResponseBody := responseRecorder.Body.String() - expectedResponseBody := `{"traffic_splits":[{"metadata":{"name":"bar","namespace":"foo","creationTimestamp":null},"spec":{}}],"weighted_services":[{"service_name:omitempty":{"Namespace":"default","Name":"bookstore-v1"},"weight:omitempty":100,"root_service:omitempty":"bookstore-apex"},{"service_name:omitempty":{"Namespace":"default","Name":"bookstore-v2"},"weight:omitempty":100,"root_service:omitempty":"bookstore-apex"}],"service_accounts":[{"Namespace":"default","Name":"bookbuyer"}],"route_groups":[{"kind":"HTTPRouteGroup","apiVersion":"specs.smi-spec.io/v1alpha2","metadata":{"name":"bookstore-service-routes","namespace":"default","creationTimestamp":null},"spec":{"matches":[{"name":"buy-books","methods":["GET"],"pathRegex":"/buy","headers":[{"user-agent":"test-UA"}]},{"name":"sell-books","methods":["GET"],"pathRegex":"/sell","headers":[{"user-agent":"test-UA"}]},{"name":"allow-everything-on-header","headers":[{"user-agent":"test-UA"}]}]}}],"traffic_targets":[{"kind":"TrafficTarget","apiVersion":"access.smi-spec.io/v1alpha2","metadata":{"name":"bookbuyer-access-bookstore","namespace":"default","creationTimestamp":null},"spec":{"destination":{"kind":"Name","name":"bookstore","namespace":"default"},"sources":[{"kind":"Name","name":"bookbuyer","namespace":"default"}],"rules":[{"kind":"HTTPRouteGroup","name":"bookstore-service-routes","matches":["buy-books","sell-books"]}]}}]}` + expectedResponseBody := `{"traffic_splits":[{"metadata":{"name":"bar","namespace":"foo","creationTimestamp":null},"spec":{}}],"weighted_services":[{"service_name:omitempty":{"Namespace":"default","Name":"bookstore-v1"},"weight:omitempty":90,"root_service:omitempty":"bookstore-apex"},{"service_name:omitempty":{"Namespace":"default","Name":"bookstore-v2"},"weight:omitempty":10,"root_service:omitempty":"bookstore-apex"}],"service_accounts":[{"Namespace":"default","Name":"bookbuyer"}],"route_groups":[{"kind":"HTTPRouteGroup","apiVersion":"specs.smi-spec.io/v1alpha2","metadata":{"name":"bookstore-service-routes","namespace":"default","creationTimestamp":null},"spec":{"matches":[{"name":"buy-books","methods":["GET"],"pathRegex":"/buy","headers":[{"user-agent":"test-UA"}]},{"name":"sell-books","methods":["GET"],"pathRegex":"/sell","headers":[{"user-agent":"test-UA"}]},{"name":"allow-everything-on-header","headers":[{"user-agent":"test-UA"}]}]}}],"traffic_targets":[{"kind":"TrafficTarget","apiVersion":"access.smi-spec.io/v1alpha2","metadata":{"name":"bookbuyer-access-bookstore","namespace":"default","creationTimestamp":null},"spec":{"destination":{"kind":"Name","name":"bookstore","namespace":"default"},"sources":[{"kind":"Name","name":"bookbuyer","namespace":"default"}],"rules":[{"kind":"HTTPRouteGroup","name":"bookstore-service-routes","matches":["buy-books","sell-books"]}]}}]}` assert.Equal(actualResponseBody, expectedResponseBody, "Actual value did not match expectations:\n%s", actualResponseBody) } diff --git a/pkg/envoy/rds/response_test.go b/pkg/envoy/rds/response_test.go index 5a7a7b403b..50103a7bb8 100644 --- a/pkg/envoy/rds/response_test.go +++ b/pkg/envoy/rds/response_test.go @@ -313,7 +313,7 @@ var _ = Describe("RDS Response", func() { expected := service.WeightedCluster{ ClusterName: service.ClusterName(tests.BookbuyerService.String()), - Weight: tests.Weight, + Weight: constants.ClusterWeightAcceptAll, } Expect(actual).To(Equal(expected)) }) diff --git a/pkg/smi/client_test.go b/pkg/smi/client_test.go index 18a26c2f74..79a75e63d4 100644 --- a/pkg/smi/client_test.go +++ b/pkg/smi/client_test.go @@ -109,11 +109,11 @@ var _ = Describe("When listing TrafficSplit", func() { Backends: []smiSplit.TrafficSplitBackend{ { Service: tests.BookstoreV1ServiceName, - Weight: tests.Weight, + Weight: tests.Weight90, }, { Service: tests.BookstoreV2ServiceName, - Weight: tests.Weight, + Weight: tests.Weight10, }, }, }, @@ -155,11 +155,11 @@ var _ = Describe("When listing TrafficSplit services", func() { Backends: []smiSplit.TrafficSplitBackend{ { Service: "bookstore-v1", - Weight: tests.Weight, + Weight: tests.Weight90, }, { Service: "bookstore-v2", - Weight: tests.Weight, + Weight: tests.Weight10, }, }, }, diff --git a/pkg/tests/fixtures.go b/pkg/tests/fixtures.go index 5f807dfcee..d2d10d21a7 100644 --- a/pkg/tests/fixtures.go +++ b/pkg/tests/fixtures.go @@ -57,8 +57,11 @@ const ( // WildcardWithHeadersMatchName is the name of the match object. WildcardWithHeadersMatchName = "allow-everything-on-header" - // Weight is the percentage of the traffic to be sent this way in a traffic split scenario. - Weight = 100 + // Weight90 is the value representing a share of the traffic to be sent this way in a traffic split scenario. + Weight90 = 90 + + // Weight10 is the value representing a share of the traffic to be sent this way in a traffic split scenario. + Weight10 = 10 // RouteGroupName is the name of the route group SMI object. RouteGroupName = "bookstore-service-routes" @@ -222,11 +225,11 @@ var ( Backends: []v1alpha2.TrafficSplitBackend{ { Service: BookstoreV1ServiceName, - Weight: Weight, + Weight: Weight90, }, { Service: BookstoreV2ServiceName, - Weight: Weight, + Weight: Weight10, }, }, }, @@ -287,7 +290,7 @@ var ( Namespace: Namespace, Name: BookstoreV1ServiceName, }, - Weight: Weight, + Weight: Weight90, RootService: BookstoreApexServiceName, } @@ -297,7 +300,7 @@ var ( Namespace: Namespace, Name: BookstoreV2ServiceName, }, - Weight: Weight, + Weight: Weight10, RootService: BookstoreApexServiceName, }