client_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package victoriametrics
  15. func newTestClient(ep string) (Client, error) {
  16. return NewClient(ep)
  17. }
  18. /*func Test_client_QueryRange(t *testing.T) {
  19. cli, err := newTestClient("http://192.168.222.171:34795/")
  20. if err != nil {
  21. t.Fatalf("newTestClient")
  22. }
  23. resp, err := cli.QueryRange(context.Background(), http.DefaultClient, `avg by(host_id) (avg_over_time(cpu_usage_active{res_type="host"}))`, time.Second*50, &TimeRange{
  24. Start: 1698724482.213,
  25. End: 1698746082.213,
  26. }, true)
  27. if err != nil {
  28. t.Fatalf("query err: %v", err)
  29. }
  30. log.Infof("get resp: %s", jsonutils.Marshal(resp).PrettyString())
  31. }*/