Skip to content

fix(pingEndpoint): change build type to 'oss2', use correct version #21723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion http/legacy/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion http/legacy/influxqld_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
60 changes: 60 additions & 0 deletions http/legacy/ping_handle_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
})
}
}
2 changes: 1 addition & 1 deletion http/legacy/ping_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion http/platform_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down