mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #105805 from stevekuznetsov/skuznets/fix-watch-e2e
e2e: conformance: correctly produce MODIFIED events
This commit is contained in:
commit
fec7005de5
@ -20,6 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
@ -476,25 +477,37 @@ func produceConfigMapEvents(f *framework.Framework, stopc <-chan struct{}, minWa
|
|||||||
tc := time.NewTicker(minWaitBetweenEvents)
|
tc := time.NewTicker(minWaitBetweenEvents)
|
||||||
defer tc.Stop()
|
defer tc.Stop()
|
||||||
i := 0
|
i := 0
|
||||||
|
updates := 0
|
||||||
for range tc.C {
|
for range tc.C {
|
||||||
op := rand.Intn(3)
|
op := rand.Intn(3)
|
||||||
if len(existing) == 0 {
|
if len(existing) == 0 {
|
||||||
op = createEvent
|
op = createEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
cm := &v1.ConfigMap{}
|
|
||||||
switch op {
|
switch op {
|
||||||
case createEvent:
|
case createEvent:
|
||||||
cm.Name = name(i)
|
cm := &v1.ConfigMap{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name(i),
|
||||||
|
},
|
||||||
|
}
|
||||||
_, err := c.CoreV1().ConfigMaps(ns).Create(context.TODO(), cm, metav1.CreateOptions{})
|
_, err := c.CoreV1().ConfigMaps(ns).Create(context.TODO(), cm, metav1.CreateOptions{})
|
||||||
framework.ExpectNoError(err, "Failed to create configmap %s in namespace %s", cm.Name, ns)
|
framework.ExpectNoError(err, "Failed to create configmap %s in namespace %s", cm.Name, ns)
|
||||||
existing = append(existing, i)
|
existing = append(existing, i)
|
||||||
i++
|
i++
|
||||||
case updateEvent:
|
case updateEvent:
|
||||||
idx := rand.Intn(len(existing))
|
idx := rand.Intn(len(existing))
|
||||||
cm.Name = name(existing[idx])
|
cm := &v1.ConfigMap{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name(existing[idx]),
|
||||||
|
Labels: map[string]string{
|
||||||
|
"mutated": strconv.Itoa(updates),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
_, err := c.CoreV1().ConfigMaps(ns).Update(context.TODO(), cm, metav1.UpdateOptions{})
|
_, err := c.CoreV1().ConfigMaps(ns).Update(context.TODO(), cm, metav1.UpdateOptions{})
|
||||||
framework.ExpectNoError(err, "Failed to update configmap %s in namespace %s", cm.Name, ns)
|
framework.ExpectNoError(err, "Failed to update configmap %s in namespace %s", cm.Name, ns)
|
||||||
|
updates++
|
||||||
case deleteEvent:
|
case deleteEvent:
|
||||||
idx := rand.Intn(len(existing))
|
idx := rand.Intn(len(existing))
|
||||||
err := c.CoreV1().ConfigMaps(ns).Delete(context.TODO(), name(existing[idx]), metav1.DeleteOptions{})
|
err := c.CoreV1().ConfigMaps(ns).Delete(context.TODO(), name(existing[idx]), metav1.DeleteOptions{})
|
||||||
|
Loading…
Reference in New Issue
Block a user