Skip to content

Commit

Permalink
enable sidecarset e2e parallelism feature
Browse files Browse the repository at this point in the history
Signed-off-by: Abner-1 <yuanyuxing.yyx@alibaba-inc.com>
  • Loading branch information
ABNER-1 authored and furykerry committed Feb 7, 2025
1 parent 35c94ed commit 58fd993
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 67 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/e2e-1.30.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
- name: Run E2E Tests
run: |
export KUBECONFIG=/home/runner/.kube/config
tools/hack/run-kruise-e2e-test.sh --focus '\[apps\] (PullImage|ContainerRecreateRequest|PullImages|PodProbeMarker)' --print-info --disable-parallel
tools/hack/run-kruise-e2e-test.sh --focus '\[apps\] (PullImage|ContainerRecreateRequest|PullImages)' --print-info --disable-parallel
advanced-daemonset:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
- name: Run E2E Tests
run: |
export KUBECONFIG=/home/runner/.kube/config
tools/hack/run-kruise-e2e-test.sh --focus '\[apps\] SidecarSet' --print-info --disable-parallel
tools/hack/run-kruise-e2e-test.sh --focus '\[apps\] SidecarSet' --print-info
ephemeraljob:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
- name: Run E2E Tests
run: |
export KUBECONFIG=/home/runner/.kube/config
tools/hack/run-kruise-e2e-test.sh --focus '\[policy\] PodUnavailableBudget' --print-info --disable-parallel
tools/hack/run-kruise-e2e-test.sh --focus '\[policy\] PodUnavailableBudget' --print-info
clonesetAndInplace:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -265,7 +265,7 @@ jobs:
- name: Run E2E Tests
run: |
export KUBECONFIG=/home/runner/.kube/config
tools/hack/run-kruise-e2e-test.sh --focus '\[apps\] (InplaceVPA)' --print-info
tools/hack/run-kruise-e2e-test.sh --focus '\[apps\] (CloneSet|InplaceVPA)' --print-info
other:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -295,4 +295,4 @@ jobs:
- name: Run E2E Tests
run: |
export KUBECONFIG=/home/runner/.kube/config
tools/hack/run-kruise-e2e-test.sh --focus "" --skip '\[apps\] (InplaceVPA|AppStatefulSetStorage|StatefulSet|PullImage|PullImages|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob|PodProbeMarker)' --skip '\[policy\] PodUnavailableBudget' --timeout 90m --print-info
tools/hack/run-kruise-e2e-test.sh --focus "" --skip '\[apps\] (CloneSet|InplaceVPA|AppStatefulSetStorage|StatefulSet|PullImage|PullImages|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' --skip '\[policy\] PodUnavailableBudget' --timeout 90m --print-info
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (p *enqueueRequestForPod) Update(ctx context.Context, evt event.TypedUpdate
oldObj := evt.ObjectOld
oldInitialCondition := util.GetCondition(oldObj, corev1.PodInitialized)
newInitialCondition := util.GetCondition(newObj, corev1.PodInitialized)
if !kubecontroller.IsPodActive(newObj) || newInitialCondition == nil ||
if newObj == nil || !kubecontroller.IsPodActive(newObj) || newInitialCondition == nil ||
newInitialCondition.Status != corev1.ConditionTrue || newObj.Spec.NodeName == "" {
return
}
Expand Down
56 changes: 6 additions & 50 deletions pkg/controller/podprobemarker/podprobemarker_event_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import (
"testing"
"time"

appsalphav1 "github.com/openkruise/kruise/apis/apps/v1alpha1"
"github.com/openkruise/kruise/pkg/features"
"github.com/openkruise/kruise/pkg/util"
utilfeature "github.com/openkruise/kruise/pkg/util/feature"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/util/workqueue"
utilpointer "k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/event"

appsalphav1 "github.com/openkruise/kruise/apis/apps/v1alpha1"
"github.com/openkruise/kruise/pkg/features"
"github.com/openkruise/kruise/pkg/util"
utilfeature "github.com/openkruise/kruise/pkg/util/feature"
)

var (
Expand Down Expand Up @@ -479,51 +480,6 @@ func TestPodUpdateEventHandler_v2(t *testing.T) {
},
expectQLen: 0,
},
<<<<<<< HEAD
=======
}

