forked from projectcontour/contour
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the partially match condition
Signed-off-by: Lubron Zhan <[email protected]>
- Loading branch information
1 parent
1d048a9
commit 725ce9b
Showing
7 changed files
with
229 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
test/e2e/gateway/http_route_partially_conflict_match_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright Project Contour Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:build e2e | ||
|
||
package gateway | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1" | ||
|
||
"github.com/projectcontour/contour/internal/gatewayapi" | ||
"github.com/projectcontour/contour/test/e2e" | ||
) | ||
|
||
func testHTTPRoutePartiallyConflictMatch(namespace string, gateway types.NamespacedName) { | ||
Specify("Creates two http routes, second one has conflict match condition as the first one", func() { | ||
By("create httproute-1 first") | ||
route1 := &gatewayapi_v1.HTTPRoute{ | ||
ObjectMeta: meta_v1.ObjectMeta{ | ||
Namespace: namespace, | ||
Name: "httproute-1", | ||
}, | ||
Spec: gatewayapi_v1.HTTPRouteSpec{ | ||
Hostnames: []gatewayapi_v1.Hostname{"queryparams.gateway.projectcontour.io"}, | ||
CommonRouteSpec: gatewayapi_v1.CommonRouteSpec{ | ||
ParentRefs: []gatewayapi_v1.ParentReference{ | ||
gatewayapi.GatewayParentRef(gateway.Namespace, gateway.Name), | ||
}, | ||
}, | ||
Rules: []gatewayapi_v1.HTTPRouteRule{ | ||
{ | ||
Matches: []gatewayapi_v1.HTTPRouteMatch{ | ||
{QueryParams: gatewayapi.HTTPQueryParamMatches(map[string]string{"animal": "whale"})}, | ||
}, | ||
BackendRefs: gatewayapi.HTTPBackendRef("echo-1", 80, 1), | ||
}, | ||
{ | ||
Matches: []gatewayapi_v1.HTTPRouteMatch{ | ||
{QueryParams: gatewayapi.HTTPQueryParamMatches(map[string]string{"animal": "dolphin"})}, | ||
}, | ||
BackendRefs: gatewayapi.HTTPBackendRef("echo-2", 80, 1), | ||
}, | ||
}, | ||
}, | ||
} | ||
f.CreateHTTPRouteAndWaitFor(route1, e2e.HTTPRouteAccepted) | ||
|
||
By("create httproute-2 with only partially conflicted matches") | ||
route2 := &gatewayapi_v1.HTTPRoute{ | ||
ObjectMeta: meta_v1.ObjectMeta{ | ||
Namespace: namespace, | ||
Name: "httproute-2", | ||
}, | ||
Spec: gatewayapi_v1.HTTPRouteSpec{ | ||
Hostnames: []gatewayapi_v1.Hostname{"queryparams.gateway.projectcontour.io"}, | ||
CommonRouteSpec: gatewayapi_v1.CommonRouteSpec{ | ||
ParentRefs: []gatewayapi_v1.ParentReference{ | ||
gatewayapi.GatewayParentRef(gateway.Namespace, gateway.Name), | ||
}, | ||
}, | ||
Rules: []gatewayapi_v1.HTTPRouteRule{ | ||
{ | ||
Matches: []gatewayapi_v1.HTTPRouteMatch{ | ||
{QueryParams: gatewayapi.HTTPQueryParamMatches(map[string]string{"animal": "whale"})}, | ||
}, | ||
BackendRefs: gatewayapi.HTTPBackendRef("echo-1", 80, 1), | ||
}, | ||
{ | ||
Matches: []gatewayapi_v1.HTTPRouteMatch{ | ||
{QueryParams: gatewayapi.HTTPQueryParamMatches(map[string]string{"no conflict": "no joke", "no conflict again": "no joke"})}, | ||
}, | ||
BackendRefs: gatewayapi.HTTPBackendRef("echo-2", 80, 1), | ||
}, | ||
}, | ||
}, | ||
} | ||
f.CreateHTTPRouteAndWaitFor(route2, e2e.HTTPRoutePartiallyAccepted) | ||
// 1) Drop Rule(s): With this approach, implementations will drop the | ||
// invalid Route Rule(s) until they are fully valid again. The message | ||
// for this condition MUST start with the prefix "Dropped Rule" and | ||
// include information about which Rules have been dropped. In this | ||
// state, the "Accepted" condition MUST be set to "True" with the latest | ||
// generation of the resource. | ||
f.CreateHTTPRouteAndWaitFor(route2, e2e.HTTPRouteAccepted) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters