Skip to content

Commit acc8b26

Browse files
authored
feat: get gRPC descriptor via server reflection (#210)
Signed-off-by: Ink33 <[email protected]>
1 parent c582610 commit acc8b26

File tree

14 files changed

+920
-555
lines changed

14 files changed

+920
-555
lines changed

.github/testing/grpc.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!api-testing
2+
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-schema.json
3+
# see also https://github.com/LinuxSuRen/api-testing
4+
name: grpc-sample
5+
api: 127.0.0.1:7070
6+
spec:
7+
grpc:
8+
import:
9+
- ./pkg/server
10+
protofile: server.proto
11+
items:
12+
- name: GetVersion
13+
request:
14+
api: /server.Runner/GetVersion
15+
- name: FunctionsQuery
16+
request:
17+
api: /server.Runner/FunctionsQuery
18+
body: |
19+
{
20+
"name": "hello"
21+
}
22+
expect:
23+
body: |
24+
{
25+
"data": [
26+
{
27+
"key": "hello",
28+
"value": "func() string"
29+
}
30+
]
31+
}
32+
- name: FunctionsQueryStream
33+
request:
34+
api: /server.Runner/FunctionsQueryStream
35+
body: |
36+
[
37+
{
38+
"name": "hello"
39+
},
40+
{
41+
"name": "title"
42+
}
43+
]
44+
expect:
45+
verify:
46+
- "len(data) == 2"

.github/testing/grpc_ref.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!api-testing
2+
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-schema.json
3+
# see also https://github.com/LinuxSuRen/api-testing
4+
name: grpc-sample
5+
api: 127.0.0.1:7070
6+
spec:
7+
grpc:
8+
serverReflection: true
9+
items:
10+
- name: GetVersion
11+
request:
12+
api: /server.Runner/GetVersion
13+
- name: FunctionsQuery
14+
request:
15+
api: /server.Runner/FunctionsQuery
16+
body: |
17+
{
18+
"name": "hello"
19+
}
20+
expect:
21+
body: |
22+
{
23+
"data": [
24+
{
25+
"key": "hello",
26+
"value": "func() string"
27+
}
28+
]
29+
}
30+
- name: FunctionsQueryStream
31+
request:
32+
api: /server.Runner/FunctionsQueryStream
33+
body: |
34+
[
35+
{
36+
"name": "hello"
37+
},
38+
{
39+
"name": "title"
40+
}
41+
]
42+
expect:
43+
verify:
44+
- "len(data) == 2"

.github/workflows/build.yaml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ jobs:
77
Test:
88
runs-on: ubuntu-20.04
99
steps:
10+
- uses: actions/[email protected]
1011
- name: Set up Go
11-
uses: actions/setup-go@v3
12+
uses: actions/setup-go@v4
1213
with:
1314
go-version: 1.18.x
14-
- uses: actions/[email protected]
1515
- name: Unit Test
1616
run: |
1717
make test-all-backend test-operator
@@ -32,30 +32,30 @@ jobs:
3232
bash <(curl -Ls https://coverage.codacy.com/get.sh) final
3333
3434
APITest:
35+
permissions: write-all
3536
runs-on: ubuntu-20.04
3637
steps:
38+
- uses: actions/[email protected]
3739
- name: Set up Go
38-
uses: actions/setup-go@v3
40+
uses: actions/setup-go@v4
3941
with:
4042
go-version: 1.18.x
41-
- uses: actions/[email protected]
4243
- name: API Test
4344
run: |
4445
make build copy
4546
sudo atest service install
4647
sudo atest service restart
4748
sudo atest service status
48-
atest run -p .github/testing/core.yaml --request-ignore-error --report md --report-file .github/workflows/report.md
49-
atest run -p sample/grpc-sample.yaml
49+
atest run -p '.github/testing/*.yaml' --request-ignore-error --report md --report-file .github/workflows/report.md
5050
sudo atest service status
5151
5252
atest convert -p .github/testing/core.yaml --converter jmeter -t sample.jmx
5353
- name: Report API Test
54-
uses: harupy/comment-on-pr@c0522c44600040927a120b9309b531e3cb6f8d48
54+
uses: thollander/actions-comment-pull-request@v2
5555
env:
5656
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757
with:
58-
filename: report.md
58+
filePath: .github/workflows/report.md
5959
- name: Run JMeter Tests
6060
uses: rbhadti94/[email protected]
6161
with:
@@ -64,28 +64,29 @@ jobs:
6464
Build:
6565
runs-on: ubuntu-20.04
6666
steps:
67+
- uses: actions/[email protected]
6768
- name: Set up Go
68-
uses: actions/setup-go@v3
69+
uses: actions/setup-go@v4
6970
with:
7071
go-version: 1.18.x
71-
- uses: actions/[email protected]
7272
- name: Run GoReleaser
73-
uses: goreleaser/[email protected]
73+
uses: goreleaser/goreleaser-action@v4
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}
7476
with:
75-
github_token: ${{ secrets.GH_PUBLISH_SECRETS }}
76-
version: v1.14.0
77+
version: latest
7778
args: release --skip-publish --rm-dist --snapshot
7879
- name: Operator
7980
run: cd operator && make build
8081

8182
BuildImage:
8283
runs-on: ubuntu-20.04
8384
steps:
85+
- uses: actions/[email protected]
8486
- name: Set up Go
85-
uses: actions/setup-go@v3
87+
uses: actions/setup-go@v4
8688
with:
8789
go-version: 1.18.x
88-
- uses: actions/[email protected]
8990
- name: Core Image
9091
run: make build-image
9192
- name: Operator Image
@@ -94,16 +95,16 @@ jobs:
9495
BuildEmbedUI:
9596
runs-on: ubuntu-20.04
9697
steps:
98+
- uses: actions/[email protected]
9799
- name: Set up Go
98-
uses: actions/setup-go@v3
100+
uses: actions/setup-go@v4
99101
with:
100102
go-version: 1.18.x
101-
- uses: actions/[email protected]
102103
- name: Use Node.js
103104
uses: actions/setup-node@v3
104105
with:
105106
node-version: 18.x
106-
cache: 'npm'
107+
cache: "npm"
107108
cache-dependency-path: console/atest-ui/package-lock.json
108109
- name: Build
109110
run: |

.github/workflows/release.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release
33
on:
44
push:
55
tags:
6-
- '*'
6+
- "*"
77
branches:
88
- master
99

@@ -21,14 +21,14 @@ jobs:
2121
- name: Unshallow
2222
run: git fetch --prune --unshallow
2323
- name: Set up Go
24-
uses: actions/setup-go@v3
24+
uses: actions/setup-go@v4
2525
with:
2626
go-version: 1.18
2727
- name: Use Node.js
2828
uses: actions/setup-node@v3
2929
with:
3030
node-version: 18.x
31-
cache: 'npm'
31+
cache: "npm"
3232
cache-dependency-path: console/atest-ui/package-lock.json
3333
- name: Run GoReleaser
3434
uses: goreleaser/[email protected]
@@ -41,11 +41,11 @@ jobs:
4141
Test:
4242
runs-on: ubuntu-20.04
4343
steps:
44+
- uses: actions/[email protected]
4445
- name: Set up Go
45-
uses: actions/setup-go@v3
46+
uses: actions/setup-go@v4
4647
with:
4748
go-version: 1.18.x
48-
- uses: actions/[email protected]
4949
- name: Unit Test
5050
run: |
5151
make test-all-backend test-operator

0 commit comments

Comments
 (0)