Skip to content

Commit b7926da

Browse files
authored
feat: custom the grpc gateway restful path (#497)
1 parent 8961971 commit b7926da

38 files changed

+2597
-1922
lines changed

.github/testing/core.yaml

Lines changed: 2 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,14 @@
11
#!api-testing
22
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-schema.json
3-
# https://docs.gitlab.com/ee/api/api_resources.html
43
name: atest
54
api: |
6-
{{default "http://localhost:8080/server.Runner" (env "SERVER")}}
5+
{{default "http://localhost:8080/api/v1" (env "SERVER")}}
76
param:
87
name: "{{randAlpha 6}}"
98
items:
109
- name: createSuite
1110
request:
12-
api: /CreateTestSuite
13-
method: POST
14-
body: |
15-
{"name": "{{.param.name}}"}
16-
- name: suites
17-
request:
18-
api: /GetSuites
19-
method: POST
20-
- name: suite
21-
request:
22-
api: /GetTestSuite
23-
method: POST
24-
body: |
25-
{"name": "{{.param.name}}"}
26-
expect:
27-
bodyFieldsExpect:
28-
name: "{{.param.name}}"
29-
api: ""
30-
- name: UpdateTestSuite
31-
request:
32-
api: /UpdateTestSuite
33-
method: POST
34-
body: |
35-
{
36-
"name": "{{.param.name}}",
37-
"api": "{{randAlpha 6}}"}
38-
}
39-
- name: DeleteTestSuiteNotFound
40-
request:
41-
api: /DeleteTestSuite
42-
method: POST
43-
body: |
44-
{"name": "{{randAlpha 6}}"}
45-
expect:
46-
statusCode: 500
47-
48-
- name: ListTestCase
49-
request:
50-
api: /ListTestCase
51-
method: POST
52-
body: |
53-
{"name": "{{.param.name}}"}
54-
- name: list-testcases-not-found
55-
request:
56-
api: /ListTestCase
57-
method: POST
58-
body: |
59-
{"name": "{{randAlpha 6}}"}
60-
expect:
61-
bodyFieldsExpect:
62-
name: ""
63-
- name: GetSuggestedAPIs-no-testsuite-found
64-
request:
65-
api: /GetSuggestedAPIs
66-
method: POST
67-
body: |
68-
{"name": "{{randAlpha 6}}"}
69-
expect:
70-
verify:
71-
- len(data.data) == 0
72-
- name: get-testcase-not-found
73-
request:
74-
api: /GetTestCase
75-
method: POST
76-
body: |
77-
{"name": "test"}
78-
expect:
79-
statusCode: 500
80-
bodyFieldsExpect:
81-
code: 2
82-
- name: get-popular-headers
83-
request:
84-
api: /PopularHeaders
85-
method: POST
86-
87-
- name: list-code-generators
88-
request:
89-
api: /ListCodeGenerator
90-
method: POST
91-
expect:
92-
verify:
93-
- len(data) == 1
94-
- name: GenerateCode
95-
request:
96-
api: /GenerateCode
97-
method: POST
98-
body: |
99-
{
100-
"TestSuite": "{{.param.name}}",
101-
"TestCase": "{{randAlpha 6}}",
102-
"Generator": "golang"
103-
}
104-
expect:
105-
statusCode: 500 # no testcase found
106-
verify:
107-
- indexOf(data.message, "not found") != -1
108-
109-
- name: listConverters
110-
request:
111-
api: /ListConverter
112-
method: POST
113-
expect:
114-
verify:
115-
- len(data) == 1
116-
- name: ConvertTestSuite
117-
request:
118-
api: /ConvertTestSuite
119-
method: POST
120-
body: |
121-
{
122-
"TestSuite": "{{.param.name}}",
123-
"Generator": "jmeter"
124-
}
125-
expect:
126-
verify:
127-
- data.message != ""
128-
- indexOf(data.message, "jmeterTestPlan") != -1
129-
130-
- name: list-stores
131-
request:
132-
api: /GetStores
133-
method: POST
134-
expect:
135-
verify:
136-
- len(data) >= 1
137-
- name: query-funcs
138-
request:
139-
api: /FunctionsQuery
140-
method: POST
141-
expect:
142-
verify:
143-
- len(data) == 1
144-
- name: version
145-
request:
146-
api: /GetVersion
147-
method: POST
148-
- name: GetSecrets
149-
request:
150-
api: /GetSecrets
151-
method: POST
152-
expect:
153-
statusCode: 500
154-
155-
- name: DeleteTestSuite
156-
request:
157-
api: /DeleteTestSuite
11+
api: /suites
15812
method: POST
15913
body: |
16014
{"name": "{{.param.name}}"}

.github/testing/grpc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ spec:
88
rpc:
99
import:
1010
- ./pkg/server
11+
- ./pkg/apispec/data/proto
1112
protofile: server.proto
1213
items:
1314
- name: GetVersion

.github/testing/grpc_descriptor_set.yaml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/testing/grpc_ref.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ api: 127.0.0.1:7070
66
spec:
77
kind: grpc
88
rpc:
9+
import:
10+
- ./pkg/apispec/data/proto
911
serverReflection: true
1012
items:
1113
- name: GetVersion

.github/testing/server.pb

-5.2 KB
Binary file not shown.

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
5151
# make test-ui-e2e
5252
53-
atest run -p '.github/testing/*.yaml' --request-ignore-error --report github --report-file bin/report.json --report-github-repo linuxsuren/api-testing --report-github-pr ${{ github.event.number }}
53+
atest run -p .github/testing/grpc.yaml --request-ignore-error --report github --report-file bin/report.json --report-github-repo linuxsuren/api-testing --report-github-pr ${{ github.event.number }}
5454
sudo atest service status
5555
sudo atest service stop
5656
sudo atest service uninstall

.github/workflows/qodana_code_quality.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

cmd/run.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23-
"github.com/linuxsuren/api-testing/pkg/util/home"
2423
"io"
2524
"net/http"
2625
"os"
@@ -30,6 +29,8 @@ import (
3029
"sync"
3130
"time"
3231

32+
"github.com/linuxsuren/api-testing/pkg/util/home"
33+
3334
"github.com/linuxsuren/api-testing/pkg/apispec"
3435
"github.com/linuxsuren/api-testing/pkg/limit"
3536
"github.com/linuxsuren/api-testing/pkg/logging"
@@ -332,6 +333,7 @@ func (o *runOption) runSuite(loader testing.Loader, dataContext map[string]inter
332333
return
333334
}
334335

336+
runLogger.Info("render test suite", "name", testSuite.Name)
335337
if err = testSuite.Render(dataContext); err != nil {
336338
return
337339
}
@@ -343,6 +345,7 @@ func (o *runOption) runSuite(loader testing.Loader, dataContext map[string]inter
343345
suiteRunner.WithOutputWriter(os.Stdout)
344346
suiteRunner.WithWriteLevel(o.level)
345347
suiteRunner.WithSuite(testSuite)
348+
runLogger.Info("run test suite", "name", testSuite.Name)
346349
for _, testCase := range testSuite.Items {
347350
if !testCase.InScope(o.caseItems) {
348351
continue

0 commit comments

Comments
 (0)