Fixing a regression with integration of two controllers (#842)
This commit is contained in:
Родитель
a7b5202209
Коммит
0b1086b5ca
|
@ -87,18 +87,6 @@ func (f *nameSpaceFixture) ipSetRestore(ipsetConfigFile string) {
|
|||
f.t.Errorf("TestAddPod failed @ ipsMgr.Restore")
|
||||
}
|
||||
}
|
||||
func newNPMgr(t *testing.T) *NetworkPolicyManager {
|
||||
npMgr := &NetworkPolicyManager{
|
||||
NsMap: make(map[string]*Namespace),
|
||||
PodMap: make(map[string]*NpmPod),
|
||||
TelemetryEnabled: false,
|
||||
}
|
||||
|
||||
// This initialization important as without this NPM will panic
|
||||
allNs, _ := newNs(util.KubeAllNamespacesFlag)
|
||||
npMgr.NsMap[util.KubeAllNamespacesFlag] = allNs
|
||||
return npMgr
|
||||
}
|
||||
|
||||
func newNameSpace(name, rv string, labels map[string]string) *corev1.Namespace {
|
||||
return &corev1.Namespace{
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
"github.com/Azure/azure-container-networking/npm/metrics"
|
||||
"github.com/Azure/azure-container-networking/npm/util"
|
||||
"github.com/Azure/azure-container-networking/telemetry"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
networkingv1 "k8s.io/api/networking/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/version"
|
||||
|
|
|
@ -10,6 +10,19 @@ import (
|
|||
"github.com/Azure/azure-container-networking/npm/util"
|
||||
)
|
||||
|
||||
func newNPMgr(t *testing.T) *NetworkPolicyManager {
|
||||
npMgr := &NetworkPolicyManager{
|
||||
NsMap: make(map[string]*Namespace),
|
||||
PodMap: make(map[string]*NpmPod),
|
||||
TelemetryEnabled: false,
|
||||
}
|
||||
|
||||
// This initialization important as without this NPM will panic
|
||||
allNs, _ := newNs(util.KubeAllNamespacesFlag)
|
||||
npMgr.NsMap[util.KubeAllNamespacesFlag] = allNs
|
||||
return npMgr
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
metrics.InitializeAll()
|
||||
iptMgr := iptm.NewIptablesManager()
|
||||
|
|
|
@ -6,10 +6,8 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-container-networking/npm/ipsm"
|
||||
"github.com/Azure/azure-container-networking/npm/util"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -20,11 +18,6 @@ import (
|
|||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
var (
|
||||
alwaysReady = func() bool { return true }
|
||||
noResyncPeriodFunc = func() time.Duration { return 0 }
|
||||
)
|
||||
|
||||
const (
|
||||
HostNetwork = true
|
||||
NonHostNetwork = false
|
||||
|
@ -88,19 +81,6 @@ func (f *podFixture) ipSetRestore(ipsetConfigFile string) {
|
|||
}
|
||||
}
|
||||
|
||||
func newNPMgr(t *testing.T) *NetworkPolicyManager {
|
||||
npMgr := &NetworkPolicyManager{
|
||||
NsMap: make(map[string]*Namespace),
|
||||
PodMap: make(map[string]*NpmPod),
|
||||
}
|
||||
|
||||
// (TODO:) should remove error return
|
||||
// (Question) Is it necessary? Seems that it is necessary. Without this, it will have panic in PodController
|
||||
allNs, _ := newNs(util.KubeAllNamespacesFlag)
|
||||
npMgr.NsMap[util.KubeAllNamespacesFlag] = allNs
|
||||
return npMgr
|
||||
}
|
||||
|
||||
func createPod(name, ns, rv, podIP string, labels map[string]string, isHostNewtwork bool, podPhase corev1.PodPhase) *corev1.Pod {
|
||||
return &corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
Загрузка…
Ссылка в новой задаче