(t *testing.T)
| 677 | } |
| 678 | |
| 679 | func TestMetrics(t *testing.T) { |
| 680 | var wg sync.WaitGroup |
| 681 | tester := caddytest.NewTester(t) |
| 682 | initServer(t, tester, ` |
| 683 | { |
| 684 | skip_install_trust |
| 685 | admin localhost:2999 |
| 686 | http_port `+testPort+` |
| 687 | https_port 9443 |
| 688 | metrics |
| 689 | } |
| 690 | |
| 691 | localhost:`+testPort+` { |
| 692 | route { |
| 693 | mercure { |
| 694 | transport local |
| 695 | anonymous |
| 696 | publisher_jwt !ChangeMe! |
| 697 | } |
| 698 | |
| 699 | php { |
| 700 | root ../testdata |
| 701 | } |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | example.com:`+testPort+` { |
| 706 | route { |
| 707 | mercure { |
| 708 | transport local |
| 709 | anonymous |
| 710 | publisher_jwt !ChangeMe! |
| 711 | } |
| 712 | |
| 713 | php { |
| 714 | root ../testdata |
| 715 | } |
| 716 | } |
| 717 | } |
| 718 | `, "caddyfile") |
| 719 | |
| 720 | // Make some requests |
| 721 | for i := range 10 { |
| 722 | wg.Add(1) |
| 723 | go func(i int) { |
| 724 | tester.AssertGetResponse(fmt.Sprintf("http://localhost:"+testPort+"/index.php?i=%d", i), http.StatusOK, fmt.Sprintf("I am by birth a Genevese (%d)", i)) |
| 725 | wg.Done() |
| 726 | }(i) |
| 727 | } |
| 728 | wg.Wait() |
| 729 | |
| 730 | // Fetch metrics |
| 731 | resp, err := http.Get("http://localhost:2999/metrics") |
| 732 | require.NoError(t, err, "failed to fetch metrics") |
| 733 | t.Cleanup(func() { |
| 734 | require.NoError(t, resp.Body.Close()) |
| 735 | }) |
| 736 |
nothing calls this directly
no test coverage detected