(t *testing.T)
| 1309 | } |
| 1310 | |
| 1311 | func 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 | }) |
nothing calls this directly
no test coverage detected