88from ydb .tests .library .compatibility .fixtures import inter_stable_binary_path , inter_stable_name
99from ydb .tests .library .compatibility .fixtures import current_binary_path , current_name
1010from ydb .tests .library .common .types import Erasure
11- import ydb .core .protos .msgbus_pb2 as msgbus
12- import ydb .core .protos .blobstorage_config_pb2 as blobstorage_config_pb2
11+ from ydb .core .protos import blobstorage_config_pb2
1312
1413logger = logging .getLogger (__name__ )
1514
@@ -43,96 +42,18 @@ def setup(self):
4342 use_in_memory_pdisks = False )
4443 next (cluster_generator )
4544
46- host_configs = self .read_host_configs ()
45+ host_configs = self .cluster . client . read_host_configs ()
4746 for host_config in host_configs :
4847 drive = host_config .Drive .add ()
4948 drive .Path = CONST_PDISK_PATH
5049 drive .PDiskConfig .ExpectedSlotCount = CONST_EXPECTED_SLOT_COUNT
51- self .define_host_configs (host_configs )
50+ self .cluster . client . define_host_configs (host_configs )
5251
5352 yield
5453
55- def read_host_configs (self ):
56- request = msgbus .TBlobStorageConfigRequest ()
57- request .Domain = 1
58- request .Request .Command .add ().ReadHostConfig .SetInParent ()
59-
60- response = self .cluster .client .send (request , 'BlobStorageConfig' ).BlobStorageConfigResponse
61- logger .info (f"read_host_config response: { response } " )
62- if not response .Success :
63- raise RuntimeError ('read_host_config request failed: %s' % response .ErrorDescription )
64- status = response .Status [0 ]
65- if not status .Success :
66- raise RuntimeError ('read_host_config has failed status: %s' % status .ErrorDescription )
67-
68- return status .HostConfig
69-
70- def define_host_configs (self , host_configs ):
71- """Define host configuration with specified host config"""
72- request = msgbus .TBlobStorageConfigRequest ()
73- request .Domain = 1
74- for host_config in host_configs :
75- request .Request .Command .add ().DefineHostConfig .MergeFrom (host_config )
76-
77- logger .info (f"define_host_config request: { request } " )
78- response = self .cluster .client .send (request , 'BlobStorageConfig' ).BlobStorageConfigResponse
79- logger .info (f"define_host_config responce: { response } " )
80- if not response .Success :
81- raise RuntimeError ('define_host_config request failed: %s' % response .ErrorDescription )
82- for i , status in enumerate (response .Status ):
83- if not status .Success :
84- raise RuntimeError ('define_host_config has failed status[%d]: %s' % (i , status ))
85-
86- def pdisk_set_all_active (self ):
87- """Update all drive statuses to ACTIVE. Equivalent to
88- `dstool pdisk set --status=ACTIVE --pdisk-ids <pdisks>`
89- """
90- base_config = self .query_base_config ()
91-
92- request = msgbus .TBlobStorageConfigRequest ()
93- request .Domain = 1
94-
95- for pdisk in base_config .BaseConfig .PDisk :
96- if pdisk .Path != CONST_PDISK_PATH :
97- continue
98- cmd = request .Request .Command .add ().UpdateDriveStatus
99- cmd .HostKey .NodeId = pdisk .NodeId
100- cmd .PDiskId = pdisk .PDiskId
101- cmd .Status = blobstorage_config_pb2 .EDriveStatus .ACTIVE
102-
103- logger .info (f"update_all_drive_status_active request: { request } " )
104- response = self .cluster .client .send (request , 'BlobStorageConfig' ).BlobStorageConfigResponse
105- logger .info (f"update_all_drive_status_active response: { response } " )
106-
107- if not response .Success :
108- raise RuntimeError ('update_all_drive_status_active request failed: %s' % response .ErrorDescription )
109- for i , status in enumerate (response .Status ):
110- if not status .Success :
111- raise RuntimeError ('update_all_drive_status_active has failed status[%d]: %s' % (i , status ))
112-
113- def query_base_config (self ):
114- request = msgbus .TBlobStorageConfigRequest ()
115- request .Domain = 1
116-
117- # Add QueryBaseConfig command
118- command = request .Request .Command .add ()
119- command .QueryBaseConfig .RetrieveDevices = True
120- command .QueryBaseConfig .VirtualGroupsOnly = False
121-
122- # Send the request
123- response = self .cluster .client .send (request , 'BlobStorageConfig' ).BlobStorageConfigResponse
124- if not response .Success :
125- raise RuntimeError ('query_base_config failed: %s' % response .ErrorDescription )
126-
127- status = response .Status [0 ]
128- if not status .Success :
129- raise RuntimeError ('query_base_config failed: %s' % status .ErrorDescription )
130-
131- return status
132-
13354 def pdisk_list (self ):
13455 """Equivalent to `dstool pdisk list`"""
135- base_config = self .query_base_config ()
56+ base_config = self .cluster . client . query_base_config ()
13657
13758 # Collect PDisk information
13859 pdisks_info = []
@@ -152,11 +73,11 @@ def wait_and_check_pdisk_list(self, check_pdisks_fn, deadline, delay=1):
15273 except AssertionError as e :
15374 if time .time () > deadline :
15475 logger .warning (f"pdisk_list incorrect: { pdisks } " )
155- raise e from e
76+ raise e
15677 else :
15778 time .sleep (delay )
15879
159- def test_infer_pdisk_expected_slot_count (self ):
80+ def test (self ):
16081 assert self .current_binary_paths_index == 0
16182 logger .info (f"Test started on { self .versions [0 ]} { time .time ()= } " )
16283 #################################################################
@@ -187,18 +108,18 @@ def check_pdisks(pdisks):
187108 ######################################################################
188109
189110 t2 = time .time ()
190- host_configs = self .read_host_configs ()
111+ host_configs = self .cluster . client . read_host_configs ()
191112 for host_config in host_configs :
192113 drive = host_config .Drive [1 ]
193114 assert drive .Path == CONST_PDISK_PATH
194115 drive .ClearField ('PDiskConfig' )
195116 drive .PDiskConfig .SetInParent ()
196117 drive .InferPDiskSlotCountFromUnitSize = CONST_10_GB
197118 drive .InferPDiskSlotCountMax = 32
198- self .define_host_configs (host_configs )
119+ self .cluster . client . define_host_configs (host_configs )
199120 logger .info (f"Inferred PDisk setting applied { time .time ()= } " )
200121
201- self .pdisk_set_all_active ()
122+ self .cluster . client . pdisk_set_all_active (pdisk_path = CONST_PDISK_PATH )
202123 logger .info (f"Drives activated { time .time ()= } " )
203124
204125 deadline = time .time () + timeout
@@ -224,7 +145,7 @@ def check_pdisks(pdisks):
224145 logger .info (f"Restarted back on version { self .versions [0 ]} { time .time ()= } " )
225146 ###########################################################################
226147
227- self .pdisk_set_all_active ()
148+ self .cluster . client . pdisk_set_all_active (pdisk_path = CONST_PDISK_PATH )
228149 logger .info (f"Drives activated { time .time ()= } " )
229150
230151 deadline = time .time () + timeout
0 commit comments