-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added convertJaegerTraceToProfile test, basic UI test, snapshot
Signed-off-by: pavelpashkovsky <pavelpashkovsky@gmail.com>
- Loading branch information
1 parent
821cfa3
commit cef24cc
Showing
6 changed files
with
926 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages/jaeger-ui/src/components/TracePage/TraceFlamegraph/__snapshots__/index.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<TraceFlamegraph /> renders as expected 1`] = ` | ||
<div | ||
className="Flamegraph-wrapper" | ||
> | ||
<dg | ||
colorMode="light" | ||
profile={ | ||
Object { | ||
"flamebearer": Object { | ||
"levels": Array [ | ||
Array [ | ||
0, | ||
1181596, | ||
0, | ||
0, | ||
], | ||
Array [ | ||
0, | ||
1181596, | ||
213262, | ||
1, | ||
], | ||
Array [ | ||
0, | ||
968334, | ||
1268, | ||
2, | ||
], | ||
Array [ | ||
0, | ||
967066, | ||
733, | ||
3, | ||
], | ||
Array [ | ||
0, | ||
966333, | ||
966333, | ||
4, | ||
], | ||
], | ||
"maxSelf": 0, | ||
"names": Array [ | ||
"total", | ||
"load-generator: OrderVehicle", | ||
"load-generator: HTTP GET", | ||
"ride-sharing-app: BikeHandler", | ||
"ride-sharing-app: FindNearestVehicle", | ||
], | ||
"numTicks": 1181596, | ||
}, | ||
"metadata": Object { | ||
"format": "single", | ||
"sampleRate": 1000000, | ||
"spyName": "tracing", | ||
"units": "trace_samples", | ||
}, | ||
"version": 1, | ||
} | ||
} | ||
/> | ||
</div> | ||
`; |
71 changes: 71 additions & 0 deletions
71
packages/jaeger-ui/src/components/TracePage/TraceFlamegraph/index.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) 2022 The Jaeger Authors. | ||
// | ||
// Licensed 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 React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { convertJaegerTraceToProfile } from '@pyroscope/flamegraph'; | ||
|
||
import TraceFlamegraph from './index'; | ||
|
||
const testTrace = require('./testTrace.json'); | ||
|
||
const profile = convertJaegerTraceToProfile(testTrace.data); | ||
|
||
describe('convertJaegerTraceToProfile', () => { | ||
it('returns correct profile format', () => { | ||
expect(profile.version).toBe(1); | ||
|
||
expect(Array.isArray(profile.flamebearer.levels)).toBe(true); | ||
expect(profile.flamebearer.levels[0].every(el => typeof el === 'number')).toBe(true); | ||
expect(Array.isArray(profile.flamebearer.names)).toBe(true); | ||
expect(profile.flamebearer.names.every(el => typeof el === 'string')).toBe(true); | ||
expect(typeof profile.flamebearer.numTicks).toBe('number'); | ||
|
||
expect(typeof profile.metadata.format).toBe('string'); | ||
expect(typeof profile.metadata.sampleRate).toBe('number'); | ||
expect(typeof profile.metadata.spyName).toBe('string'); | ||
expect(typeof profile.metadata.units).toBe('string'); | ||
}); | ||
}); | ||
|
||
describe('<TraceFlamegraph />', () => { | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
const props = { trace: testTrace }; | ||
wrapper = shallow(<TraceFlamegraph {...props} />); | ||
}); | ||
|
||
it('renders as expected', () => { | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('does not explode', () => { | ||
expect(wrapper).toBeDefined(); | ||
expect(wrapper.find('.Flamegraph-wrapper').length).toBe(1); | ||
}); | ||
|
||
it('renders profile table and flamegraph', () => { | ||
expect(wrapper).toBeDefined(); | ||
expect(wrapper.html().includes('flamegraph-table')).toBe(true); | ||
expect(wrapper.html().includes('flamegraph-view')).toBe(true); | ||
}); | ||
|
||
it('may show no profile', () => { | ||
const props = {}; | ||
wrapper = shallow(<TraceFlamegraph {...props} />); | ||
expect(wrapper).toBeDefined(); | ||
expect(wrapper.html().includes('no-profiling-data')).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.