generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
327 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/config/healthcheck_queries/failed_scheduled_atempts_since_last_started.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { getlastfailed_execution } from '../healthcheck'; | ||
//import last_scheduled_started_indexing_RESP from './last_scheduled_started_indexing_RESP.json'; | ||
|
||
const SLOTS = [ | ||
'aboveSearchInput', | ||
'belowSearchInput', | ||
'aboveResults', | ||
'belowResults', | ||
]; | ||
|
||
jest.mock('@eeacms/search', () => ({ | ||
SLOTS: SLOTS, | ||
})); | ||
|
||
jest.mock('@eeacms/search/lib/runRequest', () => ({ | ||
runRequest: jest.fn().mockResolvedValue({ | ||
body: { | ||
took: 963, | ||
timed_out: false, | ||
_shards: { | ||
total: 1, | ||
successful: 1, | ||
skipped: 0, | ||
failed: 0, | ||
}, | ||
hits: { | ||
total: { | ||
value: 624, | ||
relation: 'eq', | ||
}, | ||
max_score: null, | ||
hits: [ | ||
{ | ||
_index: 'status_test_index', | ||
_id: 'main_task_2023_09_26_12_50_13', | ||
_score: null, | ||
_source: { | ||
'@version': '1', | ||
cluster: 'main_task', | ||
start_time_ts: 1695732613000, | ||
docs_cnt: 92190, | ||
sites: ['test_site'], | ||
next_execution_date: '2023_09_26_12_55_00', | ||
next_execution_date_ts: 1695732900000, | ||
start_time: '2023_09_26_12_50_13', | ||
task_name: 'scheduled', | ||
msg: '', | ||
index_name: 'status_test_index', | ||
id: 'main_task_2023_09_26_12_50_13', | ||
status: 'Started', | ||
'@timestamp': '2023-09-26T12:50:13.450Z', | ||
}, | ||
sort: [1695732613000], | ||
}, | ||
], | ||
}, | ||
}, | ||
}), | ||
})); | ||
|
||
describe('test_healthcheck', () => { | ||
it('should return last_started and next_execution_date', async () => { | ||
const appConfig = { index_name: 'test_index' }; | ||
|
||
const resp = await getlastfailed_execution(appConfig, {}); | ||
expect(resp).toEqual({ | ||
last_started: 1695732613000, | ||
next_execution_date: 1695732900000, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/config/healthcheck_queries/last_sync_task_since_last_start.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { getlastsynctaskssincestarted } from '../healthcheck'; | ||
//import last_scheduled_started_indexing_RESP from './last_scheduled_started_indexing_RESP.json'; | ||
|
||
const SLOTS = [ | ||
'aboveSearchInput', | ||
'belowSearchInput', | ||
'aboveResults', | ||
'belowResults', | ||
]; | ||
|
||
jest.mock('@eeacms/search', () => ({ | ||
SLOTS: SLOTS, | ||
})); | ||
|
||
jest.mock('@eeacms/search/lib/runRequest', () => ({ | ||
runRequest: jest.fn().mockResolvedValue({ | ||
body: { | ||
took: 28, | ||
timed_out: false, | ||
_shards: { | ||
total: 1, | ||
successful: 1, | ||
skipped: 0, | ||
failed: 0, | ||
}, | ||
hits: { | ||
total: { | ||
value: 288, | ||
relation: 'eq', | ||
}, | ||
max_score: null, | ||
hits: [ | ||
{ | ||
_index: 'status_test_index', | ||
_id: 'main_task_2023_09_26_13_01_12', | ||
_score: null, | ||
_source: { | ||
'@version': '1', | ||
cluster: 'main_task', | ||
start_time_ts: 1695733272000, | ||
docs_cnt: 242, | ||
sites: ['test_site1', 'test_site2'], | ||
next_execution_date: '2023_09_26_14_00_00', | ||
next_execution_date_ts: 1695736800000, | ||
start_time: '2023_09_26_13_01_12', | ||
task_name: '', | ||
msg: '', | ||
index_name: 'status_test_index', | ||
id: 'main_task_2023_09_26_13_01_12', | ||
status: 'Started', | ||
'@timestamp': '2023-09-26T13:01:12.601Z', | ||
}, | ||
sort: [1695733272000], | ||
}, | ||
{ | ||
_index: 'status_test_index', | ||
_id: 'main_task_2023_09_26_12_00_24', | ||
_score: null, | ||
_source: { | ||
'@version': '1', | ||
cluster: 'main_task', | ||
start_time_ts: 1695729624000, | ||
docs_cnt: 242, | ||
sites: ['test_site1', 'test_site2'], | ||
next_execution_date: '2023_09_26_13_00_00', | ||
next_execution_date_ts: 1695733200000, | ||
start_time: '2023_09_26_12_00_24', | ||
task_name: '', | ||
msg: '', | ||
index_name: 'status_test_index', | ||
id: 'main_task_2023_09_26_12_00_24', | ||
status: 'Started', | ||
'@timestamp': '2023-09-26T12:00:24.187Z', | ||
}, | ||
sort: [1695729624000], | ||
}, | ||
], | ||
}, | ||
}, | ||
}), | ||
})); | ||
|
||
describe('test_healthcheck', () => { | ||
it('should return list of clusters', async () => { | ||
const appConfig = { index_name: 'test_index' }; | ||
|
||
const resp = await getlastsynctaskssincestarted(appConfig, {}); | ||
expect(resp).toEqual({ sites: ['test_site1', 'test_site2'] }); | ||
}); | ||
}); |
97 changes: 97 additions & 0 deletions
97
src/config/healthcheck_queries/latest_tasks_for_site.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { getlatesttasks_for_site } from '../healthcheck'; | ||
//import last_scheduled_started_indexing_RESP from './last_scheduled_started_indexing_RESP.json'; | ||
|
||
const SLOTS = [ | ||
'aboveSearchInput', | ||
'belowSearchInput', | ||
'aboveResults', | ||
'belowResults', | ||
]; | ||
|
||
jest.mock('@eeacms/search', () => ({ | ||
SLOTS: SLOTS, | ||
})); | ||
|
||
jest.mock('@eeacms/search/lib/runRequest', () => ({ | ||
runRequest: jest.fn().mockResolvedValue({ | ||
body: { | ||
took: 63, | ||
timed_out: false, | ||
_shards: { | ||
total: 1, | ||
successful: 1, | ||
skipped: 0, | ||
failed: 0, | ||
}, | ||
hits: { | ||
total: { | ||
value: 288, | ||
relation: 'eq', | ||
}, | ||
max_score: null, | ||
hits: [ | ||
{ | ||
_index: 'status_test_index', | ||
_id: 'test_site_2023_09_26_13_02_28', | ||
_score: null, | ||
_source: { | ||
'@version': '1', | ||
'@timestamp': '2023-09-26T13:04:34.337Z', | ||
cluster: 'test_site', | ||
start_time_ts: 1695733348000, | ||
msg: '', | ||
index_name: 'status_test_index', | ||
id: 'test_site_2023_09_26_13_02_28', | ||
start_time: '2023_09_26_13_02_28', | ||
status: 'Finished', | ||
}, | ||
sort: [1695733348000], | ||
}, | ||
{ | ||
_index: 'status_test_index', | ||
_id: 'test_site_2023_09_26_12_02_32', | ||
_score: null, | ||
_source: { | ||
'@version': '1', | ||
'@timestamp': '2023-09-26T12:04:57.781Z', | ||
cluster: 'test_site', | ||
start_time_ts: 1695729752000, | ||
msg: '', | ||
index_name: 'test_site', | ||
id: 'test_site_2023_09_26_12_02_32', | ||
start_time: '2023_09_26_12_02_32', | ||
status: 'Finished', | ||
}, | ||
sort: [1695729752000], | ||
}, | ||
{ | ||
_index: 'status_test_index', | ||
_id: 'test_site_2023_09_26_11_02_41', | ||
_score: null, | ||
_source: { | ||
'@version': '1', | ||
'@timestamp': '2023-09-26T11:04:21.093Z', | ||
cluster: 'test_site', | ||
start_time_ts: 1695726161000, | ||
msg: '', | ||
index_name: 'status_test_index', | ||
id: 'test_site_2023_09_26_11_02_41', | ||
start_time: '2023_09_26_11_02_41', | ||
status: 'Finished', | ||
}, | ||
sort: [1695726161000], | ||
}, | ||
], | ||
}, | ||
}, | ||
}), | ||
})); | ||
|
||
describe('test_healthcheck', () => { | ||
it('should return "OK"', async () => { | ||
const appConfig = { index_name: 'test_index' }; | ||
|
||
const resp = await getlatesttasks_for_site(appConfig, {}); | ||
expect(resp).toEqual('OK'); | ||
}); | ||
}); |
63 changes: 63 additions & 0 deletions
63
src/config/healthcheck_queries/started_or_finished_site_since_last_started.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { getlastsuccessfultasks_for_site } from '../healthcheck'; | ||
//import last_scheduled_started_indexing_RESP from './last_scheduled_started_indexing_RESP.json'; | ||
|
||
const SLOTS = [ | ||
'aboveSearchInput', | ||
'belowSearchInput', | ||
'aboveResults', | ||
'belowResults', | ||
]; | ||
|
||
jest.mock('@eeacms/search', () => ({ | ||
SLOTS: SLOTS, | ||
})); | ||
|
||
jest.mock('@eeacms/search/lib/runRequest', () => ({ | ||
runRequest: jest.fn().mockResolvedValue({ | ||
body: { | ||
took: 18, | ||
timed_out: false, | ||
_shards: { | ||
total: 1, | ||
successful: 1, | ||
skipped: 0, | ||
failed: 0, | ||
}, | ||
hits: { | ||
total: { | ||
value: 271, | ||
relation: 'eq', | ||
}, | ||
max_score: null, | ||
hits: [ | ||
{ | ||
_index: 'status_test_index', | ||
_id: 'test_site_2023_09_26_13_02_28', | ||
_score: null, | ||
_source: { | ||
'@version': '1', | ||
'@timestamp': '2023-09-26T13:04:34.337Z', | ||
cluster: 'test_site', | ||
start_time_ts: 1695733348000, | ||
msg: '', | ||
index_name: 'status_test_index', | ||
id: 'test_site_2023_09_26_13_02_28', | ||
start_time: '2023_09_26_13_02_28', | ||
status: 'Finished', | ||
}, | ||
sort: [1695733348000], | ||
}, | ||
], | ||
}, | ||
}, | ||
}), | ||
})); | ||
|
||
describe('test_healthcheck', () => { | ||
it('should return true', async () => { | ||
const appConfig = { index_name: 'test_index' }; | ||
|
||
const resp = await getlastsuccessfultasks_for_site(appConfig, {}); | ||
expect(resp).toEqual(true); | ||
}); | ||
}); |