Skip to content

Commit

Permalink
test(bgp_policies_test): add local address
Browse files Browse the repository at this point in the history
  • Loading branch information
aauren committed Oct 7, 2023
1 parent ec12fda commit 5f952e0
Showing 1 changed file with 66 additions and 29 deletions.
95 changes: 66 additions & 29 deletions pkg/controllers/routing/bgp_policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func Test_AddPolicies(t *testing.T) {
&NetworkRoutingController{
clientset: fake.NewSimpleClientset(),
hostnameOverride: "node-1",
routerID: "10.0.0.0",
routerID: "10.0.0.1",
localAddressList: []string{"0.0.0.0"},
bgpPort: 10000,
bgpFullMeshMode: false,
bgpEnableInternal: true,
Expand All @@ -62,7 +63,7 @@ func Test_AddPolicies(t *testing.T) {
Addresses: []v1core.NodeAddress{
{
Type: v1core.NodeInternalIP,
Address: "10.0.0.1",
Address: "10.0.0.2",
},
},
},
Expand All @@ -78,7 +79,7 @@ func Test_AddPolicies(t *testing.T) {
},
Spec: v1core.ServiceSpec{
Type: ClusterIPST,
ClusterIP: "10.0.0.1",
ClusterIP: "10.1.0.1",
ExternalIPs: []string{"1.1.1.1"},
},
},
Expand All @@ -104,7 +105,7 @@ func Test_AddPolicies(t *testing.T) {
MaskLengthMax: 32,
},
{
IpPrefix: "10.0.0.1/32",
IpPrefix: "10.1.0.1/32",
MaskLengthMin: 32,
MaskLengthMax: 32,
},
Expand Down Expand Up @@ -149,7 +150,8 @@ func Test_AddPolicies(t *testing.T) {
&NetworkRoutingController{
clientset: fake.NewSimpleClientset(),
hostnameOverride: "node-1",
routerID: "10.0.0.0",
routerID: "10.0.0.1",
localAddressList: []string{"0.0.0.0"},
bgpPort: 10000,
bgpFullMeshMode: false,
bgpEnableInternal: true,
Expand Down Expand Up @@ -191,7 +193,7 @@ func Test_AddPolicies(t *testing.T) {
Addresses: []v1core.NodeAddress{
{
Type: v1core.NodeInternalIP,
Address: "10.0.0.1",
Address: "10.0.0.2",
},
},
},
Expand All @@ -207,7 +209,7 @@ func Test_AddPolicies(t *testing.T) {
},
Spec: v1core.ServiceSpec{
Type: "ClusterIP",
ClusterIP: "10.0.0.1",
ClusterIP: "10.1.0.1",
ExternalIPs: []string{"1.1.1.1"},
},
},
Expand All @@ -233,7 +235,7 @@ func Test_AddPolicies(t *testing.T) {
MaskLengthMax: 32,
},
{
IpPrefix: "10.0.0.1/32",
IpPrefix: "10.1.0.1/32",
MaskLengthMin: 32,
MaskLengthMax: 32,
},
Expand Down Expand Up @@ -372,7 +374,8 @@ func Test_AddPolicies(t *testing.T) {
&NetworkRoutingController{
clientset: fake.NewSimpleClientset(),
hostnameOverride: "node-1",
routerID: "10.0.0.0",
routerID: "10.0.0.1",
localAddressList: []string{"0.0.0.0"},
bgpPort: 10000,
bgpFullMeshMode: false,
bgpEnableInternal: true,
Expand All @@ -386,11 +389,17 @@ func Test_AddPolicies(t *testing.T) {
Conf: &gobgpapi.PeerConf{
NeighborAddress: "10.10.0.1",
},
Transport: &gobgpapi.Transport{
LocalAddress: "10.0.0.1",
},
},
{
Conf: &gobgpapi.PeerConf{
NeighborAddress: "10.10.0.2",
},
Transport: &gobgpapi.Transport{
LocalAddress: "10.0.0.1",
},
},
},
nodeAsnNumber: 100,
Expand All @@ -407,7 +416,7 @@ func Test_AddPolicies(t *testing.T) {
Addresses: []v1core.NodeAddress{
{
Type: v1core.NodeInternalIP,
Address: "10.0.0.1",
Address: "10.0.0.2",
},
},
},
Expand All @@ -423,7 +432,7 @@ func Test_AddPolicies(t *testing.T) {
},
Spec: v1core.ServiceSpec{
Type: ClusterIPST,
ClusterIP: "10.0.0.1",
ClusterIP: "10.1.0.1",
ExternalIPs: []string{"1.1.1.1"},
},
},
Expand All @@ -449,7 +458,7 @@ func Test_AddPolicies(t *testing.T) {
MaskLengthMax: 32,
},
{
IpPrefix: "10.0.0.1/32",
IpPrefix: "10.1.0.1/32",
MaskLengthMin: 32,
MaskLengthMax: 32,
},
Expand Down Expand Up @@ -550,7 +559,8 @@ func Test_AddPolicies(t *testing.T) {
&NetworkRoutingController{
clientset: fake.NewSimpleClientset(),
hostnameOverride: "node-1",
routerID: "10.0.0.0",
routerID: "10.0.0.1",
localAddressList: []string{"0.0.0.0"},
bgpPort: 10000,
bgpFullMeshMode: false,
bgpEnableInternal: false,
Expand All @@ -564,11 +574,17 @@ func Test_AddPolicies(t *testing.T) {
Conf: &gobgpapi.PeerConf{
NeighborAddress: "10.10.0.1",
},
Transport: &gobgpapi.Transport{
LocalAddress: "10.0.0.1",
},
},
{
Conf: &gobgpapi.PeerConf{
NeighborAddress: "10.10.0.2",
},
Transport: &gobgpapi.Transport{
LocalAddress: "10.0.0.1",
},
},
},
nodeAsnNumber: 100,
Expand All @@ -585,7 +601,7 @@ func Test_AddPolicies(t *testing.T) {
Addresses: []v1core.NodeAddress{
{
Type: v1core.NodeInternalIP,
Address: "10.0.0.1",
Address: "10.0.0.2",
},
},
},
Expand All @@ -601,7 +617,7 @@ func Test_AddPolicies(t *testing.T) {
},
Spec: v1core.ServiceSpec{
Type: ClusterIPST,
ClusterIP: "10.0.0.1",
ClusterIP: "10.1.0.1",
ExternalIPs: []string{"1.1.1.1"},
},
},
Expand All @@ -627,7 +643,7 @@ func Test_AddPolicies(t *testing.T) {
MaskLengthMax: 32,
},
{
IpPrefix: "10.0.0.1/32",
IpPrefix: "10.1.0.1/32",
MaskLengthMin: 32,
MaskLengthMax: 32,
},
Expand Down Expand Up @@ -711,7 +727,8 @@ func Test_AddPolicies(t *testing.T) {
&NetworkRoutingController{
clientset: fake.NewSimpleClientset(),
hostnameOverride: "node-1",
routerID: "10.0.0.0",
routerID: "10.0.0.1",
localAddressList: []string{"0.0.0.0"},
bgpPort: 10000,
bgpEnableInternal: true,
bgpFullMeshMode: false,
Expand All @@ -725,11 +742,17 @@ func Test_AddPolicies(t *testing.T) {
Conf: &gobgpapi.PeerConf{
NeighborAddress: "10.10.0.1",
},
Transport: &gobgpapi.Transport{
LocalAddress: "10.0.0.1",
},
},
{
Conf: &gobgpapi.PeerConf{
NeighborAddress: "10.10.0.2",
},
Transport: &gobgpapi.Transport{
LocalAddress: "10.0.0.1",
},
},
},
nodeAsnNumber: 100,
Expand All @@ -748,7 +771,7 @@ func Test_AddPolicies(t *testing.T) {
Addresses: []v1core.NodeAddress{
{
Type: v1core.NodeInternalIP,
Address: "10.0.0.1",
Address: "10.0.0.2",
},
},
},
Expand All @@ -764,7 +787,7 @@ func Test_AddPolicies(t *testing.T) {
},
Spec: v1core.ServiceSpec{
Type: ClusterIPST,
ClusterIP: "10.0.0.1",
ClusterIP: "10.1.0.1",
ExternalIPs: []string{"1.1.1.1"},
},
},
Expand All @@ -790,7 +813,7 @@ func Test_AddPolicies(t *testing.T) {
MaskLengthMax: 32,
},
{
IpPrefix: "10.0.0.1/32",
IpPrefix: "10.1.0.1/32",
MaskLengthMin: 32,
MaskLengthMax: 32,
},
Expand Down Expand Up @@ -895,7 +918,8 @@ func Test_AddPolicies(t *testing.T) {
&NetworkRoutingController{
clientset: fake.NewSimpleClientset(),
hostnameOverride: "node-1",
routerID: "10.0.0.0",
routerID: "10.0.0.1",
localAddressList: []string{"0.0.0.0"},
bgpPort: 10000,
bgpEnableInternal: true,
bgpFullMeshMode: false,
Expand All @@ -909,11 +933,17 @@ func Test_AddPolicies(t *testing.T) {
Conf: &gobgpapi.PeerConf{
NeighborAddress: "10.10.0.1",
},
Transport: &gobgpapi.Transport{
LocalAddress: "10.0.0.1",
},
},
{
Conf: &gobgpapi.PeerConf{
NeighborAddress: "10.10.0.2",
},
Transport: &gobgpapi.Transport{
LocalAddress: "10.0.0.1",
},
},
},
nodeAsnNumber: 100,
Expand All @@ -931,7 +961,7 @@ func Test_AddPolicies(t *testing.T) {
Addresses: []v1core.NodeAddress{
{
Type: v1core.NodeInternalIP,
Address: "10.0.0.1",
Address: "10.0.0.2",
},
},
},
Expand All @@ -947,7 +977,7 @@ func Test_AddPolicies(t *testing.T) {
},
Spec: v1core.ServiceSpec{
Type: ClusterIPST,
ClusterIP: "10.0.0.1",
ClusterIP: "10.1.0.1",
ExternalIPs: []string{"1.1.1.1"},
},
},
Expand All @@ -973,7 +1003,7 @@ func Test_AddPolicies(t *testing.T) {
MaskLengthMax: 32,
},
{
IpPrefix: "10.0.0.1/32",
IpPrefix: "10.1.0.1/32",
MaskLengthMin: 32,
MaskLengthMax: 32,
},
Expand Down Expand Up @@ -1078,7 +1108,8 @@ func Test_AddPolicies(t *testing.T) {
&NetworkRoutingController{
clientset: fake.NewSimpleClientset(),
hostnameOverride: "node-1",
routerID: "10.0.0.0",
routerID: "10.0.0.1",
localAddressList: []string{"0.0.0.0"},
bgpPort: 10000,
bgpFullMeshMode: false,
bgpEnableInternal: false,
Expand All @@ -1093,11 +1124,17 @@ func Test_AddPolicies(t *testing.T) {
Conf: &gobgpapi.PeerConf{
NeighborAddress: "10.10.0.1",
},
Transport: &gobgpapi.Transport{
LocalAddress: "10.0.0.1",
},
},
{
Conf: &gobgpapi.PeerConf{
NeighborAddress: "10.10.0.2",
},
Transport: &gobgpapi.Transport{
LocalAddress: "10.0.0.1",
},
},
},
nodeAsnNumber: 100,
Expand All @@ -1115,7 +1152,7 @@ func Test_AddPolicies(t *testing.T) {
Addresses: []v1core.NodeAddress{
{
Type: v1core.NodeInternalIP,
Address: "10.0.0.1",
Address: "10.0.0.2",
},
},
},
Expand All @@ -1131,7 +1168,7 @@ func Test_AddPolicies(t *testing.T) {
},
Spec: v1core.ServiceSpec{
Type: ClusterIPST,
ClusterIP: "10.0.0.1",
ClusterIP: "10.1.0.1",
ExternalIPs: []string{"1.1.1.1"},
},
},
Expand All @@ -1157,7 +1194,7 @@ func Test_AddPolicies(t *testing.T) {
MaskLengthMax: 32,
},
{
IpPrefix: "10.0.0.1/32",
IpPrefix: "10.1.0.1/32",
MaskLengthMin: 32,
MaskLengthMax: 32,
},
Expand Down Expand Up @@ -1279,7 +1316,7 @@ func Test_AddPolicies(t *testing.T) {
if !reflect.DeepEqual(err, testcase.startBGPServerErr) {
t.Logf("expected err when invoking startBGPServer(): %v", testcase.startBGPServerErr)
t.Logf("actual err from startBGPServer() received: %v", err)
t.Error("unexpected error")
t.Fatal("unexpected error")
}
// If the server was not expected to start we should stop here as the rest of the tests are unimportant
if testcase.startBGPServerErr != nil {
Expand Down

0 comments on commit 5f952e0

Please sign in to comment.