Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gRPC e2e test #646

Merged
merged 4 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions command/forwarder/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ package forwarder

import (
"github.com/saucelabs/forwarder/bind"
"github.com/saucelabs/forwarder/command/grpctest"
"github.com/saucelabs/forwarder/command/httpbin"
"github.com/saucelabs/forwarder/command/pac"
"github.com/saucelabs/forwarder/command/ready"
"github.com/saucelabs/forwarder/command/run"
"github.com/saucelabs/forwarder/command/test/grpc"
"github.com/saucelabs/forwarder/command/test/httpbin"
"github.com/saucelabs/forwarder/command/version"
"github.com/saucelabs/forwarder/utils/cobrautil"
"github.com/saucelabs/forwarder/utils/cobrautil/templates"
Expand Down Expand Up @@ -106,12 +106,19 @@ func Command() *cobra.Command {

templates.ActsAsRootCommand(cmd, nil, cg, FlagGroups(), EnvPrefix)

// Add other commands.
cmd.AddCommand(
grpctest.Command(), // hidden
httpbin.Command(), // hidden
version.Command(),
// Add test commands.
test := &cobra.Command{
Use: "test",
Short: "Run test servers for various protocols",
}
test.AddCommand(
grpc.Command(),
httpbin.Command(),
)
cmd.AddCommand(test)
Choraden marked this conversation as resolved.
Show resolved Hide resolved

// Add version command.
cmd.AddCommand(version.Command())

// Add config-file command to all commands.
cobrautil.AddConfigFileForEachCommand(cmd, FlagGroups(), ConfigFileFlagName)
Expand Down
9 changes: 4 additions & 5 deletions command/grpctest/grpctest.go → command/test/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

package grpctest
package grpc

import (
"context"
Expand Down Expand Up @@ -107,10 +107,9 @@ func Command() *cobra.Command {
}

cmd := &cobra.Command{
Use: "grpctest [--address <host:port>] [flags]",
Short: "Start HTTP/2 gRPC server for testing",
RunE: c.runE,
Hidden: true,
Use: "grpc [--address <host:port>] [flags]",
Short: "Start HTTP/2 gRPC server for testing",
RunE: c.runE,
}

fs := cmd.Flags()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@ func Command() *cobra.Command {
c.apiServerConfig.Addr = "localhost:10000"

cmd := &cobra.Command{
Use: "httpbin [--protocol <http|https|h2>] [--address <host:port>] [flags]",
Short: "Start HTTP(S) server that serves httpbin.org API",
RunE: c.runE,
Hidden: true,
Use: "httpbin [--protocol <http|https|h2>] [--address <host:port>] [flags]",
Short: "Start HTTP(S) server that serves httpbin.org API",
RunE: c.runE,
}

fs := cmd.Flags()
Expand Down
2 changes: 1 addition & 1 deletion e2e/forwarder/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func HttpbinService() *Service {
return &Service{
Name: HttpbinServiceName,
Image: Image,
Command: "httpbin",
Command: "test httpbin",
Environment: map[string]string{
"FORWARDER_API_ADDRESS": ":10000",
},
Expand Down