mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
Use http constants instead of string (#5908)
Signed-off-by: Fish-pro <zechun.chen@daocloud.io>
This commit is contained in:
@@ -22,7 +22,7 @@ func TestHealth(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to query %s: %v", address, err)
|
t.Fatalf("Unable to query %s: %v", address, err)
|
||||||
}
|
}
|
||||||
if response.StatusCode != 200 {
|
if response.StatusCode != http.StatusOK {
|
||||||
t.Errorf("Invalid status code: expecting '200', got '%d'", response.StatusCode)
|
t.Errorf("Invalid status code: expecting '200', got '%d'", response.StatusCode)
|
||||||
}
|
}
|
||||||
content, err := io.ReadAll(response.Body)
|
content, err := io.ReadAll(response.Body)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func TestReady(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to query %s: %v", address, err)
|
t.Fatalf("Unable to query %s: %v", address, err)
|
||||||
}
|
}
|
||||||
if response.StatusCode != 503 {
|
if response.StatusCode != http.StatusServiceUnavailable {
|
||||||
t.Errorf("Invalid status code: expecting %d, got %d", 503, response.StatusCode)
|
t.Errorf("Invalid status code: expecting %d, got %d", 503, response.StatusCode)
|
||||||
}
|
}
|
||||||
response.Body.Close()
|
response.Body.Close()
|
||||||
@@ -48,7 +48,7 @@ func TestReady(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to query %s: %v", address, err)
|
t.Fatalf("Unable to query %s: %v", address, err)
|
||||||
}
|
}
|
||||||
if response.StatusCode != 200 {
|
if response.StatusCode != http.StatusOK {
|
||||||
t.Errorf("Invalid status code: expecting %d, got %d", 200, response.StatusCode)
|
t.Errorf("Invalid status code: expecting %d, got %d", 200, response.StatusCode)
|
||||||
}
|
}
|
||||||
response.Body.Close()
|
response.Body.Close()
|
||||||
@@ -62,7 +62,7 @@ func TestReady(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to query %s: %v", address, err)
|
t.Fatalf("Unable to query %s: %v", address, err)
|
||||||
}
|
}
|
||||||
if response.StatusCode != 200 {
|
if response.StatusCode != http.StatusOK {
|
||||||
t.Errorf("Invalid status code: expecting %d, got %d", 200, response.StatusCode)
|
t.Errorf("Invalid status code: expecting %d, got %d", 200, response.StatusCode)
|
||||||
}
|
}
|
||||||
response.Body.Close()
|
response.Body.Close()
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
//
|
//
|
||||||
// result := Scrape("http://localhost:9153/metrics")
|
// result := Scrape("http://localhost:9153/metrics")
|
||||||
// v := MetricValue("coredns_cache_capacity", result)
|
// v := MetricValue("coredns_cache_capacity", result)
|
||||||
//
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -217,7 +216,7 @@ func makeBuckets(m *dto.Metric) map[string]string {
|
|||||||
|
|
||||||
func fetchMetricFamilies(url string, ch chan<- *dto.MetricFamily) {
|
func fetchMetricFamilies(url string, ch chan<- *dto.MetricFamily) {
|
||||||
defer close(ch)
|
defer close(ch)
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest(http.MethodGet, url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package trace
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -152,7 +153,7 @@ func TestTrace_DOH_TraceHeaderExtraction(t *testing.T) {
|
|||||||
}
|
}
|
||||||
q := new(dns.Msg).SetQuestion("example.net.", dns.TypeA)
|
q := new(dns.Msg).SetQuestion("example.net.", dns.TypeA)
|
||||||
|
|
||||||
req := httptest.NewRequest("POST", "/dns-query", nil)
|
req := httptest.NewRequest(http.MethodPost, "/dns-query", nil)
|
||||||
|
|
||||||
outsideSpan := m.StartSpan("test-header-span")
|
outsideSpan := m.StartSpan("test-header-span")
|
||||||
outsideSpan.Tracer().Inject(outsideSpan.Context(), opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(req.Header))
|
outsideSpan.Tracer().Inject(outsideSpan.Context(), opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(req.Header))
|
||||||
|
|||||||
Reference in New Issue
Block a user