diff --git a/test/e2e/framework/resources/resources.go b/test/e2e/framework/resources/resources.go index 2d7a8526..fc1c5996 100644 --- a/test/e2e/framework/resources/resources.go +++ b/test/e2e/framework/resources/resources.go @@ -82,6 +82,18 @@ func GetSimpleDeployment(baseName string) *appsv1.Deployment { } } +func IsDeploymentProgressing(deployment *appsv1.Deployment) bool { + for _, c := range deployment.Status.Conditions { + if c.Type != appsv1.DeploymentProgressing { + continue + } + + return c.Status == corev1.ConditionTrue + } + + return false +} + func GetSimpleDaemonset() *appsv1.DaemonSet { return nil } diff --git a/test/e2e/resourcepropagation/deployments.go b/test/e2e/resourcepropagation/deployments.go new file mode 100644 index 00000000..8b253586 --- /dev/null +++ b/test/e2e/resourcepropagation/deployments.go @@ -0,0 +1,54 @@ +/* +Copyright 2023 The KubeAdmiral 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. +*/ + +package resourcepropagation + +import ( + "github.com/onsi/ginkgo/v2" + appsv1 "k8s.io/api/apps/v1" + "k8s.io/client-go/dynamic" + "k8s.io/client-go/kubernetes" + + fedtypesv1a1 "github.com/kubewharf/kubeadmiral/pkg/apis/types/v1alpha1" + "github.com/kubewharf/kubeadmiral/test/e2e/framework" + "github.com/kubewharf/kubeadmiral/test/e2e/framework/resources" +) + +var _ = ginkgo.Describe("Deployment Propagation", func() { + f := framework.NewFramework("deployment-propagation", framework.FrameworkOptions{CreateNamespace: true}) + + resourcePropagationTest( + f, + &resourcePropagationTestConfig[*appsv1.Deployment]{ + gvr: appsv1.SchemeGroupVersion.WithResource("deployments"), + objectFactory: resources.GetSimpleDeployment, + clientGetter: func(client kubernetes.Interface, namespace string) resourceClient[*appsv1.Deployment] { + return client.AppsV1().Deployments(namespace) + }, + isPropagatedResourceWorking: func( + _ kubernetes.Interface, + _ dynamic.Interface, + deployment *appsv1.Deployment, + ) (bool, error) { + return resources.IsDeploymentProgressing(deployment), nil + }, + statusCollection: &resourceStatusCollectionTestConfig{ + gvr: fedtypesv1a1.SchemeGroupVersion.WithResource("federateddeploymentstatuses"), + path: "status", + }, + }, + ) +}) diff --git a/test/e2e/resourcepropagation/framework.go b/test/e2e/resourcepropagation/framework.go index b1802e21..5520660c 100644 --- a/test/e2e/resourcepropagation/framework.go +++ b/test/e2e/resourcepropagation/framework.go @@ -92,12 +92,6 @@ func resourcePropagationTest[T k8sObject]( ginkgo.It("Should succeed", resourcePropagationTestLabel, func(ctx ginkgo.SpecContext) { var err error object := config.objectFactory(f.Name()) - - ginkgo.GinkgoLogr.WithValues( - "gvr", config.gvr.String(), - "namespace", f.TestNamespace().Name, - "name", object.GetName(), - ) hostClient := config.clientGetter(f.HostKubeClient(), f.TestNamespace().Name) var clusters []*fedcorev1a1.FederatedCluster diff --git a/test/e2e/resourcepropagation/jobs.go b/test/e2e/resourcepropagation/jobs.go index 1755caa7..c6ac322a 100644 --- a/test/e2e/resourcepropagation/jobs.go +++ b/test/e2e/resourcepropagation/jobs.go @@ -82,7 +82,8 @@ var _ = ginkgo.Context("Job Propagation", func() { isPropagatedResourceWorking: func( _ kubernetes.Interface, _ dynamic.Interface, - job *batchv1.Job) (bool, error) { + job *batchv1.Job, + ) (bool, error) { return resources.IsJobComplete(job), nil }, statusCollection: &resourceStatusCollectionTestConfig{