Skip to content

Commit

Permalink
fix(backend): adding deafult value for the analyzer plugins (#2739)
Browse files Browse the repository at this point in the history
* fix(backend): adding deafult value for the analyzer plugins

* fix(frontend): fixing protobuf file

* fix(frontend): fixing protobuf file

* fixing test suites

* fixing test suites
  • Loading branch information
xoscar committed Jun 15, 2023
1 parent 76e99bc commit e54f436
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 54 deletions.
2 changes: 1 addition & 1 deletion server/linter/resource/manager.go
Expand Up @@ -84,7 +84,7 @@ func (r *Repository) Update(ctx context.Context, linter Linter) (Linter, error)
return Linter{}, fmt.Errorf("sql exec delete: %w", err)
}

var pluginsJSON []byte
pluginsJSON := []byte("[]")
if updated.Plugins != nil {
pluginsJSON, err = json.Marshal(updated.Plugins)
if err != nil {
Expand Down
@@ -1,6 +1,6 @@
type: Demo
spec:
id: 2fnji3_VR
id: ik_4OWuVg
name: another-dev
type: pokeshop
enabled: true
Expand Down
@@ -1,6 +1,6 @@
type: Demo
spec:
id: NBnjm3_4R
id: DglVOWu4g
name: dev
type: otelstore
enabled: true
Expand Down
@@ -1,6 +1,6 @@
type: Demo
spec:
id: _889i3l4g
id: DXc4OWXVR
name: dev-updated
type: otelstore
enabled: true
Expand Down
Expand Up @@ -3,7 +3,7 @@ spec:
id: another-env
name: another-env
description: ""
createdAt: 2023-06-13T21:30:23.736515668Z
createdAt: 2023-06-15T22:14:11.945883377Z
values:
- key: Here
value: We
Expand Down
Expand Up @@ -3,7 +3,7 @@ spec:
id: .env
name: .env
description: ""
createdAt: 2023-06-13T21:30:23.72888471Z
createdAt: 2023-06-15T22:14:11.917313085Z
values:
- key: FIRST_VAR
value: some-value
Expand Down
Expand Up @@ -3,7 +3,7 @@ spec:
id: one-more-env
name: one-more-env
description: ""
createdAt: 2023-06-13T21:30:23.743358168Z
createdAt: 2023-06-15T22:14:11.971290461Z
values:
- key: This
value: Is
Expand Down
Expand Up @@ -3,7 +3,7 @@ spec:
id: .env
name: .env
description: ""
createdAt: 2023-06-13T21:30:10.439432Z
createdAt: 2023-06-15T22:13:58.234562Z
values:
- key: FIRST_VAR
value: some-value
Expand Down
2 changes: 2 additions & 0 deletions testing/cli-e2etest/testscenarios/test/resources/api.proto
Expand Up @@ -14,11 +14,13 @@ service Pokeshop {

message ImportPokemonRequest {
int32 id = 1;
optional bool isFixed = 2;
}

message GetPokemonRequest {
optional int32 skip = 1;
optional int32 take = 2;
optional bool isFixed = 3;
}

message GetPokemonListResponse {
Expand Down
Expand Up @@ -3,7 +3,7 @@ spec:
id: pokeapi-env
name: pokeapi-env
description: ""
createdAt: 2023-06-13T21:32:12.710038Z
createdAt: 2023-06-15T22:16:08.965449Z
values:
- key: POKEMON_NAME
value: snorlax
Expand Down
@@ -1,7 +1,7 @@
type: Test
spec:
id: create-pokemon
name: 'Create Pokemon'
name: "Create Pokemon"
description: Create a single pokemon on Pokeshop
trigger:
type: grpc
Expand All @@ -23,11 +23,13 @@ spec:
message ImportPokemonRequest {
int32 id = 1;
optional bool isFixed = 2;
}
message GetPokemonRequest {
optional int32 skip = 1;
optional int32 take = 2;
optional bool isFixed = 3;
}
message GetPokemonListResponse {
Expand All @@ -52,7 +54,7 @@ spec:
"isFeatured": true
}
specs:
- name: It calls Pokeshop correctly
selector: span[tracetest.span.type="rpc" name="createPokemon" rpc.system="grpc" rpc.method="createPokemon" rpc.service="Pokeshop.createPokemon"]
assertions:
- attr:rpc.grpc.status_code = 0
- name: It calls Pokeshop correctly
selector: span[tracetest.span.type="rpc" name="pokeshop.Pokeshop/createPokemon" rpc.system="grpc" rpc.method="createPokemon" rpc.service="pokeshop.Pokeshop"]
assertions:
- attr:rpc.grpc.status_code = 0
@@ -1,7 +1,7 @@
type: Test
spec:
id: create-pokemon
name: 'Create Pokemon'
name: "Create Pokemon"
description: Create a single pokemon on Pokeshop
trigger:
type: grpc
Expand All @@ -16,7 +16,7 @@ spec:
"isFeatured": true
}
specs:
- name: It calls Pokeshop correctly
selector: span[tracetest.span.type="rpc" name="createPokemon" rpc.system="grpc" rpc.method="createPokemon" rpc.service="Pokeshop.createPokemon"]
assertions:
- attr:rpc.grpc.status_code = 0
- name: It calls Pokeshop correctly
selector: span[tracetest.span.type="rpc" name="pokeshop.Pokeshop/createPokemon" rpc.system="grpc" rpc.method="createPokemon" rpc.service="pokeshop.Pokeshop"]
assertions:
- attr:rpc.grpc.status_code = 0
Expand Up @@ -9,17 +9,18 @@ spec:
url: http://demo-api:8081/pokemon
method: POST
headers:
- key: Content-Type
value: application/json
- key: Content-Type
value: application/json
body: '{"name":"${env:POKEMON_NAME}","type":"normal","imageUrl":"${env:POKEMON_URL}","isFeatured":true}'
specs:
- name: It should add a Pokemon correctly
selector: span[tracetest.span.type="http" name="POST /pokemon" http.method="POST"]
assertions:
- attr:http.status_code = 201
- name: It should save the correct data
selector: span[tracetest.span.type="database" name="create pokeshop.pokemon" db.system="postgres"
db.name="postgres" db.user="postgres" db.operation="create" db.sql.table="pokemon"]
assertions:
- attr:db.result contains '"imageUrl":"${env:POKEMON_URL}"'
- attr:db.result contains '"name":"${env:POKEMON_NAME}"'
- name: It should add a Pokemon correctly
selector: span[tracetest.span.type="http" name="POST /pokemon" http.method="POST"]
assertions:
- attr:http.status_code = 201
- name: It should save the correct data
selector:
span[tracetest.span.type="database" name="create postgres.pokemon" db.system="postgres"
db.name="postgres" db.user="postgres" db.operation="create" db.sql.table="pokemon"]
assertions:
- attr:db.result contains '"imageUrl":"${env:POKEMON_URL}"'
- attr:db.result contains '"name":"${env:POKEMON_NAME}"'
Expand Up @@ -17,7 +17,7 @@ spec:
"serviceUnderTest": {
"triggerType": "grpc",
"grpc": {
"protobufFile": "syntax = \"proto3\";\r\n\r\noption java_multiple_files = true;\r\noption java_outer_classname = \"PokeshopProto\";\r\noption objc_class_prefix = \"PKS\";\r\n\r\npackage pokeshop;\r\n\r\nservice Pokeshop {\r\n rpc getPokemonList (GetPokemonRequest) returns (GetPokemonListResponse) {}\r\n rpc createPokemon (Pokemon) returns (Pokemon) {}\r\n rpc importPokemon (ImportPokemonRequest) returns (ImportPokemonRequest) {}\r\n}\r\n\r\nmessage ImportPokemonRequest {\r\n int32 id = 1;\r\n}\r\n\r\nmessage GetPokemonRequest {\r\n optional int32 skip = 1;\r\n optional int32 take = 2;\r\n}\r\n\r\nmessage GetPokemonListResponse {\r\n repeated Pokemon items = 1;\r\n int32 totalCount = 2;\r\n}\r\n\r\nmessage Pokemon {\r\n optional int32 id = 1;\r\n string name = 2;\r\n string type = 3;\r\n bool isFeatured = 4;\r\n optional string imageUrl = 5;\r\n}",
"protobufFile": "syntax = \"proto3\";\n\noption java_multiple_files = true;\noption java_outer_classname = \"PokeshopProto\";\noption objc_class_prefix = \"PKS\";\n\npackage pokeshop;\n\nservice Pokeshop {\n rpc getPokemonList (GetPokemonRequest) returns (GetPokemonListResponse) {}\n rpc createPokemon (Pokemon) returns (Pokemon) {}\n rpc importPokemon (ImportPokemonRequest) returns (ImportPokemonRequest) {}\n}\n\nmessage ImportPokemonRequest {\n int32 id = 1;\n optional bool isFixed = 2;\n}\n\nmessage GetPokemonRequest {\n optional int32 skip = 1;\n optional int32 take = 2;\n optional bool isFixed = 3;\n}\n\nmessage GetPokemonListResponse {\n repeated Pokemon items = 1;\n int32 totalCount = 2;\n}\n\nmessage Pokemon {\n optional int32 id = 1;\n string name = 2;\n string type = 3;\n bool isFeatured = 4;\n optional string imageUrl = 5;\n}",
"address": "${env:DEMO_APP_GRPC_URL}",
"method": "pokeshop.Pokeshop.importPokemon",
"request": "{\"id\": 52}"
Expand All @@ -26,7 +26,7 @@ spec:
"specs": [
{
"selectorParsed": {
"query": "span[name = \"queue.synchronizePokemon send\"]"
"query": "span[name = \"queue.synchronizePokemon publish\"]"
},
"assertions": ["attr:tracetest.selected_spans.count > 0"]
}
Expand Down
Expand Up @@ -9,15 +9,15 @@ spec:
url: ${env:TARGET_URL}/api/tests
method: POST
headers:
- key: Content-Type
value: application/json
- key: Content-Type
value: application/json
body: |
{
"name": "gRPC pokemon list",
"serviceUnderTest": {
"triggerType": "grpc",
"grpc": {
"protobufFile": "syntax = \"proto3\";\r\n\r\noption java_multiple_files = true;\r\noption java_outer_classname = \"PokeshopProto\";\r\noption objc_class_prefix = \"PKS\";\r\n\r\npackage pokeshop;\r\n\r\nservice Pokeshop {\r\n rpc getPokemonList (GetPokemonRequest) returns (GetPokemonListResponse) {}\r\n rpc createPokemon (Pokemon) returns (Pokemon) {}\r\n rpc importPokemon (ImportPokemonRequest) returns (ImportPokemonRequest) {}\r\n}\r\n\r\nmessage ImportPokemonRequest {\r\n int32 id = 1;\r\n}\r\n\r\nmessage GetPokemonRequest {\r\n optional int32 skip = 1;\r\n optional int32 take = 2;\r\n}\r\n\r\nmessage GetPokemonListResponse {\r\n repeated Pokemon items = 1;\r\n int32 totalCount = 2;\r\n}\r\n\r\nmessage Pokemon {\r\n optional int32 id = 1;\r\n string name = 2;\r\n string type = 3;\r\n bool isFeatured = 4;\r\n optional string imageUrl = 5;\r\n}",
"protobufFile": "syntax = \"proto3\";\n\noption java_multiple_files = true;\noption java_outer_classname = \"PokeshopProto\";\noption objc_class_prefix = \"PKS\";\n\npackage pokeshop;\n\nservice Pokeshop {\n rpc getPokemonList (GetPokemonRequest) returns (GetPokemonListResponse) {}\n rpc createPokemon (Pokemon) returns (Pokemon) {}\n rpc importPokemon (ImportPokemonRequest) returns (ImportPokemonRequest) {}\n}\n\nmessage ImportPokemonRequest {\n int32 id = 1;\n optional bool isFixed = 2;\n}\n\nmessage GetPokemonRequest {\n optional int32 skip = 1;\n optional int32 take = 2;\n optional bool isFixed = 3;\n}\n\nmessage GetPokemonListResponse {\n repeated Pokemon items = 1;\n int32 totalCount = 2;\n}\n\nmessage Pokemon {\n optional int32 id = 1;\n string name = 2;\n string type = 3;\n bool isFeatured = 4;\n optional string imageUrl = 5;\n}",
"address": "${env:DEMO_APP_GRPC_URL}",
"method": "pokeshop.Pokeshop.importPokemon",
"request": "{\"id\": 52}",
Expand All @@ -27,27 +27,27 @@ spec:
"specs": [
{
"selectorParsed": {
"query": "span[name = \"queue.synchronizePokemon send\"]"
"query": "span[name = \"queue.synchronizePokemon publish\"]"
},
"assertions": ["attr:tracetest.selected_spans.count > 0"]
}
]
}
specs:
- selector: span[name = "Tracetest trigger"]
assertions:
- attr:tracetest.selected_spans.count = 1
- attr:tracetest.response.status = 200
- selector: span[name="POST /api/tests" tracetest.span.type="http"]
assertions:
- attr:tracetest.selected_spans.count = 1
- selector: span[name = "exec INSERT"]
assertions:
- attr:tracetest.selected_spans.count = 1
- selector: span[name = "exec INSERT"]:first
assertions:
- attr:sql.query contains "INSERT INTO tests"
- selector: span[name = "Tracetest trigger"]
assertions:
- attr:tracetest.selected_spans.count = 1
- attr:tracetest.response.status = 200
- selector: span[name="POST /api/tests" tracetest.span.type="http"]
assertions:
- attr:tracetest.selected_spans.count = 1
- selector: span[name = "exec INSERT"]
assertions:
- attr:tracetest.selected_spans.count = 1
- selector: span[name = "exec INSERT"]:first
assertions:
- attr:sql.query contains "INSERT INTO tests"
outputs:
- name: GRPC_TEST_INVALID_METADATA_ID
selector: span[name = "Tracetest trigger"]
value: attr:tracetest.response.body | json_path '$.id'
- name: GRPC_TEST_INVALID_METADATA_ID
selector: span[name = "Tracetest trigger"]
value: attr:tracetest.response.body | json_path '$.id'
Expand Up @@ -30,7 +30,7 @@ spec:
"specs": [
{
"selectorParsed": {
"query": "span[name = \"pg.query:SELECT postgres\"]"
"query": "span[name = \"findMany postgres.pokemon\"]"
},
"assertions": ["attr:tracetest.selected_spans.count > 0"]
}
Expand Down

0 comments on commit e54f436

Please sign in to comment.