Skip to content

Commit 2e745e7

Browse files
Adds integration tests for node balancer with UDP configuration (#801)
1 parent 254a70f commit 2e745e7

File tree

2 files changed

+361
-0
lines changed

2 files changed

+361
-0
lines changed

tests/integration/nodebalancers/fixtures.py

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,161 @@ 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",
177+
"us-ord",
178+
"--client_conn_throttle",
179+
"20",
180+
"--firewall_id",
181+
linode_cloud_firewall,
182+
"--text",
183+
"--delimiter",
184+
",",
185+
"--format",
186+
"id",
187+
"--no-headers",
188+
]
189+
)
190+
config_id = exec_test_command(
191+
BASE_CMDS["nodebalancers"]
192+
+ [
193+
"config-create",
194+
nodebalancer_id,
195+
"--port",
196+
"80",
197+
"--protocol",
198+
"udp",
199+
"--algorithm",
200+
"roundrobin",
201+
"--check_interval",
202+
"90",
203+
"--check_timeout",
204+
"10",
205+
"--check_attempts",
206+
"3",
207+
"--check_path",
208+
"/test",
209+
"--check_body",
210+
"it works",
211+
"--delimiter",
212+
",",
213+
"--text",
214+
"--no-headers",
215+
"--format",
216+
"id",
217+
]
218+
)
219+
220+
linode_create = exec_test_command(
221+
BASE_CMDS["linodes"]
222+
+ [
223+
"create",
224+
"--root_pass",
225+
"aComplex@Password",
226+
"--booted",
227+
"true",
228+
"--region",
229+
"us-ord",
230+
"--type",
231+
"g6-nanode-1",
232+
"--private_ip",
233+
"true",
234+
"--image",
235+
DEFAULT_TEST_IMAGE,
236+
"--firewall_id",
237+
linode_cloud_firewall,
238+
"--text",
239+
"--delimiter",
240+
",",
241+
"--format",
242+
"id,ipv4",
243+
"--no-header",
244+
"--suppress-warnings",
245+
]
246+
)
247+
linode_arr = linode_create.split(",")
248+
linode_id = linode_arr[0]
249+
ip_arr = linode_arr[1].split(" ")
250+
node_ip = ip_arr[1]
251+
node_label = "defaultnode1"
252+
node_id = exec_test_command(
253+
BASE_CMDS["nodebalancers"]
254+
+ [
255+
"node-create",
256+
nodebalancer_id,
257+
config_id,
258+
"--address",
259+
node_ip + ":80",
260+
"--label",
261+
node_label,
262+
"--weight",
263+
"100",
264+
"--delimiter",
265+
",",
266+
"--text",
267+
"--no-headers",
268+
"--format",
269+
"id",
270+
]
271+
)
272+
273+
yield nodebalancer_id, config_id, node_id, node_ip
274+
275+
delete_target_id(target="nodebalancers", id=nodebalancer_id)
276+
delete_target_id(target="linodes", id=linode_id)
277+
278+
279+
@pytest.fixture(scope="module")
280+
def simple_nodebalancer_with_config(linode_cloud_firewall):
281+
nodebalancer_id = exec_test_command(
282+
BASE_CMDS["nodebalancers"]
283+
+ [
284+
"create",
285+
"--region",
286+
"us-ord",
287+
"--client_conn_throttle",
288+
"20",
289+
"--firewall_id",
290+
linode_cloud_firewall,
291+
"--text",
292+
"--delimiter",
293+
",",
294+
"--format",
295+
"id",
296+
"--no-headers",
297+
]
298+
)
299+
config_id = exec_test_command(
300+
BASE_CMDS["nodebalancers"]
301+
+ [
302+
"config-create",
303+
nodebalancer_id,
304+
"--port",
305+
"81",
306+
"--protocol",
307+
"http",
308+
"--algorithm",
309+
"leastconn",
310+
"--check_path",
311+
"/test",
312+
"--check_body",
313+
"it works",
314+
"--text",
315+
"--no-headers",
316+
"--delimiter",
317+
",",
318+
"--format",
319+
"id",
320+
]
321+
)
322+
323+
yield nodebalancer_id, config_id
324+
325+
delete_target_id(target="nodebalancers", id=nodebalancer_id)

tests/integration/nodebalancers/test_node_balancers.py

Lines changed: 203 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,206 @@ def test_list_multiple_configuration_profile(nodebalancer_w_config_and_node):
340342
)
341343

342344

