Skip to content

Commit

Permalink
Add unit test coverage for Nodebalancers related methods/functions (#682
Browse files Browse the repository at this point in the history
)

* node_test

* node_tests
  • Loading branch information
vshanthe authored Feb 19, 2025
1 parent 33d2c6a commit 1f1254b
Show file tree
Hide file tree
Showing 21 changed files with 775 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/unit/fixtures/nodebalancer_config_create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": 456,
"port": 80,
"protocol": "http",
"algorithm": "roundrobin",
"stickiness": "table",
"check": "connection",
"check_interval": 5,
"check_attempts": 3,
"check_path": "/",
"check_body": "",
"check_passive": true,
"check_timeout": 30,
"cipher_suite": "recommended",
"nodebalancer_id": 123,
"ssl_commonname": "",
"ssl_fingerprint": "",
"ssl_cert": "",
"ssl_key": "",
"nodes_status": {
"up": 2,
"down": 1
}
}

25 changes: 25 additions & 0 deletions test/unit/fixtures/nodebalancer_config_get.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": 456,
"port": 80,
"protocol": "http",
"algorithm": "roundrobin",
"stickiness": "table",
"check": "connection",
"check_interval": 5,
"check_attempts": 3,
"check_path": "/",
"check_body": "",
"check_passive": true,
"check_timeout": 30,
"cipher_suite": "recommended",
"nodebalancer_id": 123,
"ssl_commonname": "",
"ssl_fingerprint": "",
"ssl_cert": "",
"ssl_key": "",
"nodes_status": {
"up": 2,
"down": 1
}
}

31 changes: 31 additions & 0 deletions test/unit/fixtures/nodebalancer_config_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"data": [
{
"id": 456,
"address": "192.168.1.1",
"label": "Test Node",
"status": "UP",
"weight": 50,
"mode": "accept",
"config_id": 456,
"nodebalancer_id": 123,
"port": 80,
"protocol": "http"
},
{
"id": 457,
"address": "192.168.1.2",
"label": "Backup Node",
"status": "UP",
"weight": 40,
"mode": "backup",
"config_id": 456,
"nodebalancer_id": 123,
"port": 80,
"protocol": "http"
}
],
"page": 1,
"pages": 1,
"results": 2
}
25 changes: 25 additions & 0 deletions test/unit/fixtures/nodebalancer_config_rebuild.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": 456,
"port": 443,
"protocol": "https",
"algorithm": "roundrobin",
"stickiness": "none",
"check": "connection",
"check_interval": 5,
"check_attempts": 3,
"check_path": "/",
"check_body": "",
"check_passive": true,
"check_timeout": 30,
"cipher_suite": "recommended",
"nodebalancer_id": 123,
"ssl_commonname": "",
"ssl_fingerprint": "",
"ssl_cert": "",
"ssl_key": "",
"nodes_status": {
"up": 2,
"down": 1
}
}

25 changes: 25 additions & 0 deletions test/unit/fixtures/nodebalancer_config_update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": 456,
"port": 443,
"protocol": "https",
"algorithm": "roundrobin",
"stickiness": "none",
"check": "connection",
"check_interval": 5,
"check_attempts": 3,
"check_path": "/",
"check_body": "",
"check_passive": true,
"check_timeout": 30,
"cipher_suite": "recommended",
"nodebalancer_id": 123,
"ssl_commonname": "",
"ssl_fingerprint": "",
"ssl_cert": "",
"ssl_key": "",
"nodes_status": {
"up": 2,
"down": 1
}
}

18 changes: 18 additions & 0 deletions test/unit/fixtures/nodebalancer_create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"id": 123,
"label": "Test NodeBalancer",
"region": "us-east",
"hostname": "test.nodebalancer.linode.com",
"ipv4": "192.0.2.1",
"ipv6": "2600:3c03::f03c:91ff:fe24:9dcf",
"client_conn_throttle": 10,
"transfer": {
"total": 1000.5,
"in": 500.3,
"out": 500.2
},
"tags": ["test", "example"],
"created": "2025-02-01T10:00:00",
"updated": "2025-02-06T10:00:00"
}

