|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package metricsink_test |
| 19 | + |
| 20 | +import ( |
| 21 | + "encoding/json" |
| 22 | + "github.com/go-chassis/go-chassis/third_party/forked/afex/hystrix-go/hystrix" |
| 23 | + "github.com/huaweicse/cse-collector/pkg/monitoring" |
| 24 | + "testing" |
| 25 | + "time" |
| 26 | +) |
| 27 | + |
| 28 | +func TestGetReporter(t *testing.T) { |
| 29 | + hystrix.Do("cmd", func() error { |
| 30 | + time.Sleep(20 * time.Millisecond) |
| 31 | + return nil |
| 32 | + }, nil) |
| 33 | + hystrix.Do("cmd", func() error { |
| 34 | + time.Sleep(10 * time.Millisecond) |
| 35 | + return nil |
| 36 | + }, nil) |
| 37 | + hystrix.Do("cmd", func() error { |
| 38 | + time.Sleep(2 * time.Millisecond) |
| 39 | + return nil |
| 40 | + }, nil) |
| 41 | + time.Sleep(1 * time.Second) |
| 42 | + data := &monitoring.MonitorData{} |
| 43 | + cb, _, _ := hystrix.GetCircuit("cmd") |
| 44 | + data.AppendInterfaceInfo(cb) |
| 45 | + b, _ := json.MarshalIndent(data, "", " ") |
| 46 | + t.Log(string(b)) |
| 47 | +} |
0 commit comments