MM-13027: Don't have a diagnostics segment key in dev builds. (#9938)
* MM-13027: Don't have a diagnostics segment key in dev builds. * Fix tests.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
dbd3801271
Коммит
487f82f30e
@@ -14,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SEGMENT_KEY = "fwb7VPbFeQ7SKp3wHm1RzFUuXZudqVok"
|
SEGMENT_KEY = "placeholder_segment_key"
|
||||||
|
|
||||||
TRACK_CONFIG_SERVICE = "config_service"
|
TRACK_CONFIG_SERVICE = "config_service"
|
||||||
TRACK_CONFIG_TEAM = "config_team"
|
TRACK_CONFIG_TEAM = "config_team"
|
||||||
@@ -59,7 +59,11 @@ const (
|
|||||||
var client *analytics.Client
|
var client *analytics.Client
|
||||||
|
|
||||||
func (a *App) SendDailyDiagnostics() {
|
func (a *App) SendDailyDiagnostics() {
|
||||||
if *a.Config().LogSettings.EnableDiagnostics && a.IsLeader() {
|
a.sendDailyDiagnostics(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) sendDailyDiagnostics(override bool) {
|
||||||
|
if *a.Config().LogSettings.EnableDiagnostics && a.IsLeader() && (!strings.Contains(SEGMENT_KEY, "placeholder") || override) {
|
||||||
a.initDiagnostics("")
|
a.initDiagnostics("")
|
||||||
a.trackActivity()
|
a.trackActivity()
|
||||||
a.trackConfig()
|
a.trackConfig()
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ func TestDiagnostics(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("SendDailyDiagnostics", func(t *testing.T) {
|
t.Run("SendDailyDiagnostics", func(t *testing.T) {
|
||||||
th.App.SendDailyDiagnostics()
|
th.App.sendDailyDiagnostics(true)
|
||||||
|
|
||||||
info := ""
|
info := ""
|
||||||
// Collect the info sent.
|
// Collect the info sent.
|
||||||
@@ -147,10 +147,21 @@ func TestDiagnostics(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("SendDailyDiagnosticsNoSegmentKey", func(t *testing.T) {
|
||||||
|
th.App.SendDailyDiagnostics()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-data:
|
||||||
|
t.Fatal("Should not send diagnostics when the segment key is not set")
|
||||||
|
case <-time.After(time.Second * 1):
|
||||||
|
// Did not receive diagnostics
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("SendDailyDiagnosticsDisabled", func(t *testing.T) {
|
t.Run("SendDailyDiagnosticsDisabled", func(t *testing.T) {
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.LogSettings.EnableDiagnostics = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.LogSettings.EnableDiagnostics = false })
|
||||||
|
|
||||||
th.App.SendDailyDiagnostics()
|
th.App.sendDailyDiagnostics(true)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-data:
|
case <-data:
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user