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

feat: test models + list tests endpoint #2681

Merged
merged 17 commits into from
Jun 9, 2023

Conversation

mathnogueira
Copy link
Contributor

@mathnogueira mathnogueira commented Jun 7, 2023

This PR adds the list tests endpoint. I'll add the resource manager test in the next PR (POST /api/tests) because it will be way easier to do that way. It's hard to implement it right now because there's no easy way of adding the test into the database (I don't want to mess up with the models.Test object.

Checklist

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

@mathnogueira mathnogueira changed the base branch from main to feat/tests-as-resources June 7, 2023 19:35
@@ -88,7 +88,7 @@ jobs:
cache: true
cache-dependency-path: go.work
- name: Run unit tests
run: cd server; make test
run: cd server; make test -B
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, this was not running the tests and was printing test is up-to-date. Adding the -B forces make to run this regardless of the cache.

@mathnogueira mathnogueira marked this pull request as ready for review June 8, 2023 19:26
Copy link
Contributor

@xoscar xoscar left a comment

Choose a reason for hiding this comment

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

Hey @mathnogueira this looks great! One question have you done anything about the resource endpoint FE uses for the dashboard? or should stay as it is for the moment?

Awesome job! 🔥

triggerType:
type: string
enum: ["http", "grpc", "traceid"]
type:
type: string
enum: ["http", "grpc", "traceid"]
Copy link
Contributor

Choose a reason for hiding this comment

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

We can update the FE to use the new version right?

registerDemosResource(demoRepo, apiRouter, provisioner, tracer)
registerDataStoreResource(dataStoreRepo, apiRouter, provisioner, tracer)
registerlinterResource(linterRepo, apiRouter, provisioner, tracer)
registerTestResource(testRepo, apiRouter, provisioner, tracer)
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥

@@ -0,0 +1,65 @@
package trigger
Copy link
Contributor

Choose a reason for hiding this comment

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

I like that we moved the triggers here!

Copy link
Contributor

@schoren schoren left a comment

Choose a reason for hiding this comment

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

This is looking great. There are some improvements that we can make, since we're already working on this are, so I added some comments.

Specially around versioning of json representations. I think it's very important that we standardize on a way to handle this, since it's happened a few times so far, and it's very likely to keep happening

@@ -43,7 +43,6 @@ func (c *customController) Routes() openapi.Routes {

routes[c.getRouteIndex("GetTestRuns")].HandlerFunc = c.GetTestRuns

routes[c.getRouteIndex("GetTests")].HandlerFunc = paginatedEndpoint[openapi.Test](c.service.GetTests, c.errorHandler)
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

Assertions []Assertion
}

type keyValueSpec struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to version the entire TestSpec json instead of just the things that change, like here: https://github.com/kubeshop/tracetest/blob/main/server/model/trigger_json.go

This makes it easier to keep updating the json, adding new versions, with a standardized approach

"github.com/stretchr/testify/require"
)

func TestSpecRetrocompability(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for the tests: https://github.com/kubeshop/tracetest/blob/main/server/model/trigger_json_test.go

It's easier to understand the chronological order of the versions

TraceID *TraceIDRequest `json:"traceid,omitempty"`
}

type oldTriggerFormat struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

again, I think having "versioned" formats makes it easier to understand the chronology: https://github.com/kubeshop/tracetest/blob/main/server/model/trigger_json.go

func (t *Trigger) UnmarshalJSON(data []byte) error {
var trigger triggerFormat
err := json.Unmarshal(data, &trigger)
if err != nil || trigger.Type == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the current main version of this function is more future-friendly with the versioning: https://github.com/kubeshop/tracetest/blob/main/server/model/trigger_json.go#LL49C6-L49C6

@mathnogueira
Copy link
Contributor Author

@schoren I changed all the things you mentioned

@mathnogueira mathnogueira requested a review from schoren June 9, 2023 18:40
Copy link
Contributor

@schoren schoren left a comment

Choose a reason for hiding this comment

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

this is great! lef a few optional nits, but it's ready to merge!

@@ -4,7 +4,6 @@ on:
push:
branches: [main]
pull_request:
branches: [main]
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

return deepcopy.DeepCopy(v2, t)
}

// v2
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
// v2
// v3

assert.Equal(t, expected, current)
}

