9
9
10
10
import pytest
11
11
12
- from linode_api4 import ApiError , LinodeClient
12
+ from linode_api4 import ApiError , LinodeClient , NodeBalancer
13
13
from linode_api4 .objects import (
14
14
NodeBalancerConfig ,
15
15
NodeBalancerNode ,
@@ -64,6 +64,55 @@ def create_nb_config(test_linode_client, e2e_test_firewall):
64
64
nb .delete ()
65
65
66
66
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 ,
104
+ label = label ,
105
+ firewall = e2e_test_firewall .id ,
106
+ client_udp_sess_throttle = 5 ,
107
+ )
108
+
109
+ assert TEST_REGION , nb .region
110
+ assert label == nb .label
111
+ assert 5 == nb .client_udp_sess_throttle
112
+
113
+ nb .delete ()
114
+
115
+
67
116
def test_get_nodebalancer_config (test_linode_client , create_nb_config ):
68
117
config = test_linode_client .load (
69
118
NodeBalancerConfig ,
@@ -72,6 +121,65 @@ def test_get_nodebalancer_config(test_linode_client, create_nb_config):
72
121
)
73
122
74
123
124
+ def test_get_nb_config_with_udp (test_linode_client , create_nb_config_with_udp ):
125
+ config = test_linode_client .load (
126
+ NodeBalancerConfig ,
127
+ create_nb_config_with_udp .id ,
128
+ create_nb_config_with_udp .nodebalancer_id ,
129
+ )
130
+
131
+ assert "udp" == config .protocol
132
+ assert 1234 == config .udp_check_port
133
+ assert 16 == config .udp_session_timeout
134
+
135
+
136
+ def test_update_nb_config (test_linode_client , create_nb_config_with_udp ):
137
+ config = test_linode_client .load (
138
+ NodeBalancerConfig ,
139
+ create_nb_config_with_udp .id ,
140
+ create_nb_config_with_udp .nodebalancer_id ,
141
+ )
142
+
143
+ config .udp_check_port = 4321
144
+ config .save ()
145
+
146
+ config_updated = test_linode_client .load (
147
+ NodeBalancerConfig ,
148
+ create_nb_config_with_udp .id ,
149
+ create_nb_config_with_udp .nodebalancer_id ,
150
+ )
151
+
152
+ assert 4321 == config_updated .udp_check_port
153
+
154
+
155
+ def test_get_nb (test_linode_client , create_nb ):
156
+ nb = test_linode_client .load (
157
+ NodeBalancer ,
158
+ create_nb .id ,
159
+ )
160
+
161
+ assert nb .id == create_nb .id
162
+
163
+
164
+ def test_update_nb (test_linode_client , create_nb ):
165
+ nb = test_linode_client .load (
166
+ NodeBalancer ,
167
+ create_nb .id ,
168
+ )
169
+
170
+ nb .label = "ThisNewLabel"
171
+ nb .client_udp_sess_throttle = 5
172
+ nb .save ()
173
+
174
+ nb_updated = test_linode_client .load (
175
+ NodeBalancer ,
176
+ create_nb .id ,
177
+ )
178
+
179
+ assert "ThisNewLabel" == nb_updated .label
180
+ assert 5 == nb_updated .client_udp_sess_throttle
181
+
182
+
75
183
@pytest .mark .smoke
76
184
def test_create_nb_node (
77
185
test_linode_client , create_nb_config , linode_with_private_ip
0 commit comments