345+
def test_update_node_balancer_udp_configuration(
346+
simple_nodebalancer_with_config,
347+
):
348+
nodebalancer_id = simple_nodebalancer_with_config[0]
349+
config_id = simple_nodebalancer_with_config[1]
350+
351+
result = exec_test_command(
352+
BASE_CMDS["nodebalancers"]
353+
+ [
354+
"config-update",
355+
nodebalancer_id,
356+
config_id,
357+
"--port",
358+
"80",
359+
"--protocol",
360+
"udp",
361+
"--algorithm",
362+
"roundrobin",
363+
"--check_interval",
364+
"80",
365+
"--check_timeout",
366+
"15",
367+
"--check_attempts",
368+
"2",
369+
"--check_path",
370+
"/testUpdate",
371+
"--check_body",
372+
"OK",
373+
"--check_passive",
374+
"False",
375+
"--delimiter",
376+
",",
377+
"--text",
378+
"--no-headers",
379+
]
380+
)
381+
assert result == config_id + ",80,udp,roundrobin,none,False,none,,"
382+
383+
384+
def test_rebuild_node_balancer_udp_configuration(
385+
nodebalancer_with_udp_config_and_node,
386+
):
387+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
388+
config_id = nodebalancer_with_udp_config_and_node[1]
389+
390+
result = exec_test_command(
391+
BASE_CMDS["nodebalancers"]
392+
+ [
393+
"config-rebuild",
394+
nodebalancer_id,
395+
config_id,
396+
"--port",
397+
"80",
398+
"--protocol",
399+
"udp",
400+
"--algorithm",
401+
"ring_hash",
402+
"--nodes.label",
403+
"defaultnode1",
404+
"--nodes.address",
405+
nodebalancer_with_udp_config_and_node[3] + ":80",
406+
"--nodes.weight",
407+
"50",
408+
"--delimiter",
409+
",",
410+
"--text",
411+
"--no-headers",
412+
]
413+
)
414+
assert result == config_id + ",80,udp,ring_hash,session,False,none,,"
415+
416+
417+
def test_list_node_balancer_configurations_with_udp_type(
418+
nodebalancer_with_udp_config_and_node,
419+
):
420+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
421+
config_id = nodebalancer_with_udp_config_and_node[1]
422+
423+
result = exec_test_command(
424+
BASE_CMDS["nodebalancers"]
425+
+ [
426+
"configs-list",
427+
nodebalancer_id,
428+
"--delimiter",
429+
",",
430+
"--text",
431+
"--no-headers",
432+
]
433+
)
434+
assert result == config_id + ",80,udp,roundrobin,session,False,none,,"
435+
436+
437+
def test_view_node_balancer_udp_configuration(
438+
nodebalancer_with_udp_config_and_node,
439+
):
440+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
441+
config_id = nodebalancer_with_udp_config_and_node[1]
442+
443+
result = exec_test_command(
444+
BASE_CMDS["nodebalancers"]
445+
+ [
446+
"config-view",
447+
nodebalancer_id,
448+
config_id,
449+
"--delimiter",
450+
",",
451+
"--text",
452+
"--no-headers",
453+
]
454+
)
455+
assert result == config_id + ",80,udp,roundrobin,session,False,none,,"
456+
457+
458+
def test_update_node_for_node_balancer_udp_configuration(
459+
nodebalancer_with_udp_config_and_node,
460+
):
461+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
462+
config_id = nodebalancer_with_udp_config_and_node[1]
463+
node_id = nodebalancer_with_udp_config_and_node[2]
464+
465+
result = exec_test_command(
466+
BASE_CMDS["nodebalancers"]
467+
+ [
468+
"node-update",
469+
nodebalancer_id,
470+
config_id,
471+
node_id,
472+
"--weight",
473+
"30",
474+
"--delimiter",
475+
",",
476+
"--text",
477+
"--no-headers",
478+
]
479+
)
480+
assert (
481+
result
482+
== node_id
483+
+ ",defaultnode1,"
484+
+ nodebalancer_with_udp_config_and_node[3]
485+
+ ":80,Unknown,30,none"
486+
)
487+
488+
489+
def test_list_nodes_for_node_balancer_udp_configuration(
490+
nodebalancer_with_udp_config_and_node,
491+
):
492+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
493+
config_id = nodebalancer_with_udp_config_and_node[1]
494+
node_id = nodebalancer_with_udp_config_and_node[2]
495+
496+
result = exec_test_command(
497+
BASE_CMDS["nodebalancers"]
498+
+ [
499+
"nodes-list",
500+
nodebalancer_id,
501+
config_id,
502+
"--delimiter",
503+
",",
504+
"--text",
505+
"--no-headers",
506+
]
507+
)
508+
assert (
509+
result
510+
== node_id
511+
+ ",defaultnode1,"
512+
+ nodebalancer_with_udp_config_and_node[3]
513+
+ ":80,Unknown,100,none"
514+
)
515+
516+
517+
def test_view_node_for_node_balancer_udp_configuration(
518+
nodebalancer_with_udp_config_and_node,
519+
):
520+
nodebalancer_id = nodebalancer_with_udp_config_and_node[0]
521+
config_id = nodebalancer_with_udp_config_and_node[1]
522+
node_id = nodebalancer_with_udp_config_and_node[2]
523+
524+
result = exec_test_command(
525+
BASE_CMDS["nodebalancers"]
526+
+ [
527+
"node-view",
528+
nodebalancer_id,
529+
config_id,
530+
node_id,
531+
"--delimiter",
532+
",",
533+
"--text",
534+
"--no-headers",
535+
]
536+
)
537+
assert (
538+
result
539+
== node_id
540+
+ ",defaultnode1,"
541+
+ nodebalancer_with_udp_config_and_node[3]
542+
+ ":80,Unknown,100,none"
543+
)
544+
545+
343546
def nodebalancer_created():
344547
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)