mirror of
https://github.com/fluxcd/flagger.git
synced 2026-04-15 06:57:34 +00:00
add router_test and make test install script platform agnostic
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
This commit is contained in:
committed by
Sanskar Jaiswal
parent
00d54d268c
commit
5e1d00d4d2
@@ -7,17 +7,25 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// SchemeGroupVersion is the GroupVersion for the Kuma API
|
||||
// SchemeGroupVersion is the identifier for the API which includes
|
||||
// the name of the group and the version of the API
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: gatewayapi.GroupName, Version: "v1alpha2"}
|
||||
|
||||
// Resource gets a Kuma GroupResource for a specified resource
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
var (
|
||||
// SchemeBuilder collects functions that add things to a scheme. It's to allow
|
||||
// code to compile without explicitly referencing generated types. You should
|
||||
// declare one in each package that will have generated deep copy or conversion
|
||||
// functions.
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
|
||||
// AddToScheme applies all the stored functions to the scheme. A non-nil error
|
||||
// indicates that one function failed and the attempt was abandoned.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to Scheme.
|
||||
|
||||
@@ -68,7 +68,7 @@ func (factory Factory) Observer(provider string) Interface {
|
||||
return &NginxObserver{
|
||||
client: factory.Client,
|
||||
}
|
||||
case provider == flaggerv1.KubernetesProvider || provider == flaggerv1.GatewayAPIProvider:
|
||||
case provider == flaggerv1.KubernetesProvider || strings.HasPrefix(provider, flaggerv1.GatewayAPIProvider):
|
||||
return &HttpObserver{
|
||||
client: factory.Client,
|
||||
}
|
||||
|
||||
+15
-12
@@ -164,20 +164,23 @@ func (gwr *GatewayAPIRouter) Reconcile(canary *flaggerv1.Canary) error {
|
||||
return fmt.Errorf("HTTPRoute %s.%s get error: %w", apexSvcName, hrNamespace, err)
|
||||
}
|
||||
|
||||
if diff := cmp.Diff(
|
||||
httpRoute.Spec, httpRouteSpec,
|
||||
cmpopts.IgnoreFields(v1alpha2.BackendRef{}, "Weight"),
|
||||
); diff != "" {
|
||||
hrClone := httpRoute.DeepCopy()
|
||||
hrClone.Spec = httpRouteSpec
|
||||
_, err := gwr.gatewayAPIClient.GatewayapiV1alpha2().HTTPRoutes(hrNamespace).
|
||||
Update(context.TODO(), hrClone, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("HTTPRoute %s.%s update error: %w", hrClone.GetName(), hrNamespace, err)
|
||||
if httpRoute != nil {
|
||||
if diff := cmp.Diff(
|
||||
httpRoute.Spec, httpRouteSpec,
|
||||
cmpopts.IgnoreFields(v1alpha2.BackendRef{}, "Weight"),
|
||||
); diff != "" {
|
||||
hrClone := httpRoute.DeepCopy()
|
||||
hrClone.Spec = httpRouteSpec
|
||||
_, err := gwr.gatewayAPIClient.GatewayapiV1alpha2().HTTPRoutes(hrNamespace).
|
||||
Update(context.TODO(), hrClone, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("HTTPRoute %s.%s update error: %w", hrClone.GetName(), hrNamespace, err)
|
||||
}
|
||||
gwr.logger.With("canary", fmt.Sprintf("%s.%s", canary.Name, canary.Namespace)).
|
||||
Infof("HTTPProxy %s.%s updated", hrClone.GetName(), hrNamespace)
|
||||
}
|
||||
gwr.logger.With("canary", fmt.Sprintf("%s.%s", canary.Name, canary.Namespace)).
|
||||
Infof("HTTPProxy %s.%s updated", hrClone.GetName(), hrNamespace)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ func newFixture(c *flaggerv1.Canary) fixture {
|
||||
newTestDeployment(),
|
||||
newTestABTestDeployment(),
|
||||
newTestIngress(),
|
||||
newTestGateway(),
|
||||
)
|
||||
|
||||
meshClient := fakeFlagger.NewSimpleClientset()
|
||||
@@ -529,25 +528,3 @@ func newTestGatewayAPICanary() *flaggerv1.Canary {
|
||||
}
|
||||
return cd
|
||||
}
|
||||
|
||||
func newTestGateway() *v1alpha2.Gateway {
|
||||
hostName := v1alpha2.Hostname("app.example.com")
|
||||
gw := &v1alpha2.Gateway{
|
||||
TypeMeta: metav1.TypeMeta{APIVersion: v1alpha2.SchemeGroupVersion.String()},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "default",
|
||||
Name: "podinfo",
|
||||
},
|
||||
Spec: v1alpha2.GatewaySpec{
|
||||
GatewayClassName: "example",
|
||||
Listeners: []v1alpha2.Listener{
|
||||
{
|
||||
Hostname: &hostName,
|
||||
Name: "http",
|
||||
Port: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return gw
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
KUSTOMIZE_VERSION=4.5.2
|
||||
OS=$(uname -s)
|
||||
ARCH=$(arch)
|
||||
if [[ $ARCH == "x86_64" ]]; then
|
||||
ARCH="amd64"
|
||||
fi
|
||||
|
||||
mkdir -p ${REPO_ROOT}/bin
|
||||
|
||||
@@ -22,9 +25,9 @@ kubectl -n projectcontour rollout status deployment/contour
|
||||
kubectl -n projectcontour get all
|
||||
|
||||
echo '>>> Installing Kustomize'
|
||||
cd ${REPO_ROOT}/bin && kustomize_url=https://github.com/kubernetes-sigs/kustomize/releases/download && \
|
||||
curl -sL ${kustomize_url}/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_${OS}_${ARCH}.tar.gz | \
|
||||
tar xz
|
||||
cd ${REPO_ROOT}/bin && \
|
||||
curl -sL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_${OS}_${ARCH}.tar.gz | \
|
||||
tar xz
|
||||
|
||||
echo '>>> Installing Flagger'
|
||||
${REPO_ROOT}/bin/kustomize build ${REPO_ROOT}/test/gatewayapi | kubectl apply -f -
|
||||
|
||||
@@ -8,4 +8,4 @@ DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
"$DIR"/install.sh
|
||||
|
||||
"$REPO_ROOT"/test/workloads/init.sh
|
||||
"$DIR"/run-canary.sh
|
||||
"$DIR"/test-canary.sh
|
||||
|
||||
Reference in New Issue
Block a user