MCPcopy Create free account
hub / github.com/php/frankenphp / TestMultiWorkersMetrics

Function TestMultiWorkersMetrics

caddy/caddy_test.go:1311–1418  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1309}
1310
1311func TestMultiWorkersMetrics(t *testing.T) {
1312 var wg sync.WaitGroup
1313 tester := caddytest.NewTester(t)
1314 initServer(t, tester, `
1315 {
1316 skip_install_trust
1317 admin localhost:2999
1318 http_port `+testPort+`
1319 https_port 9443
1320 metrics
1321
1322 frankenphp {
1323 worker {
1324 name service1
1325 file ../testdata/index.php
1326 num 2
1327 }
1328 worker {
1329 name service2
1330 file ../testdata/ini.php
1331 num 3
1332 }
1333 }
1334 }
1335
1336 localhost:`+testPort+` {
1337 route {
1338 php {
1339 root ../testdata
1340 }
1341 }
1342 }
1343
1344 example.com:`+testPort+` {
1345 route {
1346 php {
1347 root ../testdata
1348 }
1349 }
1350 }
1351 `, "caddyfile")
1352
1353 // Make some requests
1354 for i := range 10 {
1355 wg.Add(1)
1356 go func(i int) {
1357 tester.AssertGetResponse(fmt.Sprintf("http://localhost:"+testPort+"/index.php?i=%d", i), http.StatusOK, fmt.Sprintf("I am by birth a Genevese (%d)", i))
1358 wg.Done()
1359 }(i)
1360 }
1361 wg.Wait()
1362
1363 // Fetch metrics
1364 resp, err := http.Get("http://localhost:2999/metrics")
1365 require.NoError(t, err, "failed to fetch metrics")
1366 t.Cleanup(func() {
1367 require.NoError(t, resp.Body.Close())
1368 })

Callers

nothing calls this directly

Calls 4

initServerFunction · 0.85
getNumThreadsFunction · 0.85
GetMethod · 0.80
CloseMethod · 0.80

Tested by

no test coverage detected