Skip to content

Commit

Permalink
Merge branch '8.10' into backport/8.10/pr-164516
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Aug 23, 2023
2 parents a5369ff + 7552ff2 commit 5d1f414
Show file tree
Hide file tree
Showing 52 changed files with 749 additions and 702 deletions.
3 changes: 1 addition & 2 deletions test/functional/apps/discover/group2/_sql_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'discover:enableSql': true,
};

// Failing: See https://github.com/elastic/kibana/issues/159194
describe.skip('discover sql view', async function () {
describe('discover sql view', async function () {
before(async () => {
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']);
log.debug('load kibana index with default index pattern');
Expand Down
11 changes: 11 additions & 0 deletions x-pack/plugins/enterprise_search/common/connectors/connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ export const CONNECTOR_DEFINITIONS: ConnectorServerSideDefinition[] = [
}),
serviceType: 'postgresql',
},
{
iconPath: 'salesforce.svg',
isBeta: true,
isNative: false,
isTechPreview: false,
keywords: ['salesforce', 'cloud', 'connector'],
name: i18n.translate('xpack.enterpriseSearch.content.nativeConnectors.salesforce.name', {
defaultMessage: 'Salesforce',
}),
serviceType: 'salesforce',
},
{
iconPath: 'servicenow.svg',
isBeta: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export interface CrawlScheduleFromServer {
// Client

export interface CrawlerCustomSchedule {
scheduleKey: string;
name: string;
customEntryPointUrls: string[];
customSitemapUrls: string[];
Expand All @@ -183,6 +184,8 @@ export interface CrawlerCustomSchedule {
selectedSitemapUrls: string[];
interval: string; // interval has crontab syntax
enabled: boolean;
entryPointUrls: string[];
sitemapUrls: string[];
}

export enum CustomCrawlType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,34 +248,39 @@ export const domainConfigServerToClient = (
export const crawlerCustomSchedulingServerToClient = (
customSchedulingFromServer: CrawlerCustomSchedulesServer
): CrawlerCustomSchedule[] =>
Object.entries(customSchedulingFromServer.custom_scheduling).map((scheduleMapping) => {
const {
name,
interval,
configuration_overrides: configurationOverrides,
enabled,
} = scheduleMapping[1];
const {
max_crawl_depth: maxCrawlDepth = 2,
sitemap_discovery_disabled: notIncludeSitemapsInRobotsTxt = false,
domain_allowlist: selectedDomainUrls = [],
sitemap_urls: customSitemapUrls = [],
seed_urls: customEntryPointUrls = [],
} = configurationOverrides;

return {
name,
interval,
enabled,
maxCrawlDepth,
includeSitemapsInRobotsTxt: !notIncludeSitemapsInRobotsTxt,
selectedDomainUrls,
selectedEntryPointUrls: [],
selectedSitemapUrls: [],
customEntryPointUrls,
customSitemapUrls,
};
});
Object.entries(customSchedulingFromServer.custom_scheduling).map(
([scheduleKey, scheduleMapping]) => {
const {
name,
interval,
configuration_overrides: configurationOverrides,
enabled,
} = scheduleMapping;
const {
max_crawl_depth: maxCrawlDepth = 2,
sitemap_discovery_disabled: notIncludeSitemapsInRobotsTxt = false,
domain_allowlist: selectedDomainUrls = [],
sitemap_urls: customSitemapUrls = [],
seed_urls: customEntryPointUrls = [],
} = configurationOverrides;

return {
scheduleKey,
name,
interval,
enabled,
maxCrawlDepth,
includeSitemapsInRobotsTxt: !notIncludeSitemapsInRobotsTxt,
selectedDomainUrls,
selectedEntryPointUrls: [],
selectedSitemapUrls: [],
customEntryPointUrls,
customSitemapUrls,
entryPointUrls: [],
sitemapUrls: [],
};
}
);

export const crawlerCustomSchedulingClientToServer = (
crawlerCustomSchedules: CrawlerCustomSchedule[]
Expand Down Expand Up @@ -304,8 +309,7 @@ export const crawlerCustomSchedulingClientToServer = (

const customSchedules: CrawlerCustomScheduleMappingClient = crawlerCustomSchedules.reduce(
(map, schedule) => {
const scheduleNameFormatted = schedule.name.replace(/\s+/g, '_').toLowerCase();
map.set(scheduleNameFormatted, mapToServerFormat(schedule));
map.set(schedule.scheduleKey, mapToServerFormat(schedule));
return map;
},
new Map()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { CrawlCustomSettingsFlyoutCrawlTypeSelection } from './crawl_custom_sett
import { CrawlCustomSettingsFlyoutDomainsPanelWithLogicProps } from './crawl_custom_settings_flyout_domains_panel';
import { CrawlCustomSettingsFlyoutLogic } from './crawl_custom_settings_flyout_logic';
import { CrawlCustomSettingsFlyoutMultipleCrawlDelete } from './crawl_custom_settings_flyout_multi_crawl_delete';
import { CrawlCustomSettingsFlyoutMultiCrawlLogic } from './crawl_custom_settings_flyout_multi_crawl_logic';
import { CrawlCustomSettingsFlyoutMultipleCrawlTabs } from './crawl_custom_settings_flyout_multi_crawl_tabs';
import { CrawlCustomSettingsFlyoutMultiCrawlScheduling } from './crawl_custom_settings_flyout_mutli_crawl';
import { CrawlCustomSettingsFlyoutSeedUrlsPanelWithLogicProps } from './crawl_custom_settings_flyout_seed_urls_panel';
Expand All @@ -45,6 +46,7 @@ export const CrawlCustomSettingsFlyout: React.FC = () => {
isSingleCrawlType,
selectedDomainUrls,
} = useValues(CrawlCustomSettingsFlyoutLogic);
const { crawlerCustomSchedulingIsValid } = useValues(CrawlCustomSettingsFlyoutMultiCrawlLogic);
const { hideFlyout, startCustomCrawl, saveCustomSchedulingConfiguration } = useActions(
CrawlCustomSettingsFlyoutLogic
);
Expand Down Expand Up @@ -125,7 +127,11 @@ export const CrawlCustomSettingsFlyout: React.FC = () => {
data-telemetry-id="entSearchContent-crawler-customCrawlSettings-startCrawl"
fill
onClick={submitFunctionLogic}
disabled={isDataLoading || selectedDomainUrls.length === 0}
disabled={
isSingleCrawlType
? isDataLoading || selectedDomainUrls.length === 0
: !crawlerCustomSchedulingIsValid
}
isLoading={isFormSubmitting}
>
{isSingleCrawlType
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { LogicMounter, mockHttpValues } from '../../../../../__mocks__/kea_logic';
import '../../_mocks_/index_name_logic.mock';

import { nextTick } from '@kbn/test-jest-helpers';

import { itShowsServerErrorAsFlashMessage } from '../../../../../test_helpers';
import { DomainConfig } from '../../../../api/crawler/types';

import { CrawlCustomSettingsFlyoutDomainConfigLogic } from './crawl_custom_settings_flyout_domain_logic';

describe('CrawlCustomSettingsFlyoutDomainConfigLogic', () => {
const { mount } = new LogicMounter(CrawlCustomSettingsFlyoutDomainConfigLogic);

const { http } = mockHttpValues;

beforeEach(() => {
jest.clearAllMocks();
mount();
});

it('has expected default values', () => {
expect(CrawlCustomSettingsFlyoutDomainConfigLogic.values).toEqual({
domainConfigMap: {},
domainConfigs: [],
domainUrls: [],
});
});

describe('actions', () => {
describe('fetchDomainConfigData', () => {
it('updates logic with data that has been converted from server to client', async () => {
jest.spyOn(CrawlCustomSettingsFlyoutDomainConfigLogic.actions, 'onRecieveDomainConfigData');

http.get.mockReturnValueOnce(
Promise.resolve({
meta: {
page: {
current: 1,
size: 1,
total_pages: 2,
},
},
results: [
{
id: '1234',
name: 'https://www.elastic.co',
seed_urls: [],
sitemap_urls: [],
},
],
})
);

http.get.mockReturnValueOnce(
Promise.resolve({
meta: {
page: {
current: 2,
size: 1,
total_pages: 2,
},
},
results: [
{
id: '5678',
name: 'https://www.swiftype.com',
seed_urls: [],
sitemap_urls: [],
},
],
})
);

CrawlCustomSettingsFlyoutDomainConfigLogic.actions.fetchDomainConfigData();
await nextTick();

expect(http.get).toHaveBeenNthCalledWith(
1,
'/internal/enterprise_search/indices/index-name/crawler/domain_configs',
{
query: {
'page[current]': 1,
'page[size]': 100,
},
}
);
expect(http.get).toHaveBeenNthCalledWith(
2,
'/internal/enterprise_search/indices/index-name/crawler/domain_configs',
{
query: {
'page[current]': 2,
'page[size]': 1,
},
}
);
expect(
CrawlCustomSettingsFlyoutDomainConfigLogic.actions.onRecieveDomainConfigData
).toHaveBeenCalledWith([
{
id: '1234',
name: 'https://www.elastic.co',
seedUrls: [],
sitemapUrls: [],
},
{
id: '5678',
name: 'https://www.swiftype.com',
seedUrls: [],
sitemapUrls: [],
},
]);
});

itShowsServerErrorAsFlashMessage(http.get, () => {
CrawlCustomSettingsFlyoutDomainConfigLogic.actions.fetchDomainConfigData();
});
});

describe('onRecieveDomainConfigData', () => {
it('saves the data', () => {
mount({
domainConfigs: [],
});

CrawlCustomSettingsFlyoutDomainConfigLogic.actions.onRecieveDomainConfigData([
{
name: 'https://www.elastic.co',
},
] as DomainConfig[]);

expect(CrawlCustomSettingsFlyoutDomainConfigLogic.values.domainConfigs).toEqual([
{
name: 'https://www.elastic.co',
},
]);
});
});
});

describe('selectors', () => {
beforeEach(() => {
mount({
domainConfigs: [
{
name: 'https://www.elastic.co',
sitemapUrls: [
'https://www.elastic.co/sitemap1.xml',
'https://www.elastic.co/sitemap2.xml',
],
seedUrls: ['https://www.elastic.co/', 'https://www.elastic.co/guide'],
},
{
name: 'https://swiftype.com',
sitemapUrls: ['https://swiftype.com/sitemap1.xml', 'https://swiftype.com/sitemap2.xml'],
seedUrls: ['https://swiftype.com/', 'https://swiftype.com/documentation'],
},
],
});
});

describe('domainUrls', () => {
it('contains all the domain urls from the domain config', () => {
expect(CrawlCustomSettingsFlyoutDomainConfigLogic.values.domainUrls).toEqual([
'https://www.elastic.co',
'https://swiftype.com',
]);
});
});

describe('domainConfigMap', () => {
it('contains all the domain urls from the domain config', () => {
expect(CrawlCustomSettingsFlyoutDomainConfigLogic.values.domainConfigMap).toEqual({
'https://www.elastic.co': {
name: 'https://www.elastic.co',
sitemapUrls: [
'https://www.elastic.co/sitemap1.xml',
'https://www.elastic.co/sitemap2.xml',
],
seedUrls: ['https://www.elastic.co/', 'https://www.elastic.co/guide'],
},
'https://swiftype.com': {
name: 'https://swiftype.com',
sitemapUrls: ['https://swiftype.com/sitemap1.xml', 'https://swiftype.com/sitemap2.xml'],
seedUrls: ['https://swiftype.com/', 'https://swiftype.com/documentation'],
},
});
});
});
});
});
Loading

0 comments on commit 5d1f414

Please sign in to comment.