Skip to content
Closed
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
6e0ab6e
stop API + refactoring
chennn1990 Feb 24, 2026
c6bade9
added start API
chennn1990 Feb 24, 2026
ca1f02f
fix update to be boolean
chennn1990 Feb 25, 2026
4400e4c
Merge branch 'main' into entity-store/entity-maintainers-public-apis
chennn1990 Feb 25, 2026
3348767
introduce get all maintainers API
chennn1990 Feb 25, 2026
4dad781
remove dummy regisration
chennn1990 Feb 25, 2026
da7864b
minor fixes
chennn1990 Feb 25, 2026
7a8c7b8
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Feb 25, 2026
917d948
copilot review + client unit tests
chennn1990 Feb 26, 2026
5aa705c
Merge branch 'entity-store/entity-maintainers-public-apis' of https:/…
chennn1990 Feb 26, 2026
bc7f14a
added index to log_extraction directory
chennn1990 Feb 26, 2026
1f45619
Merge branch 'main' into entity-store/entity-maintainers-public-apis
chennn1990 Feb 26, 2026
15da864
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Feb 26, 2026
c14689b
Merge branch 'main' into entity-store/entity-maintainers-public-apis
chennn1990 Feb 26, 2026
139154e
Merge branch 'entity-store/entity-maintainers-public-apis' of https:/…
chennn1990 Feb 26, 2026
fa81898
use routes as a common constant
chennn1990 Feb 26, 2026
8a2d5cd
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Feb 26, 2026
ea3565c
inject CRUDClient
chennn1990 Mar 2, 2026
4dea074
Merge branch 'main' into entity-store/entity-maintainers-public-apis
chennn1990 Mar 2, 2026
73d1c4c
fix
chennn1990 Mar 2, 2026
8b56f3b
fix
chennn1990 Mar 2, 2026
2022057
Merge branch 'entity-store/entity-maintainers-public-apis' of https:/…
chennn1990 Mar 2, 2026
9624e1d
Merge branch 'entity-store/entity-maintainers-public-apis' into entit…
chennn1990 Mar 2, 2026
ed91817
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Mar 2, 2026
bb16562
apply changes
chennn1990 Mar 3, 2026
4aed0c0
manage taskStatus in task state
chennn1990 Mar 3, 2026
df17cf4
create new endpoint + initialize on security page open
chennn1990 Mar 4, 2026
baa8db7
remove dummy maintainer
chennn1990 Mar 4, 2026
c6e6bd6
add validation + non default space coverage
chennn1990 Mar 4, 2026
6e4cfec
Merge branch 'main' into entity-store/entity-maintainers-public-apis
chennn1990 Mar 4, 2026
2af89be
CR comments
chennn1990 Mar 4, 2026
57571d3
Merge branch 'entity-store/entity-maintainers-public-apis' of https:/…
chennn1990 Mar 4, 2026
7e38ee9
Merge branch 'entity-store/entity-maintainers-public-apis' into entit…
chennn1990 Mar 4, 2026
c82bde7
fix merge
chennn1990 Mar 4, 2026
4c063ae
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Mar 4, 2026
0ec46b2
Merge branch 'entity-store/entity-maintainers-public-apis' into entit…
chennn1990 Mar 4, 2026
33b7ed8
Merge branch 'main' into entity-store/entity-maintainers-public-apis
chennn1990 Mar 5, 2026
a27f1d0
Merge branch 'main' into entity-store/entity-maintainers-public-apis
chennn1990 Mar 5, 2026
79378e5
Merge branch 'entity-store/entity-maintainers-public-apis' into entit…
chennn1990 Mar 5, 2026
3074fb7
Merge branch 'main' into entity-store/entity-maintainers-public-apis
chennn1990 Mar 5, 2026
396f331
shared validations
chennn1990 Mar 5, 2026
e1bfcfe
Merge branch 'main' into entity-store/entity-maintainers-public-apis
chennn1990 Mar 5, 2026
984c59c
Merge branch 'entity-store/entity-maintainers-public-apis' into entit…
chennn1990 Mar 5, 2026
8ee9af5
remove test maintainer
chennn1990 Mar 5, 2026
67e2bad
Merge branch 'main' into entity-store/schedule-maintainers
chennn1990 Mar 5, 2026
f222eb3
Merge branch 'main' into entity-store/schedule-maintainers
chennn1990 Mar 5, 2026
52f2a6f
Merge branch 'main' into entity-store/schedule-maintainers
chennn1990 Mar 5, 2026
d7f9266
CR commets
chennn1990 Mar 5, 2026
b355150
Merge branch 'main' into entity-store/schedule-maintainers
chennn1990 Mar 5, 2026
02e5e07
Changes from node scripts/lint.js --fix
kibanamachine Mar 5, 2026
8739447
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Mar 5, 2026
6b26bfb
[dashboards as code] clarify default schema values (#256288)
nreese Mar 5, 2026
c2d00f0
[Discover][Traces] Use Both transaction and span documents on RED met…
cauemarcondes Mar 5, 2026
25f3141
[Security Solution] Investigate Rule Execution Index Pattern Access W…
hannahbrooks Mar 5, 2026
5266290
[Metrics][Discover] Fetch `METRICS_INFO` (#254980)
jorgeoliveira117 Mar 5, 2026
5018831
Update settings readme to remove serverless (#256098)
kilfoyle Mar 5, 2026
87ba99a
[CodeRabbit] Add kibana-management (#256299)
kapral18 Mar 5, 2026
57c0a1b
[Search] Dynamic AI Connectors (#254826)
TattdCodeMonkey Mar 5, 2026
e549648
[features] features filter (#255459)
klacabane Mar 5, 2026
3d9d3e8
fix invalid describe.skip call (#256324)
h88 Mar 5, 2026
13c03d3
[Serverless] Allow up to 800 rules per minute for security projects (…
mikecote Mar 5, 2026
1ac3713
skip through apiTest.skip @ schema.spec.ts (#256344)
delanni Mar 5, 2026
3d78e97
fix invalid commented line after describe.skip call (#256345)
PhilippeOberti Mar 5, 2026
1fcbd0a
[coderabbit] Prevent review status when review is skipped (#256364)
tylersmalley Mar 6, 2026
f4a541b
[Discover] Add `renderHeader` to `getDocViewer` extension point (#251…
Copilot Mar 6, 2026
9e3f752
coderabbit: enable inheritance (#256366)
tylersmalley Mar 6, 2026
a3fad9a
[skill] Branch readiness checks (#253811)
clintandrewhall Mar 6, 2026
7190b9b
[skills] Add optimize-bundle-size (#255920)
tylersmalley Mar 6, 2026
63dacf5
First pass at a google calendar source (#252740)
seanstory Mar 6, 2026
cc30531
First pass at Tavily data source (#252717)
seanstory Mar 6, 2026
6a642b9
Cypress to scout skill (#254539)
MadameSheema Mar 6, 2026
4a9f278
[api-docs] 2026-03-06 Daily api_docs build (#256378)
kibanamachine Mar 6, 2026
8fb4f0c
[ES|QL] Small redesign follows ups (#256221)
stratoula Mar 6, 2026
d37bfed
[Cascade] remove unnecessary use of EUITruncateText (#256254)
eokoneyo Mar 6, 2026
f7091ba
chore(NA): increase jest sharding for better parallelization (#256369)
mistic Mar 6, 2026
d97bb85
Make manual run public API (#253010)
nkhristinin Mar 6, 2026
eec2df5
[One Workflow] feat: add AWS Lambda connector for workflows (#256150)
talboren Mar 6, 2026
8ad3cb2
Register SLO embeddable transform out in embeddablePlugin.registerLeg…
mgiota Mar 6, 2026
e87c37f
chore: add missing names to gh workflows (#256291)
TamerlanG Mar 6, 2026
6de6e8c
chore: Remove empty codeowner entries (#256164)
delanni Mar 6, 2026
d1cbdd0
[Discover|Traces] E2E journeys in Discover: Overview tab sections vis…
Mar 6, 2026
b7c5f48
Remove maxConcurrency from backfill task (#255980)
nkhristinin Mar 6, 2026
d46f781
[APM] Service map: the go to full map button should be present (#256276)
jennypavlova Mar 6, 2026
29f3ffd
Fix: prevent JSON logger scalar meta field explosion (#256233)
jloleysens Mar 6, 2026
30397a0
[Discover][Embeddable] Use same return navigation path for by-ref & b…
Bluefinger Mar 6, 2026
5dca947
fix: enable all plugins when generating SO migration baseline snapsho…
gsoldevila Mar 6, 2026
3c28832
[ES|QL] Track time spent in callbacks while doing validations (#256011)
sddonne Mar 6, 2026
23dd50a
[SLO] Fix flaky SLOs page Jest test: mock unmocked hooks (#256227)
fkanout Mar 6, 2026
3454461
[Cases] Template import UI (#255286)
MykhailoKondrat Mar 6, 2026
183632a
[Synthetics] Fix flaky MonitorEditPage Jest test timeout (#256025)
fkanout Mar 6, 2026
d86871a
[Infra] Fix Hosts filters (#256000)
rmyz Mar 6, 2026
ed5b7ca
[Streams] Sort by @timestamp descending when opening Discover (#255491)
flash1293 Mar 6, 2026
f2776bd
[Docs] Add Scout's CLI New `repeatEach` flag (#256292)
steliosmavro Mar 6, 2026
ff38ec3
skip failing test suite (#256405)
kibanamachine Mar 6, 2026
e00dbce
[ML] Log rate/pattern analysis and Change point detection a11y headin…
KodeRad Mar 6, 2026
6ef8260
Skip flaky Dataset Quality test (Stateful) (#256404)
mykolaharmash Mar 6, 2026
387c500
[SLO] Fix flaky find_slo test: use single-instance groupBy (#256223)
fkanout Mar 6, 2026
f2d95ea
[SLO] Fix flaky burn rate rule test: filter for CRITICAL alert (#256224)
fkanout Mar 6, 2026
62c202e
[ObsPresentation][APM] Fix APM crash when navigating away during asyn…
MiriamAparicio Mar 6, 2026
c2eaf5c
[Streams] Handle data stream missing for stream more gracefully (#252…
flash1293 Mar 6, 2026
2d098e6
[One Workflow] Add new http connectors to enabledActionTypes configs …
semd Mar 6, 2026
ed71c99
[Agent Builder] Add server-side agent visibility access control (#255…
machadoum Mar 6, 2026
03805a1
[Entity Store] Refactor server domain to follow same client structure…
romulets Mar 6, 2026
6538bce
Refactor change password modal unit tests (#255287)
jeramysoucy Mar 6, 2026
c0ebf8b
[Infra] Fix asset details locator params in custom dashboards (#256412)
rmyz Mar 6, 2026
9284f66
[One Workflow] Fix false Liquid validation errors from YAML comments …
dej611 Mar 6, 2026
edf2b0a
fix(dev,ci): fix Scout Test Run config script location for the Cosmos…
azasypkin Mar 6, 2026
9d632da
Enhance getActiveMaintenanceWindows to handle paginated responses (#2…
c-salv Mar 6, 2026
e26b439
[Streams] Default-exclude unbacked queries and fix accidental promoti…
cesco-f Mar 6, 2026
4614301
[SLO] update group by schema in SLO overview embeddable with remote (…
mgiota Mar 6, 2026
8fae92a
Upgrade inversify, mock-fs and related @types packages (#255769)
gsoldevila Mar 6, 2026
50e16fe
[Security Solution] Fix "unbounded array" code scanner warning for pr…
nikitaindik Mar 6, 2026
e461a4f
[Observability:Streams] Leave strings untrimmed in processor data pre…
couvq Mar 6, 2026
a4605b6
[Search]Update placeholder in Search application search bar (#256078)
saarikabhasi Mar 6, 2026
750c826
[ES|QL] Add autocomplete summary and column after to Registered domai…
bartoval Mar 6, 2026
eed0992
[Response Ops][Alerting] Add additional features to alerting rules (#…
denar50 Mar 6, 2026
c43e84b
[Security Solution] [Attacks/Alerts] Flyout: Move attack transform fu…
agusruidiazgd Mar 6, 2026
bdbff8c
[Sigevents][Evals] Capture non-functional metrics for SigEvents evalu…
viduni94 Mar 6, 2026
2f40389
[ES|QL] Performance test: add pauses to get more datapoints (#255751)
sddonne Mar 6, 2026
cbcaeee
[Workplace AI] Fix Workflow and Tools Filtering logic (#256136)
Samiul-TheSoccerFan Mar 6, 2026
cdca220
test(serverless): fix flaky relationships API test (#256283)
gsoldevila Mar 6, 2026
ed0d0cd
Fix flaky payload timeout functional test (#242750) (#256273)
gsoldevila Mar 6, 2026
b090600
[Shared UX][DateRangePicker] Restructure layout and add new props (#2…
acstll Mar 6, 2026
35ef6a2
Upgrade @elastic/elasticsearch to 9.3.3, use structured acceptedParam…
gsoldevila Mar 6, 2026
1e9b605
fix backfill tests (#256431)
nkhristinin Mar 6, 2026
5e18da3
[Streams] Query streams ensure childs are excluded from parent view (…
diogoplima Mar 6, 2026
f477f6f
[chore] update playwright dependencies (#256207)
dmlemeshko Mar 6, 2026
a059b07
Show informational message for missing metrics on messaging consumer …
miloszmarcinkowski Mar 6, 2026
9b6146b
[React18/Chrome] remove mount point from breadcrumbs extension (#256422)
Dosant Mar 6, 2026
9fb94a6
[Scout] Add comprehensive Dashboard UI release tests (#256282)
fake-haris Mar 6, 2026
a3612ad
[Alerting] Unskips alerting_api_integration/spaces_only/tests/alertin…
doakalexi Mar 6, 2026
e1cdfd9
[Alerting] add project routing for rule execution when CPS is enabled…
ersin-erdal Mar 6, 2026
df83816
[Lens as code] fix explore in discover for ES|QL visualizations (#256…
drewdaemon Mar 6, 2026
7e56902
Upgrade Hono (#256334)
rgodfrey-elastic Mar 6, 2026
f5cf79d
[SLO] Fix error on burn rate alert details page for suppressed alerts…
benakansara Mar 6, 2026
69ac763
[Entity Store] [Asset Mgr] Upgrade Entity Store v1 to v2 when feature…
kubasobon Mar 6, 2026
980c8fe
[Entity Analytics] Adding skill for querying security ml jobs (#254908)
ymao1 Mar 6, 2026
322ec1d
[Synthetics] Read kibana.dev.yaml (#252078)
shahzad31 Mar 6, 2026
f657470
Remove propTypes (#256328)
kowalczyk-krzysztof Mar 6, 2026
1a84db7
Add coderabbit for onboarding team (#256436)
flash1293 Mar 6, 2026
9ac98e9
Update skills for docs, and adjust docs accordingly (#256332)
seanstory Mar 6, 2026
2776ebe
Limit only 1 backfill per ruel per gap auto fill scheduler (#256258)
nkhristinin Mar 6, 2026
dd8069d
[Scout] Document feature flags and custom servers configs (#256266)
csr Mar 6, 2026
b43f229
[Lens powered by ES|QL] Fix flyout configuration changes are not upda…
mariairiartef Mar 6, 2026
a5c6f43
Alert status flyout v2 (#255317)
DennisKo Mar 6, 2026
8938352
fix: bump disk space from 105 to 120 (#256503)
TamerlanG Mar 6, 2026
353a250
Explore requests from Service Map in Discover (#254011)
miloszmarcinkowski Mar 6, 2026
9574c21
[APM] Add Minimap to the service map (#256240)
jennypavlova Mar 6, 2026
d01e5dd
Prevent new connectors from listing mapped pages (#256308)
seanstory Mar 6, 2026
a40b412
[Dashboards as code] SLO error budget schema registration (#256054)
mgiota Mar 6, 2026
e870760
[Agent Builder] Dashboard: Attachment header buttons & Enhance panel…
rbrtj Mar 6, 2026
f6f3874
[Search] Conditionally show callouts for cloud connected mode (#256063)
seialkali Mar 6, 2026
f28dbc2
[Security Solution][Attacks/Alerts] Telemetry for Attacks and Alerts …
e40pud Mar 6, 2026
cd2ff36
[SigEvents][Evals] Update GCS bucket for SigEvents and add README wit…
viduni94 Mar 6, 2026
20a5528
[kbn-evals] In-tool dataset management (#255204)
SrdjanLL Mar 6, 2026
8cb8764
[Fleet] Ensure time series index mode is not enabled on non-metrics t…
jsoriano Mar 6, 2026
20b8157
[DOCS] Update alert & action settings yaml (#256347)
kilfoyle Mar 6, 2026
0c9d768
[Security Solution][Alerts Table] hide timeline footer on fullscreen …
kelvtanv Mar 6, 2026
c8d4935
Upgrade immutable 5.1.3 → 5.1.5 (#256465)
jeramysoucy Mar 6, 2026
fc0b7ce
[Discover][Metrics] Add Scout E2E tests for metrics insights flyout a…
lucaslopezf Mar 6, 2026
b95c873
[dashboards as code] unskip dashboard REST schema test (#256494)
nreese Mar 6, 2026
84fe92d
Slo overview default value instance (#256242)
mgiota Mar 6, 2026
cf257a5
[Unified Rules] Add case actions to unified rules (#255879)
baileycash-elastic Mar 7, 2026
4f97dcf
[api-docs] 2026-03-07 Daily api_docs build (#256577)
kibanamachine Mar 7, 2026
c929b3e
Fix: gap auto-fill scheduler fails with "Backfill cannot look back mo…
nkhristinin Mar 7, 2026
0cb9239
[Scout] Update test config manifests (#256575)
kibanamachine Mar 7, 2026
f3bf285
[Emotion] Use patched Emotion library to resolve Flyout System issue …
tsullivan Mar 7, 2026
8b35098
[api-docs] 2026-03-08 Daily api_docs build (#256598)
kibanamachine Mar 8, 2026
e660bcf
[Entity Store]fix generic entity store orchestrator.resource.ip type …
alexreal1314 Mar 8, 2026
9783fe4
Merge branch 'main' into entity-store/schedule-maintainers
chennn1990 Mar 8, 2026
782eb14
test fixes
chennn1990 Mar 8, 2026
3b04d37
Changes from node scripts/lint.js --fix
kibanamachine Mar 8, 2026
b671ec0
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Mar 8, 2026
f0bcd80
skip test
chennn1990 Mar 8, 2026
13427ae
Merge branch 'entity-store/schedule-maintainers' of https://github.co…
chennn1990 Mar 8, 2026
4441918
fix scout
chennn1990 Mar 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/platform/plugins/shared/streams/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ dependsOn:
- '@kbn/esql-language'
- '@kbn/core-elasticsearch-server-mocks'
- '@kbn/core-logging-server-mocks'
- '@kbn/logging-mocks'
tags:
- plugin
- prod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ export class TaskScheduling {

public async bulkUpdateState(
taskIds: string[],
stateMapFn: (s: ConcreteTaskInstance['state'], id: string) => ConcreteTaskInstance['state']
stateMapFn: (s: ConcreteTaskInstance['state'], id: string) => ConcreteTaskInstance['state'],
options?: ApiKeyOptions
) {
return await retryableBulkUpdate({
taskIds,
Expand All @@ -216,6 +217,7 @@ export class TaskScheduling {
state: stateMapFn(task.state, task.id),
}),
validate: false,
options,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export const ENTITY_STORE_ROUTES = {
CRUD_UPSERT: `${ENTITY_STORE_BASE_ROUTE}/entities/{entityType}`,
CRUD_UPSERT_BULK: `${ENTITY_STORE_BASE_ROUTE}/entities/bulk`,
CRUD_DELETE: `${ENTITY_STORE_BASE_ROUTE}/entities/`,
ENTITY_MAINTAINERS_START: `${ENTITY_STORE_BASE_ROUTE}/entity_maintainers/start/{id}`,
ENTITY_MAINTAINERS_STOP: `${ENTITY_STORE_BASE_ROUTE}/entity_maintainers/stop/{id}`,
ENTITY_MAINTAINERS_GET: `${ENTITY_STORE_BASE_ROUTE}/entity_maintainers`,
ENTITY_MAINTAINERS_INIT: `${ENTITY_STORE_BASE_ROUTE}/entity_maintainers/init`,
} as const satisfies Record<string, string>;

export const getErrorMessage = (error: unknown): string => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,104 +44,101 @@ describe('useInstallEntityStoreV2', () => {
expect(mockServices.http.post).not.toHaveBeenCalled();
});

it('should not install when not in default space', async () => {
it('should do nothing when not in default space and entity store is not installed', async () => {
const mockServices = createMockServices();
mockServices.uiSettings.get.mockReturnValue(true);
mockServices.spaces.getActiveSpace.mockResolvedValue({ id: 'custom-space' });
mockServices.http.get.mockResolvedValueOnce({ status: EntityStoreStatus.Values.not_installed });

renderHook(() => useInstallEntityStoreV2(asServices(mockServices)));

await waitFor(() => {
expect(mockServices.spaces.getActiveSpace).toHaveBeenCalled();
expect(mockServices.http.get).toHaveBeenCalled();
});

expect(mockServices.http.post).not.toHaveBeenCalled();
});

it("should not install when entity store status is 'running'", async () => {
it('when not default space but entity store is already installed, inits entity maintainers only', async () => {
const mockServices = createMockServices();
mockServices.uiSettings.get.mockReturnValue(true);
mockServices.spaces.getActiveSpace.mockResolvedValue({ id: 'default' });
mockServices.spaces.getActiveSpace.mockResolvedValue({ id: 'custom-space' });
mockServices.http.get.mockResolvedValueOnce({ status: EntityStoreStatus.Values.running });
mockServices.http.post.mockResolvedValue({});

renderHook(() => useInstallEntityStoreV2(asServices(mockServices)));

await waitFor(() => {
expect(mockServices.http.get).toHaveBeenCalledWith({
path: ENTITY_STORE_ROUTES.STATUS,
query: { apiVersion: '2', include_components: false },
});
expect(mockServices.http.post).toHaveBeenCalledTimes(1);
});

expect(mockServices.http.post).not.toHaveBeenCalled();
});

it("should not install when entity store status is 'installing'", async () => {
const mockServices = createMockServices();
mockServices.uiSettings.get.mockReturnValue(true);
mockServices.spaces.getActiveSpace.mockResolvedValue({ id: 'default' });
mockServices.http.get.mockResolvedValueOnce({ status: EntityStoreStatus.Values.installing });

renderHook(() => useInstallEntityStoreV2(asServices(mockServices)));

await waitFor(() => {
expect(mockServices.http.get).toHaveBeenCalledTimes(1);
expect(mockServices.http.post).toHaveBeenCalledWith({
path: ENTITY_STORE_ROUTES.ENTITY_MAINTAINERS_INIT,
body: JSON.stringify({}),
query: { apiVersion: '2' },
});

expect(mockServices.http.post).not.toHaveBeenCalled();
});

it("should not install when entity store status is 'stopped'", async () => {
const mockServices = createMockServices();
mockServices.uiSettings.get.mockReturnValue(true);
mockServices.spaces.getActiveSpace.mockResolvedValue({ id: 'default' });
mockServices.http.get.mockResolvedValueOnce({ status: EntityStoreStatus.Values.stopped });

renderHook(() => useInstallEntityStoreV2(asServices(mockServices)));

await waitFor(() => {
expect(mockServices.http.get).toHaveBeenCalledTimes(1);
expect(mockServices.http.post).not.toHaveBeenCalledWith({
path: ENTITY_STORE_ROUTES.INSTALL,
body: JSON.stringify({}),
query: { apiVersion: '2' },
});

expect(mockServices.http.post).not.toHaveBeenCalled();
});

it("should not install when entity store status is 'error'", async () => {
it('when entity store is already installed, inits entity maintainers only', async () => {
const mockServices = createMockServices();
mockServices.uiSettings.get.mockReturnValue(true);
mockServices.spaces.getActiveSpace.mockResolvedValue({ id: 'default' });
mockServices.http.get.mockResolvedValueOnce({ status: EntityStoreStatus.Values.error });
mockServices.http.get.mockResolvedValueOnce({ status: EntityStoreStatus.Values.running });
mockServices.http.post.mockResolvedValue({});

renderHook(() => useInstallEntityStoreV2(asServices(mockServices)));

await waitFor(() => {
expect(mockServices.http.get).toHaveBeenCalledTimes(1);
expect(mockServices.http.post).toHaveBeenCalledTimes(1);
});

expect(mockServices.http.post).not.toHaveBeenCalled();
expect(mockServices.http.get).toHaveBeenCalledWith({
path: ENTITY_STORE_ROUTES.STATUS,
query: { apiVersion: '2', include_components: false },
});
expect(mockServices.http.post).toHaveBeenCalledWith({
path: ENTITY_STORE_ROUTES.ENTITY_MAINTAINERS_INIT,
body: JSON.stringify({}),
query: { apiVersion: '2' },
});
expect(mockServices.http.post).not.toHaveBeenCalledWith({
path: ENTITY_STORE_ROUTES.INSTALL,
body: JSON.stringify({}),
query: { apiVersion: '2' },
});
});

it('should install when entity store is not installed', async () => {
it('when entity store is not installed and space is default, installs entity store then inits entity maintainers', async () => {
const mockServices = createMockServices();
mockServices.uiSettings.get.mockReturnValue(true);
mockServices.spaces.getActiveSpace.mockResolvedValue({ id: 'default' });
mockServices.http.get.mockResolvedValueOnce({ status: EntityStoreStatus.Values.not_installed });
mockServices.http.post.mockResolvedValueOnce({});
mockServices.http.post.mockResolvedValue({});

renderHook(() => useInstallEntityStoreV2(asServices(mockServices)));

await waitFor(() => {
expect(mockServices.http.post).toHaveBeenCalledTimes(1);
expect(mockServices.http.post).toHaveBeenCalledTimes(2);
});

expect(mockServices.http.get).toHaveBeenCalledWith({
path: ENTITY_STORE_ROUTES.STATUS,
query: { apiVersion: '2', include_components: false },
});
expect(mockServices.http.post).toHaveBeenCalledWith({
expect(mockServices.http.post).toHaveBeenNthCalledWith(1, {
path: ENTITY_STORE_ROUTES.INSTALL,
body: JSON.stringify({}),
query: { apiVersion: '2' },
});
expect(mockServices.http.post).toHaveBeenNthCalledWith(2, {
path: ENTITY_STORE_ROUTES.ENTITY_MAINTAINERS_INIT,
body: JSON.stringify({}),
query: { apiVersion: '2' },
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ const installAllEntitiesRequest: HttpFetchOptionsWithPath = {
query: { apiVersion: '2' },
};

const initEntityMaintainersRequest: HttpFetchOptionsWithPath = {
path: ENTITY_STORE_ROUTES.ENTITY_MAINTAINERS_INIT,
body: JSON.stringify({}),
query: { apiVersion: '2' },
};

/**
* Hook to install Entity Store V2. Should be called from the root Security Solution app component.
* @param services - Kibana services required to install Entity Store V2
Expand All @@ -46,14 +52,21 @@ export const useInstallEntityStoreV2 = (services: Services) => {
if (!isEntityStoreV2Enabled) return;

const space = await services.spaces.getActiveSpace();
if (space.id !== 'default') return;

const statusResponse = await services.http.get<{ status: EntityStoreStatus }>(
getStatusRequest
);
if (isEntityStoreInstalled(statusResponse.status)) return;

await services.http.post(installAllEntitiesRequest);
const installed = isEntityStoreInstalled(statusResponse.status);
Comment thread
chennn1990 marked this conversation as resolved.
Outdated
// Entity store already installed → init entity maintainers only (any space).
if (installed) {
await services.http.post(initEntityMaintainersRequest);
return;
}
// Entity store not installed and default space → install entity store, then init entity maintainers.
if (space.id === 'default') {
await services.http.post(installAllEntitiesRequest);
await services.http.post(initEntityMaintainersRequest);
}
// Entity store not installed and non-default space → do nothing.
} catch (e) {
services.logger.error('Failed to initialize Entity Store V2');
services.logger.error(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type { CheckPrivilegesResponse } from '@kbn/security-plugin-types-server'
import { SavedObjectsErrorHelpers } from '@kbn/core/server';
import type { EntityType } from '../../common';
import { scheduleExtractEntityTask, stopExtractEntityTask } from '../tasks/extract_entity_task';
import { scheduleEntityMaintainerTasks } from '../tasks/entity_maintainer';
import { installElasticsearchAssets, uninstallElasticsearchAssets } from './assets/install_assets';
import {
EngineDescriptorTypeName,
Expand Down Expand Up @@ -44,7 +43,7 @@ import {
getUpdatesComponentTemplateName,
} from './assets/component_templates';
import { getUpdatesEntitiesDataStreamName } from './assets/updates_data_stream';
import type { LogsExtractionClient } from './logs_extraction_client';
import type { LogsExtractionClient } from './logs_extraction';
import type { ManagedEntityDefinition } from '../../common/domain/definitions/entity_schema';
import { getEntityDefinition } from '../../common/domain/definitions/registry';
import { installEuidStoredScripts, deleteEuidStoredScripts } from './assets/euid_stored_scripts';
Expand Down Expand Up @@ -100,13 +99,6 @@ export class AssetManager {
await Promise.all([
...entityTypes.map((type) => this.initEntity(request, type, logExtractionParams)),

scheduleEntityMaintainerTasks({
logger: this.logger,
taskManager: this.taskManager,
namespace: this.namespace,
request,
}),

installEuidStoredScripts({
esClient: this.esClient,
logger: this.logger,
Expand Down Expand Up @@ -263,7 +255,7 @@ export class AssetManager {
});
}

public async install(
private async install(
type: EntityType,
logExtractionParams?: LogExtractionBodyParams
): Promise<boolean> {
Expand Down
Loading