Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] Updates for integration tests (#208) #239

Merged
merged 6 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ import { CoreStart } from '<%= importFromRoot('src/core/public') %>';
};

// Render the application DOM.
// Note that `navigation.ui.TopNavMenu` is a stateful component exported on the `navigation`
plugin's start contract.
// Note that `navigation.ui.TopNavMenu` is a stateful component exported on the `navigation` plugin's start contract.
return (
<Router basename={basename}>
<I18nProvider>
Expand Down
16 changes: 8 additions & 8 deletions src/core/public/application/integration_tests/router.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('AppRouter', () => {

expect(app1.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /app/app1
html: <span>App 1</span>
</div></div>"
Expand All @@ -119,7 +119,7 @@ describe('AppRouter', () => {
expect(app1Unmount).toHaveBeenCalled();
expect(app2.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /app/app2
html: <div>App 2</div>
</div></div>"
Expand All @@ -133,7 +133,7 @@ describe('AppRouter', () => {

expect(standardApp.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /app/app1
html: <span>App 1</span>
</div></div>"
Expand All @@ -145,7 +145,7 @@ describe('AppRouter', () => {
expect(standardAppUnmount).toHaveBeenCalled();
expect(chromelessApp.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /chromeless-a/path
html: <div>Chromeless A</div>
</div></div>"
Expand All @@ -157,7 +157,7 @@ describe('AppRouter', () => {
expect(chromelessAppUnmount).toHaveBeenCalled();
expect(standardApp.mounter.mount).toHaveBeenCalledTimes(2);
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /app/app1
html: <span>App 1</span>
</div></div>"
Expand All @@ -171,7 +171,7 @@ describe('AppRouter', () => {

expect(chromelessAppA.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /chromeless-a/path
html: <div>Chromeless A</div>
</div></div>"
Expand All @@ -183,7 +183,7 @@ describe('AppRouter', () => {
expect(chromelessAppAUnmount).toHaveBeenCalled();
expect(chromelessAppB.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /chromeless-b/path
html: <div>Chromeless B</div>
</div></div>"
Expand All @@ -195,7 +195,7 @@ describe('AppRouter', () => {
expect(chromelessAppBUnmount).toHaveBeenCalled();
expect(chromelessAppA.mounter.mount).toHaveBeenCalledTimes(2);
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /chromeless-a/path
html: <div>Chromeless A</div>
</div></div>"
Expand Down
4 changes: 2 additions & 2 deletions src/core/public/application/ui/app_container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import React, {
useState,
MutableRefObject,
} from 'react';
import { EuiLoadingElastic } from '@elastic/eui';
import { EuiLoadingSpinner } from '@elastic/eui';

import type { MountPoint } from '../../types';
import { AppLeaveHandler, AppStatus, AppUnmount, Mounter } from '../types';
Expand Down Expand Up @@ -120,7 +120,7 @@ export const AppContainer: FunctionComponent<Props> = ({
{appNotFound && <AppNotFound />}
{showSpinner && (
<div className="appContainer__loading">
<EuiLoadingElastic aria-label="Loading application" size="xxl" />
<EuiLoadingSpinner aria-label="Loading application" size="xl" />
</div>
)}
<div key={appId} ref={elementRef} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jest.doMock('../../opensearch/legacy/scoped_cluster_client', () => ({
),
}));

jest.doMock('opensearch', () => {
const realOpenSearch = jest.requireActual('opensearch');
jest.doMock('elasticsearch', () => {
const realOpenSearch = jest.requireActual('elasticsearch');
return {
...realOpenSearch,
// eslint-disable-next-line object-shorthand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ export const migratorInstanceMock = mockOpenSearchDashboardsMigrator.create();
export const OpenSearchDashboardsMigratorMock = jest
.fn()
.mockImplementation(() => migratorInstanceMock);
jest.doMock('../../migrations/opensearch-dashboards/opensearch_dashboards_migrator', () => ({
jest.doMock('../../migrations/opensearch_dashboards/opensearch_dashboards_migrator', () => ({
OpenSearchDashboardsMigrator: OpenSearchDashboardsMigratorMock,
}));
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ const createRegistryMock = (): jest.Mocked<
mock.getVisibleTypes.mockReturnValue([]);
mock.getAllTypes.mockReturnValue([]);
mock.getImportableAndExportableTypes.mockReturnValue([]);
mock.getIndex.mockReturnValue('.opensearch_dashboards-test');
mock.getIndex.mockReturnValue('.opensearch_dashboards-test');
mock.getIndex.mockReturnValue('.opensearch_dashboards_test');
mock.getIndex.mockReturnValue('.opensearch_dashboards_test');
mock.isHidden.mockReturnValue(false);
mock.isNamespaceAgnostic.mockImplementation((type: string) => type === 'global');
mock.isSingleNamespace.mockImplementation(
Expand Down
12 changes: 6 additions & 6 deletions src/core/server/saved_objects/service/lib/repository.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe('SavedObjectsRepository', () => {
const allowedTypes = [...new Set(allTypes.filter((type) => !registry.isHidden(type)))];

savedObjectsRepository = new SavedObjectsRepository({
index: '.opensearch_dashboards-test',
index: '.opensearch_dashboards_test',
mappings,
client,
migrator,
Expand Down Expand Up @@ -689,7 +689,7 @@ describe('SavedObjectsRepository', () => {
await bulkCreateSuccess([obj1, obj2]);
expectClientCallArgsAction([obj1, obj2], {
method: 'create',
_index: '.opensearch_dashboards-test',
_index: '.opensearch_dashboards_test',
});
});

Expand Down Expand Up @@ -1937,7 +1937,7 @@ describe('SavedObjectsRepository', () => {
it(`should use default index`, async () => {
await createSuccess(type, attributes, { id });
expect(client.create).toHaveBeenCalledWith(
expect.objectContaining({ index: '.opensearch_dashboards-test' }),
expect.objectContaining({ index: '.opensearch_dashboards_test' }),
expect.anything()
);
});
Expand Down Expand Up @@ -2416,7 +2416,7 @@ describe('SavedObjectsRepository', () => {
it(`should use all indices for types that are not namespace-agnostic`, async () => {
await deleteByNamespaceSuccess(namespace);
expect(client.updateByQuery).toHaveBeenCalledWith(
expect.objectContaining({ index: ['.opensearch_dashboards-test', 'custom'] }),
expect.objectContaining({ index: ['.opensearch_dashboards_test', 'custom'] }),
expect.anything()
);
});
Expand Down Expand Up @@ -3450,7 +3450,7 @@ describe('SavedObjectsRepository', () => {
it(`should use default index`, async () => {
const expectFn = () =>
expect(client.delete).toHaveBeenCalledWith(
expect.objectContaining({ index: '.opensearch_dashboards-test' }),
expect.objectContaining({ index: '.opensearch_dashboards_test' }),
expect.anything()
);
await deleteFromNamespacesSuccessDelete(expectFn);
Expand Down Expand Up @@ -3527,7 +3527,7 @@ describe('SavedObjectsRepository', () => {
it(`should use default index`, async () => {
const expectFn = () =>
expect(client.update).toHaveBeenCalledWith(
expect.objectContaining({ index: '.opensearch_dashboards-test' }),
expect.objectContaining({ index: '.opensearch_dashboards_test' }),
expect.anything()
);
await deleteFromNamespacesSuccessUpdate(expectFn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('SavedObjectsRepository#createRepository', () => {
originalRepository.createRepository(
(migrator as unknown) as OpenSearchDashboardsMigrator,
typeRegistry,
'.opensearch_dashboards-test',
'.opensearch_dashboards_test',
callAdminCluster,
['unMappedType1', 'unmappedType2']
);
Expand All @@ -94,7 +94,7 @@ describe('SavedObjectsRepository#createRepository', () => {
const repository = originalRepository.createRepository(
(migrator as unknown) as OpenSearchDashboardsMigrator,
typeRegistry,
'.opensearch_dashboards-test',
'.opensearch_dashboards_test',
callAdminCluster,
[],
SavedObjectsRepository
Expand All @@ -112,7 +112,7 @@ describe('SavedObjectsRepository#createRepository', () => {
const repository = originalRepository.createRepository(
(migrator as unknown) as OpenSearchDashboardsMigrator,
typeRegistry,
'.opensearch_dashboards-test',
'.opensearch_dashboards_test',
callAdminCluster,
['hiddenType', 'hiddenType', 'hiddenType'],
SavedObjectsRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ describe('createOrUpgradeSavedConfig()', () => {
await osd.stop();
}, 30000);

it('upgrades the previous version on each increment', async function () {
// TODO: [RENAMEME] Test can be enabled once there is a valid snapshot URL
xit('upgrades the previous version on each increment', async function () {
kavilla marked this conversation as resolved.
Show resolved Hide resolved
// ------------------------------------
// upgrade to 5.4.0
await createOrUpgradeSavedConfig({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import { docExistsSuite } from './doc_exists';
import { docMissingSuite } from './doc_missing';
import { docMissingAndIndexReadOnlySuite } from './doc_missing_and_index_read_only';

describe('uiSettings/routes', function () {
// TODO: [RENAMEME] Test can be enabled once there is a valid snapshot URL
xdescribe('uiSettings/routes', function () {
jest.setTimeout(10000);

beforeAll(startServers);
Expand Down
8 changes: 4 additions & 4 deletions src/core/test_helpers/osd_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const request: Record<
put: (root, path) => getSupertest(root, 'put', path),
};

export interface TestOpenSearchhServer {
export interface TestOpenSearchServer {
getStartTimeout: () => number;
start: (opensearchArgs: string[], opensearchEnvVars: Record<string, string>) => Promise<void>;
stop: () => Promise<void>;
Expand All @@ -161,7 +161,7 @@ export interface TestOpenSearchhServer {

export interface TestOpenSearchUtils {
stop: () => Promise<void>;
opensearch: TestOpenSearchhServer;
opensearch: TestOpenSearchServer;
hosts: string[];
username: string;
password: string;
Expand Down Expand Up @@ -262,14 +262,14 @@ export function createTestServers({
opensearchPort: opensearchTestConfig.getUrlParts().port,
updates: [
...usersToBeAdded,
// user elastic
// user opensearch
opensearchTestConfig.getUrlParts(),
// user opensearchDashboards
osdTestConfig.getUrlParts(),
],
});

// Override provided configs, we know what the elastic user is now
// Override provided configs, we know what the opensearch user is now
osdSettings.opensearch = {
hosts: [opensearchTestConfig.getUrl()],
username: opensearchDashboardsServerTestUser.username,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('/api/stats', () => {
}),
config: {
allowAnonymous: true,
opensearchDashboardsIndex: '.opensearch_dashboards-test',
opensearchDashboardsIndex: '.opensearch_dashboards_test',
opensearchDashboardsVersion: '8.8.8-SNAPSHOT',
server: {
name: 'myopensearchDashboards',
Expand All @@ -86,10 +86,10 @@ describe('/api/stats', () => {
it('successfully returns data', async () => {
const response = await supertest(httpSetup.server.listener).get('/api/stats').expect(200);
expect(response.body).toMatchObject({
opensearchDashboards: {
opensearch_dashboards: {
uuid: 'xxx-xxxxx',
name: 'myopensearchDashboards',
index: '.opensearch_dashboards-test',
index: '.opensearch_dashboards_test',
host: 'myopensearchDashboards.com',
locale: 'en',
transport_address: `myopensearchDashboards.com:1234`,
Expand Down