Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for trace view data frames #133

Merged
merged 4 commits into from
Apr 13, 2023
Merged

Conversation

idastambuk
Copy link
Contributor

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@idastambuk idastambuk requested a review from a team as a code owner April 12, 2023 08:39
@idastambuk idastambuk requested review from fridgepoet and removed request for a team April 12, 2023 08:39
@github-actions
Copy link

github-actions bot commented Apr 12, 2023

Levitate is-compatible report:

🔍 Resolving @grafana/data@latest...
🔍 Resolving @grafana/ui@latest...
🔍 Resolving @grafana/runtime@latest...
🔍 Resolving @grafana/e2e-selectors@latest...

🔬 Checking compatibility between ./src/module.ts and @grafana/data@9.4.7...
✔ Found @grafana/data version 9.0.2 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/ui@9.4.7...
✔ Found @grafana/ui version 9.0.2 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/runtime@9.4.7...
✔ Found @grafana/runtime version 9.0.2 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/e2e-selectors@9.4.7...
✔ Found @grafana/e2e-selectors version 9.0.2 locally

✔️ ./src/module.ts appears to be compatible with @grafana/data,@grafana/ui,@grafana/runtime,@grafana/e2e-selectors

@github-actions
Copy link

Backend code coverage report for PR #133
No changes

@github-actions
Copy link

github-actions bot commented Apr 12, 2023

Frontend code coverage report for PR #133

Plugin Main PR Difference
src 76.89% 77.76% .87%

Copy link
Member

@sarahzinger sarahzinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool stuff Ida!

This is a bit nitpicky so please take it or leave it: my general preference when it comes to this sort of thing is to only test the top level exported function. My reasoning with that is that it might be that we someday change up something in transformTraceResponse that causes a test to fail, but that doesn't necessarily prove something is broken. What we want is to test that we can take a trace and turn it into a dataframe, and the sort of particulars of how we go about that can be changed pretty frequently but hopefully the tests that prove we can handle creating a dataframe do not change.

@idastambuk
Copy link
Contributor Author

Cool stuff Ida!

This is a bit nitpicky so please take it or leave it: my general preference when it comes to this sort of thing is to only test the top level exported function. My reasoning with that is that it might be that we someday change up something in transformTraceResponse that causes a test to fail, but that doesn't necessarily prove something is broken. What we want is to test that we can take a trace and turn it into a dataframe, and the sort of particulars of how we go about that can be changed pretty frequently but hopefully the tests that prove we can handle creating a dataframe do not change.

Yeah, that makes sense! I initially went with that approach, but though about how it would be more tricky to debug failing tests if we don't know which of the several functions was responsible for it failing. I'll think about how to have the best of both worlds and rewrite :)

@sarahzinger
Copy link
Member

Rad up to you! No pressure to rewrite more just sharing a thought! But if you feel inspired to go for it!

Copy link
Member

@sarahzinger sarahzinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆒

@@ -0,0 +1,156 @@
// cSpell:disable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh neat I didn't know you could do this I always just add weird words to the list 😆 good to know

new Date('2023-04-11T11:14:30.717151Z').getTime(),
])
);
// cSpell:disable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe better to add the list of weird words rather than not use cspell? idk I guess either way haha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disabled this block cause these words are probably just a one-time thing specific to this test and they most likely won't be repeated anywhere else

@@ -129,27 +130,27 @@ export const createTraceDataFrame = (targets, response): DataQueryResponse => {
return { data: dataFrames, key: targets[0].refId };
};

function transformTraceResponse(spanList: OpenSearchSpan[]): TraceSpanRow[] {
export function transformTraceResponse(spanList: OpenSearchSpan[]): TraceSpanRow[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to export anymore right?

@idastambuk idastambuk merged commit 9f44503 into traces-query-editor Apr 13, 2023
3 checks passed
@idastambuk idastambuk deleted the tests-trace branch April 13, 2023 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants