Skip to content

Commit

Permalink
feat: enable refelction of the extension server (#511)
Browse files Browse the repository at this point in the history
Co-authored-by: rick <LinuxSuRen@users.noreply.github.com>
  • Loading branch information
LinuxSuRen and LinuxSuRen authored Jul 11, 2024
1 parent 2b98b95 commit a8c52fa
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 17 deletions.
6 changes: 6 additions & 0 deletions e2e/test-suite-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ items:
"suite": "{{.param.suiteName}}",
"testcase": "{{.param.caseName}}"
}
- name: deleteTestSuite
request:
api: /suites/{{.param.suiteName}}
method: DELETE
header:
X-Store-Name: "{{.param.store}}"
- name: createGRPCSuite
request:
api: /suites
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ require (
go.uber.org/zap v1.27.0
golang.org/x/oauth2 v0.18.0
golang.org/x/sync v0.6.0
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -87,7 +88,7 @@ require (
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
2 changes: 2 additions & 0 deletions pkg/extension/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)

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

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

RegisterStopSignal(c.Context(), func() {
Expand Down
3 changes: 2 additions & 1 deletion pkg/runner/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (r *gRPCTestCaseRunner) RunTestCase(testcase *testing.TestCase, dataContext
if err == protoregistry.NotFound {
return nil, fmt.Errorf("api %q is not found", testcase.Request.API)
}
return nil, err
return nil, fmt.Errorf("failed to get method descriptor: %v", err)
}

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

linker, err := compileProto(ctx, r)
if err != nil {
err = fmt.Errorf("failed to compile proto: %v", err)
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/server/remote_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func (s *server) RunTestCase(ctx context.Context, in *TestCaseIdentity) (result
if result.Error == "" {
ExecutionSuccessNum.Inc()
} else {
ExecutionFailNum.Inc()
ExecutionFailNum.Inc()
}
}()

Expand Down
28 changes: 14 additions & 14 deletions pkg/testing/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ limitations under the License.
package testing

import (
"bytes"
"errors"
"fmt"
"io"
"mime/multipart"
"net/http"
"net/url"
"os"
"path"
"strings"
"bytes"
"errors"
"fmt"
"io"
"mime/multipart"
"net/http"
"net/url"
"os"
"path"
"strings"

"github.com/linuxsuren/api-testing/docs"
"github.com/linuxsuren/api-testing/pkg/render"
"github.com/linuxsuren/api-testing/pkg/util"
"gopkg.in/yaml.v3"
"github.com/linuxsuren/api-testing/docs"
"github.com/linuxsuren/api-testing/pkg/render"
"github.com/linuxsuren/api-testing/pkg/util"
"gopkg.in/yaml.v3"
)

const (
Expand Down

0 comments on commit a8c52fa

Please sign in to comment.