Skip to content

Commit 963b0fd

Browse files
authored
[7.x] Core usage data (#79101) (#79557)
* Core usage data (#79101) * Core Telemetry service * CoreTelemetryService mock * Add missing config values back, cleanup * Core usage collector * HttpConfig path is 'server' * Fix tests * CoreTelemetry -> CoreUsageData * Improve tests / docs * Fix telemetry_check * Don't catch fetch function exceptions, let usage collector handle it * Code review * Collect saved object index usage data * Fix tests and telemetry_check * explicitly import/export usage data types for telemetry_check * Remove OS data for now, test for SO usage data * Fix tests * Polish core docs * This shouldn't be here * Fix test
1 parent da467e9 commit 963b0fd

File tree

22 files changed

+1462
-4
lines changed

22 files changed

+1462
-4
lines changed
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { PublicMethodsOf } from '@kbn/utility-types';
21+
import { BehaviorSubject } from 'rxjs';
22+
import { CoreUsageDataService } from './core_usage_data_service';
23+
import { CoreUsageData, CoreUsageDataStart } from './types';
24+
25+
const createStartContractMock = () => {
26+
const startContract: jest.Mocked<CoreUsageDataStart> = {
27+
getCoreUsageData: jest.fn().mockResolvedValue(
28+
new BehaviorSubject<CoreUsageData>({
29+
config: {
30+
elasticsearch: {
31+
apiVersion: 'master',
32+
customHeadersConfigured: false,
33+
healthCheckDelayMs: 2500,
34+
logQueries: false,
35+
numberOfHostsConfigured: 1,
36+
pingTimeoutMs: 30000,
37+
requestHeadersWhitelistConfigured: false,
38+
requestTimeoutMs: 30000,
39+
shardTimeoutMs: 30000,
40+
sniffIntervalMs: -1,
41+
sniffOnConnectionFault: false,
42+
sniffOnStart: false,
43+
ssl: {
44+
alwaysPresentCertificate: false,
45+
certificateAuthoritiesConfigured: false,
46+
certificateConfigured: false,
47+
keyConfigured: false,
48+
verificationMode: 'full',
49+
keystoreConfigured: false,
50+
truststoreConfigured: false,
51+
},
52+
},
53+
http: {
54+
basePathConfigured: false,
55+
compression: {
56+
enabled: true,
57+
referrerWhitelistConfigured: false,
58+
},
59+
keepaliveTimeout: 120000,
60+
maxPayloadInBytes: 1048576,
61+
requestId: {
62+
allowFromAnyIp: false,
63+
ipAllowlistConfigured: false,
64+
},
65+
rewriteBasePath: false,
66+
socketTimeout: 120000,
67+
ssl: {
68+
certificateAuthoritiesConfigured: false,
69+
certificateConfigured: false,
70+
cipherSuites: [
71+
'ECDHE-RSA-AES128-GCM-SHA256',
72+
'ECDHE-ECDSA-AES128-GCM-SHA256',
73+
'ECDHE-RSA-AES256-GCM-SHA384',
74+
'ECDHE-ECDSA-AES256-GCM-SHA384',
75+
'DHE-RSA-AES128-GCM-SHA256',
76+
'ECDHE-RSA-AES128-SHA256',
77+
'DHE-RSA-AES128-SHA256',
78+
'ECDHE-RSA-AES256-SHA384',
79+
'DHE-RSA-AES256-SHA384',
80+
'ECDHE-RSA-AES256-SHA256',
81+
'DHE-RSA-AES256-SHA256',
82+
'HIGH',
83+
'!aNULL',
84+
'!eNULL',
85+
'!EXPORT',
86+
'!DES',
87+
'!RC4',
88+
'!MD5',
89+
'!PSK',
90+
'!SRP',
91+
'!CAMELLIA',
92+
],
93+
clientAuthentication: 'none',
94+
keyConfigured: false,
95+
keystoreConfigured: false,
96+
redirectHttpFromPortConfigured: false,
97+
supportedProtocols: ['TLSv1.1', 'TLSv1.2'],
98+
truststoreConfigured: false,
99+
},
100+
xsrf: {
101+
disableProtection: false,
102+
whitelistConfigured: false,
103+
},
104+
},
105+
logging: {
106+
appendersTypesUsed: [],
107+
loggersConfiguredCount: 0,
108+
},
109+
savedObjects: {
110+
maxImportExportSizeBytes: 10000,
111+
maxImportPayloadBytes: 10485760,
112+
},
113+
},
114+
environment: {
115+
memory: {
116+
heapSizeLimit: 1,
117+
heapTotalBytes: 1,
118+
heapUsedBytes: 1,
119+
},
120+
},
121+
services: {
122+
savedObjects: {
123+
indices: [
124+
{
125+
docsCount: 1,
126+
docsDeleted: 1,
127+
alias: 'test_index',
128+
primaryStoreSizeBytes: 1,
129+
storeSizeBytes: 1,
130+
},
131+
],
132+
},
133+
},
134+
})
135+
),
136+
};
137+
138+
return startContract;
139+
};
140+
141+
const createMock = () => {
142+
const mocked: jest.Mocked<PublicMethodsOf<CoreUsageDataService>> = {
143+
setup: jest.fn(),
144+
start: jest.fn().mockReturnValue(createStartContractMock()),
145+
stop: jest.fn(),
146+
};
147+
return mocked;
148+
};
149+
150+
export const coreUsageDataServiceMock = {
151+
create: createMock,
152+
createStartContract: createStartContractMock,
153+
};

0 commit comments

Comments
 (0)