99
1010import pytest
1111
12- from linode_api4 import ApiError , LinodeClient
12+ from linode_api4 import ApiError , LinodeClient , NodeBalancer , ExplicitNullValue
1313from linode_api4 .objects import (
1414 NodeBalancerConfig ,
1515 NodeBalancerNode ,
@@ -64,6 +64,52 @@ def create_nb_config(test_linode_client, e2e_test_firewall):
6464 nb .delete ()
6565
6666
67+ @pytest .fixture (scope = "session" )
68+ def create_nb_config_with_udp (test_linode_client , e2e_test_firewall ):
69+ client = test_linode_client
70+ label = get_test_label (8 )
71+
72+ nb = client .nodebalancer_create (
73+ region = TEST_REGION , label = label , firewall = e2e_test_firewall .id
74+ )
75+
76+ config = nb .config_create (protocol = "udp" , udp_check_port = 1234 )
77+
78+ yield config
79+
80+ config .delete ()
81+ nb .delete ()
82+
83+
84+ @pytest .fixture (scope = "session" )
85+ def create_nb (test_linode_client , e2e_test_firewall ):
86+ client = test_linode_client
87+ label = get_test_label (8 )
88+
89+ nb = client .nodebalancer_create (
90+ region = TEST_REGION , label = label , firewall = e2e_test_firewall .id
91+ )
92+
93+ yield nb
94+
95+ nb .delete ()
96+
97+
98+ def test_create_nb (test_linode_client , e2e_test_firewall ):
99+ client = test_linode_client
100+ label = get_test_label (8 )
101+
102+ nb = client .nodebalancer_create (
103+ region = TEST_REGION , label = label , firewall = e2e_test_firewall .id , client_udp_sess_throttle = 5
104+ )
105+
106+ assert TEST_REGION , nb .region
107+ assert label == nb .label
108+ assert 5 == nb .client_udp_sess_throttle
109+
110+ nb .delete ()
111+
112+
67113def test_get_nodebalancer_config (test_linode_client , create_nb_config ):
68114 config = test_linode_client .load (
69115 NodeBalancerConfig ,
@@ -72,6 +118,64 @@ def test_get_nodebalancer_config(test_linode_client, create_nb_config):
72118 )
73119
74120
121+ def test_get_nb_config_with_udp (test_linode_client , create_nb_config_with_udp ):
122+ config = test_linode_client .load (
123+ NodeBalancerConfig ,
124+ create_nb_config_with_udp .id ,
125+ create_nb_config_with_udp .nodebalancer_id ,
126+ )
127+
128+ assert "udp" == config .protocol
129+ assert 1234 == config .udp_check_port
130+ assert 16 == config .udp_session_timeout
131+
132+
133+ def test_update_nb_config (test_linode_client , create_nb_config_with_udp ):
134+ config = test_linode_client .load (
135+ NodeBalancerConfig ,
136+ create_nb_config_with_udp .id ,
137+ create_nb_config_with_udp .nodebalancer_id ,
138+ )
139+
140+ config .udp_check_port = 4321
141+ config .cipher_suite = ExplicitNullValue
142+ config .save ()
143+
144+ config_updated = test_linode_client .load (
145+ NodeBalancerConfig ,
146+ create_nb_config_with_udp .id ,
147+ create_nb_config_with_udp .nodebalancer_id ,
148+ )
149+
150+ assert 4321 == config_updated .udp_check_port
151+
152+
153+ def test_get_nb (test_linode_client , create_nb ):
154+ nb = test_linode_client .load (
155+ NodeBalancer ,
156+ create_nb .id ,
157+ )
158+
159+
160+ def test_update_nb (test_linode_client , create_nb ):
161+ nb = test_linode_client .load (
162+ NodeBalancer ,
163+ create_nb .id ,
164+ )
165+
166+ nb .label = "ThisNewLabel"
167+ nb .client_udp_sess_throttle = 5
168+ nb .save ()
169+
170+ nb_updated = test_linode_client .load (
171+ NodeBalancer ,
172+ create_nb .id ,
173+ )
174+
175+ assert "ThisNewLabel" == nb_updated .label
176+ assert 5 == nb_updated .client_udp_sess_throttle
177+
178+
75179@pytest .mark .smoke
76180def test_create_nb_node (
77181 test_linode_client , create_nb_config , linode_with_private_ip
0 commit comments