Skip to content

Commit

Permalink
- Revert "fix unit test"
Browse files Browse the repository at this point in the history
- tests each component of index pattern title for index matches

This reverts commit a3a27df.
  • Loading branch information
ogupte committed Jul 13, 2021
1 parent a3a27df commit b4904f6
Show file tree
Hide file tree
Showing 2 changed files with 348 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ import { createSecurityLayerDescriptors } from './create_layer_descriptors';

describe('createLayerDescriptor', () => {
test('apm index', () => {
expect(
createSecurityLayerDescriptors('id', 'traces-apm*,logs-apm*,metrics-apm*,apm-*')
).toEqual([
expect(createSecurityLayerDescriptors('id', 'apm-*-transaction*')).toEqual([
{
__dataRequests: [],
alpha: 0.75,
id: '12345',
includeInFitToBounds: true,
joins: [],
label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Source Point',
label: 'apm-*-transaction* | Source Point',
maxZoom: 24,
minZoom: 0,
sourceDescriptor: {
Expand Down Expand Up @@ -148,7 +146,7 @@ describe('createLayerDescriptor', () => {
id: '12345',
includeInFitToBounds: true,
joins: [],
label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Destination point',
label: 'apm-*-transaction* | Destination point',
maxZoom: 24,
minZoom: 0,
sourceDescriptor: {
Expand Down Expand Up @@ -257,7 +255,7 @@ describe('createLayerDescriptor', () => {
id: '12345',
includeInFitToBounds: true,
joins: [],
label: 'traces-apm*,logs-apm*,metrics-apm*,apm-* | Line',
label: 'apm-*-transaction* | Line',
maxZoom: 24,
minZoom: 0,
sourceDescriptor: {
Expand Down Expand Up @@ -708,4 +706,343 @@ describe('createLayerDescriptor', () => {
},
]);
});

test('apm data stream', () => {
expect(createSecurityLayerDescriptors('id', 'traces-apm-opbean-node')).toEqual([
{
__dataRequests: [],
alpha: 0.75,
id: '12345',
includeInFitToBounds: true,
joins: [],
label: 'traces-apm-opbean-node | Source Point',
maxZoom: 24,
minZoom: 0,
sourceDescriptor: {
applyGlobalQuery: true,
applyGlobalTime: true,
filterByMapBounds: true,
geoField: 'client.geo.location',
id: '12345',
indexPatternId: 'id',
scalingType: 'TOP_HITS',
sortField: '',
sortOrder: 'desc',
tooltipProperties: [
'host.name',
'client.ip',
'client.domain',
'client.geo.country_iso_code',
'client.as.organization.name',
],
topHitsSize: 1,
topHitsSplitField: 'client.ip',
type: 'ES_SEARCH',
},
style: {
isTimeAware: true,
properties: {
fillColor: {
options: {
color: '#6092C0',
},
type: 'STATIC',
},
icon: {
options: {
value: 'home',
},
type: 'STATIC',
},
iconOrientation: {
options: {
orientation: 0,
},
type: 'STATIC',
},
iconSize: {
options: {
size: 8,
},
type: 'STATIC',
},
labelBorderColor: {
options: {
color: '#FFFFFF',
},
type: 'STATIC',
},
labelBorderSize: {
options: {
size: 'SMALL',
},
},
labelColor: {
options: {
color: '#000000',
},
type: 'STATIC',
},
labelSize: {
options: {
size: 14,
},
type: 'STATIC',
},
labelText: {
options: {
value: '',
},
type: 'STATIC',
},
lineColor: {
options: {
color: '#FFFFFF',
},
type: 'STATIC',
},
lineWidth: {
options: {
size: 2,
},
type: 'STATIC',
},
symbolizeAs: {
options: {
value: 'icon',
},
},
},
type: 'VECTOR',
},
type: 'VECTOR',
visible: true,
},
{
__dataRequests: [],
alpha: 0.75,
id: '12345',
includeInFitToBounds: true,
joins: [],
label: 'traces-apm-opbean-node | Destination point',
maxZoom: 24,
minZoom: 0,
sourceDescriptor: {
applyGlobalQuery: true,
applyGlobalTime: true,
filterByMapBounds: true,
geoField: 'server.geo.location',
id: '12345',
indexPatternId: 'id',
scalingType: 'TOP_HITS',
sortField: '',
sortOrder: 'desc',
tooltipProperties: [
'host.name',
'server.ip',
'server.domain',
'server.geo.country_iso_code',
'server.as.organization.name',
],
topHitsSize: 1,
topHitsSplitField: 'server.ip',
type: 'ES_SEARCH',
},
style: {
isTimeAware: true,
properties: {
fillColor: {
options: {
color: '#D36086',
},
type: 'STATIC',
},
icon: {
options: {
value: 'marker',
},
type: 'STATIC',
},
iconOrientation: {
options: {
orientation: 0,
},
type: 'STATIC',
},
iconSize: {
options: {
size: 8,
},
type: 'STATIC',
},
labelBorderColor: {
options: {
color: '#FFFFFF',
},
type: 'STATIC',
},
labelBorderSize: {
options: {
size: 'SMALL',
},
},
labelColor: {
options: {
color: '#000000',
},
type: 'STATIC',
},
labelSize: {
options: {
size: 14,
},
type: 'STATIC',
},
labelText: {
options: {
value: '',
},
type: 'STATIC',
},
lineColor: {
options: {
color: '#FFFFFF',
},
type: 'STATIC',
},
lineWidth: {
options: {
size: 2,
},
type: 'STATIC',
},
symbolizeAs: {
options: {
value: 'icon',
},
},
},
type: 'VECTOR',
},
type: 'VECTOR',
visible: true,
},
{
__dataRequests: [],
alpha: 0.75,
id: '12345',
includeInFitToBounds: true,
joins: [],
label: 'traces-apm-opbean-node | Line',
maxZoom: 24,
minZoom: 0,
sourceDescriptor: {
applyGlobalQuery: true,
applyGlobalTime: true,
destGeoField: 'server.geo.location',
id: '12345',
indexPatternId: 'id',
metrics: [
{
field: 'client.bytes',
type: 'sum',
},
{
field: 'server.bytes',
type: 'sum',
},
],
sourceGeoField: 'client.geo.location',
type: 'ES_PEW_PEW',
},
style: {
isTimeAware: true,
properties: {
fillColor: {
options: {
color: '#54B399',
},
type: 'STATIC',
},
icon: {
options: {
value: 'marker',
},
type: 'STATIC',
},
iconOrientation: {
options: {
orientation: 0,
},
type: 'STATIC',
},
iconSize: {
options: {
size: 6,
},
type: 'STATIC',
},
labelBorderColor: {
options: {
color: '#FFFFFF',
},
type: 'STATIC',
},
labelBorderSize: {
options: {
size: 'SMALL',
},
},
labelColor: {
options: {
color: '#000000',
},
type: 'STATIC',
},
labelSize: {
options: {
size: 14,
},
type: 'STATIC',
},
labelText: {
options: {
value: '',
},
type: 'STATIC',
},
lineColor: {
options: {
color: '#6092C0',
},
type: 'STATIC',
},
lineWidth: {
options: {
field: {
name: 'doc_count',
origin: 'source',
},
fieldMetaOptions: {
isEnabled: true,
sigma: 3,
},
maxSize: 8,
minSize: 1,
},
type: 'DYNAMIC',
},
symbolizeAs: {
options: {
value: 'circle',
},
},
},
type: 'VECTOR',
},
type: 'VECTOR',
visible: true,
},
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ const defaultDynamicProperties = getDefaultDynamicProperties();
const euiVisColorPalette = euiPaletteColorBlind();

function isApmIndex(indexPatternTitle: string) {
return minimatch(indexPatternTitle, APM_INDEX_PATTERN_TITLE);
return APM_INDEX_PATTERN_TITLE.split(',')
.map((pattern) => {
return minimatch(indexPatternTitle, pattern);
})
.some(Boolean);
}

function getSourceField(indexPatternTitle: string) {
Expand Down

0 comments on commit b4904f6

Please sign in to comment.