Merge pull request #6260 from tstromberg/service_test_race
De-parallelize GetServiceURL unit tests: the mocks are not thread safepull/6265/head
commit
010338ff99
|
@ -44,6 +44,7 @@ import (
|
||||||
"k8s.io/minikube/pkg/minikube/tests"
|
"k8s.io/minikube/pkg/minikube/tests"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Mock Kubernetes client getter - NOT THREAD SAFE
|
||||||
type MockClientGetter struct {
|
type MockClientGetter struct {
|
||||||
servicesMap map[string]typed_core.ServiceInterface
|
servicesMap map[string]typed_core.ServiceInterface
|
||||||
endpointsMap map[string]typed_core.EndpointsInterface
|
endpointsMap map[string]typed_core.EndpointsInterface
|
||||||
|
@ -76,6 +77,7 @@ func (m *MockCoreClient) Services(namespace string) typed_core.ServiceInterface
|
||||||
return m.servicesMap[namespace]
|
return m.servicesMap[namespace]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mock Kubernetes client - NOT THREAD SAFE
|
||||||
type MockCoreClient struct {
|
type MockCoreClient struct {
|
||||||
fake.FakeCoreV1
|
fake.FakeCoreV1
|
||||||
servicesMap map[string]typed_core.ServiceInterface
|
servicesMap map[string]typed_core.ServiceInterface
|
||||||
|
@ -466,8 +468,6 @@ func TestGetServiceURLs(t *testing.T) {
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
test := test
|
test := test
|
||||||
t.Run(test.description, func(t *testing.T) {
|
t.Run(test.description, func(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
K8s = &MockClientGetter{
|
K8s = &MockClientGetter{
|
||||||
servicesMap: serviceNamespaces,
|
servicesMap: serviceNamespaces,
|
||||||
endpointsMap: endpointNamespaces,
|
endpointsMap: endpointNamespaces,
|
||||||
|
@ -536,7 +536,6 @@ func TestGetServiceURLsForService(t *testing.T) {
|
||||||
defer revertK8sClient(K8s)
|
defer revertK8sClient(K8s)
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.description, func(t *testing.T) {
|
t.Run(test.description, func(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
K8s = &MockClientGetter{
|
K8s = &MockClientGetter{
|
||||||
servicesMap: serviceNamespaces,
|
servicesMap: serviceNamespaces,
|
||||||
endpointsMap: endpointNamespaces,
|
endpointsMap: endpointNamespaces,
|
||||||
|
|
Loading…
Reference in New Issue