MCPcopy
hub / github.com/cloudflare/cloudflared / TestConcurrentUpdateAndRead

Function TestConcurrentUpdateAndRead

orchestration/orchestrator_test.go:249–406  ·  view source on GitHub ↗

TestConcurrentUpdateAndRead makes sure orchestrator can receive updates and return origin proxy concurrently

(t *testing.T)

Source from the content-addressed store, hash-verified

247
248// TestConcurrentUpdateAndRead makes sure orchestrator can receive updates and return origin proxy concurrently
249func TestConcurrentUpdateAndRead(t *testing.T) {
250 const (
251 concurrentRequests = 200
252 hostname = "public.tunnels.org"
253 expectedHost = "internal.tunnels.svc.cluster.local"
254 tcpBody = "testProxyTCP"
255 )
256
257 httpOrigin := httptest.NewServer(&validateHostHandler{
258 expectedHost: expectedHost,
259 body: t.Name(),
260 })
261 defer httpOrigin.Close()
262
263 tcpOrigin, err := net.Listen("tcp", "127.0.0.1:0")
264 require.NoError(t, err)
265 defer tcpOrigin.Close()
266
267 originDialer := ingress.NewOriginDialer(ingress.OriginConfig{
268 DefaultDialer: testDefaultDialer,
269 TCPWriteTimeout: 1 * time.Second,
270 }, &testLogger)
271
272 var (
273 configJSONV1 = []byte(fmt.Sprintf(`
274{
275 "originRequest": {
276 "connectTimeout": 90,
277 "noHappyEyeballs": true
278 },
279 "ingress": [
280 {
281 "hostname": "%s",
282 "service": "%s",
283 "originRequest": {
284 "httpHostHeader": "%s",
285 "connectTimeout": 10
286 }
287 },
288 {
289 "service": "http_status:404"
290 }
291 ],
292 "warp-routing": {
293 }
294}
295`, hostname, httpOrigin.URL, expectedHost))
296 configJSONV2 = []byte(`
297{
298 "ingress": [
299 {
300 "service": "http_status:204"
301 }
302 ],
303 "warp-routing": {
304 }
305}
306`)

Callers

nothing calls this directly

Calls 15

GetOriginProxyMethod · 0.95
NewOriginDialerFunction · 0.92
NewOrchestratorFunction · 0.85
updateWithValidationFunction · 0.85
serveTCPOriginFunction · 0.85
proxyHTTPFunction · 0.85
newRespReadWriteFlusherFunction · 0.85
tcpEyeballFunction · 0.85
proxyTCPFunction · 0.85
AddrMethod · 0.80
WaitMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected