mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-07 03:59:36 +00:00
Fix or remove tests that don't work in race mode
Kubernetes-commit: 68bb8b827b3827cbee61d3fcc560738beba3e110
This commit is contained in:
parent
ec8fb0246c
commit
0693903770
24
tools/cache/mutation_detector_test.go
vendored
24
tools/cache/mutation_detector_test.go
vendored
@ -1,5 +1,3 @@
|
|||||||
// +build !race
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2016 The Kubernetes Authors.
|
Copyright 2016 The Kubernetes Authors.
|
||||||
|
|
||||||
@ -25,6 +23,7 @@ import (
|
|||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,33 +45,30 @@ func TestMutationDetector(t *testing.T) {
|
|||||||
}
|
}
|
||||||
stopCh := make(chan struct{})
|
stopCh := make(chan struct{})
|
||||||
defer close(stopCh)
|
defer close(stopCh)
|
||||||
addReceived := make(chan bool)
|
|
||||||
mutationFound := make(chan bool)
|
mutationFound := make(chan bool)
|
||||||
|
|
||||||
informer := NewSharedInformer(lw, &v1.Pod{}, 1*time.Second).(*sharedIndexInformer)
|
informer := NewSharedInformer(lw, &v1.Pod{}, 1*time.Second).(*sharedIndexInformer)
|
||||||
informer.cacheMutationDetector = &defaultCacheMutationDetector{
|
detector := &defaultCacheMutationDetector{
|
||||||
name: "name",
|
name: "name",
|
||||||
period: 1 * time.Second,
|
period: 1 * time.Second,
|
||||||
failureFunc: func(message string) {
|
failureFunc: func(message string) {
|
||||||
mutationFound <- true
|
mutationFound <- true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
informer.AddEventHandler(
|
informer.cacheMutationDetector = detector
|
||||||
ResourceEventHandlerFuncs{
|
|
||||||
AddFunc: func(obj interface{}) {
|
|
||||||
addReceived <- true
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
go informer.Run(stopCh)
|
go informer.Run(stopCh)
|
||||||
|
|
||||||
fakeWatch.Add(pod)
|
fakeWatch.Add(pod)
|
||||||
|
|
||||||
select {
|
wait.PollImmediate(100*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) {
|
||||||
case <-addReceived:
|
detector.addedObjsLock.Lock()
|
||||||
}
|
defer detector.addedObjsLock.Unlock()
|
||||||
|
return len(detector.addedObjs) > 0, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
detector.compareObjectsLock.Lock()
|
||||||
pod.Labels["change"] = "true"
|
pod.Labels["change"] = "true"
|
||||||
|
detector.compareObjectsLock.Unlock()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-mutationFound:
|
case <-mutationFound:
|
||||||
|
Loading…
Reference in New Issue
Block a user