fix(pingEndpoint): change build type to 'oss2', use correct version (#21723)
Signed-off-by: Jakub Bednar <jakub.bednar@gmail.com>pull/21747/head
parent
156e55a6d1
commit
6aae544ac8
|
@ -45,7 +45,7 @@ type HandlerConfig struct {
|
|||
}
|
||||
|
||||
func NewHandlerConfig() *HandlerConfig {
|
||||
return &HandlerConfig{}
|
||||
return &HandlerConfig{Version: influxdb.GetBuildInfo().Version}
|
||||
}
|
||||
|
||||
// Opts returns the CLI options for use with kit/cli.
|
||||
|
|
|
@ -233,7 +233,7 @@ func TestInfluxQLdHandler_HandleQuery(t *testing.T) {
|
|||
InfluxqldQueryService: tt.fields.ProxyQueryService,
|
||||
}
|
||||
|
||||
h := NewInfluxQLHandler(b, HandlerConfig{})
|
||||
h := NewInfluxQLHandler(b, *NewHandlerConfig())
|
||||
h.Logger = zaptest.NewLogger(t)
|
||||
|
||||
if tt.context != nil {
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package legacy
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPingHandler(t *testing.T) {
|
||||
type wants struct {
|
||||
statusCode int
|
||||
version string
|
||||
build string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
w *httptest.ResponseRecorder
|
||||
r *http.Request
|
||||
wants wants
|
||||
}{
|
||||
{
|
||||
name: "GET request",
|
||||
w: httptest.NewRecorder(),
|
||||
r: httptest.NewRequest(http.MethodGet, "/ping", nil),
|
||||
wants: wants{
|
||||
statusCode: http.StatusNoContent,
|
||||
version: "2.0.0",
|
||||
build: "oss2",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "HEAD request",
|
||||
w: httptest.NewRecorder(),
|
||||
r: httptest.NewRequest(http.MethodHead, "/ping", nil),
|
||||
wants: wants{
|
||||
statusCode: http.StatusNoContent,
|
||||
version: "2.0.0",
|
||||
build: "oss2",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
NewPingHandler("2.0.0").pingHandler(tt.w, tt.r)
|
||||
res := tt.w.Result()
|
||||
build := res.Header.Get("X-Influxdb-Build")
|
||||
version := res.Header.Get("X-Influxdb-Version")
|
||||
|
||||
if res.StatusCode != tt.wants.statusCode {
|
||||
t.Errorf("%q. PingHandler() = %v, want %v", tt.name, res.StatusCode, tt.wants.statusCode)
|
||||
}
|
||||
if build != tt.wants.build {
|
||||
t.Errorf("%q. PingHandler() = %v, want %v", tt.name, build, tt.wants.build)
|
||||
}
|
||||
if version != tt.wants.version {
|
||||
t.Errorf("%q. PingHandler() = %v, want %v", tt.name, version, tt.wants.version)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ func NewPingHandler(version string) *PingHandler {
|
|||
|
||||
// handlePostLegacyWrite is the HTTP handler for the POST /write route.
|
||||
func (h *PingHandler) pingHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("X-Influxdb-Build", "cloud2")
|
||||
w.Header().Add("X-Influxdb-Build", "oss2")
|
||||
w.Header().Add("X-Influxdb-Version", h.InfluxDBVersion)
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ func NewPlatformHandler(b *APIBackend, opts ...APIHandlerOptFn) *PlatformHandler
|
|||
wrappedHandler = kithttp.SkipOptions(wrappedHandler)
|
||||
|
||||
legacyBackend := newLegacyBackend(b)
|
||||
lh := newLegacyHandler(legacyBackend, legacy.HandlerConfig{})
|
||||
lh := newLegacyHandler(legacyBackend, *legacy.NewHandlerConfig())
|
||||
|
||||
return &PlatformHandler{
|
||||
AssetHandler: assetHandler,
|
||||
|
|
Loading…
Reference in New Issue