From 0e858dddab0ad57a188eb813f95ba23dcf4f8cd2 Mon Sep 17 00:00:00 2001 From: Everett Ross Date: Thu, 5 Mar 2020 17:20:18 -0500 Subject: [PATCH 1/2] Fix span links for leading 0s trace ID Signed-off-by: Everett Ross --- .../src/components/SearchTracePage/SearchResults/index.js | 2 +- packages/jaeger-ui/src/components/SearchTracePage/url.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jaeger-ui/src/components/SearchTracePage/SearchResults/index.js b/packages/jaeger-ui/src/components/SearchTracePage/SearchResults/index.js index 9f4bfd467f..10fb11dc6b 100644 --- a/packages/jaeger-ui/src/components/SearchTracePage/SearchResults/index.js +++ b/packages/jaeger-ui/src/components/SearchTracePage/SearchResults/index.js @@ -208,7 +208,7 @@ export class UnconnectedSearchResults extends React.PureComponent { ).toBe(`/search?traceID=${trace0}`); }); - it('converts spanLink and traceID to traceID and span', () => { + it('converts spanLink and its traceID to just span', () => { expect( getUrl({ traceID: trace0, From d952746caf8c19326e210a6343315fab83d46889 Mon Sep 17 00:00:00 2001 From: Everett Ross Date: Mon, 9 Mar 2020 16:55:16 -0400 Subject: [PATCH 2/2] Add tests for deep linking leading 0s Fix lookback test issue with dst Signed-off-by: Everett Ross --- .../SearchTracePage/SearchForm.test.js | 10 +++++-- .../SearchResults/index.test.js | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/packages/jaeger-ui/src/components/SearchTracePage/SearchForm.test.js b/packages/jaeger-ui/src/components/SearchTracePage/SearchForm.test.js index ecb8fea1f6..b50a64cd94 100644 --- a/packages/jaeger-ui/src/components/SearchTracePage/SearchForm.test.js +++ b/packages/jaeger-ui/src/components/SearchTracePage/SearchForm.test.js @@ -148,9 +148,13 @@ describe('lookback utils', () => { it('creates timestamp for days ago', () => { [1, 2, 4, 7].forEach(lookbackNum => { - expect(nowInMicroseconds - lookbackToTimestamp(`${lookbackNum}d`, now)).toBe( - lookbackNum * 24 * hourInMicroseconds - ); + const actual = nowInMicroseconds - lookbackToTimestamp(`${lookbackNum}d`, now); + const expected = lookbackNum * 24 * hourInMicroseconds; + try { + expect(actual).toBe(expected); + } catch (_e) { + expect(Math.abs(actual - expected)).toBe(hourInMicroseconds); + } }); }); diff --git a/packages/jaeger-ui/src/components/SearchTracePage/SearchResults/index.test.js b/packages/jaeger-ui/src/components/SearchTracePage/SearchResults/index.test.js index 8f7fbc4c7d..c3dbd51faf 100644 --- a/packages/jaeger-ui/src/components/SearchTracePage/SearchResults/index.test.js +++ b/packages/jaeger-ui/src/components/SearchTracePage/SearchResults/index.test.js @@ -74,6 +74,36 @@ describe('', () => { expect(wrapper.find(ResultItem).length).toBe(traces.length); }); + it('deep links traces', () => { + const uiFind = 'ui-find'; + const spanLinks = { + [traces[0].traceID]: uiFind, + }; + wrapper.setProps({ spanLinks }); + const results = wrapper.find(ResultItem); + expect(results.at(0).prop('linkTo').search).toBe(`uiFind=${uiFind}`); + expect(results.at(1).prop('linkTo').search).toBeUndefined(); + }); + + it('deep links traces with leading 0', () => { + const uiFind0 = 'ui-find-0'; + const uiFind1 = 'ui-find-1'; + const traceID0 = '00traceID0'; + const traceID1 = 'traceID1'; + const spanLinks = { + [traceID0]: uiFind0, + [traceID1]: uiFind1, + }; + const zeroIDTraces = [ + { traceID: traceID0, spans: [], processes: {} }, + { traceID: `000${traceID1}`, spans: [], processes: {} }, + ]; + wrapper.setProps({ spanLinks, traces: zeroIDTraces }); + const results = wrapper.find(ResultItem); + expect(results.at(0).prop('linkTo').search).toBe(`uiFind=${uiFind0}`); + expect(results.at(1).prop('linkTo').search).toBe(`uiFind=${uiFind1}`); + }); + describe('ddg', () => { const searchParam = 'view'; const viewDdg = 'ddg';