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

feature: Tracetest Linter 🐙 #2547

Merged
merged 45 commits into from
May 31, 2023
Merged

feature: Tracetest Linter 🐙 #2547

merged 45 commits into from
May 31, 2023

Conversation

xoscar
Copy link
Collaborator

@xoscar xoscar commented May 16, 2023

This PR adds the first version of the Tracetest Linter to the project, including the following features:

  1. Enable/disable the linter
  2. Score system
  3. Minimum score to break the tests
  4. Plugins and rules

Changes

  • Adds new components to support the linter system
  • Includes new domain for the BE to support linter plugins and rules
  • Wires up the linter to the test runner

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

https://www.loom.com/share/577fd2cb4f3b45b6be9b8c6c6e0abfe0

@xoscar xoscar self-assigned this May 16, 2023
@xoscar xoscar changed the title feature: Tracetest OctoLint 🐙 feature: Tracetest Linter 🐙 May 29, 2023
@xoscar xoscar marked this pull request as ready for review May 30, 2023 18:20
@xoscar xoscar added enhancement New feature or request frontend backend labels May 30, 2023
@olha23
Copy link

olha23 commented May 31, 2023

@xoscar i have couple comments:
Settings page needs to be improved:

  • I prefer to place toggle before the text, like we did on configure data store page. It looks more clear.
  • what mean that Required checkboxes near each of toggles? If you explain it maybe I can create more good visual representation for it.
  • need to add some info icon near each of plugins where we give short explanation for them
    Lint result page:
  • Circle charts must be align in one line at top
  • results for each of plugins not looks collapsed, please make it like in my mockups (with arrow)

@xoscar
Copy link
Collaborator Author

xoscar commented May 31, 2023

Moving @schoren slack comment to the PRs thread

This looks awesome. My only suggestion would be: in the tracing page, where you see the lint results, we could add some text explaining what this is (or linking to docs), and a link to the settings to enable/disable it.
If the setting is disabled, I’d show some text encouraging users to enable, and again the link to settings.
Other than that, while everything can always be improved, I think it’s a good enough v1 for this feature, and it looks very appealing IMO

@xoscar
Copy link
Collaborator Author

xoscar commented May 31, 2023

Hello @schoren and @olha23 I just updated the PR with some changes based on your feedback. Here's a video demonstrating the things that changed

https://www.loom.com/share/42a61e7ac7e546b0814cedb6a7fe0e30

@xoscar xoscar requested review from jorgeepc, mathnogueira, kdhamric, olha23 and danielbdias and removed request for jorgeepc May 31, 2023 18:30
@schoren
Copy link
Collaborator

schoren commented May 31, 2023

looks good to me!

Copy link
Contributor

@danielbdias danielbdias left a comment

Choose a reason for hiding this comment

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

First of all: fantastic work, team! This feature is pretty cool!

I've added some comments about one little thing here or there in the code that we can improve, but that can be on future versions.

@@ -23,6 +23,7 @@ import (
httpServer "github.com/kubeshop/tracetest/server/http"
"github.com/kubeshop/tracetest/server/http/mappings"
"github.com/kubeshop/tracetest/server/http/websocket"
linter_resource "github.com/kubeshop/tracetest/server/linter/resource"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: we should avoid snake_case and use camelCase here.

@@ -7,6 +7,7 @@ import (
"github.com/kubeshop/tracetest/server/executor"
"github.com/kubeshop/tracetest/server/executor/pollingprofile"
"github.com/kubeshop/tracetest/server/executor/trigger"
linter_resource "github.com/kubeshop/tracetest/server/linter/resource"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Can we rename this to camelCase?


"github.com/kubeshop/tracetest/server/analytics"
"github.com/kubeshop/tracetest/server/linter"
linter_resource "github.com/kubeshop/tracetest/server/linter/resource"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change to camelCase?

}
}

