MCPcopy
hub / github.com/grpc/grpc-go / newServers

Function newServers

internal/xds/test/e2e/e2e.go:140–168  ·  view source on GitHub ↗

newServer creates multiple servers with the given bootstrap content. Each server gets a different hostname, in the format of <hostnamePrefix>-<index>.

(hostnamePrefix, binaryPath, bootstrap string, logger io.Writer, count int)

Source from the content-addressed store, hash-verified

138// Each server gets a different hostname, in the format of
139// <hostnamePrefix>-<index>.
140func newServers(hostnamePrefix, binaryPath, bootstrap string, logger io.Writer, count int) (_ []*server, err error) {
141 var ret []*server
142 defer func() {
143 if err != nil {
144 for _, s := range ret {
145 s.stop()
146 }
147 }
148 }()
149 for i := 0; i < count; i++ {
150 port := serverPort + i
151 cmd := cmd(
152 binaryPath,
153 logger,
154 []string{
155 fmt.Sprintf("--port=%d", port),
156 fmt.Sprintf("--host_name_override=%s-%d", hostnamePrefix, i),
157 },
158 []string{
159 "GRPC_GO_LOG_VERBOSITY_LEVEL=99",
160 "GRPC_GO_LOG_SEVERITY_LEVEL=info",
161 "GRPC_XDS_BOOTSTRAP_CONFIG=" + bootstrap, // The bootstrap content doesn't need to be quoted.,
162 },
163 )
164 cmd.Start()
165 ret = append(ret, &server{cmd: cmd, port: port})
166 }
167 return ret, nil
168}
169
170func (s *server) stop() {
171 s.cmd.Process.Kill()

Callers 1

setupFunction · 0.85

Calls 3

cmdFunction · 0.85
stopMethod · 0.65
StartMethod · 0.65

Tested by 1

setupFunction · 0.68