Skip to content

Commit a864da2

Browse files
committed
remove tests
1 parent 276f162 commit a864da2

File tree

1 file changed

+0
-246
lines changed

1 file changed

+0
-246
lines changed

cloud/linode/loadbalancers_test.go

Lines changed: 0 additions & 246 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,6 @@ func TestCCMLoadBalancers(t *testing.T) {
311311
name: "Update Load Balancer - No Nodes",
312312
f: testUpdateLoadBalancerNoNodes,
313313
},
314-
{
315-
name: "Update Load Balancer - Node excluded by annotation",
316-
f: testUpdateLoadBalancerNodeExcludedByAnnotation,
317-
},
318314
{
319315
name: "Create Load Balancer - Very long Service name",
320316
f: testVeryLongServiceName,
@@ -4650,248 +4646,6 @@ func testCleanupDoesntCall(t *testing.T, client *linodego.Client, fakeAPI *fakeA
46504646
})
46514647
}
46524648

4653-
func testUpdateLoadBalancerNodeExcludedByAnnotation(t *testing.T, client *linodego.Client, _ *fakeAPI) {
4654-
t.Helper()
4655-
svc := &v1.Service{
4656-
ObjectMeta: metav1.ObjectMeta{
4657-
Name: randString(),
4658-
UID: "foobar123",
4659-
Annotations: map[string]string{},
4660-
},
4661-
Spec: v1.ServiceSpec{
4662-
Ports: []v1.ServicePort{
4663-
{
4664-
Name: randString(),
4665-
Protocol: "http",
4666-
Port: int32(80),
4667-
NodePort: int32(8080),
4668-
},
4669-
},
4670-
},
4671-
}
4672-
4673-
lb, assertion := newLoadbalancers(client, "us-west").(*loadbalancers)
4674-
if !assertion {
4675-
t.Error("type assertion failed")
4676-
}
4677-
defer func() {
4678-
_ = lb.EnsureLoadBalancerDeleted(t.Context(), "linodelb", svc)
4679-
}()
4680-
4681-
fakeClientset := fake.NewSimpleClientset()
4682-
lb.kubeClient = fakeClientset
4683-
4684-
nodeBalancer, err := client.CreateNodeBalancer(t.Context(), linodego.NodeBalancerCreateOptions{
4685-
Region: lb.zone,
4686-
})
4687-
if err != nil {
4688-
t.Fatalf("failed to create NodeBalancer: %s", err)
4689-
}
4690-
svc.Status.LoadBalancer = *makeLoadBalancerStatus(svc, nodeBalancer)
4691-
stubService(fakeClientset, svc)
4692-
svc.SetAnnotations(map[string]string{
4693-
annotations.AnnLinodeNodeBalancerID: strconv.Itoa(nodeBalancer.ID),
4694-
})
4695-
4696-
// setup done, test ensure/update
4697-
nodes := []*v1.Node{
4698-
{
4699-
ObjectMeta: metav1.ObjectMeta{
4700-
Name: "node-1",
4701-
},
4702-
Status: v1.NodeStatus{
4703-
Addresses: []v1.NodeAddress{
4704-
{
4705-
Type: v1.NodeInternalIP,
4706-
Address: "127.0.0.1",
4707-
},
4708-
},
4709-
},
4710-
},
4711-
{
4712-
ObjectMeta: metav1.ObjectMeta{
4713-
Name: "node-2",
4714-
Labels: map[string]string{
4715-
v1.LabelNodeExcludeBalancers: "true",
4716-
},
4717-
},
4718-
Status: v1.NodeStatus{
4719-
Addresses: []v1.NodeAddress{
4720-
{
4721-
Type: v1.NodeInternalIP,
4722-
Address: "127.0.0.2",
4723-
},
4724-
},
4725-
},
4726-
},
4727-
{
4728-
ObjectMeta: metav1.ObjectMeta{
4729-
Name: "node-3",
4730-
},
4731-
Status: v1.NodeStatus{
4732-
Addresses: []v1.NodeAddress{
4733-
{
4734-
Type: v1.NodeInternalIP,
4735-
Address: "127.0.0.3",
4736-
},
4737-
},
4738-
},
4739-
},
4740-
}
4741-
4742-
// Test initial creation - should only create nodes that aren't excluded
4743-
lbStatus, err := lb.EnsureLoadBalancer(t.Context(), "linodelb", svc, nodes)
4744-
if err != nil {
4745-
t.Fatalf("expected no error got %v", err)
4746-
}
4747-
svc.Status.LoadBalancer = *lbStatus
4748-
stubServiceUpdate(fakeClientset, svc)
4749-
nodeBalancerNodes := getLatestNbNodesForService(t, client, svc, lb)
4750-
// Should have only 2 nodes (node-1 and node-3), since node-2 is excluded
4751-
if len(nodeBalancerNodes) != 2 {
4752-
t.Errorf("expected 2 nodes, got %d", len(nodeBalancerNodes))
4753-
}
4754-
4755-
// Verify excluded node is not present
4756-
for _, nbNode := range nodeBalancerNodes {
4757-
if strings.Contains(nbNode.Label, "node-2") {
4758-
t.Errorf("excluded node 'node-2' should not be present in nodeBalancer nodes")
4759-
}
4760-
}
4761-
4762-
// Test Update operation
4763-
updatedNodes := []*v1.Node{
4764-
{
4765-
ObjectMeta: metav1.ObjectMeta{
4766-
Name: "node-1",
4767-
Labels: map[string]string{
4768-
v1.LabelNodeExcludeBalancers: "true",
4769-
},
4770-
},
4771-
Status: v1.NodeStatus{
4772-
Addresses: []v1.NodeAddress{
4773-
{
4774-
Type: v1.NodeInternalIP,
4775-
Address: "127.0.0.1",
4776-
},
4777-
},
4778-
},
4779-
},
4780-
{
4781-
ObjectMeta: metav1.ObjectMeta{
4782-
Name: "node-2",
4783-
Labels: map[string]string{
4784-
v1.LabelNodeExcludeBalancers: "true",
4785-
},
4786-
},
4787-
Status: v1.NodeStatus{
4788-
Addresses: []v1.NodeAddress{
4789-
{
4790-
Type: v1.NodeInternalIP,
4791-
Address: "127.0.0.2",
4792-
},
4793-
},
4794-
},
4795-
},
4796-
{
4797-
ObjectMeta: metav1.ObjectMeta{
4798-
Name: "node-3",
4799-
},
4800-
Status: v1.NodeStatus{
4801-
Addresses: []v1.NodeAddress{
4802-
{
4803-
Type: v1.NodeInternalIP,
4804-
Address: "127.0.0.3",
4805-
},
4806-
},
4807-
},
4808-
},
4809-
}
4810-
4811-
// Update the load balancer with updated nodes
4812-
if err = lb.UpdateLoadBalancer(t.Context(), "linodelb", svc, updatedNodes); err != nil {
4813-
t.Fatalf("unexpected error updating LoadBalancer: %v", err)
4814-
}
4815-
4816-
// Verify nodes were updated correctly
4817-
nodeBalancerNodesAfterUpdate := getLatestNbNodesForService(t, client, svc, lb)
4818-
4819-
// Should have only 1 node (node-3), since both node-1 and node-2 are excluded
4820-
if len(nodeBalancerNodesAfterUpdate) != 1 {
4821-
t.Errorf("expected 1 node after update, got %d", len(nodeBalancerNodesAfterUpdate))
4822-
}
4823-
4824-
// Verify excluded nodes are not present
4825-
for _, nbNode := range nodeBalancerNodesAfterUpdate {
4826-
if strings.Contains(nbNode.Label, "node-1") || strings.Contains(nbNode.Label, "node-2") {
4827-
t.Errorf("excluded nodes should not be present in nodeBalancer nodes after update")
4828-
}
4829-
}
4830-
4831-
// Test edge case: all nodes excluded
4832-
allExcludedNodes := []*v1.Node{
4833-
{
4834-
ObjectMeta: metav1.ObjectMeta{
4835-
Name: "node-1",
4836-
Labels: map[string]string{
4837-
v1.LabelNodeExcludeBalancers: "true",
4838-
},
4839-
},
4840-
Status: v1.NodeStatus{
4841-
Addresses: []v1.NodeAddress{
4842-
{
4843-
Type: v1.NodeInternalIP,
4844-
Address: "127.0.0.1",
4845-
},
4846-
},
4847-
},
4848-
},
4849-
{
4850-
ObjectMeta: metav1.ObjectMeta{
4851-
Name: "node-2",
4852-
Labels: map[string]string{
4853-
v1.LabelNodeExcludeBalancers: "true",
4854-
},
4855-
},
4856-
Status: v1.NodeStatus{
4857-
Addresses: []v1.NodeAddress{
4858-
{
4859-
Type: v1.NodeInternalIP,
4860-
Address: "127.0.0.2",
4861-
},
4862-
},
4863-
},
4864-
},
4865-
{
4866-
ObjectMeta: metav1.ObjectMeta{
4867-
Name: "node-3",
4868-
Labels: map[string]string{
4869-
v1.LabelNodeExcludeBalancers: "true",
4870-
},
4871-
},
4872-
Status: v1.NodeStatus{
4873-
Addresses: []v1.NodeAddress{
4874-
{
4875-
Type: v1.NodeInternalIP,
4876-
Address: "127.0.0.3",
4877-
},
4878-
},
4879-
},
4880-
},
4881-
}
4882-
4883-
if err = lb.UpdateLoadBalancer(t.Context(), "linodelb", svc, allExcludedNodes); err != nil {
4884-
t.Errorf("expected no error when all nodes are excluded, got %v", err)
4885-
}
4886-
4887-
// Verify nodes were updated correctly
4888-
nodeBalancerNodesAfterUpdate = getLatestNbNodesForService(t, client, svc, lb)
4889-
// Should have only 0 node (node-3), since all nodes are excluded
4890-
if len(nodeBalancerNodesAfterUpdate) != 0 {
4891-
t.Errorf("expected 0 nodes after update, got %d", len(nodeBalancerNodesAfterUpdate))
4892-
}
4893-
}
4894-
48954649
func testUpdateLoadBalancerNoNodes(t *testing.T, client *linodego.Client, _ *fakeAPI) {
48964650
t.Helper()
48974651

0 commit comments

Comments
 (0)