func (e *defaultlinterRunner) Runlinter(ctx context.Context, request LinterRequest) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (e *defaultlinterRunner) Runlinter(ctx context.Context, request LinterRequest) {
func (e *defaultlinterRunner) RunLinter(ctx context.Context, request LinterRequest) {

Comment on lines +16 to +17
dnsFields = []string{"net.peer.name", "http.url", "db.connection_string", "net.sock.peer.addr", "net.host.name"}
)
Copy link
Contributor

Choose a reason for hiding this comment

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

To think in the future: can we open this configuration this somehow in the future (probably as an outside yaml)?

Some linters as ESLint (https://eslint.org/docs/latest/rules/array-callback-return) and Rubocop (https://docs.rubocop.org/rubocop/1.51/configuration.html) does this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes sir, we are going to have a bunch of fancy ways to configure the octolint

TestID: testID,
RunID: runID,
Stage: model.StageTrace,
Type: "TRACE_linter_START",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Type: "TRACE_linter_START",
Type: "TRACE_LINTER_START",

TestID: testID,
RunID: runID,
Stage: model.StageTrace,
Type: "TRACE_linter_SKIPPED",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Type: "TRACE_linter_SKIPPED",
Type: "TRACE_LINTER_SKIPPED",

TestID: testID,
RunID: runID,
Stage: model.StageTrace,
Type: "TRACE_linter_SUCCESS",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Type: "TRACE_linter_SUCCESS",
Type: "TRACE_LINTER_SUCCESS",

TestID: testID,
RunID: runID,
Stage: model.StageTrace,
Type: "TRACE_linter_ERROR",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Type: "TRACE_linter_ERROR",
Type: "TRACE_LINTER_ERROR",

@@ -62,7 +62,7 @@ describe('Transactions', () => {

cy.submitCreateForm('CreateTransactionFactory');
cy.get('[data-cy=transaction-details-name').should('have.text', `${name} (v1)`);
cy.get('[data-cy=transaction-run-button]', {timeout: 30000}).should('be.visible');
cy.get('[data-cy=transaction-run-button]', {timeout: 50000}).should('be.visible');
Copy link
Contributor

Choose a reason for hiding this comment

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

Should timeout be a constant on this test file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to revamp the FE e2e tests, which would include cleaning up all of this 💩 more tests, better tests!

@xoscar xoscar requested a review from schoren May 31, 2023 21:50
@xoscar xoscar merged commit a5de528 into main May 31, 2023
28 checks passed
@xoscar xoscar deleted the feature/the-dream branch May 31, 2023 22:15
schoren pushed a commit that referenced this pull request Jun 5, 2023
* feature: The Dream 💜

* feature(openapi): adding specs for linterns

* updating types for lintern

* updating types for lintern

* adding lintern resource logic

* feature(cli): fixing UI type

* add runner structure

* add rule to check if there are missing required attributes

* add test to required attributes rule

* registering lintern resource on app

* registering lintern resource on app

* feat(frontend): add linter settings page

* adding lintern runner logic

* registering lintern resource on app

* feat(frontend): add LintResult component in test run page

* first working version

* fix(frontend): fix rule results

* add not empty attribute rule

* feat(frontend): add LinterResults component styles

* add rule to validate attribute names

* remove anonymous variables

* rename files

* add kind to span and add span naming rule

* registering rules

* finishing required attrs rule

* feat(frontend): add dag lint icon and result click

* feat(frontend): add linter loading component

* adding common and security plugins

* feat(frontend): add dag lint errors component

* UI cleanup

* UI cleanup

* fix(frontend): fix styles and linter settings

* feat(frontend): add octolint footer

* fixing unit tests

* fixing unit tests

* fixing annoying typo

* fixing e2e tests

* cleanup changes

* tracetest linter UX mvp improvements

* tracetest linter UX mvp improvements

* PR comments and beta badge

---------

Co-authored-by: Matheus Nogueira <matheus.nogueira2008@gmail.com>
Co-authored-by: Jorge Padilla <jorge.esteban.padilla@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants