66 get_region ,
77 get_token ,
88)
9- from test .integration .helpers import get_test_label
9+ from test .integration .helpers import (
10+ get_test_label ,
11+ wait_for_condition ,
12+ )
13+ from test .integration .filters .fixtures import (
14+ lke_cluster ,
15+ )
16+ from linode_api4 .objects import (
17+ LKECluster ,
18+ )
1019
1120import pytest
1221
@@ -184,10 +193,43 @@ def test_get_nb(test_linode_client, create_nb):
184193 )
185194
186195 assert nb .id == create_nb .id
187- assert nb .type == ' common'
196+ assert nb .type == " common"
188197 assert nb .lke_cluster is None
189198
190199
200+ def find_related_nodebalancer (client , cluster : LKECluster ):
201+ nbs = client .nodebalancers ()
202+ for nb in nbs :
203+ if nb .lke_cluster is not None and nb .lke_cluster .id == cluster .id :
204+ return nb .id
205+ return 0
206+
207+
208+ def is_related_nodebalancer_exist (client , cluster : LKECluster ):
209+ if find_related_nodebalancer (client , cluster ):
210+ return True
211+ return False
212+
213+
214+ def test_get_nb_with_lke_cluster (test_linode_client , lke_cluster ):
215+ wait_for_condition (
216+ 10 ,
217+ 600 ,
218+ is_related_nodebalancer_exist ,
219+ test_linode_client ,
220+ lke_cluster ,
221+ )
222+ nb = test_linode_client .load (
223+ NodeBalancer ,
224+ find_related_nodebalancer (test_linode_client , lke_cluster ),
225+ )
226+ assert nb .type == "common"
227+ assert nb .lke_cluster is not None
228+ assert nb .lke_cluster .label is not None
229+ assert nb .lke_cluster .type == "lkecluster"
230+ assert "/lke/clusters/" in str (nb .lke_cluster .url )
231+
232+
191233def test_update_nb (test_linode_client , create_nb ):
192234 nb = test_linode_client .load (
193235 NodeBalancer ,
@@ -207,7 +249,7 @@ def test_update_nb(test_linode_client, create_nb):
207249
208250 assert new_label == nb_updated .label
209251 assert 5 == nb_updated .client_udp_sess_throttle
210- assert nb .type == ' common'
252+ assert nb .type == " common"
211253 assert nb .lke_cluster is None
212254
213255
@@ -231,15 +273,32 @@ def test_create_nb_node(
231273
232274
233275@pytest .mark .smoke
234- def test_get_nb_node (test_linode_client , create_nb_config ):
235- test_linode_client .load (
276+ def test_get_nb_node (
277+ test_linode_client , create_nb_config , linode_with_private_ip
278+ ):
279+ address = [
280+ a for a in linode_with_private_ip .ipv4 if re .search ("192.168.+" , a )
281+ ][0 ]
282+ create_nb_config .node_create (
283+ "node_test" , address + ":80" , weight = 50 , mode = "accept"
284+ )
285+ node = test_linode_client .load (
236286 NodeBalancerNode ,
237287 create_nb_config .nodes [0 ].id ,
238288 (create_nb_config .id , create_nb_config .nodebalancer_id ),
239289 )
290+ assert "node_test" == node .label
240291
241292
242- def test_update_nb_node (test_linode_client , create_nb_config ):
293+ def test_update_nb_node (
294+ test_linode_client , create_nb_config , linode_with_private_ip
295+ ):
296+ address = [
297+ a for a in linode_with_private_ip .ipv4 if re .search ("192.168.+" , a )
298+ ][0 ]
299+ create_nb_config .node_create (
300+ "node_test" , address + ":80" , weight = 50 , mode = "accept"
301+ )
243302 config = test_linode_client .load (
244303 NodeBalancerConfig ,
245304 create_nb_config .id ,
0 commit comments