18 changes: 18 additions & 0 deletions test/unit/fixtures/nodebalancer_firewall_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"data": [
{
"id": 789,
"label": "firewall-1",
"status": "enabled"
},
{
"id": 790,
"label": "firewall-2",
"status": "disabled"
}
],
"page": 1,
"pages": 1,
"results": 2
}

18 changes: 18 additions & 0 deletions test/unit/fixtures/nodebalancer_get.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"id": 123,
"label": "Existing NodeBalancer",
"region": "us-west",
"hostname": "existing.nodebalancer.linode.com",
"ipv4": "192.0.2.2",
"ipv6": "2600:3c03::f03c:91ff:fe24:abcd",
"client_conn_throttle": 20,
"transfer": {
"total": 2000.0,
"in": 1000.0,
"out": 1000.0
},
"tags": ["production"],
"created": "2025-01-15T08:00:00",
"updated": "2025-02-05T12:00:00"
}

11 changes: 11 additions & 0 deletions test/unit/fixtures/nodebalancer_node_create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": 789,
"address": "192.168.1.1",
"label": "Test Node",
"status": "UP",
"weight": 50,
"mode": "accept",
"config_id": 456,
"nodebalancer_id": 123
}

27 changes: 27 additions & 0 deletions test/unit/fixtures/nodebalancer_node_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"data": [
{
"id": 789,
"address": "192.168.1.1",
"label": "Test Node",
"status": "UP",
"weight": 50,
"mode": "accept",
"config_id": 456,
"nodebalancer_id": 123
},
{
"id": 790,
"address": "192.168.1.2",
"label": "Backup Node",
"status": "UP",
"weight": 40,
"mode": "backup",
"config_id": 456,
"nodebalancer_id": 123
}
],
"page": 1,
"pages": 1,
"results": 2
}
11 changes: 11 additions & 0 deletions test/unit/fixtures/nodebalancer_node_update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": 789,
"address": "192.168.1.2",
"label": "Updated Node",
"status": "UP",
"weight": 60,
"mode": "drain",
"config_id": 456,
"nodebalancer_id": 123
}

20 changes: 20 additions & 0 deletions test/unit/fixtures/nodebalancer_stats_get.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"title": "NodeBalancer Stats",
"data": {
"connections": [
[1000.0, 2000.0],
[3000.0, 4000.0]
],
"traffic": {
"in": [
[1000.0, 2000.0],
[3000.0, 4000.0]
],
"out": [
[500.0, 1000.0],
[1500.0, 2000.0]
]
}
}
}

18 changes: 18 additions & 0 deletions test/unit/fixtures/nodebalancer_update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"id": 456,
"label": "Updated NodeBalancer",
"region": "us-west",
"hostname": "updated.nodebalancer.linode.com",
"ipv4": "192.0.2.5",
"ipv6": "2600:3c03::f03c:91ff:fe24:3333",
"client_conn_throttle": 5,
"transfer": {
"total": 1500.0,
"in": 750.0,
"out": 750.0
},
"tags": ["updated", "production"],
"created": "2025-01-15T08:00:00",
"updated": "2025-02-06T15:00:00"
}

19 changes: 19 additions & 0 deletions test/unit/fixtures/nodebalancers_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"data": [
{
"id": 123,
"label": "NodeBalancer A",
"region": "us-east",
"tags": ["tag1", "tag2"]
},
{
"id": 456,
"label": "NodeBalancer B",
"region": "us-west",
"tags": ["tag3"]
}
],
"page": 1,
"pages": 1,
"results": 2
}
27 changes: 27 additions & 0 deletions test/unit/fixtures/nodebalancers_types_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"data": [
{
"id": "123",
"label": "NodeBalancer A",
"region": "us-east",
"tags": ["tag1", "tag2"],
"price": {
"hourly": 0.10,
"monthly": 10.00
}
},
{
"id": "456",
"label": "NodeBalancer B",
"region": "us-west",
"tags": ["tag3"],
"price": {
"hourly": 0.15,
"monthly": 15.00
}
}
],
"page": 1,
"pages": 1,
"results": 2
}
Loading

0 comments on commit 1f1254b

Please sign in to comment.