Skip to content

Commit 9ca91ac

Browse files
committed
Adds integration tests for node balancer with UDP configuration
1 parent d5136db commit 9ca91ac

File tree

2 files changed

+265
-0
lines changed

2 files changed

+265
-0
lines changed

tests/integration/nodebalancers/fixtures.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,120 @@ def nodebalancer_with_default_conf(linode_cloud_firewall):
165165
res_arr = result.split(",")
166166
nodebalancer_id = res_arr[0]
167167
delete_target_id(target="nodebalancers", id=nodebalancer_id)
168+
169+
170+
@pytest.fixture(scope="module")
171+
def nodebalancer_with_udp_config_and_node(linode_cloud_firewall):
172+
nodebalancer_id = exec_test_command(
173+
BASE_CMDS["nodebalancers"]
174+
+ [
175+
"create",
176+
"--region", "us-ord",
177+
"--client_conn_throttle", "20",
178+
"--firewall_id", linode_cloud_firewall,
179+
"--text",
180+
"--delimiter", ",",
181+
"--format", "id",
182+
"--no-headers",
183+
]
184+
)
185+
config_id = exec_test_command(
186+
BASE_CMDS["nodebalancers"]
187+
+ [
188+
"config-create",
189+
nodebalancer_id,
190+
"--port", "80",
191+
"--protocol", "udp",
192+
"--algorithm", "roundrobin",
193+
"--check_interval", "90",
194+
"--check_timeout", "10",
195+
"--check_attempts", "3",
196+
"--check_path", "/test",
197+
"--check_body", "it works",
198+
"--delimiter",",",
199+
"--text",
200+
"--no-headers",
201+
"--format", "id",
202+
]
203+
)
204+
205+
linode_create = exec_test_command(
206+
BASE_CMDS["linodes"]
207+
+ [
208+
"create",
209+
"--root_pass", "aComplex@Password",
210+
"--booted", "true",
211+
"--region", "us-ord",
212+
"--type", "g6-nanode-1",
213+
"--private_ip", "true",
214+
"--image", DEFAULT_TEST_IMAGE,
215+
"--firewall_id", linode_cloud_firewall,
216+
"--text",
217+
"--delimiter", ",",
218+
"--format", "id,ipv4",
219+
"--no-header",
220+
"--suppress-warnings",
221+
]
222+
)
223+
linode_arr = linode_create.split(",")
224+
linode_id = linode_arr[0]
225+
ip_arr = linode_arr[1].split(" ")
226+
node_ip = ip_arr[1]
227+
node_label = "defaultnode1"
228+
node_id = exec_test_command(
229+
BASE_CMDS["nodebalancers"]
230+
+ [
231+
"node-create",
232+
nodebalancer_id,
233+
config_id,
234+
"--address", node_ip + ":80",
235+
"--label", node_label,
236+
"--weight", "100",
237+
"--delimiter", ",",
238+
"--text",
239+
"--no-headers",
240+
"--format", "id",
241+
]
242+
)
243+
244+
yield nodebalancer_id, config_id, node_id, node_ip
245+
246+
delete_target_id(target="nodebalancers", id=nodebalancer_id)
247+
delete_target_id(target="linodes", id=linode_id)
248+
249+
250+
@pytest.fixture(scope="module")
251+
def simple_nodebalancer_with_config(linode_cloud_firewall):
252+
nodebalancer_id = exec_test_command(
253+
BASE_CMDS["nodebalancers"]
254+
+ [
255+
"create",
256+
"--region", "us-ord",
257+
"--client_conn_throttle", "20",
258+
"--firewall_id", linode_cloud_firewall,
259+
"--text",
260+
"--delimiter", ",",
261+
"--format", "id",
262+
"--no-headers",
263+
]
264+
)
265+
config_id = exec_test_command(
266+
BASE_CMDS["nodebalancers"]
267+
+ [
268+
"config-create",
269+
nodebalancer_id,
270+
"--port", "81",
271+
"--protocol", "http",
272+
"--algorithm", "leastconn",
273+
"--check_path", "/test",
274+
"--check_body", "it works",
275+
"--text",
276+
"--no-headers",
277+
"--delimiter", ",",
278+
"--format", "id",
279+
]
280+
)
281+
282+
yield nodebalancer_id, config_id
283+
284+
delete_target_id(target="nodebalancers", id=nodebalancer_id)

tests/integration/nodebalancers/test_node_balancers.py

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
linode_to_add,
1313
nodebalancer_w_config_and_node,
1414
nodebalancer_with_default_conf,
15+
nodebalancer_with_udp_config_and_node,
16+
simple_nodebalancer_with_config,
1517
)
1618

1719

@@ -340,5 +342,151 @@ def test_list_multiple_configuration_profile(nodebalancer_w_config_and_node):
340342
)
341343

342344