func TestTriggerFormatV2(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need a TestTriggerFormatv3 or is that covered by other tests? if possible I would add it here for the sake of completeness

@mathnogueira mathnogueira merged commit 156e841 into feat/tests-as-resources Jun 9, 2023
@mathnogueira mathnogueira deleted the feat/test-models branch June 9, 2023 19:06
mathnogueira added a commit that referenced this pull request Jun 13, 2023
* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>
mathnogueira added a commit that referenced this pull request Jun 14, 2023
* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>
schoren added a commit that referenced this pull request Jun 21, 2023
* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>
mathnogueira added a commit that referenced this pull request Jun 21, 2023
* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>
schoren added a commit that referenced this pull request Jun 22, 2023
* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>
mathnogueira added a commit that referenced this pull request Jun 26, 2023
* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>
danielbdias pushed a commit that referenced this pull request Jun 26, 2023
* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>
mathnogueira added a commit that referenced this pull request Jul 3, 2023
* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>
mathnogueira added a commit that referenced this pull request Jul 3, 2023
* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>
mathnogueira added a commit that referenced this pull request Jul 3, 2023
* chore(docs): Adding App Insights Configuration Page (#2820)

* chore(docs): Adding App Insights Configuration Page

* fixing typo

* fix(frontend): Fixing Resizable Panels UI bugs (#2827)

* fix(tests): add analyzer resource to cli e2e table (#2826)

* chore(docs): Azure App Insights Recipes (#2821)

* chore(docs): Adding App Insights Configuration Page

* chore(docs): Adding App Insights Recipes

* chore(docs): Adding App Insights Recipes

* chore(docs): fixing typo

* adding recipe links

* adding recipe links

* fixing typo

* chore(frotend): Test Definition Name Input (#2830)

* chore(frotend): Updating Panel Splitter w/ Tooltip (#2828)

* chore(frotend): Updating Panel Splitter w/ Tooltip

* Updating theme color

* removing unnecessary flag

* undo change

* fix(frontend): fix missing font-face (#2833)

* feat(cli): refactor list formatter for better resource manager support (#2829)

* feat(frontend): add independent trace vs test data (#2815)

* feat(cli): refactor Get formatter for better resource manager support (#2831)

* feat(cli): dynamic list of available resources (#2832)

* feat(cli): refactor Delete to new resource manager client (#2836)

* feat(cli): update export command with new resourcemanager client (#2838)

* Standardize old resources to to use list method with SQL Injection protection and stardardize PollingProfile file (#2839)

* wip: update list on demo and environment to use the same standards as tests and transactions

* Fixing provisioning test

* Update provisioning test

* feature(frontend): Contact Us Modal (#2835)

* feature(frontend): Contact Us Modal

* feature(frontend): Contact Us Modal

* feat(cli): update apply command with new resourcemanager client (#2841)

* feat(frontend): trace vs test data for timeline and attribute list (#2837)

* feat: new tests openapi spec (#2658)

update get tests endpoint to use resource manager

* fix: move transactions to it's own module (#2664)

* fix: move transactions to the transactions folder

* remove alias to transactions module

* feat: test models + list tests endpoint (#2681)

* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>

* 2659 cli improvements migrate tests to resource manager architecture get tests frontend (#2702)

chore(frontend): updating FE to support GET /tests endpoint changes

* feat: test list augmented response (#2732)

add augmented list

* fix(server): fix trigger json encoding versioning and test (#2795)

* feat: test models + list tests endpoint (#2681)

* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>

* GET endpoint

* fix rebase

* add create method and fix tests

* add rest of methods

* Changing test structure and fixing method by method

* Update tests

* Fixing test errors for Delete

* Adding gRPC tests

* Adding tests for traceid trigger

* migrate rest of endpoints and fix compilation errors

* fix all unit and integration tests

* Improving tests

* fix building errors

---------

Co-authored-by: Oscar Reyes <[email protected]>
Co-authored-by: Jorge Padilla <[email protected]>
Co-authored-by: Sebastian Choren <[email protected]>
Co-authored-by: Daniel Baptista Dias <[email protected]>
Co-authored-by: Daniel Dias <[email protected]>
xoscar added a commit that referenced this pull request Jul 6, 2023
* feat: new tests openapi spec (#2658)

update get tests endpoint to use resource manager

* fix: move transactions to it's own module (#2664)

* fix: move transactions to the transactions folder

* remove alias to transactions module

* feat: test models + list tests endpoint (#2681)

* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>

* 2659 cli improvements migrate tests to resource manager architecture get tests frontend (#2702)

chore(frontend): updating FE to support GET /tests endpoint changes

* feat: test list augmented response (#2732)

add augmented list

* fix(server): fix trigger json encoding versioning and test (#2795)

* WIP feat: get endpoint (#2789)

* chore(docs): Adding App Insights Configuration Page (#2820)

* chore(docs): Adding App Insights Configuration Page

* fixing typo

* fix(frontend): Fixing Resizable Panels UI bugs (#2827)

* fix(tests): add analyzer resource to cli e2e table (#2826)

* chore(docs): Azure App Insights Recipes (#2821)

* chore(docs): Adding App Insights Configuration Page

* chore(docs): Adding App Insights Recipes

* chore(docs): Adding App Insights Recipes

* chore(docs): fixing typo

* adding recipe links

* adding recipe links

* fixing typo

* chore(frotend): Test Definition Name Input (#2830)

* chore(frotend): Updating Panel Splitter w/ Tooltip (#2828)

* chore(frotend): Updating Panel Splitter w/ Tooltip

* Updating theme color

* removing unnecessary flag

* undo change

* fix(frontend): fix missing font-face (#2833)

* feat(cli): refactor list formatter for better resource manager support (#2829)

* feat(frontend): add independent trace vs test data (#2815)

* feat(cli): refactor Get formatter for better resource manager support (#2831)

* feat(cli): dynamic list of available resources (#2832)

* feat(cli): refactor Delete to new resource manager client (#2836)

* feat(cli): update export command with new resourcemanager client (#2838)

* Standardize old resources to to use list method with SQL Injection protection and stardardize PollingProfile file (#2839)

* wip: update list on demo and environment to use the same standards as tests and transactions

* Fixing provisioning test

* Update provisioning test

* feature(frontend): Contact Us Modal (#2835)

* feature(frontend): Contact Us Modal

* feature(frontend): Contact Us Modal

* feat(cli): update apply command with new resourcemanager client (#2841)

* feat(frontend): trace vs test data for timeline and attribute list (#2837)

* feat: new tests openapi spec (#2658)

update get tests endpoint to use resource manager

* fix: move transactions to it's own module (#2664)

* fix: move transactions to the transactions folder

* remove alias to transactions module

* feat: test models + list tests endpoint (#2681)

* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>

* 2659 cli improvements migrate tests to resource manager architecture get tests frontend (#2702)

chore(frontend): updating FE to support GET /tests endpoint changes

* feat: test list augmented response (#2732)

add augmented list

* fix(server): fix trigger json encoding versioning and test (#2795)

* feat: test models + list tests endpoint (#2681)

* add test, run, and trigger objects

* feat: move test and run structs into the test package

* list tests

* add old format attributes again

* fix mapping

* compatibility mode

* fix server prefix integration test

* force server unit tests to run

* fix tracetest test

* trigger CI

* Apply suggestions from code review

Co-authored-by: Sebastian Choren <[email protected]>

* fix build

* version test specs

* update test names

* use sqlutils

* dont specify branch target in pull_request

* fix list test

---------

Co-authored-by: Sebastian Choren <[email protected]>

* GET endpoint

* fix rebase

* add create method and fix tests

* add rest of methods

* Changing test structure and fixing method by method

* Update tests

* Fixing test errors for Delete

* Adding gRPC tests

* Adding tests for traceid trigger

* migrate rest of endpoints and fix compilation errors

* fix all unit and integration tests

* Improving tests

* fix building errors

---------

Co-authored-by: Oscar Reyes <[email protected]>
Co-authored-by: Jorge Padilla <[email protected]>
Co-authored-by: Sebastian Choren <[email protected]>
Co-authored-by: Daniel Baptista Dias <[email protected]>
Co-authored-by: Daniel Dias <[email protected]>

* fix a couple of issues

* fix wrong variable name

* fix part of the tracetests

* Fixing small bugs on server

* Fixing test run problem

* fix: tracetests (#2852)

fix grpc tests and transaction tracetests

* fixing FE tests and types

* Updating test assertion validation

* Tests cli resourcemanager client (#2849)

* fixing FE tests and updating models

* fixing FE tests and updating models

* Updating trigger mapping to populate httpRequest field on OpenAPI based endpoints

* Removing deprecated fields

* fix trigger type in fe

* add cli e2e test for test resource (#2854)

* Fixed bug in dogfooding test

* Making backend-arch-graph step not block CI on failure

* fix trigger result type in fe

* Deprecate commands (#2857)

* Move test deprecated notice to subcommands

* Update CLI e2e docs

* fix(docs): fix deprecated test command (#2874)

---------

Co-authored-by: Matheus Nogueira <[email protected]>
Co-authored-by: Sebastian Choren <[email protected]>
Co-authored-by: Jorge Padilla <[email protected]>
Co-authored-by: Daniel Baptista Dias <[email protected]>
Co-authored-by: Daniel Dias <[email protected]>
Co-authored-by: Sebastian Choren <[email protected]>
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.

3 participants