mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #26407 from saad-ali/fixRaceReconcilerTest
Automatic merge from submit-queue Fix DATA RACE in unit tests: reconciler_test.go Fixes https://github.com/kubernetes/kubernetes/issues/26377
This commit is contained in:
commit
071cfe6086
@ -256,14 +256,14 @@ func waitForAttachCallCount(
|
|||||||
t *testing.T,
|
t *testing.T,
|
||||||
expectedAttachCallCount int,
|
expectedAttachCallCount int,
|
||||||
fakePlugin *volumetesting.FakeVolumePlugin) {
|
fakePlugin *volumetesting.FakeVolumePlugin) {
|
||||||
if len(fakePlugin.Attachers) == 0 && expectedAttachCallCount == 0 {
|
if len(fakePlugin.GetAttachers()) == 0 && expectedAttachCallCount == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := retryWithExponentialBackOff(
|
err := retryWithExponentialBackOff(
|
||||||
time.Duration(5*time.Millisecond),
|
time.Duration(5*time.Millisecond),
|
||||||
func() (bool, error) {
|
func() (bool, error) {
|
||||||
for i, attacher := range fakePlugin.Attachers {
|
for i, attacher := range fakePlugin.GetAttachers() {
|
||||||
actualCallCount := attacher.GetAttachCallCount()
|
actualCallCount := attacher.GetAttachCallCount()
|
||||||
if actualCallCount == expectedAttachCallCount {
|
if actualCallCount == expectedAttachCallCount {
|
||||||
return true, nil
|
return true, nil
|
||||||
@ -293,14 +293,14 @@ func waitForDetachCallCount(
|
|||||||
t *testing.T,
|
t *testing.T,
|
||||||
expectedDetachCallCount int,
|
expectedDetachCallCount int,
|
||||||
fakePlugin *volumetesting.FakeVolumePlugin) {
|
fakePlugin *volumetesting.FakeVolumePlugin) {
|
||||||
if len(fakePlugin.Detachers) == 0 && expectedDetachCallCount == 0 {
|
if len(fakePlugin.GetDetachers()) == 0 && expectedDetachCallCount == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := retryWithExponentialBackOff(
|
err := retryWithExponentialBackOff(
|
||||||
time.Duration(5*time.Millisecond),
|
time.Duration(5*time.Millisecond),
|
||||||
func() (bool, error) {
|
func() (bool, error) {
|
||||||
for i, detacher := range fakePlugin.Detachers {
|
for i, detacher := range fakePlugin.GetDetachers() {
|
||||||
actualCallCount := detacher.GetDetachCallCount()
|
actualCallCount := detacher.GetDetachCallCount()
|
||||||
if actualCallCount == expectedDetachCallCount {
|
if actualCallCount == expectedDetachCallCount {
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -206,6 +206,12 @@ func (plugin *FakeVolumePlugin) NewAttacher() (Attacher, error) {
|
|||||||
return plugin.getFakeVolume(&plugin.Attachers), nil
|
return plugin.getFakeVolume(&plugin.Attachers), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *FakeVolumePlugin) GetAttachers() (Attachers []*FakeVolume) {
|
||||||
|
plugin.RLock()
|
||||||
|
defer plugin.RUnlock()
|
||||||
|
return plugin.Attachers
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *FakeVolumePlugin) GetNewAttacherCallCount() int {
|
func (plugin *FakeVolumePlugin) GetNewAttacherCallCount() int {
|
||||||
plugin.RLock()
|
plugin.RLock()
|
||||||
defer plugin.RUnlock()
|
defer plugin.RUnlock()
|
||||||
@ -219,6 +225,12 @@ func (plugin *FakeVolumePlugin) NewDetacher() (Detacher, error) {
|
|||||||
return plugin.getFakeVolume(&plugin.Detachers), nil
|
return plugin.getFakeVolume(&plugin.Detachers), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *FakeVolumePlugin) GetDetachers() (Detachers []*FakeVolume) {
|
||||||
|
plugin.RLock()
|
||||||
|
defer plugin.RUnlock()
|
||||||
|
return plugin.Detachers
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *FakeVolumePlugin) GetNewDetacherCallCount() int {
|
func (plugin *FakeVolumePlugin) GetNewDetacherCallCount() int {
|
||||||
plugin.RLock()
|
plugin.RLock()
|
||||||
defer plugin.RUnlock()
|
defer plugin.RUnlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user