345+
def test_update_node_balancer_udp_configuration(simple_nodebalancer_with_config):
346+
nodebalancer_id = simple_nodebalancer_with_config[0]
347+
config_id = simple_nodebalancer_with_config[1]
348+
349+
result = exec_test_command(
350+
BASE_CMDS["nodebalancers"]
351+
+ [
352+
"config-update",
353+
nodebalancer_id,
354+
config_id,
355+
"--port", "80",
356+
"--protocol", "udp",
357+
"--algorithm", "roundrobin",
358+
"--check_interval", "80",
359+
"--check_timeout", "15",
360+
"--check_attempts", "2",
361+
"--check_path", "/testUpdate",
362+
"--check_body", "OK",
363+
"--check_passive", "False",
364+
"--delimiter",",",
365+
"--text",
366+
"--no-headers",
367+
]
368+
)
369+
assert result == config_id + ',80,udp,roundrobin,none,False,none,,'
370+
371+
372+
def test_rebuild_node_balancer_udp_configuration(nodebalancer_with_udp_config_and_node):
373+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
374+
config_id = nodebalancer_with_udp_config_and_node[1]
375+
376+
result = exec_test_command(
377+
BASE_CMDS["nodebalancers"]
378+
+ [
379+
"config-rebuild",
380+
nodebalancer_id,
381+
config_id,
382+
"--port", "80",
383+
"--protocol", "udp",
384+
"--algorithm", "ring_hash",
385+
"--nodes.label", "defaultnode1",
386+
"--nodes.address", nodebalancer_with_udp_config_and_node[3] + ":80",
387+
"--nodes.weight", "50",
388+
"--delimiter", ",",
389+
"--text",
390+
"--no-headers",
391+
]
392+
)
393+
assert result == config_id + ',80,udp,ring_hash,session,False,none,,'
394+
395+
396+
def test_list_node_balancer_configurations_with_udp_type(nodebalancer_with_udp_config_and_node):
397+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
398+
config_id = nodebalancer_with_udp_config_and_node[1]
399+
400+
result = exec_test_command(
401+
BASE_CMDS["nodebalancers"]
402+
+ [
403+
"configs-list",
404+
nodebalancer_id,
405+
"--delimiter", ",",
406+
"--text",
407+
"--no-headers",
408+
]
409+
)
410+
assert result == config_id + ',80,udp,roundrobin,session,False,none,,'
411+
412+
413+
def test_view_node_balancer_udp_configuration(nodebalancer_with_udp_config_and_node):
414+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
415+
config_id = nodebalancer_with_udp_config_and_node[1]
416+
417+
result = exec_test_command(
418+
BASE_CMDS["nodebalancers"]
419+
+ [
420+
"config-view",
421+
nodebalancer_id,
422+
config_id,
423+
"--delimiter", ",",
424+
"--text",
425+
"--no-headers",
426+
]
427+
)
428+
assert result == config_id + ',80,udp,roundrobin,session,False,none,,'
429+
430+
431+
def test_update_node_for_node_balancer_udp_configuration(nodebalancer_with_udp_config_and_node):
432+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
433+
config_id = nodebalancer_with_udp_config_and_node[1]
434+
node_id = nodebalancer_with_udp_config_and_node[2]
435+
436+
result = exec_test_command(
437+
BASE_CMDS["nodebalancers"]
438+
+ [
439+
"node-update",
440+
nodebalancer_id,
441+
config_id,
442+
node_id,
443+
"--weight", "30",
444+
"--delimiter", ",",
445+
"--text",
446+
"--no-headers",
447+
]
448+
)
449+
assert result == node_id + ',defaultnode1,' + nodebalancer_with_udp_config_and_node[3] + ':80,Unknown,30,none'
450+
451+
452+
def test_list_nodes_for_node_balancer_udp_configuration(nodebalancer_with_udp_config_and_node):
453+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
454+
config_id = nodebalancer_with_udp_config_and_node[1]
455+
node_id = nodebalancer_with_udp_config_and_node[2]
456+
457+
result = exec_test_command(
458+
BASE_CMDS["nodebalancers"]
459+
+ [
460+
"nodes-list",
461+
nodebalancer_id,
462+
config_id,
463+
"--delimiter", ",",
464+
"--text",
465+
"--no-headers",
466+
]
467+
)
468+
assert result == node_id + ',defaultnode1,' + nodebalancer_with_udp_config_and_node[3] + ':80,Unknown,100,none'
469+
470+
471+
def test_view_node_for_node_balancer_udp_configuration(nodebalancer_with_udp_config_and_node):
472+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
473+
config_id = nodebalancer_with_udp_config_and_node[1]
474+
node_id = nodebalancer_with_udp_config_and_node[2]
475+
476+
result = exec_test_command(
477+
BASE_CMDS["nodebalancers"]
478+
+ [
479+
"node-view",
480+
nodebalancer_id,
481+
config_id,
482+
node_id,
483+
"--delimiter", ",",
484+
"--text",
485+
"--no-headers",
486+
]
487+
)
488+
assert result == node_id + ',defaultnode1,' + nodebalancer_with_udp_config_and_node[3] + ':80,Unknown,100,none'
489+
490+
343491
def nodebalancer_created():
344492
return "[0-9]+,balancer[0-9]+,us-ord,[0-9]+-[0-9]+-[0-9]+-[0-9]+.ip.linodeusercontent.com,0"

0 commit comments

Comments
 (0)