Skip to content

Commit

Permalink
test(e2e): add deployment e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-lgy committed Apr 15, 2023
1 parent 29fc4db commit 9628ce3
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 7 deletions.
12 changes: 12 additions & 0 deletions test/e2e/framework/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
54 changes: 54 additions & 0 deletions test/e2e/resourcepropagation/deployments.go
Original file line number Diff line number Diff line change
@@ -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",
},
},
)
})
6 changes: 0 additions & 6 deletions test/e2e/resourcepropagation/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/resourcepropagation/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 9628ce3

Please sign in to comment.