Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { getCytoscapeElements } from './get_cytoscape_elements';

describe('getCytoscapeElements', () => {
describe('with an empty list', () => {
it('returns an empty list', () => {
expect(getCytoscapeElements([], '')).toEqual([]);
});
});

describe('with an external and a service with the same destination.address', () => {
it('only returns the service', () => {
const responses = [
{
after: undefined,
connections: [
{
source: {
'service.environment': null,
'service.name': 'client',
'service.framework.name': null,
'agent.name': 'js-base'
},
destination: {
'destination.address': 'opbeans-node',
'span.subtype': null,
'span.type': 'resource'
}
},
{
source: {
'service.environment': null,
'service.name': 'client',
'service.framework.name': null,
'agent.name': 'js-base'
},
destination: {
'service.environment': 'production',
'service.name': 'opbeans-node',
'service.framework.name': null,
'agent.name': 'nodejs'
}
}
],
discoveredServices: [],
services: [
{
'service.name': 'client',
'agent.name': 'js-base',
'service.environment': null,
'service.framework.name': null
}
]
}
];

const returnValue = [
{
group: 'nodes',
data: {
id: 'client',
label: 'client',
href:
'#/services/client/service-map?rangeFrom=now-24h&rangeTo=now&refreshPaused=true&refreshInterval=0',
agentName: 'js-base',
frameworkName: null,
type: 'service'
}
},
{
group: 'nodes',
data: {
id: '>opbeans-node',
label: 'opbeans-node',
type: 'resource',
subtype: null
}
},
{
group: 'nodes',
data: {
id: 'opbeans-node',
label: 'opbeans-node',
href:
'#/services/opbeans-node/service-map?rangeFrom=now-24h&rangeTo=now&refreshPaused=true&refreshInterval=0',
agentName: 'nodejs',
frameworkName: null,
type: 'service'
}
},
{
group: 'edges',
classes: undefined,
data: {
id: 'client~>opbeans-node',
source: 'client',
target: '>opbeans-node',
bidirectional: undefined
}
},
{
group: 'edges',
classes: undefined,
data: {
id: 'client~opbeans-node',
source: 'client',
target: 'opbeans-node',
bidirectional: undefined
}
}
];

expect(getCytoscapeElements(responses, '')).toEqual(returnValue);
});
});
});
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/common/service_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface ServiceConnectionNode {
export interface ExternalConnectionNode {
'destination.address': string;
'span.type': string;
'span.subtype': string;
'span.subtype': string | null;
}

export type ConnectionNode = ServiceConnectionNode | ExternalConnectionNode;
Expand Down