mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
parent
e45921e449
commit
8a442ac4a7
9 changed files with 527 additions and 0 deletions
Binary file not shown.
After Width: | Height: | Size: 80 KiB |
BIN
src/server/sample_data/data_sets/ecommerce/ecommerce.json.gz
Normal file
BIN
src/server/sample_data/data_sets/ecommerce/ecommerce.json.gz
Normal file
Binary file not shown.
179
src/server/sample_data/data_sets/ecommerce/field_mappings.js
Normal file
179
src/server/sample_data/data_sets/ecommerce/field_mappings.js
Normal file
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* eslint max-len: 0 */
|
||||
/* eslint quotes: 0 */
|
||||
|
||||
export const fieldMappings = {
|
||||
category: {
|
||||
type: 'text',
|
||||
fields: {
|
||||
keyword: {
|
||||
type: 'keyword',
|
||||
}
|
||||
}
|
||||
},
|
||||
currency: {
|
||||
type: 'keyword'
|
||||
},
|
||||
customer_birth_date: {
|
||||
type: 'date'
|
||||
},
|
||||
customer_first_name: {
|
||||
type: 'text',
|
||||
fields: {
|
||||
keyword: {
|
||||
type: 'keyword',
|
||||
ignore_above: 256
|
||||
}
|
||||
}
|
||||
},
|
||||
customer_full_name: {
|
||||
type: 'text',
|
||||
fields: {
|
||||
keyword: {
|
||||
type: 'keyword',
|
||||
ignore_above: 256
|
||||
}
|
||||
}
|
||||
},
|
||||
customer_gender: {
|
||||
type: 'keyword'
|
||||
},
|
||||
customer_id: {
|
||||
type: 'keyword'
|
||||
},
|
||||
customer_last_name: {
|
||||
type: 'text',
|
||||
fields: {
|
||||
keyword: {
|
||||
type: 'keyword',
|
||||
ignore_above: 256
|
||||
}
|
||||
}
|
||||
},
|
||||
customer_phone: {
|
||||
type: 'keyword'
|
||||
},
|
||||
day_of_week: {
|
||||
type: 'keyword'
|
||||
},
|
||||
day_of_week_i: {
|
||||
type: 'integer'
|
||||
},
|
||||
email: {
|
||||
type: 'keyword'
|
||||
},
|
||||
manufacturer: {
|
||||
type: 'text',
|
||||
fields: {
|
||||
keyword: {
|
||||
type: 'keyword',
|
||||
}
|
||||
}
|
||||
},
|
||||
order_date: {
|
||||
type: 'date'
|
||||
},
|
||||
order_id: {
|
||||
type: 'keyword'
|
||||
},
|
||||
products: {
|
||||
properties: {
|
||||
base_price: { type: 'half_float' },
|
||||
discount_percentage: { type: 'half_float' },
|
||||
quantity: { type: 'integer' },
|
||||
manufacturer: {
|
||||
type: 'text',
|
||||
fields: {
|
||||
keyword: {
|
||||
type: 'keyword'
|
||||
}
|
||||
}
|
||||
},
|
||||
tax_amount: { type: 'half_float' },
|
||||
product_id: { type: 'long' },
|
||||
category: {
|
||||
type: 'text',
|
||||
fields: {
|
||||
keyword: {
|
||||
type: 'keyword'
|
||||
}
|
||||
}
|
||||
},
|
||||
sku: { type: 'keyword' },
|
||||
taxless_price: { type: 'half_float' },
|
||||
unit_discount_amount: { type: 'half_float' },
|
||||
min_price: { type: 'half_float' },
|
||||
_id: {
|
||||
type: 'text',
|
||||
fields: {
|
||||
keyword: {
|
||||
type: 'keyword',
|
||||
ignore_above: 256
|
||||
}
|
||||
}
|
||||
},
|
||||
discount_amount: { type: 'half_float' },
|
||||
created_on: { type: 'date' },
|
||||
product_name: {
|
||||
type: 'text',
|
||||
analyzer: 'english',
|
||||
fields: {
|
||||
keyword: {
|
||||
type: 'keyword'
|
||||
}
|
||||
}
|
||||
},
|
||||
price: { type: 'half_float' },
|
||||
taxful_price: { type: 'half_float' },
|
||||
base_unit_price: { type: 'half_float' },
|
||||
}
|
||||
},
|
||||
sku: {
|
||||
type: 'keyword'
|
||||
},
|
||||
taxful_total_price: {
|
||||
type: 'half_float'
|
||||
},
|
||||
taxless_total_price: {
|
||||
type: 'half_float'
|
||||
},
|
||||
total_quantity: {
|
||||
type: 'integer'
|
||||
},
|
||||
total_unique_products: {
|
||||
type: 'integer'
|
||||
},
|
||||
type: {
|
||||
type: 'keyword'
|
||||
},
|
||||
user: {
|
||||
type: 'keyword'
|
||||
},
|
||||
geoip: {
|
||||
properties: {
|
||||
country_iso_code: { type: 'keyword' },
|
||||
location: { type: 'geo_point' },
|
||||
region_name: { type: 'keyword' },
|
||||
continent_name: { type: 'keyword' },
|
||||
city_name: { type: 'keyword' }
|
||||
}
|
||||
}
|
||||
};
|
44
src/server/sample_data/data_sets/ecommerce/index.js
Normal file
44
src/server/sample_data/data_sets/ecommerce/index.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import { savedObjects } from './saved_objects';
|
||||
import { fieldMappings } from './field_mappings';
|
||||
|
||||
export function ecommerceSpecProvider() {
|
||||
return {
|
||||
id: 'ecommerce',
|
||||
name: 'Sample eCommerce orders',
|
||||
description: 'Sample data, visualizations, and dashboards for tracking eCommerce orders.',
|
||||
previewImagePath: '/plugins/kibana/home/sample_data_resources/ecommerce/dashboard.png',
|
||||
overviewDashboard: '722b74f0-b882-11e8-a6d9-e546fe2bba5f',
|
||||
defaultIndex: 'ff959d40-b880-11e8-a6d9-e546fe2bba5f',
|
||||
savedObjects: savedObjects,
|
||||
dataIndices: [
|
||||
{
|
||||
id: 'ecommerce',
|
||||
dataPath: path.join(__dirname, './ecommerce.json.gz'),
|
||||
fields: fieldMappings,
|
||||
timeFields: ['order_date'],
|
||||
currentTimeMarker: '2016-12-11T00:00:00',
|
||||
preserveDayOfWeekTimeOfDay: true,
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
261
src/server/sample_data/data_sets/ecommerce/saved_objects.js
Normal file
261
src/server/sample_data/data_sets/ecommerce/saved_objects.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -19,3 +19,4 @@
|
|||
|
||||
export { flightsSpecProvider } from './flights';
|
||||
export { logsSpecProvider } from './logs';
|
||||
export { ecommerceSpecProvider } from './ecommerce';
|
||||
|
|
|
@ -38,3 +38,13 @@ test('load log data', async () => {
|
|||
expect(myDocsCount).toBe(14005);
|
||||
expect(count).toBe(14005);
|
||||
});
|
||||
|
||||
test('load ecommerce data', async () => {
|
||||
let myDocsCount = 0;
|
||||
const bulkInsertMock = (docs) => {
|
||||
myDocsCount += docs.length;
|
||||
};
|
||||
const count = await loadData('./src/server/sample_data/data_sets/ecommerce/ecommerce.json.gz', bulkInsertMock);
|
||||
expect(myDocsCount).toBe(4675);
|
||||
expect(count).toBe(4675);
|
||||
});
|
||||
|
|
|
@ -27,6 +27,7 @@ import {
|
|||
import {
|
||||
flightsSpecProvider,
|
||||
logsSpecProvider,
|
||||
ecommerceSpecProvider
|
||||
} from './data_sets';
|
||||
|
||||
export function sampleDataMixin(kbnServer, server) {
|
||||
|
@ -68,4 +69,5 @@ export function sampleDataMixin(kbnServer, server) {
|
|||
|
||||
server.registerSampleDataset(flightsSpecProvider);
|
||||
server.registerSampleDataset(logsSpecProvider);
|
||||
server.registerSampleDataset(ecommerceSpecProvider);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,13 @@ export default function ({ getService, getPageObjects }) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should display registered ecommerce sample data sets', async ()=> {
|
||||
await retry.try(async () => {
|
||||
const exists = await PageObjects.home.doesSampleDataSetExist('ecommerce');
|
||||
expect(exists).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should install flights sample data set', async ()=> {
|
||||
await PageObjects.home.addSampleDataSet('flights');
|
||||
const isInstalled = await PageObjects.home.isSampleDataSetInstalled('flights');
|
||||
|
@ -58,6 +65,12 @@ export default function ({ getService, getPageObjects }) {
|
|||
expect(isInstalled).to.be(true);
|
||||
});
|
||||
|
||||
it('should install ecommerce sample data set', async ()=> {
|
||||
await PageObjects.home.addSampleDataSet('ecommerce');
|
||||
const isInstalled = await PageObjects.home.isSampleDataSetInstalled('ecommerce');
|
||||
expect(isInstalled).to.be(true);
|
||||
});
|
||||
|
||||
describe('dashboard', () => {
|
||||
afterEach(async () => {
|
||||
await PageObjects.common.navigateToUrl('home', 'tutorial_directory/sampleData');
|
||||
|
@ -114,6 +127,18 @@ export default function ({ getService, getPageObjects }) {
|
|||
expect(panelCount).to.be(11);
|
||||
});
|
||||
|
||||
it('should launch sample ecommerce data set dashboard', async ()=> {
|
||||
await PageObjects.home.launchSampleDataSet('ecommerce');
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
const today = new Date();
|
||||
const todayYearMonthDay = today.toISOString().substring(0, 10);
|
||||
const fromTime = `${todayYearMonthDay} 00:00:00.000`;
|
||||
const toTime = `${todayYearMonthDay} 23:59:59.999`;
|
||||
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
|
||||
const panelCount = await PageObjects.dashboard.getPanelCount();
|
||||
expect(panelCount).to.be(12);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// needs to be in describe block so it is run after 'dashboard describe block'
|
||||
|
@ -130,6 +155,11 @@ export default function ({ getService, getPageObjects }) {
|
|||
expect(isInstalled).to.be(false);
|
||||
});
|
||||
|
||||
it('should uninstall ecommerce sample data set', async ()=> {
|
||||
await PageObjects.home.removeSampleDataSet('ecommerce');
|
||||
const isInstalled = await PageObjects.home.isSampleDataSetInstalled('ecommerce');
|
||||
expect(isInstalled).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue