66 get_region ,
77 get_token ,
88)
9- from test .integration .helpers import get_test_label
9+ from test .integration .filters .fixtures import ( # noqa: F401
10+ create_lke_cluster_with_related_nb ,
11+ )
12+ from test .integration .helpers import (
13+ get_test_label ,
14+ wait_for_condition ,
15+ )
1016
1117import pytest
1218
1319from linode_api4 import ApiError , LinodeClient , NodeBalancer
1420from linode_api4 .objects import (
21+ LKECluster ,
1522 NodeBalancerConfig ,
1623 NodeBalancerNode ,
1724 NodeBalancerType ,
@@ -167,7 +174,7 @@ def test_create_nb_with_reserved_ip(
167174
168175
169176def test_get_nodebalancer_config (test_linode_client , create_nb_config ):
170- config = test_linode_client .load (
177+ test_linode_client .load (
171178 NodeBalancerConfig ,
172179 create_nb_config .id ,
173180 create_nb_config .nodebalancer_id ,
@@ -212,6 +219,45 @@ def test_get_nb(test_linode_client, create_nb):
212219 )
213220
214221 assert nb .id == create_nb .id
222+ assert nb .type == "common"
223+ assert nb .lke_cluster is None
224+
225+
226+ def find_related_nodebalancer (client , cluster : LKECluster ):
227+ nbs = client .nodebalancers ()
228+ for nb in nbs :
229+ if nb .lke_cluster is not None and nb .lke_cluster .id == cluster .id :
230+ return nb .id
231+ return 0
232+
233+
234+ def is_related_nodebalancer_exist (client , cluster : LKECluster ):
235+ if find_related_nodebalancer (client , cluster ):
236+ return True
237+ return False
238+
239+
240+ def test_get_nb_with_lke_cluster (
241+ test_linode_client , create_lke_cluster_with_related_nb
242+ ):
243+ wait_for_condition (
244+ 10 ,
245+ 600 ,
246+ is_related_nodebalancer_exist ,
247+ test_linode_client ,
248+ create_lke_cluster_with_related_nb ,
249+ )
250+ nb = test_linode_client .load (
251+ NodeBalancer ,
252+ find_related_nodebalancer (
253+ test_linode_client , create_lke_cluster_with_related_nb
254+ ),
255+ )
256+ assert nb .type == "common"
257+ assert nb .lke_cluster is not None
258+ assert nb .lke_cluster .label is not None
259+ assert nb .lke_cluster .type == "lkecluster"
260+ assert "/lke/clusters/" in str (nb .lke_cluster .url )
215261
216262
217263def test_update_nb (test_linode_client , create_nb ):
@@ -233,6 +279,8 @@ def test_update_nb(test_linode_client, create_nb):
233279
234280 assert new_label == nb_updated .label
235281 assert 5 == nb_updated .client_udp_sess_throttle
282+ assert nb .type == "common"
283+ assert nb .lke_cluster is None
236284
237285
238286@pytest .mark .smoke
@@ -255,15 +303,32 @@ def test_create_nb_node(
255303
256304
257305@pytest .mark .smoke
258- def test_get_nb_node (test_linode_client , create_nb_config ):
306+ def test_get_nb_node (
307+ test_linode_client , create_nb_config , linode_with_private_ip
308+ ):
309+ address = [
310+ a for a in linode_with_private_ip .ipv4 if re .search ("192.168.+" , a )
311+ ][0 ]
312+ create_nb_config .node_create (
313+ "node_test" , address + ":80" , weight = 50 , mode = "accept"
314+ )
259315 node = test_linode_client .load (
260316 NodeBalancerNode ,
261317 create_nb_config .nodes [0 ].id ,
262318 (create_nb_config .id , create_nb_config .nodebalancer_id ),
263319 )
320+ assert "node_test" == node .label
264321
265322
266- def test_update_nb_node (test_linode_client , create_nb_config ):
323+ def test_update_nb_node (
324+ test_linode_client , create_nb_config , linode_with_private_ip
325+ ):
326+ address = [
327+ a for a in linode_with_private_ip .ipv4 if re .search ("192.168.+" , a )
328+ ][0 ]
329+ create_nb_config .node_create (
330+ "node_test" , address + ":80" , weight = 50 , mode = "accept"
331+ )
267332 config = test_linode_client .load (
268333 NodeBalancerConfig ,
269334 create_nb_config .id ,
0 commit comments