-
Notifications
You must be signed in to change notification settings - Fork 923
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes search usage telemetry (#1427)
* fix search usage telemetry Signed-off-by: Tao liu <liutaoaz@amazon.com> * add unit tests and fixes comments Signed-off-by: Tao liu <liutaoaz@amazon.com> * add newline at the end of usage.test.ts Signed-off-by: Tao liu <liutaoaz@amazon.com> * add docker var change Signed-off-by: Tao liu <liutaoaz@amazon.com> * update check configuration Signed-off-by: Tao liu <liutaoaz@amazon.com>
- Loading branch information
1 parent
4478b90
commit f0ea74e
Showing
6 changed files
with
92 additions
and
33 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
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
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
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,40 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Any modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
import { coreMock } from '../../../../../core/server/mocks'; | ||
import { CoreSetup } from '../../../../../core/server'; | ||
import { first } from 'rxjs/operators'; | ||
import { usageProvider } from '..'; | ||
import { ConfigSchema } from '../../../config'; | ||
|
||
describe('Search usage telemetry', () => { | ||
let mockCoreSetup: MockedKeys<CoreSetup>; | ||
const initializerContext = coreMock.createPluginInitializerContext({ | ||
search: { usageTelemetry: { enabled: false } }, | ||
}); | ||
|
||
it('trackSuccess should not throw with disabled usageTelemetry', async () => { | ||
const configObject = await initializerContext.config | ||
.create<ConfigSchema>() | ||
.pipe(first()) | ||
.toPromise(); | ||
expect(configObject.search.usageTelemetry.enabled).toBe(false); | ||
|
||
const searchUsage = usageProvider(mockCoreSetup, initializerContext); | ||
expect(searchUsage.trackSuccess(1)).resolves.not.toThrow(); | ||
}); | ||
|
||
it('trackError should not throw with disabled usageTelemetry', () => { | ||
const searchUsage = usageProvider(mockCoreSetup, initializerContext); | ||
expect(searchUsage.trackError.name).toBe('trackError'); | ||
expect(searchUsage.trackError()).resolves.not.toThrow(); | ||
}); | ||
}); |
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
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