summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexvru <[email protected]>2022-08-12 20:56:38 +0300
committeralexvru <[email protected]>2022-08-12 20:56:38 +0300
commitdc73d320529d49c9b56de46cba4bd88ef7748e84 (patch)
treebd53980aa60ce42356fd2b3f7dd59c4ec4769d8b
parentb33cc79896fde2118cfdc506cc6199ef46f0f879 (diff)
Support Hive creation to start BlobDepot
-rw-r--r--ydb/core/blobstorage/ut_blobstorage/blob_depot.cpp53
-rw-r--r--ydb/core/blobstorage/ut_blobstorage/lib/CMakeLists.txt1
-rw-r--r--ydb/core/blobstorage/ut_blobstorage/lib/defs.h4
-rw-r--r--ydb/core/blobstorage/ut_blobstorage/lib/env.h111
4 files changed, 52 insertions, 117 deletions
diff --git a/ydb/core/blobstorage/ut_blobstorage/blob_depot.cpp b/ydb/core/blobstorage/ut_blobstorage/blob_depot.cpp
index ba4374b9c80..91ee27b1a17 100644
--- a/ydb/core/blobstorage/ut_blobstorage/blob_depot.cpp
+++ b/ydb/core/blobstorage/ut_blobstorage/blob_depot.cpp
@@ -22,9 +22,7 @@ Y_UNIT_TEST_SUITE(BlobDepot) {
envPtr = std::make_unique<TEnvironmentSetup>(TEnvironmentSetup::TSettings{
.NodeCount = nodeCount,
.Erasure = erasure,
- .BlobDepotId = BLOB_DEPOT_TABLET_ID,
- .BlobDepotChannels = 4,
- .BlobDepotUseMockGroup = false,
+ .SetupHive = true,
});
envPtr->CreateBoxAndPool(1, numGroups + 1);
@@ -32,41 +30,40 @@ Y_UNIT_TEST_SUITE(BlobDepot) {
std::vector<ui32> allGroups = envPtr->GetGroups();
- envPtr->SetupBlobDepot(allGroups[numGroups]);
- blobDepotGroup = allGroups[numGroups];
+ blobDepotGroup = allGroups.back();
allGroups.pop_back();
regularGroups = allGroups;
NKikimrBlobStorage::TConfigRequest request;
- auto *cmd = request.AddCommand()->MutableAllocateVirtualGroup();
- cmd->SetName("vg");
- cmd->SetHiveId(1);
- cmd->SetStoragePoolName(envPtr->StoragePoolName);
- cmd->SetBlobDepotId(envPtr->Settings.BlobDepotId);
- auto *prof = cmd->AddChannelProfiles();
- prof->SetStoragePoolKind("");
- prof->SetCount(2);
- prof = cmd->AddChannelProfiles();
- prof->SetStoragePoolKind("");
- prof->SetChannelKind(NKikimrBlobDepot::TChannelKind::Data);
- prof->SetCount(2);
+ TString virtualPool = "virtual_pool";
+ {
+ auto *cmd = request.AddCommand()->MutableDefineStoragePool();
+ cmd->SetBoxId(1);
+ cmd->SetName(virtualPool);
+ cmd->SetErasureSpecies("none");
+ cmd->SetVDiskKind("Default");
+ }
+ {
+ auto *cmd = request.AddCommand()->MutableAllocateVirtualGroup();
+ cmd->SetName("vg");
+ cmd->SetHiveId(envPtr->Runtime->GetAppData()->DomainsInfo->HivesByHiveUid.begin()->second);
+ cmd->SetStoragePoolName(virtualPool);
+ auto *prof = cmd->AddChannelProfiles();
+ prof->SetStoragePoolName(envPtr->StoragePoolName);
+ prof->SetCount(2);
+ prof = cmd->AddChannelProfiles();
+ prof->SetStoragePoolName(envPtr->StoragePoolName);
+ prof->SetChannelKind(NKikimrBlobDepot::TChannelKind::Data);
+ prof->SetCount(2);
+ }
auto response = envPtr->Invoke(request);
UNIT_ASSERT_C(response.GetSuccess(), response.GetErrorDescription());
- {
- auto ev = std::make_unique<TEvBlobDepot::TEvApplyConfig>();
- auto *config = ev->Record.MutableConfig();
- config->SetOperationMode(NKikimrBlobDepot::VirtualGroup);
- config->MutableChannelProfiles()->CopyFrom(cmd->GetChannelProfiles());
-
- const TActorId edge = envPtr->Runtime->AllocateEdgeActor(1, __FILE__, __LINE__);
- envPtr->Runtime->SendToPipe(envPtr->Settings.BlobDepotId, edge, ev.release(), 0, TTestActorSystem::GetPipeConfigWithRetries());
- envPtr->WaitForEdgeActorEvent<TEvBlobDepot::TEvApplyConfigResult>(edge);
- }
+ blobDepot = response.GetStatus(1).GetGroupId(0);
- blobDepot = response.GetStatus(0).GetGroupId(0);
+ envPtr->Sim(TDuration::Seconds(5)); // some time for blob depot to crank up
}
TString DataGen(ui32 len) {
diff --git a/ydb/core/blobstorage/ut_blobstorage/lib/CMakeLists.txt b/ydb/core/blobstorage/ut_blobstorage/lib/CMakeLists.txt
index 8d4b52db8ea..ac81357a1ae 100644
--- a/ydb/core/blobstorage/ut_blobstorage/lib/CMakeLists.txt
+++ b/ydb/core/blobstorage/ut_blobstorage/lib/CMakeLists.txt
@@ -23,6 +23,7 @@ target_link_libraries(blobstorage-ut_blobstorage-lib PUBLIC
ydb-core-mind
core-mind-bscontroller
core-mind-hive
+ core-sys_view-service
core-tx-scheme_board
core-tx-tx_allocator
core-tx-mediator
diff --git a/ydb/core/blobstorage/ut_blobstorage/lib/defs.h b/ydb/core/blobstorage/ut_blobstorage/lib/defs.h
index c6835f67504..85fa8435757 100644
--- a/ydb/core/blobstorage/ut_blobstorage/lib/defs.h
+++ b/ydb/core/blobstorage/ut_blobstorage/lib/defs.h
@@ -12,7 +12,11 @@
#include <ydb/core/mind/bscontroller/bsc.h>
#include <ydb/core/mind/bscontroller/types.h>
#include <ydb/core/mind/dynamic_nameserver.h>
+#include <ydb/core/mind/labels_maintainer.h>
#include <ydb/core/mind/local.h>
+#include <ydb/core/mind/tenant_pool.h>
+#include <ydb/core/mind/tenant_node_enumeration.h>
+#include <ydb/core/sys_view/service/sysview_service.h>
#include <ydb/core/tx/coordinator/coordinator.h>
#include <ydb/core/tx/tx_allocator/txallocator.h>
#include <ydb/core/tx/mediator/mediator.h>
diff --git a/ydb/core/blobstorage/ut_blobstorage/lib/env.h b/ydb/core/blobstorage/ut_blobstorage/lib/env.h
index 6f0d94d2715..f71c12a34bf 100644
--- a/ydb/core/blobstorage/ut_blobstorage/lib/env.h
+++ b/ydb/core/blobstorage/ut_blobstorage/lib/env.h
@@ -9,6 +9,7 @@
struct TEnvironmentSetup {
std::unique_ptr<TTestActorSystem> Runtime;
static constexpr ui32 DrivesPerNode = 5;
+ const TString DomainName = "Root";
const ui32 DomainId = 1;
const ui64 TabletId = MakeBSControllerID(DomainId);
const ui32 GroupId = 0;
@@ -31,10 +32,7 @@ struct TEnvironmentSetup {
const bool Cache = false;
const ui32 NumDataCenters = 0;
const std::function<TNodeLocation(ui32)> LocationGenerator;
- const bool SetupTablets = false;
- const ui64 BlobDepotId = 0;
- const ui32 BlobDepotChannels = 0;
- const bool BlobDepotUseMockGroup = true;
+ const bool SetupHive = false;
};
const TSettings Settings;
@@ -112,11 +110,13 @@ struct TEnvironmentSetup {
SetupLogging();
Runtime->Start();
auto *appData = Runtime->GetAppData();
- if (Settings.SetupTablets) {
- SetupDomainForTablets();
- } else {
- appData->DomainsInfo->AddDomain(TDomainsInfo::TDomain::ConstructEmptyDomain("dom", DomainId).Release());
+
+ auto domain = TDomainsInfo::TDomain::ConstructEmptyDomain(DomainName, DomainId);
+ appData->DomainsInfo->AddDomain(domain.Get());
+ if (Settings.SetupHive) {
+ appData->DomainsInfo->AddHive(domain->DefaultHiveUid, MakeDefaultHiveID(domain->DefaultStateStorageGroup));
}
+
if (Settings.LocationGenerator) {
Runtime->SetupTabletRuntime(Settings.LocationGenerator, Settings.ControllerNodeId);
} else {
@@ -125,9 +125,6 @@ struct TEnvironmentSetup {
SetupStaticStorage();
SetupTablet();
SetupStorage();
- if (Settings.SetupTablets) {
- InitRoot();
- }
}
void StopNode(ui32 nodeId) {
@@ -238,6 +235,8 @@ struct TEnvironmentSetup {
NActorsServices::TEST,
// NKikimrServices::BLOB_DEPOT,
// NKikimrServices::BLOB_DEPOT_AGENT,
+// NKikimrServices::HIVE,
+// NKikimrServices::LOCAL,
// NActorsServices::INTERCONNECT,
// NActorsServices::INTERCONNECT_SESSION,
};
@@ -289,43 +288,16 @@ struct TEnvironmentSetup {
}
}
- void SetupDomainForTablets() {
- TAppData *appData = Runtime->GetAppData();
-
- const ui32 hiveUid = 1;
-
- appData->DomainsInfo->AddDomain(TDomainsInfo::TDomain::ConstructDomain<std::vector<ui32>, std::vector<ui64>>(
- "Root",
- DomainId,
- 72075186232723360,
- 1,
- 1,
- {1},
- hiveUid,
- {hiveUid},
- 100,
- {1, 2, 3},
- {1, 2, 3},
- {1, 2, 3}
- ).Release());
-
- appData->DomainsInfo->AddHive(hiveUid, MakeDefaultHiveID(1));
- }
-
void SetupTablet() {
struct TTabletInfo {
ui64 TabletId;
TTabletTypes::EType Type;
IActor* (*Create)(const TActorId&, TTabletStorageInfo*);
- ui32 NumChannels = 4;
+ ui32 NumChannels = 3;
};
std::vector<TTabletInfo> tablets{
{MakeBSControllerID(DomainId), TTabletTypes::BSController, &CreateFlatBsController},
};
- if (Settings.BlobDepotId && Settings.BlobDepotUseMockGroup) {
- tablets.push_back(TTabletInfo{Settings.BlobDepotId, TTabletTypes::BlobDepot, &NBlobDepot::CreateBlobDepot,
- Settings.BlobDepotChannels});
- }
auto *appData = Runtime->GetAppData();
@@ -333,22 +305,6 @@ struct TEnvironmentSetup {
tablets.push_back(TTabletInfo{tabletId, TTabletTypes::Hive, &CreateDefaultHive});
}
- const TDomainsInfo::TDomain& domain = appData->DomainsInfo->GetDomain(DomainId);
- if (domain.SchemeRoot) {
- tablets.push_back(TTabletInfo{domain.SchemeRoot, TTabletTypes::SchemeShard, &CreateFlatTxSchemeShard});
- }
- for (const ui64 tabletId : domain.Coordinators) {
- tablets.push_back(TTabletInfo{tabletId, TTabletTypes::Coordinator, &CreateFlatTxCoordinator});
- }
- for (const ui64 tabletId : domain.Mediators) {
- tablets.push_back(TTabletInfo{tabletId, TTabletTypes::Mediator, &CreateTxMediator});
- }
- TVector<ui64> allocators;
- for (const ui64 tabletId : domain.TxAllocators) {
- tablets.push_back(TTabletInfo{tabletId, TTabletTypes::TxAllocator, &CreateTxAllocator});
- allocators.push_back(tabletId);
- }
-
for (const TTabletInfo& tablet : tablets) {
Runtime->CreateTestBootstrapper(
TTestActorSystem::CreateTestTabletInfo(tablet.TabletId, tablet.Type, Settings.Erasure.GetErasure(), GroupId, tablet.NumChannels),
@@ -359,49 +315,26 @@ struct TEnvironmentSetup {
}
auto localConfig = MakeIntrusive<TLocalConfig>();
+
localConfig->TabletClassInfo[TTabletTypes::BlobDepot] = TLocalConfig::TTabletClassInfo(new TTabletSetupInfo(
&NBlobDepot::CreateBlobDepot, TMailboxType::ReadAsFilled, appData->SystemPoolId, TMailboxType::ReadAsFilled,
appData->SystemPoolId));
- if (Settings.SetupTablets) {
- for (ui32 nodeId : Runtime->GetNodes()) {
- Runtime->RegisterService(MakeTxProxyID(), Runtime->Register(CreateTxProxy(allocators), nodeId));
- Runtime->RegisterService(MakeLocalID(nodeId), Runtime->Register(CreateLocal(localConfig.Get()), nodeId));
+ auto tenantPoolConfig = MakeIntrusive<TTenantPoolConfig>(localConfig);
+ tenantPoolConfig->AddStaticSlot(DomainName);
- auto config = MakeIntrusive<NSchemeCache::TSchemeCacheConfig>();
- config->Roots.emplace_back(DomainId, domain.SchemeRoot, domain.Name);
- config->Counters = MakeIntrusive<::NMonitoring::TDynamicCounters>();
- Runtime->RegisterService(MakeSchemeCacheID(), Runtime->Register(CreateSchemeBoardSchemeCache(config.Get()), nodeId));
+ if (Settings.SetupHive) {
+ for (ui32 nodeId : Runtime->GetNodes()) {
+ Runtime->RegisterService(MakeTenantPoolRootID(),
+ Runtime->Register(CreateTenantPool(tenantPoolConfig), nodeId));
+ Runtime->RegisterService(NSysView::MakeSysViewServiceID(nodeId),
+ Runtime->Register(NSysView::CreateSysViewServiceForTests().Release(), nodeId));
+ Runtime->Register(CreateTenantNodeEnumerationPublisher(), nodeId);
+ Runtime->Register(CreateLabelsMaintainer({}), nodeId);
}
}
}
- void SetupBlobDepot(ui32 group) {
- Runtime->CreateTestBootstrapper(
- TTestActorSystem::CreateTestTabletInfo(Settings.BlobDepotId, TTabletTypes::BlobDepot, Settings.Erasure.GetErasure(), group, Settings.BlobDepotChannels),
- &NBlobDepot::CreateBlobDepot, Settings.ControllerNodeId);
-
- bool working = true;
- Runtime->Sim([&] { return working; }, [&](IEventHandle& event) { working = event.GetTypeRewrite() != TEvTablet::EvBoot; });
- }
-
- void InitRoot() {
- auto *appData = Runtime->GetAppData();
- auto& domain = appData->DomainsInfo->GetDomain(DomainId);
- if (domain.SchemeRoot) {
- auto edge = Runtime->AllocateEdgeActor(1);
- auto pipeId = Runtime->Register(NTabletPipe::CreateClient(edge, domain.SchemeRoot), 1);
- Runtime->WrapInActorContext(edge, [&] {
- const TActorContext& ctx = TActivationContext::AsActorContext();
- NTabletPipe::SendData(ctx, pipeId, new NSchemeShard::TEvSchemeShard::TEvInitRootShard(edge, domain.DomainRootTag(), domain.Name));
- NTabletPipe::CloseClient(ctx, pipeId);
- });
- auto res = WaitForEdgeActorEvent<NSchemeShard::TEvSchemeShard::TEvInitRootShardResult>(edge);
- Cerr << res->Get()->ToString() << Endl;
- ::exit(1);
- }
- }
-
void CreateBoxAndPool(ui32 numDrivesPerNode = 0, ui32 numGroups = 0, ui32 numStorageNodes = 0) {
NKikimrBlobStorage::TConfigRequest request;