Skip to content

Commit a8c52fa

Browse files
authored
feat: enable refelction of the extension server (#511)
Co-authored-by: rick <[email protected]>
1 parent 2b98b95 commit a8c52fa

File tree

6 files changed

+27
-17
lines changed

6 files changed

+27
-17
lines changed

e2e/test-suite-common.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ items:
212212
"suite": "{{.param.suiteName}}",
213213
"testcase": "{{.param.caseName}}"
214214
}
215+
- name: deleteTestSuite
216+
request:
217+
api: /suites/{{.param.suiteName}}
218+
method: DELETE
219+
header:
220+
X-Store-Name: "{{.param.store}}"
215221
- name: createGRPCSuite
216222
request:
217223
api: /suites

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ require (
3535
go.uber.org/zap v1.27.0
3636
golang.org/x/oauth2 v0.18.0
3737
golang.org/x/sync v0.6.0
38+
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80
3839
google.golang.org/grpc v1.62.1
3940
google.golang.org/protobuf v1.33.0
4041
gopkg.in/yaml.v3 v3.0.1
@@ -87,7 +88,7 @@ require (
8788
golang.org/x/sys v0.18.0 // indirect
8889
golang.org/x/text v0.14.0 // indirect
8990
google.golang.org/appengine v1.6.8 // indirect
90-
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
91+
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
9192
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
9293
gopkg.in/yaml.v2 v2.4.0 // indirect
9394
)

pkg/extension/option.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/spf13/cobra"
2828
"github.com/spf13/pflag"
2929
"google.golang.org/grpc"
30+
"google.golang.org/grpc/reflection"
3031
)
3132

3233
// Extension is the default command option of the extension
@@ -79,6 +80,7 @@ func CreateRunner(ext *Extension, c *cobra.Command, remoteServer remote.LoaderSe
7980

8081
gRPCServer := grpc.NewServer()
8182
remote.RegisterLoaderServer(gRPCServer, remoteServer)
83+
reflection.Register(gRPCServer)
8284
c.Printf("%s@%s is running at %s\n", ext.GetFullName(), version.GetVersion(), address)
8385

8486
RegisterStopSignal(c.Context(), func() {

pkg/runner/grpc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (r *gRPCTestCaseRunner) RunTestCase(testcase *testing.TestCase, dataContext
129129
if err == protoregistry.NotFound {
130130
return nil, fmt.Errorf("api %q is not found", testcase.Request.API)
131131
}
132-
return nil, err
132+
return nil, fmt.Errorf("failed to get method descriptor: %v", err)
133133
}
134134

135135
// pass the headers into gRPC request metadata
@@ -424,6 +424,7 @@ func getByProto(ctx context.Context, r *gRPCTestCaseRunner, fullName protoreflec
424424

425425
linker, err := compileProto(ctx, r)
426426
if err != nil {
427+
err = fmt.Errorf("failed to compile proto: %v", err)
427428
return nil, err
428429
}
429430

pkg/server/remote_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ func (s *server) RunTestCase(ctx context.Context, in *TestCaseIdentity) (result
516516
if result.Error == "" {
517517
ExecutionSuccessNum.Inc()
518518
} else {
519-
ExecutionFailNum.Inc()
519+
ExecutionFailNum.Inc()
520520
}
521521
}()
522522

pkg/testing/parser.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ limitations under the License.
1616
package testing
1717

1818
import (
19-
"bytes"
20-
"errors"
21-
"fmt"
22-
"io"
23-
"mime/multipart"
24-
"net/http"
25-
"net/url"
26-
"os"
27-
"path"
28-
"strings"
19+
"bytes"
20+
"errors"
21+
"fmt"
22+
"io"
23+
"mime/multipart"
24+
"net/http"
25+
"net/url"
26+
"os"
27+
"path"
28+
"strings"
2929

30-
"github.com/linuxsuren/api-testing/docs"
31-
"github.com/linuxsuren/api-testing/pkg/render"
32-
"github.com/linuxsuren/api-testing/pkg/util"
33-
"gopkg.in/yaml.v3"
30+
"github.com/linuxsuren/api-testing/docs"
31+
"github.com/linuxsuren/api-testing/pkg/render"
32+
"github.com/linuxsuren/api-testing/pkg/util"
33+
"gopkg.in/yaml.v3"
3434
)
3535

3636
const (

0 commit comments

Comments
 (0)