for _, cs := range cases {
t.Run(cs.name, func(t *testing.T) {
fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build()
handler := enqueueRequestForPod{reader: fakeClient}
for _, ppm := range cs.ppmList.Items {
fakeClient.Create(context.TODO(), &ppm)
}
newPod := podDemo.DeepCopy()
newPod.ResourceVersion = fmt.Sprintf("%d", time.Now().Unix())
util.SetPodCondition(newPod, corev1.PodCondition{
Type: corev1.PodInitialized,
Status: corev1.ConditionTrue,
})
util.SetPodCondition(podDemo, corev1.PodCondition{
Type: corev1.PodInitialized,
Status: corev1.ConditionFalse,
})

updateQ := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter())
updateEvent := event.TypedUpdateEvent[*corev1.Pod]{
ObjectOld: podDemo,
ObjectNew: newPod,
}
handler.Update(context.TODO(), updateEvent, updateQ)
if updateQ.Len() != cs.expectQLen {
t.Errorf("unexpected update event handle queue size, expected %v actual %d", cs.expectQLen, updateQ.Len())
}
})
}
}

func TestGetPodProbeMarkerForPod(t *testing.T) {

cases := []struct {
name string
ppmList *appsalphav1.PodProbeMarkerList
pod *corev1.Pod
expect []*appsalphav1.PodProbeMarker
expectErr error
}{
>>>>>>> 155229207 (upgrade k8s deps 1.30)
{
name: "podUpdateEvent, serverless pods",
getPod: func() (*corev1.Pod, *corev1.Pod) {
Expand Down Expand Up @@ -635,7 +591,7 @@ func TestGetPodProbeMarkerForPod(t *testing.T) {
_ = fakeClient.Create(context.TODO(), cs.getNode())
oldPod, newPod := cs.getPod()
updateQ := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter())
updateEvent := event.UpdateEvent{
updateEvent := event.TypedUpdateEvent[*corev1.Pod]{
ObjectOld: oldPod,
ObjectNew: newPod,
}
Expand Down
17 changes: 15 additions & 2 deletions pkg/util/podprobemarker/pod_probe_marker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import (
"reflect"
"testing"

appsalphav1 "github.com/openkruise/kruise/apis/apps/v1alpha1"
"github.com/openkruise/kruise/pkg/util"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

appsalphav1 "github.com/openkruise/kruise/apis/apps/v1alpha1"
"github.com/openkruise/kruise/pkg/util"
)

func init() {
Expand Down Expand Up @@ -213,6 +214,10 @@ func TestGetPodProbeMarkerForPod(t *testing.T) {
},
expect: []*appsalphav1.PodProbeMarker{
{
TypeMeta: metav1.TypeMeta{
Kind: "PodProbeMarker",
APIVersion: "apps.kruise.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "game-server-probe-v2",
Namespace: "sp1",
Expand Down Expand Up @@ -263,6 +268,10 @@ func TestGetPodProbeMarkerForPod(t *testing.T) {
},
},
{
TypeMeta: metav1.TypeMeta{
Kind: "PodProbeMarker",
APIVersion: "apps.kruise.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "game-server-probe-v3",
Namespace: "sp1",
Expand Down Expand Up @@ -747,6 +756,10 @@ func TestGetPodProbeMarkerForPod(t *testing.T) {
if !reflect.DeepEqual(cs.expectErr, err) {
t.Errorf("expectErr: %v, but: %v", cs.expectErr, err)
}
for i := range get {
get[i].TypeMeta.Kind = "PodProbeMarker"
get[i].TypeMeta.APIVersion = "apps.kruise.io/v1alpha1"
}
if !reflect.DeepEqual(util.DumpJSON(cs.expect), util.DumpJSON(get)) {
t.Errorf("expectGet: %v, but: %v", util.DumpJSON(cs.expect), util.DumpJSON(get))
}
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/apps/podprobemarker.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ var _ = SIGDescribe("PodProbeMarker", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
for _, npp := range nppList.Items {
for _, podProbe := range npp.Spec.PodProbes {
if podProbe.Namespace != ns {
continue
}
gomega.Expect(validPods.Has(podProbe.UID)).To(gomega.BeTrue())
}
}
Expand Down Expand Up @@ -265,6 +268,9 @@ var _ = SIGDescribe("PodProbeMarker", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
for _, npp := range nppList.Items {
for _, podProbe := range npp.Spec.PodProbes {
if podProbe.Namespace != ns {
continue
}
gomega.Expect(validPods.Has(podProbe.UID)).To(gomega.BeTrue())
}
}
Expand Down Expand Up @@ -531,6 +537,9 @@ var _ = SIGDescribe("PodProbeMarker", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
for _, npp := range nppList.Items {
for _, podProbe := range npp.Spec.PodProbes {
if podProbe.Namespace != ns {
continue
}
gomega.Expect(validPods.Has(podProbe.UID)).To(gomega.BeTrue())
}
}
Expand Down Expand Up @@ -560,6 +569,9 @@ var _ = SIGDescribe("PodProbeMarker", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
for _, npp := range nppList.Items {
for _, podProbe := range npp.Spec.PodProbes {
if podProbe.Namespace != ns {
continue
}
gomega.Expect(validPods.Has(podProbe.UID)).To(gomega.BeTrue())
}
}
Expand Down
10 changes: 6 additions & 4 deletions test/e2e/apps/sidecarset.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ import (
"strconv"
"time"

v1core "k8s.io/client-go/kubernetes/typed/core/v1"

appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1"
kruiseclientset "github.com/openkruise/kruise/pkg/client/clientset/versioned"
"github.com/openkruise/kruise/pkg/control/sidecarcontrol"
"github.com/openkruise/kruise/pkg/util"
"github.com/openkruise/kruise/pkg/util/configuration"
"github.com/openkruise/kruise/test/e2e/framework"
v1core "k8s.io/client-go/kubernetes/typed/core/v1"

"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
Expand All @@ -47,6 +48,7 @@ import (
)

var _ = SIGDescribe("SidecarSet", func() {
framework.TestContext.DeleteNamespaceOnFailure = false
f := framework.NewDefaultFramework("sidecarset")
var ns string
var c clientset.Interface
Expand All @@ -66,7 +68,7 @@ var _ = SIGDescribe("SidecarSet", func() {
framework.DumpDebugInfo(c, ns)
}
framework.Logf("Deleting all SidecarSet in cluster")
tester.DeleteSidecarSets()
tester.DeleteSidecarSets(ns)
tester.DeleteDeployments(ns)
})
framework.ConformanceIt("pods don't have matched sidecarSet", func() {
Expand Down Expand Up @@ -652,14 +654,14 @@ var _ = SIGDescribe("SidecarSet", func() {
})*/
})

framework.KruiseDescribe("SidecarSet Upgrade functionality [SidecarSeUpgrade]", func() {
framework.KruiseDescribe("SidecarSet Upgrade functionality [SidecarSetUpgrade]", func() {

ginkgo.AfterEach(func() {
if ginkgo.CurrentGinkgoTestDescription().Failed {
framework.DumpDebugInfo(c, ns)
}
framework.Logf("Deleting all SidecarSet in cluster")
tester.DeleteSidecarSets()
tester.DeleteSidecarSets(ns)
tester.DeleteDeployments(ns)
})

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/apps/sidecarset_hotupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var _ = SIGDescribe("SidecarSet", func() {
framework.DumpDebugInfo(c, ns)
}
framework.Logf("Deleting all SidecarSet in cluster")
tester.DeleteSidecarSets()
tester.DeleteSidecarSets(ns)
tester.DeleteDeployments(ns)
})

Expand Down
12 changes: 9 additions & 3 deletions test/e2e/framework/sidecarset_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ package framework

import (
"context"
"fmt"
"time"

"k8s.io/utils/ptr"

appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1"
kruiseclientset "github.com/openkruise/kruise/pkg/client/clientset/versioned"
"github.com/openkruise/kruise/pkg/control/sidecarcontrol"
"github.com/openkruise/kruise/pkg/util"
webhookutil "github.com/openkruise/kruise/pkg/webhook/util"
"k8s.io/utils/ptr"

"github.com/onsi/gomega"
apps "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -58,7 +60,8 @@ func (s *SidecarSetTester) NewBaseSidecarSet(ns string) *appsv1alpha1.SidecarSet
APIVersion: "apps.kruise.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-sidecarset",

Name: fmt.Sprintf("test-sidecarset-%s", ns),
Labels: map[string]string{
"app": "sidecar",
},
Expand Down Expand Up @@ -226,14 +229,17 @@ func (s *SidecarSetTester) CreateDeployment(deployment *apps.Deployment) {
s.WaitForDeploymentRunning(deployment)
}

func (s *SidecarSetTester) DeleteSidecarSets() {
func (s *SidecarSetTester) DeleteSidecarSets(ns string) {
sidecarSetList, err := s.kc.AppsV1alpha1().SidecarSets().List(context.TODO(), metav1.ListOptions{})
if err != nil {
Logf("List sidecarSets failed: %s", err.Error())
return
}

for _, sidecarSet := range sidecarSetList.Items {
if sidecarSet.Namespace != ns {
continue
}
s.DeleteSidecarSet(&sidecarSet)
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/policy/podunavailablebudget.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var _ = SIGDescribe("PodUnavailableBudget", func() {
tester.DeletePubs(ns)
tester.DeleteDeployments(ns)
tester.DeleteCloneSets(ns)
sidecarTester.DeleteSidecarSets()
sidecarTester.DeleteSidecarSets(ns)
})

ginkgo.It("PodUnavailableBudget selector no matched pods", func() {
Expand Down

0 comments on commit 58fd993

Please sign in to comment.