Skip to content

Commit 3edef7f

Browse files
committed
fix couple of e2e tests and use latest linodego
1 parent 87d70d4 commit 3edef7f

File tree

5 files changed

+60
-22
lines changed

5 files changed

+60
-22
lines changed

cloud/linode/loadbalancers_test.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ o/aoxqmE0mN1lyCPOa9UP//LlsREkWVKI3+Wld/xERtzf66hjcH+ilsXDxxpMEXo
115115
bSiPJQsGIKtQvyCaZY2szyOoeUGgOId+He7ITlezxKrjdj+1pLMESvAxKeo=
116116
-----END RSA PRIVATE KEY-----`
117117

118-
const drop string = "DROP"
118+
const (
119+
drop string = "DROP"
120+
defaultSubnet string = "default"
121+
)
119122

120123
func TestCCMLoadBalancers(t *testing.T) {
121124
testCases := []struct {
@@ -555,14 +558,14 @@ func testCreateNodeBalancerWithVPCBackend(t *testing.T, client *linodego.Client,
555558
Options.SubnetNames = subnetNames
556559
}()
557560
Options.VPCNames = "test1"
558-
Options.SubnetNames = "default"
561+
Options.SubnetNames = defaultSubnet
559562
_, _ = client.CreateVPC(t.Context(), linodego.VPCCreateOptions{
560563
Label: "test1",
561564
Description: "",
562565
Region: "us-west",
563566
Subnets: []linodego.VPCSubnetCreateOptions{
564567
{
565-
Label: "default",
568+
Label: defaultSubnet,
566569
IPv4: "10.0.0.0/8",
567570
},
568571
},
@@ -597,14 +600,14 @@ func testUpdateNodeBalancerWithVPCBackend(t *testing.T, client *linodego.Client,
597600
Options.SubnetNames = subnetNames
598601
}()
599602
Options.VPCNames = "test1"
600-
Options.SubnetNames = "default"
603+
Options.SubnetNames = defaultSubnet
601604
_, _ = client.CreateVPC(t.Context(), linodego.VPCCreateOptions{
602605
Label: "test1",
603606
Description: "",
604607
Region: "us-west",
605608
Subnets: []linodego.VPCSubnetCreateOptions{
606609
{
607-
Label: "default",
610+
Label: defaultSubnet,
608611
IPv4: "10.0.0.0/8",
609612
},
610613
},
@@ -684,15 +687,15 @@ func testCreateNodeBalancerWithVPCOnlySubnetFlag(t *testing.T, client *linodego.
684687
Options.NodeBalancerBackendIPv4Subnet = nbBackendSubnet
685688
}()
686689
Options.VPCNames = "test-subflag"
687-
Options.SubnetNames = "default"
690+
Options.SubnetNames = defaultSubnet
688691
Options.NodeBalancerBackendIPv4Subnet = "10.254.0.0/24"
689692
_, _ = client.CreateVPC(t.Context(), linodego.VPCCreateOptions{
690693
Label: "test-subflag",
691694
Description: "",
692695
Region: "us-west",
693696
Subnets: []linodego.VPCSubnetCreateOptions{
694697
{
695-
Label: "default",
698+
Label: defaultSubnet,
696699
IPv4: "10.0.0.0/8",
697700
},
698701
},
@@ -778,14 +781,14 @@ func testCreateNodeBalancerWithVPCNoFlagOrAnnotation(t *testing.T, client *linod
778781
Options.SubnetNames = subnetNames
779782
}()
780783
Options.VPCNames = "test-noflags"
781-
Options.SubnetNames = "default"
784+
Options.SubnetNames = defaultSubnet
782785
_, _ = client.CreateVPC(t.Context(), linodego.VPCCreateOptions{
783786
Label: "test-noflags",
784787
Description: "",
785788
Region: "us-west",
786789
Subnets: []linodego.VPCSubnetCreateOptions{
787790
{
788-
Label: "default",
791+
Label: defaultSubnet,
789792
IPv4: "10.0.0.0/8",
790793
},
791794
},
@@ -861,14 +864,14 @@ func testCreateNodeBalancerWithVPCAnnotationOnly(t *testing.T, client *linodego.
861864
Options.SubnetNames = subnetNames
862865
}()
863866
Options.VPCNames = "test-onlyannotation"
864-
Options.SubnetNames = "default"
867+
Options.SubnetNames = defaultSubnet
865868
_, _ = client.CreateVPC(t.Context(), linodego.VPCCreateOptions{
866869
Label: "test-onlyannotation",
867870
Description: "",
868871
Region: "us-west",
869872
Subnets: []linodego.VPCSubnetCreateOptions{
870873
{
871-
Label: "default",
874+
Label: defaultSubnet,
872875
IPv4: "10.0.0.0/8",
873876
},
874877
{
@@ -950,15 +953,15 @@ func testCreateNodeBalancerWithVPCOnlySubnetIDFlag(t *testing.T, client *linodeg
950953
Options.NodeBalancerBackendIPv4SubnetID = nbBackendSubnetID
951954
}()
952955
Options.VPCNames = "test1"
953-
Options.SubnetNames = "default"
956+
Options.SubnetNames = defaultSubnet
954957
Options.NodeBalancerBackendIPv4SubnetID = 1111
955958
_, _ = client.CreateVPC(t.Context(), linodego.VPCCreateOptions{
956959
Label: "test-subid-flag",
957960
Description: "",
958961
Region: "us-west",
959962
Subnets: []linodego.VPCSubnetCreateOptions{
960963
{
961-
Label: "default",
964+
Label: defaultSubnet,
962965
IPv4: "10.0.0.0/8",
963966
},
964967
},
@@ -1044,7 +1047,7 @@ func testCreateNodeBalancerWithVPCAnnotationOverwrite(t *testing.T, client *lino
10441047
Region: "us-west",
10451048
Subnets: []linodego.VPCSubnetCreateOptions{
10461049
{
1047-
Label: "default",
1050+
Label: defaultSubnet,
10481051
IPv4: "10.0.0.0/8",
10491052
},
10501053
},

e2e/test/lb-preserve-annotation-new-nb-specified/chainsaw-test.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,29 @@ spec:
4444
# Create new nodebalancer and use it
4545
LABEL="ccm-$(head /dev/urandom | tr -dc 'a-z0-9' | head -c 5)"
4646
47+
# Get VPC config for the old nodebalancer if it exists
48+
vpcconfig=$(curl -s \
49+
-H "Authorization: Bearer $LINODE_TOKEN" \
50+
-H "Content-Type: application/json" \
51+
"https://api.linode.com/v4beta/nodebalancers/$old_nbid/vpcs")
52+
53+
echo "Nodebalancer ID: $old_nbid"
54+
echo "VPC config: $vpcconfig"
55+
56+
SUBNET_ID=$(echo $vpcconfig | jq -r ".data[] | select(.nodebalancer_id == $old_nbid) | .subnet_id")
57+
echo "Subnet ID: $SUBNET_ID"
58+
59+
data="{\"label\": \"$LABEL\", \"region\": \"$REGION\", \"vpcs\": [{\"subnet_id\": $SUBNET_ID}]}"
60+
if [[ -z $SUBNET_ID ]]; then
61+
data="{\"label\": \"$LABEL\", \"region\": \"$REGION\"}"
62+
fi
63+
4764
nbid=$(curl -s --request POST \
4865
-H "Authorization: Bearer $LINODE_TOKEN" \
4966
-H "Content-Type: application/json" \
5067
-H "accept: application/json" \
51-
"https://api.linode.com/v4/nodebalancers" \
52-
--data "{\"label\": \"$LABEL\", \"region\": \"$REGION\"}" | jq .id)
68+
"https://api.linode.com/v4beta/nodebalancers" \
69+
--data "$data" | jq .id)
5370
5471
if ! [[ $nbid =~ $re ]]; then
5572
echo "Nodebalancer id [$nbid] is incorrect, failed to create nodebalancer"

e2e/test/lb-updated-with-nb-id/chainsaw-test.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,32 @@ spec:
3939
re='^[0-9]+$'
4040
LABEL="ccm-$(head /dev/urandom | tr -dc 'a-z0-9' | head -c 5)"
4141
42+
# Get existing nodebalancer id
43+
old_nbid=$(KUBECONFIG=$KUBECONFIG NAMESPACE=$NAMESPACE LINODE_TOKEN=$LINODE_TOKEN ../scripts/get-nb-id.sh)
44+
45+
# Get VPC config for the old nodebalancer if it exists
46+
vpcconfig=$(curl -s \
47+
-H "Authorization: Bearer $LINODE_TOKEN" \
48+
-H "Content-Type: application/json" \
49+
"https://api.linode.com/v4beta/nodebalancers/$old_nbid/vpcs")
50+
51+
echo "Nodebalancer ID: $old_nbid"
52+
echo "VPC config: $vpcconfig"
53+
54+
SUBNET_ID=$(echo $vpcconfig | jq -r ".data[] | select(.nodebalancer_id == $old_nbid) | .subnet_id")
55+
echo "Subnet ID: $SUBNET_ID"
56+
57+
data="{\"label\": \"$LABEL\", \"region\": \"$REGION\", \"vpcs\": [{\"subnet_id\": $SUBNET_ID}]}"
58+
if [[ -z $SUBNET_ID ]]; then
59+
data="{\"label\": \"$LABEL\", \"region\": \"$REGION\"}"
60+
fi
61+
4262
nbid=$(curl -s --request POST \
4363
-H "Authorization: Bearer $LINODE_TOKEN" \
4464
-H "Content-Type: application/json" \
4565
-H "accept: application/json" \
4666
"https://api.linode.com/v4/nodebalancers" \
47-
--data "{\"label\": \"$LABEL\", \"region\": \"$REGION\"}" | jq .id)
67+
--data "$data" | jq .id)
4868
4969
if ! [[ $nbid =~ $re ]]; then
5070
echo "Nodebalancer id [$nbid] for label [$lABEL] is incorrect, failed to create nodebalancer"

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/golang/mock v1.6.0
1212
github.com/google/uuid v1.6.0
1313
github.com/hexdigest/gowrap v1.4.2
14-
github.com/linode/linodego v1.50.0
14+
github.com/linode/linodego v1.52.0
1515
github.com/prometheus/client_golang v1.22.0
1616
github.com/spf13/pflag v1.0.6
1717
github.com/stretchr/testify v1.10.0
@@ -190,5 +190,3 @@ replace (
190190
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.33.0
191191
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.33.0
192192
)
193-
194-
replace github.com/linode/linodego => github.com/rahulait/linodego v1.50.1-0.20250522183359-5da732de45af

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
201201
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
202202
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=
203203
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
204+
github.com/linode/linodego v1.52.0 h1:SN1PSekrZBcHtRt1pADTz0JO7NX9pQv/Gf8Jc9s9l8w=
205+
github.com/linode/linodego v1.52.0/go.mod h1:zEN2sX+cSdp67EuRY1HJiyuLujoa7HqvVwNEcJv3iXw=
204206
github.com/mackerelio/go-osstat v0.2.5 h1:+MqTbZUhoIt4m8qzkVoXUJg1EuifwlAJSk4Yl2GXh+o=
205207
github.com/mackerelio/go-osstat v0.2.5/go.mod h1:atxwWF+POUZcdtR1wnsUcQxTytoHG4uhl2AKKzrOajY=
206208
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=
@@ -266,8 +268,6 @@ github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ
266268
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
267269
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
268270
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
269-
github.com/rahulait/linodego v1.50.1-0.20250522183359-5da732de45af h1:LG/Nrmv3UyKsLqk2Juy7DJPJL+DEtef4AIeBtkYOOp8=
270-
github.com/rahulait/linodego v1.50.1-0.20250522183359-5da732de45af/go.mod h1:zEN2sX+cSdp67EuRY1HJiyuLujoa7HqvVwNEcJv3iXw=
271271
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
272272
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
273273
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

0 commit comments

Comments
 (0)