diff --git a/ChangeLog.md b/ChangeLog.md index 43c40c7..94ee89c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,13 @@ to [Semantic Versioning](http://semver.org/) rules. ## [Next Release] +## [v1.13.1] - 2023-02-23 + +* upd: Modifies the PromQLResponse and PromQLError types to support more types +of PromQL data values. +* upd: Updates unit tests and examples to use NewClient(). +* upd: Ensures default values are set for snowth client timeouts. + ## [v1.13.0] - 2023-02-23 * fix: Corrects a bug that could cause snowth client creation to fail if a @@ -453,6 +460,7 @@ writing to histogram endpoints. any delay, once started. Created: 2019-03-12. Fixed: 2019-03-13. [Next Release]: https://github.com/circonus-labs/gosnowth +[v1.13.1]: https://github.com/circonus-labs/gosnowth/releases/tag/v1.13.1 [v1.13.0]: https://github.com/circonus-labs/gosnowth/releases/tag/v1.13.0 [v1.12.5]: https://github.com/circonus-labs/gosnowth/releases/tag/v1.12.5 [v1.12.4]: https://github.com/circonus-labs/gosnowth/releases/tag/v1.12.4 diff --git a/activity_test.go b/activity_test.go index 038b61c..f0cd38c 100644 --- a/activity_test.go +++ b/activity_test.go @@ -53,7 +53,8 @@ func TestRebuildActivity(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/caql_test.go b/caql_test.go index 84f9a5f..d402d77 100644 --- a/caql_test.go +++ b/caql_test.go @@ -1,6 +1,7 @@ package gosnowth import ( + "context" "io" "net/http" "net/http/httptest" @@ -86,7 +87,8 @@ func TestGetCAQLQuery(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/client.go b/client.go index a8c4c09..45aa2ff 100644 --- a/client.go +++ b/client.go @@ -143,6 +143,14 @@ type SnowthClient struct { func NewClient(ctx context.Context, cfg *Config, logs ...Logger, ) (*SnowthClient, error) { + if cfg.Timeout == 0 { + cfg.Timeout = time.Second * 10 + } + + if cfg.DialTimeout == 0 { + cfg.DialTimeout = time.Millisecond * 500 + } + client := &http.Client{ Timeout: cfg.Timeout, Transport: &http.Transport{ diff --git a/client_test.go b/client_test.go index 8d22003..245db49 100644 --- a/client_test.go +++ b/client_test.go @@ -34,18 +34,6 @@ func TestSnowthNode(t *testing.T) { } } -func TestNewSnowthClient(t *testing.T) { - t.Parallel() - - // crude test to ensure err is returned for invalid snowth url - badAddr := "foobar" - - _, err := NewSnowthClient(false, badAddr) - if err == nil { - t.Errorf("Error not encountered on invalid snowth addr %v", badAddr) - } -} - func TestNewClientTimeout(t *testing.T) { t.Parallel() @@ -59,7 +47,7 @@ func TestNewClientTimeout(t *testing.T) { t.Error("Error expected for new client timeout test") } - if !strings.Contains(err.Error(), "context deadline exceeded") { + if !strings.Contains(err.Error(), "no snowth nodes could be activated") { t.Errorf("Expected context error, got: %v", err.Error()) } } @@ -95,7 +83,8 @@ func TestSnowthClientRequest(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -195,7 +184,8 @@ func TestSnowthClientDiscoverNodesWatch(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(true, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -324,7 +314,8 @@ func TestSnowthClientLog(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(true, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/common_test.go b/common_test.go index bcd97d1..af0f700 100644 --- a/common_test.go +++ b/common_test.go @@ -3,7 +3,6 @@ package gosnowth import ( "bytes" "encoding/xml" - "fmt" "io" "net/http" "net/url" @@ -43,27 +42,6 @@ func TestResolveURL(t *testing.T) { } } -func TestMultiError(t *testing.T) { - t.Parallel() - - me := newMultiError() - if me.HasError() { - t.Error("Should have no errors yet") - } - - me.Add(fmt.Errorf("error 1")) - me.Add(fmt.Errorf("error 2")) - me.Add(nil) - - if !me.HasError() { - t.Error("Should have errors") - } - - if res, exp := me.Error(), "error 1; error 2"; res != exp { - t.Errorf("Expected result: %v, got: %v", exp, res) - } -} - func TestDecodeJSON(t *testing.T) { t.Parallel() diff --git a/examples/retrieval.go b/examples/retrieval.go index 8dfc626..e3d0924 100644 --- a/examples/retrieval.go +++ b/examples/retrieval.go @@ -15,7 +15,6 @@ import ( func ExampleReadNNT() { // Create a new client. cfg := gosnowth.NewConfig(SnowthServers...) - cfg.Discover = true client, err := gosnowth.NewClient(context.Background(), cfg) if err != nil { @@ -61,7 +60,6 @@ func ExampleReadNNT() { func ExampleReadText() { // Create a new client. cfg := gosnowth.NewConfig(SnowthServers...) - cfg.Discover = true client, err := gosnowth.NewClient(context.Background(), cfg) if err != nil { @@ -94,7 +92,8 @@ func ExampleFetchQuery() { return } - sc, err := gosnowth.NewSnowthClient(false, host) + sc, err := gosnowth.NewClient(context.Background(), + &gosnowth.Config{Servers: []string{host}}) if err != nil { log.Fatal("Unable to create snowth client", err) } @@ -144,7 +143,8 @@ func ExampleFetchQueryMultiStream() { return } - sc, err := gosnowth.NewSnowthClient(false, host) + sc, err := gosnowth.NewClient(context.Background(), + &gosnowth.Config{Servers: []string{host}}) if err != nil { log.Fatal("Unable to create snowth client", err) } @@ -182,7 +182,8 @@ func ExampleCAQLQuery() { return } - sc, err := gosnowth.NewSnowthClient(false, host) + sc, err := gosnowth.NewClient(context.Background(), + &gosnowth.Config{Servers: []string{host}}) if err != nil { log.Fatal("Unable to create snowth client", err) } @@ -216,7 +217,8 @@ func ExampleGetCheckTags() { return } - sc, err := gosnowth.NewSnowthClient(false, host) + sc, err := gosnowth.NewClient(context.Background(), + &gosnowth.Config{Servers: []string{host}}) if err != nil { log.Fatal("Unable to create snowth client", err) } diff --git a/examples/state.go b/examples/state.go index 317f91b..dade128 100644 --- a/examples/state.go +++ b/examples/state.go @@ -12,7 +12,6 @@ import ( func ExampleGetNodeState() { // Create a new client. cfg := gosnowth.NewConfig(SnowthServers...) - cfg.Discover = true client, err := gosnowth.NewClient(context.Background(), cfg) if err != nil { @@ -34,7 +33,6 @@ func ExampleGetNodeState() { func ExampleGetNodeGossip() { // Create a new client. cfg := gosnowth.NewConfig(SnowthServers...) - cfg.Discover = true client, err := gosnowth.NewClient(context.Background(), cfg) if err != nil { @@ -56,7 +54,6 @@ func ExampleGetNodeGossip() { func ExampleGetTopology() { // Create a new client. cfg := gosnowth.NewConfig(SnowthServers...) - cfg.Discover = true client, err := gosnowth.NewClient(context.Background(), cfg) if err != nil { diff --git a/examples/submission.go b/examples/submission.go index 03a5431..00c9946 100644 --- a/examples/submission.go +++ b/examples/submission.go @@ -19,7 +19,6 @@ import ( func ExampleSubmitText() { // Create a new client. cfg := gosnowth.NewConfig(SnowthServers...) - cfg.Discover = true client, err := gosnowth.NewClient(context.Background(), cfg) if err != nil { @@ -43,7 +42,6 @@ func ExampleSubmitText() { func ExampleSubmitNNT() { // Create a new client. cfg := gosnowth.NewConfig(SnowthServers...) - cfg.Discover = true client, err := gosnowth.NewClient(context.Background(), cfg) if err != nil { @@ -76,7 +74,6 @@ func ExampleSubmitNNT() { func ExampleSubmitHistogram() { // Create a new client. cfg := gosnowth.NewConfig(SnowthServers...) - cfg.Discover = true client, err := gosnowth.NewClient(context.Background(), cfg) if err != nil { @@ -113,7 +110,8 @@ func ExampleWriteRawMetricList(b *testing.B) { return } - sc, err := gosnowth.NewSnowthClient(false, host) + sc, err := gosnowth.NewClient(context.Background(), + &gosnowth.Config{Servers: []string{host}}) if err != nil { log.Fatal("Unable to create snowth client", err) } @@ -160,7 +158,8 @@ func ExampleBulkWriteRawMetricList(b *testing.B) { return } - sc, err := gosnowth.NewSnowthClient(false, host) + sc, err := gosnowth.NewClient(context.Background(), + &gosnowth.Config{Servers: []string{host}}) if err != nil { log.Fatal("Unable to create snowth client", err) } diff --git a/fetch_test.go b/fetch_test.go index f8193d2..9a89a6f 100644 --- a/fetch_test.go +++ b/fetch_test.go @@ -2,6 +2,7 @@ package gosnowth import ( "bytes" + "context" "encoding/json" "net/http" "net/http/httptest" @@ -115,7 +116,8 @@ func TestFetchQuery(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/gossip_test.go b/gossip_test.go index 55d3522..33f216a 100644 --- a/gossip_test.go +++ b/gossip_test.go @@ -160,7 +160,8 @@ func TestGetGossipInfo(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/graphite_test.go b/graphite_test.go index 0a46ef2..b869cfa 100644 --- a/graphite_test.go +++ b/graphite_test.go @@ -1,6 +1,7 @@ package gosnowth import ( + "context" "net/http" "net/http/httptest" "net/url" @@ -62,7 +63,8 @@ func TestGraphiteFindMetrics(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -118,7 +120,8 @@ func TestGraphiteFindTags(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -174,7 +177,8 @@ func TestGraphiteGetDatapoints(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/histogram_test.go b/histogram_test.go index 17867a8..625fd55 100644 --- a/histogram_test.go +++ b/histogram_test.go @@ -2,6 +2,7 @@ package gosnowth import ( "bytes" + "context" "encoding/json" "net/http" "net/http/httptest" @@ -112,7 +113,8 @@ func TestReadHistogramValues(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -199,7 +201,8 @@ func TestWriteHistogram(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/location_test.go b/location_test.go index 085a07a..45c9de0 100644 --- a/location_test.go +++ b/location_test.go @@ -2,6 +2,7 @@ package gosnowth import ( "bytes" + "context" "encoding/xml" "net/http" "net/http/httptest" @@ -133,7 +134,8 @@ func TestLocateMetric(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -196,7 +198,8 @@ func TestLocateMetricFindMetric(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/lua_test.go b/lua_test.go index 3daf314..9875491 100644 --- a/lua_test.go +++ b/lua_test.go @@ -1,6 +1,7 @@ package gosnowth import ( + "context" "net/http" "net/http/httptest" "net/url" @@ -84,7 +85,8 @@ func TestGetLuaExtension(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -172,7 +174,8 @@ func TestExecLuaExtensionContext(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/nnt_test.go b/nnt_test.go index 871f729..817479d 100644 --- a/nnt_test.go +++ b/nnt_test.go @@ -2,6 +2,7 @@ package gosnowth import ( "bytes" + "context" "encoding/json" "net/http" "net/http/httptest" @@ -171,7 +172,8 @@ func TestNNTReadWrite(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/nntbs_test.go b/nntbs_test.go index 323758e..d5028a7 100644 --- a/nntbs_test.go +++ b/nntbs_test.go @@ -1,6 +1,7 @@ package gosnowth import ( + "context" "io" "net/http" "net/http/httptest" @@ -56,7 +57,8 @@ func TestWriteNNTBSFlatbuffer(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/numeric_test.go b/numeric_test.go index 256437c..c05dacd 100644 --- a/numeric_test.go +++ b/numeric_test.go @@ -2,6 +2,7 @@ package gosnowth import ( "bytes" + "context" "encoding/json" "net/http" "net/http/httptest" @@ -171,7 +172,8 @@ func TestNumericReadWrite(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/promql.go b/promql.go index 34b7c21..9909b7b 100644 --- a/promql.go +++ b/promql.go @@ -29,20 +29,20 @@ type PromQLRangeQuery struct { // decoder, and is left to subsequent parsing and decoding by the user. // This is intentional to avoid tight coupling to PromQL protocol formats. type PromQLResponse struct { - Status string `json:"status,omitempty"` - Data map[string]interface{} `json:"data,omitempty"` - ErrorType string `json:"errorType,omitempty"` - Error string `json:"error,omitempty"` - Warnings []string `json:"warnings,omitempty"` + Status string `json:"status,omitempty"` + Data interface{} `json:"data,omitempty"` + ErrorType string `json:"errorType,omitempty"` + Error string `json:"error,omitempty"` + Warnings []string `json:"warnings,omitempty"` } // PromQLError values represent a PromQL response envelope containing an error. type PromQLError struct { - Status string `json:"status,omitempty"` - Data map[string]interface{} `json:"data,omitempty"` - ErrorType string `json:"errorType,omitempty"` - Err string `json:"error,omitempty"` - Warnings []string `json:"warnings,omitempty"` + Status string `json:"status,omitempty"` + Data interface{} `json:"data,omitempty"` + ErrorType string `json:"errorType,omitempty"` + Err string `json:"error,omitempty"` + Warnings []string `json:"warnings,omitempty"` } // String returns this value as a JSON format string. diff --git a/promql_test.go b/promql_test.go index d10550c..20ecb18 100644 --- a/promql_test.go +++ b/promql_test.go @@ -1,6 +1,7 @@ package gosnowth import ( + "context" "io" "net/http" "net/http/httptest" @@ -98,7 +99,8 @@ func TestPromQLRangeQuery(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -124,8 +126,8 @@ func TestPromQLRangeQuery(t *testing.T) { t.Fatal(err) } - if len(res.Data) != 2 { - t.Fatalf("Expected data length: 2, got: %v", len(res.Data)) + if res.Data == nil { + t.Fatalf("Expected data: 2, got: %v", res.Data) } res, err = sc.PromQLRangeQuery(&PromQLRangeQuery{ diff --git a/raw_test.go b/raw_test.go index e0d80c6..d0389d0 100644 --- a/raw_test.go +++ b/raw_test.go @@ -60,7 +60,8 @@ func TestWriteRaw(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -133,7 +134,8 @@ func TestReadRawNumericValues(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -200,7 +202,8 @@ func TestWriteRawMetricList(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -249,7 +252,8 @@ func BenchmarkWriteRawFlatbuffer(b *testing.B) { b.StopTimer() - sc, err := NewSnowthClient(false, host) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{host}}) if err != nil { b.Fatal("Unable to create snowth client", err) } @@ -302,7 +306,8 @@ func BenchmarkWriteRawMetricList(b *testing.B) { b.StopTimer() - sc, err := NewSnowthClient(false, host) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{host}}) if err != nil { b.Fatal("Unable to create snowth client", err) } @@ -384,7 +389,8 @@ func BenchmarkWriteRawMetricListLocal(b *testing.B) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { b.Fatal("Unable to create snowth client", err) } diff --git a/rollup_test.go b/rollup_test.go index 5430ed6..51f406b 100644 --- a/rollup_test.go +++ b/rollup_test.go @@ -2,6 +2,7 @@ package gosnowth import ( "bytes" + "context" "encoding/json" "net/http" "net/http/httptest" @@ -191,7 +192,8 @@ func TestReadRollupValues(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -253,7 +255,8 @@ func TestReadRollupAllValues(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/stats_test.go b/stats_test.go index 608f12a..e7f2567 100644 --- a/stats_test.go +++ b/stats_test.go @@ -1,6 +1,7 @@ package gosnowth import ( + "context" "net/http" "net/http/httptest" "net/url" @@ -64,7 +65,8 @@ func TestGetStats(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/tags_test.go b/tags_test.go index 6f4c20a..9db9bca 100644 --- a/tags_test.go +++ b/tags_test.go @@ -2,6 +2,7 @@ package gosnowth import ( "bytes" + "context" "encoding/json" "net/http" "net/http/httptest" @@ -134,7 +135,8 @@ func TestFindTags(t *testing.T) { //nolint:gocyclo defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -309,7 +311,8 @@ func TestFindTagCats(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -363,7 +366,8 @@ func TestFindTagVals(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -416,7 +420,8 @@ func TestGetCheckTags(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -469,7 +474,8 @@ func TestDeleteCheckTags(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -514,7 +520,8 @@ func TestUpdateCheckTags(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/text_test.go b/text_test.go index 3ec024f..a3cb81a 100644 --- a/text_test.go +++ b/text_test.go @@ -1,6 +1,7 @@ package gosnowth import ( + "context" "encoding/json" "net/http" "net/http/httptest" @@ -51,7 +52,8 @@ func TestReadTextValuesFindMetricNode(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -105,7 +107,8 @@ func TestReadTextValues(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -166,7 +169,8 @@ func TestWriteText(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } diff --git a/topology_test.go b/topology_test.go index 4ae1b76..9a8e71b 100644 --- a/topology_test.go +++ b/topology_test.go @@ -2,6 +2,7 @@ package gosnowth import ( "bytes" + "context" "encoding/json" "encoding/xml" "net/http" @@ -174,7 +175,8 @@ func TestLiveNode(t *testing.T) { nids := 10 nmetrics := 10 - sc, err := NewSnowthClient(false, base) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) } @@ -250,7 +252,8 @@ func TestTopology(t *testing.T) { defer ms.Close() - sc, err := NewSnowthClient(false, ms.URL) + sc, err := NewClient(context.Background(), + &Config{Servers: []string{ms.URL}}) if err != nil { t.Fatal("Unable to create snowth client", err) }