Skip to content

Commit

Permalink
Add CODEOWNERS + fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed May 7, 2020
1 parent af25b3f commit d1e1583
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
# Pulse
/packages/kbn-analytics/ @elastic/pulse
/src/legacy/core_plugins/ui_metric/ @elastic/pulse
/src/plugins/kibana_usage_collection/ @elastic/pulse
/src/plugins/telemetry/ @elastic/pulse
/src/plugins/telemetry_collection_manager/ @elastic/pulse
/src/plugins/telemetry_management_section/ @elastic/pulse
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 39 additions & 4 deletions src/plugins/kibana_usage_collection/server/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
* under the License.
*/

import { Observable } from 'rxjs';
import { coreMock } from '../../../core/server/mocks';
import { BehaviorSubject } from 'rxjs';
import {
coreMock,
savedObjectsRepositoryMock,
uiSettingsServiceMock,
} from '../../../core/server/mocks';
import { UsageCollectionSetup } from '../../usage_collection/server';
import { plugin } from './';

Expand All @@ -41,15 +45,46 @@ describe('kibana_usage_collection', () => {

test('Runs the setup method without issues', () => {
const coreSetup = coreMock.createSetup();
coreSetup.metrics.getOpsMetrics$.mockImplementation(() => new Observable());
coreSetup.metrics.getOpsMetrics$.mockImplementation(
() =>
new BehaviorSubject({
process: {
memory: {
heap: { total_in_bytes: 1, used_in_bytes: 1, size_limit: 1 },
resident_set_size_in_bytes: 1,
},
event_loop_delay: 1,
pid: 1,
uptime_in_millis: 1,
},
os: {
platform: 'darwin' as const,
platformRelease: 'test',
load: { '1m': 1, '5m': 1, '15m': 1 },
memory: { total_in_bytes: 1, free_in_bytes: 1, used_in_bytes: 1 },
uptime_in_millis: 1,
},
response_times: { avg_in_millis: 1, max_in_millis: 1 },
requests: { disconnects: 1, total: 1, statusCodes: { '200': 1 } },
concurrent_connections: 1,
})
);

expect(pluginInstance.setup(coreSetup, { usageCollection })).toBe(undefined);
usageCollectors.forEach(({ isReady }) => {
expect(isReady()).toMatchSnapshot(); // Some should return false at this stage
});
});

test('Runs the start method without issues', () => {
expect(pluginInstance.start(coreMock.createStart())).toBe(undefined);
const coreStart = coreMock.createStart();
coreStart.savedObjects.createInternalRepository.mockImplementation(() =>
savedObjectsRepositoryMock.create()
);
coreStart.uiSettings.asScopedToClient.mockImplementation(() =>
uiSettingsServiceMock.createClient()
);
expect(pluginInstance.start(coreStart)).toBe(undefined);
usageCollectors.forEach(({ isReady }) => {
expect(isReady()).toBe(true); // All should return true at this point
});
Expand Down

0 comments on commit d1e1583

Please sign in to comment.