Skip to content

Commit 83d7002

Browse files
author
Rahul Sharma
committed
add test for bgp custom id map
1 parent e8be2af commit 83d7002

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cloud/linode/cilium_loadbalancers_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"net"
8+
"os"
89
"testing"
910

1011
k8sClient "github.com/cilium/cilium/pkg/k8s/client"
@@ -201,6 +202,7 @@ func createNewIpHolderInstance() linodego.Instance {
201202
func testNoBGPNodeLabel(t *testing.T, mc *mocks.MockClient) {
202203
Options.BGPNodeSelector = ""
203204
Options.IpHolderSuffix = "linodelb"
205+
os.Setenv("BGP_PEER_PREFIX", "2600:3cef")
204206
svc := createTestService()
205207
newIpHolderInstance = createNewIpHolderInstance()
206208

@@ -244,6 +246,7 @@ func testNoBGPNodeLabel(t *testing.T, mc *mocks.MockClient) {
244246
if lbStatus == nil {
245247
t.Fatal("expected non-nil lbStatus")
246248
}
249+
os.Unsetenv("BGP_PEER_PREFIX")
247250
}
248251

249252
func testUnsupportedRegion(t *testing.T, mc *mocks.MockClient) {
@@ -257,11 +260,23 @@ func testUnsupportedRegion(t *testing.T, mc *mocks.MockClient) {
257260

258261
lbStatus, err := lb.EnsureLoadBalancer(context.TODO(), "linodelb", svc, nodes)
259262
if err == nil {
260-
t.Fatal("expected nil error")
263+
t.Fatal("expected not nil error")
261264
}
262265
if lbStatus != nil {
263266
t.Fatalf("expected a nil lbStatus, got %v", lbStatus)
264267
}
268+
269+
// Use BGP custom id map
270+
os.Setenv("BGP_CUSTOM_ID_MAP", "{'us-foobar': 2}")
271+
lb = &loadbalancers{mc, zone, kubeClient, ciliumClient, ciliumLBType}
272+
lbStatus, err = lb.EnsureLoadBalancer(context.TODO(), "linodelb", svc, nodes)
273+
if err == nil {
274+
t.Fatal("expected not nil error")
275+
}
276+
if lbStatus != nil {
277+
t.Fatalf("expected a nil lbStatus, got %v", lbStatus)
278+
}
279+
os.Unsetenv("BGP_CUSTOM_ID_MAP")
265280
}
266281

267282
func testCreateWithExistingIPHolderWithOldIpHolderNamingConvention(t *testing.T, mc *mocks.MockClient) {

0 commit comments

Comments
 (0)