From f40d2601bedbdd250e2e670f27a11304a66f4b97 Mon Sep 17 00:00:00 2001 From: "j. Emrys Landivar (docmerlin)" Date: Tue, 26 Jul 2022 15:23:42 -0500 Subject: [PATCH] WIP --- alert/topics.go | 3 +++ build.py | 10 ++++++++-- integrations/streamer_test.go | 2 +- server/server.go | 1 + server/server_test.go | 9 +++------ services/removed/removed.go | 12 +++++------- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/alert/topics.go b/alert/topics.go index b34b0618e..6f1bb3c81 100644 --- a/alert/topics.go +++ b/alert/topics.go @@ -392,6 +392,9 @@ type bufHandler struct { } func newHandler(h Handler, bufferSize int) *bufHandler { + if h == nil { + panic("here h is nil") + } if bufferSize < MinimumEventBufferSize { bufferSize = DefaultEventBufferSize } diff --git a/build.py b/build.py index 0bdec206b..c51d24980 100755 --- a/build.py +++ b/build.py @@ -200,6 +200,8 @@ def run_tests(race, parallel, timeout, verbose): if timeout is not None: logging.info("Using timeout: {}".format(timeout)) + + test_command = "go test --failfast" if verbose: test_command += " -v" @@ -209,10 +211,14 @@ def run_tests(race, parallel, timeout, verbose): test_command += " -parallel {}".format(parallel) if timeout is not None: test_command += " -timeout {}".format(timeout) - test_command += " ./..." + test_command += " -p 1 {}" logging.info("Running tests...") logging.info("Test command: " + test_command) - output = run(test_command, printOutput=logging.getLogger().getEffectiveLevel() == logging.DEBUG) + packages = run("go list ./...", printOutput=logging.getLogger().getEffectiveLevel() == logging.DEBUG) + + for package in packages.split(): + if package.strip() != "": + run(test_command.format(package), printOutput=logging.getLogger().getEffectiveLevel() == logging.DEBUG) return True def package_udfs(version, dist_dir): diff --git a/integrations/streamer_test.go b/integrations/streamer_test.go index 4b2572f7e..cc4a73070 100644 --- a/integrations/streamer_test.go +++ b/integrations/streamer_test.go @@ -13812,7 +13812,7 @@ func testStreamerNoOutput( duration time.Duration, tmInit func(tm *kapacitor.TaskMaster), ) { - t.Helper() + //t.Helper() clock, et, replayErr, tm := testStreamer(t, name, script, tmInit) defer tm.Close() err := fastForwardTask(clock, et, replayErr, tm, duration) diff --git a/server/server.go b/server/server.go index ab5d2d8f1..3bc1fa6d4 100644 --- a/server/server.go +++ b/server/server.go @@ -958,6 +958,7 @@ func (s *Server) appendRemovedServices() { for name := range removed.ServiceNames { srv := removed.NewService(name, vars.Info, s.DiagService.NewRemovedHandler(name)) s.AppendService(name, srv) + s.AlertService.RemovedService = srv s.SetDynamicService(name, srv) } } diff --git a/server/server_test.go b/server/server_test.go index 9ebd5aa21..9efc28d8f 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -8024,13 +8024,10 @@ func TestServer_AlertHandlers(t *testing.T) { ts := ctxt.Value("server").(*removedtest.Server) ts.Close() got := ts.Requests() - exp := []removedtest.Request{{ - URL: "/1234567/notification?auth_token=testtoken1234567", - PostData: nil, - }} - if !reflect.DeepEqual(exp, got) { - return fmt.Errorf("unexpected hipchat request:\nexp\n%+v\ngot\n%+v\n", exp, got) + if len(got) != 0 { + fmt.Errorf("unexpected hipchat request, hipchat support has been removed:\ngot\n%+v\n", got) } + return nil }, }, diff --git a/services/removed/removed.go b/services/removed/removed.go index 945daca6c..d3cd8b287 100644 --- a/services/removed/removed.go +++ b/services/removed/removed.go @@ -4,19 +4,17 @@ import ( "fmt" "github.com/influxdata/kapacitor/alert" "github.com/influxdata/kapacitor/keyvalue" + "strings" ) -// sort the Removed services -//func init() { -// sort.Strings(RemovedServices) -//} - var ServiceNames = map[string]struct{}{ HipChatName: struct{}{}, } const HipChatName = "hipchat" +var HipChatLCName = strings.ToLower(HipChatName) + var ErrHipChatRemoved = ErrRemoved(HipChatName) func ErrRemoved(name string) error { @@ -51,7 +49,7 @@ func (s *Service) Close() error { } func (s *Service) Handle(event alert.Event) { - switch s.Name { + switch strings.ToLower(s.Name) { case HipChatName: s.diag.Error("failed to send event because service is removed", ErrHipChatRemoved) default: @@ -79,7 +77,7 @@ func (s *Service) Test(options interface{}) error { if !ok { return fmt.Errorf("unexpected options type %T", options) } - switch o.Name { + switch strings.ToLower(o.Name) { case HipChatName: return ErrHipChatRemoved default: