From d8603117848c9aeb897da7b758ffa3ab704740f4 Mon Sep 17 00:00:00 2001 From: TeoV Date: Tue, 23 Oct 2018 08:00:21 -0400 Subject: [PATCH] Check Events cache in stats metrics for ID instead of TenantID --- engine/libstats.go | 10 +- engine/statmetrics.go | 76 +++++++-------- engine/statmetrics_test.go | 188 ++++++++++++++++++------------------- 3 files changed, 137 insertions(+), 137 deletions(-) diff --git a/engine/libstats.go b/engine/libstats.go index 2dbbbfa5b..74b8fdb9c 100644 --- a/engine/libstats.go +++ b/engine/libstats.go @@ -143,10 +143,10 @@ func (sq *StatQueue) ProcessEvent(ev *utils.CGREvent) (err error) { } // remStatEvent removes an event from metrics -func (sq *StatQueue) remEventWithID(evTenantID string) { +func (sq *StatQueue) remEventWithID(evID string) { for metricID, metric := range sq.SQMetrics { - if err := metric.RemEvent(evTenantID); err != nil { - utils.Logger.Warning(fmt.Sprintf(" metricID: %s, remove eventID: %s, error: %s", metricID, evTenantID, err.Error())) + if err := metric.RemEvent(evID); err != nil { + utils.Logger.Warning(fmt.Sprintf(" metricID: %s, remove eventID: %s, error: %s", metricID, evID, err.Error())) } } } @@ -192,12 +192,12 @@ func (sq *StatQueue) addStatEvent(ev *utils.CGREvent) { struct { EventID string ExpiryTime *time.Time - }{ev.TenantID(), expTime}) + }{ev.ID, expTime}) for metricID, metric := range sq.SQMetrics { if err := metric.AddEvent(ev); err != nil { utils.Logger.Warning(fmt.Sprintf(" metricID: %s, add eventID: %s, error: %s", - metricID, ev.TenantID(), err.Error())) + metricID, ev.ID, err.Error())) } } } diff --git a/engine/statmetrics.go b/engine/statmetrics.go index 3a5e74150..ebe33f987 100644 --- a/engine/statmetrics.go +++ b/engine/statmetrics.go @@ -115,7 +115,7 @@ func (asr *StatASR) AddEvent(ev *utils.CGREvent) (err error) { } else if !at.IsZero() { answered = true } - asr.Events[ev.TenantID()] = answered + asr.Events[ev.ID] = answered asr.Count += 1 if answered { asr.Answered += 1 @@ -124,8 +124,8 @@ func (asr *StatASR) AddEvent(ev *utils.CGREvent) (err error) { return } -func (asr *StatASR) RemEvent(evTenantID string) (err error) { - answered, has := asr.Events[evTenantID] +func (asr *StatASR) RemEvent(evID string) (err error) { + answered, has := asr.Events[evID] if !has { return utils.ErrNotFound } @@ -133,7 +133,7 @@ func (asr *StatASR) RemEvent(evTenantID string) (err error) { asr.Answered -= 1 } asr.Count -= 1 - delete(asr.Events, evTenantID) + delete(asr.Events, evID) asr.val = nil return } @@ -209,14 +209,14 @@ func (acd *StatACD) AddEvent(ev *utils.CGREvent) (err error) { acd.Sum += duration } } - acd.Events[ev.TenantID()] = value + acd.Events[ev.ID] = value acd.Count += 1 acd.val = nil return } -func (acd *StatACD) RemEvent(evTenantID string) (err error) { - duration, has := acd.Events[evTenantID] +func (acd *StatACD) RemEvent(evID string) (err error) { + duration, has := acd.Events[evID] if !has { return utils.ErrNotFound } @@ -224,7 +224,7 @@ func (acd *StatACD) RemEvent(evTenantID string) (err error) { acd.Sum -= duration } acd.Count -= 1 - delete(acd.Events, evTenantID) + delete(acd.Events, evID) acd.val = nil return } @@ -298,14 +298,14 @@ func (tcd *StatTCD) AddEvent(ev *utils.CGREvent) (err error) { } } - tcd.Events[ev.TenantID()] = value + tcd.Events[ev.ID] = value tcd.Count += 1 tcd.val = nil return } -func (tcd *StatTCD) RemEvent(evTenantID string) (err error) { - duration, has := tcd.Events[evTenantID] +func (tcd *StatTCD) RemEvent(evID string) (err error) { + duration, has := tcd.Events[evID] if !has { return utils.ErrNotFound } @@ -313,7 +313,7 @@ func (tcd *StatTCD) RemEvent(evTenantID string) (err error) { tcd.Sum -= duration } tcd.Count -= 1 - delete(tcd.Events, evTenantID) + delete(tcd.Events, evID) tcd.val = nil return } @@ -384,14 +384,14 @@ func (acc *StatACC) AddEvent(ev *utils.CGREvent) (err error) { acc.Sum += cost } } - acc.Events[ev.TenantID()] = value + acc.Events[ev.ID] = value acc.Count += 1 acc.val = nil return } -func (acc *StatACC) RemEvent(evTenantID string) (err error) { - cost, has := acc.Events[evTenantID] +func (acc *StatACC) RemEvent(evID string) (err error) { + cost, has := acc.Events[evID] if !has { return utils.ErrNotFound } @@ -399,7 +399,7 @@ func (acc *StatACC) RemEvent(evTenantID string) (err error) { acc.Sum -= cost } acc.Count -= 1 - delete(acc.Events, evTenantID) + delete(acc.Events, evID) acc.val = nil return } @@ -470,14 +470,14 @@ func (tcc *StatTCC) AddEvent(ev *utils.CGREvent) (err error) { tcc.Sum += cost } } - tcc.Events[ev.TenantID()] = value + tcc.Events[ev.ID] = value tcc.Count += 1 tcc.val = nil return } -func (tcc *StatTCC) RemEvent(evTenantID string) (err error) { - cost, has := tcc.Events[evTenantID] +func (tcc *StatTCC) RemEvent(evID string) (err error) { + cost, has := tcc.Events[evID] if !has { return utils.ErrNotFound } @@ -485,7 +485,7 @@ func (tcc *StatTCC) RemEvent(evTenantID string) (err error) { tcc.Sum -= cost } tcc.Count -= 1 - delete(tcc.Events, evTenantID) + delete(tcc.Events, evID) tcc.val = nil return } @@ -560,14 +560,14 @@ func (pdd *StatPDD) AddEvent(ev *utils.CGREvent) (err error) { pdd.Sum += duration } } - pdd.Events[ev.TenantID()] = value + pdd.Events[ev.ID] = value pdd.Count += 1 pdd.val = nil return } -func (pdd *StatPDD) RemEvent(evTenantID string) (err error) { - duration, has := pdd.Events[evTenantID] +func (pdd *StatPDD) RemEvent(evID string) (err error) { + duration, has := pdd.Events[evID] if !has { return utils.ErrNotFound } @@ -575,7 +575,7 @@ func (pdd *StatPDD) RemEvent(evTenantID string) (err error) { pdd.Sum -= duration } pdd.Count -= 1 - delete(pdd.Events, evTenantID) + delete(pdd.Events, evID) pdd.val = nil return } @@ -628,22 +628,22 @@ func (ddc *StatDDC) AddEvent(ev *utils.CGREvent) (err error) { if _, has := ddc.Destinations[dest]; !has { ddc.Destinations[dest] = make(map[string]bool) } - ddc.Destinations[dest][ev.TenantID()] = true - ddc.Events[ev.TenantID()] = dest + ddc.Destinations[dest][ev.ID] = true + ddc.Events[ev.ID] = dest return } -func (ddc *StatDDC) RemEvent(evTenantID string) (err error) { - destination, has := ddc.Events[evTenantID] +func (ddc *StatDDC) RemEvent(evID string) (err error) { + destination, has := ddc.Events[evID] if !has { return utils.ErrNotFound } - delete(ddc.Events, evTenantID) + delete(ddc.Events, evID) if len(ddc.Destinations[destination]) == 1 { delete(ddc.Destinations, destination) return } - delete(ddc.Destinations[destination], evTenantID) + delete(ddc.Destinations[destination], evID) return } @@ -705,20 +705,20 @@ func (sum *StatSum) AddEvent(ev *utils.CGREvent) (err error) { value = val sum.Sum += val } - sum.Events[ev.TenantID()] = value + sum.Events[ev.ID] = value sum.val = nil return } -func (sum *StatSum) RemEvent(evTenantID string) (err error) { - val, has := sum.Events[evTenantID] +func (sum *StatSum) RemEvent(evID string) (err error) { + val, has := sum.Events[evID] if !has { return utils.ErrNotFound } if val != 0 { sum.Sum -= val } - delete(sum.Events, evTenantID) + delete(sum.Events, evID) sum.val = nil return } @@ -784,15 +784,15 @@ func (avg *StatAverage) AddEvent(ev *utils.CGREvent) (err error) { } else if val > 0 { value = val avg.Sum += val - avg.Events[ev.TenantID()] = value + avg.Events[ev.ID] = value avg.Count += 1 avg.val = nil } return } -func (avg *StatAverage) RemEvent(evTenantID string) (err error) { - val, has := avg.Events[evTenantID] +func (avg *StatAverage) RemEvent(evID string) (err error) { + val, has := avg.Events[evID] if !has { return utils.ErrNotFound } @@ -800,7 +800,7 @@ func (avg *StatAverage) RemEvent(evTenantID string) (err error) { avg.Sum -= val } avg.Count -= 1 - delete(avg.Events, evTenantID) + delete(avg.Events, evID) avg.val = nil return } diff --git a/engine/statmetrics_test.go b/engine/statmetrics_test.go index eda2332cc..33e97d8e6 100644 --- a/engine/statmetrics_test.go +++ b/engine/statmetrics_test.go @@ -46,7 +46,7 @@ func TestASRGetStringValue(t *testing.T) { if strVal := asr.GetStringValue(""); strVal != "33.33333%" { t.Errorf("wrong asr value: %s", strVal) } - asr.RemEvent(ev3.TenantID()) + asr.RemEvent(ev3.ID) if strVal := asr.GetStringValue(""); strVal != "50%" { t.Errorf("wrong asr value: %s", strVal) } @@ -58,16 +58,16 @@ func TestASRGetStringValue(t *testing.T) { "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC)}} asr.AddEvent(ev4) asr.AddEvent(ev5) - asr.RemEvent(ev.TenantID()) + asr.RemEvent(ev.ID) if strVal := asr.GetStringValue(""); strVal != "66.66667%" { t.Errorf("wrong asr value: %s", strVal) } - asr.RemEvent(ev2.TenantID()) + asr.RemEvent(ev2.ID) if strVal := asr.GetStringValue(""); strVal != "100%" { t.Errorf("wrong asr value: %s", strVal) } - asr.RemEvent(ev4.TenantID()) - asr.RemEvent(ev5.TenantID()) + asr.RemEvent(ev4.ID) + asr.RemEvent(ev5.ID) if strVal := asr.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong asr value: %s", strVal) } @@ -89,7 +89,7 @@ func TestASRGetValue(t *testing.T) { if v := asr.GetValue(); v != 33.33333 { t.Errorf("wrong asr value: %f", v) } - asr.RemEvent(ev3.TenantID()) + asr.RemEvent(ev3.ID) if v := asr.GetValue(); v != 50.0 { t.Errorf("wrong asr value: %f", v) } @@ -101,19 +101,19 @@ func TestASRGetValue(t *testing.T) { "AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC)}} asr.AddEvent(ev4) asr.AddEvent(ev5) - asr.RemEvent(ev.TenantID()) + asr.RemEvent(ev.ID) if v := asr.GetValue(); v != 66.666670 { t.Errorf("wrong asr value: %f", v) } - asr.RemEvent(ev2.TenantID()) + asr.RemEvent(ev2.ID) if v := asr.GetValue(); v != 100.0 { t.Errorf("wrong asr value: %f", v) } - asr.RemEvent(ev4.TenantID()) + asr.RemEvent(ev4.ID) if v := asr.GetValue(); v != -1.0 { t.Errorf("wrong asr value: %f", v) } - asr.RemEvent(ev5.TenantID()) + asr.RemEvent(ev5.ID) if v := asr.GetValue(); v != -1.0 { t.Errorf("wrong asr value: %f", v) } @@ -143,7 +143,7 @@ func TestACDGetStringValue(t *testing.T) { if strVal := acd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong acd value: %s", strVal) } - acd.RemEvent(ev.TenantID()) + acd.RemEvent(ev.ID) if strVal := acd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong acd value: %s", strVal) } @@ -167,13 +167,13 @@ func TestACDGetStringValue(t *testing.T) { if strVal := acd.GetStringValue(""); strVal != "1m15s" { t.Errorf("wrong acd value: %s", strVal) } - acd.RemEvent(ev2.TenantID()) + acd.RemEvent(ev2.ID) if strVal := acd.GetStringValue(""); strVal != "1m15s" { t.Errorf("wrong acd value: %s", strVal) } - acd.RemEvent(ev5.TenantID()) - acd.RemEvent(ev4.TenantID()) - acd.RemEvent(ev5.TenantID()) + acd.RemEvent(ev5.ID) + acd.RemEvent(ev4.ID) + acd.RemEvent(ev5.ID) if strVal := acd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong acd value: %s", strVal) } @@ -214,19 +214,19 @@ func TestACDGetFloat64Value(t *testing.T) { if strVal := acd.GetFloat64Value(); strVal != 53.333333333 { t.Errorf("wrong acd value: %v", strVal) } - acd.RemEvent(ev2.TenantID()) + acd.RemEvent(ev2.ID) if strVal := acd.GetFloat64Value(); strVal != 53.333333333 { t.Errorf("wrong acd value: %v", strVal) } - acd.RemEvent(ev4.TenantID()) + acd.RemEvent(ev4.ID) if strVal := acd.GetFloat64Value(); strVal != 50.0 { t.Errorf("wrong acd value: %v", strVal) } - acd.RemEvent(ev.TenantID()) + acd.RemEvent(ev.ID) if strVal := acd.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong acd value: %v", strVal) } - acd.RemEvent(ev5.TenantID()) + acd.RemEvent(ev5.ID) if strVal := acd.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong acd value: %v", strVal) } @@ -252,11 +252,11 @@ func TestACDGetValue(t *testing.T) { if v := acd.GetValue(); v != time.Duration(9*time.Second) { t.Errorf("wrong acd value: %+v", v) } - acd.RemEvent(ev.TenantID()) + acd.RemEvent(ev.ID) if v := acd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { t.Errorf("wrong acd value: %+v", v) } - acd.RemEvent(ev2.TenantID()) + acd.RemEvent(ev2.ID) if v := acd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { t.Errorf("wrong acd value: %+v", v) } @@ -277,12 +277,12 @@ func TestACDGetValue(t *testing.T) { if v := acd.GetValue(); v != time.Duration(2*time.Minute+45*time.Second) { t.Errorf("wrong acd value: %+v", v) } - acd.RemEvent(ev5.TenantID()) - acd.RemEvent(ev4.TenantID()) + acd.RemEvent(ev5.ID) + acd.RemEvent(ev4.ID) if v := acd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { t.Errorf("wrong acd value: %+v", v) } - acd.RemEvent(ev3.TenantID()) + acd.RemEvent(ev3.ID) if v := acd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { t.Errorf("wrong acd value: %+v", v) } @@ -313,11 +313,11 @@ func TestTCDGetStringValue(t *testing.T) { if strVal := tcd.GetStringValue(""); strVal != "20s" { t.Errorf("wrong tcd value: %s", strVal) } - tcd.RemEvent(ev2.TenantID()) + tcd.RemEvent(ev2.ID) if strVal := tcd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong tcd value: %s", strVal) } - tcd.RemEvent(ev.TenantID()) + tcd.RemEvent(ev.ID) if strVal := tcd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong tcd value: %s", strVal) } @@ -338,12 +338,12 @@ func TestTCDGetStringValue(t *testing.T) { if strVal := tcd.GetStringValue(""); strVal != "2m30s" { t.Errorf("wrong tcd value: %s", strVal) } - tcd.RemEvent(ev4.TenantID()) + tcd.RemEvent(ev4.ID) if strVal := tcd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong tcd value: %s", strVal) } - tcd.RemEvent(ev5.TenantID()) - tcd.RemEvent(ev3.TenantID()) + tcd.RemEvent(ev5.ID) + tcd.RemEvent(ev3.ID) if strVal := tcd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong tcd value: %s", strVal) } @@ -384,19 +384,19 @@ func TestTCDGetFloat64Value(t *testing.T) { if strVal := tcd.GetFloat64Value(); strVal != 160.0 { t.Errorf("wrong tcd value: %f", strVal) } - tcd.RemEvent(ev2.TenantID()) + tcd.RemEvent(ev2.ID) if strVal := tcd.GetFloat64Value(); strVal != 160.0 { t.Errorf("wrong tcd value: %f", strVal) } - tcd.RemEvent(ev4.TenantID()) + tcd.RemEvent(ev4.ID) if strVal := tcd.GetFloat64Value(); strVal != 100.0 { t.Errorf("wrong tcd value: %f", strVal) } - tcd.RemEvent(ev.TenantID()) + tcd.RemEvent(ev.ID) if strVal := tcd.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong tcd value: %f", strVal) } - tcd.RemEvent(ev5.TenantID()) + tcd.RemEvent(ev5.ID) if strVal := tcd.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong tcd value: %f", strVal) } @@ -422,11 +422,11 @@ func TestTCDGetValue(t *testing.T) { if v := tcd.GetValue(); v != time.Duration(15*time.Second) { t.Errorf("wrong tcd value: %+v", v) } - tcd.RemEvent(ev.TenantID()) + tcd.RemEvent(ev.ID) if v := tcd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { t.Errorf("wrong tcd value: %+v", v) } - tcd.RemEvent(ev2.TenantID()) + tcd.RemEvent(ev2.ID) if v := tcd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { t.Errorf("wrong tcd value: %+v", v) } @@ -447,12 +447,12 @@ func TestTCDGetValue(t *testing.T) { if v := tcd.GetValue(); v != time.Duration(2*time.Minute+30*time.Second) { t.Errorf("wrong tcd value: %+v", v) } - tcd.RemEvent(ev5.TenantID()) - tcd.RemEvent(ev4.TenantID()) + tcd.RemEvent(ev5.ID) + tcd.RemEvent(ev4.ID) if v := tcd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { t.Errorf("wrong tcd value: %+v", v) } - tcd.RemEvent(ev3.TenantID()) + tcd.RemEvent(ev3.ID) if v := tcd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { t.Errorf("wrong tcd value: %+v", v) } @@ -481,7 +481,7 @@ func TestACCGetStringValue(t *testing.T) { if strVal := acc.GetStringValue(""); strVal != "12.3" { t.Errorf("wrong acc value: %s", strVal) } - acc.RemEvent(ev3.TenantID()) + acc.RemEvent(ev3.ID) if strVal := acc.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong acc value: %s", strVal) } @@ -495,16 +495,16 @@ func TestACCGetStringValue(t *testing.T) { "Cost": 1.2}} acc.AddEvent(ev4) acc.AddEvent(ev5) - acc.RemEvent(ev.TenantID()) + acc.RemEvent(ev.ID) if strVal := acc.GetStringValue(""); strVal != "3.4" { t.Errorf("wrong acc value: %s", strVal) } - acc.RemEvent(ev2.TenantID()) + acc.RemEvent(ev2.ID) if strVal := acc.GetStringValue(""); strVal != "3.4" { t.Errorf("wrong acc value: %s", strVal) } - acc.RemEvent(ev4.TenantID()) - acc.RemEvent(ev5.TenantID()) + acc.RemEvent(ev4.ID) + acc.RemEvent(ev5.ID) if strVal := acc.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong acc value: %s", strVal) } @@ -530,7 +530,7 @@ func TestACCGetValue(t *testing.T) { if strVal := acc.GetValue(); strVal != -1.0 { t.Errorf("wrong acc value: %v", strVal) } - acc.RemEvent(ev3.TenantID()) + acc.RemEvent(ev3.ID) if strVal := acc.GetValue(); strVal != -1.0 { t.Errorf("wrong acc value: %v", strVal) } @@ -544,16 +544,16 @@ func TestACCGetValue(t *testing.T) { "Cost": "1.2"}} acc.AddEvent(ev4) acc.AddEvent(ev5) - acc.RemEvent(ev.TenantID()) + acc.RemEvent(ev.ID) if strVal := acc.GetValue(); strVal != 3.4 { t.Errorf("wrong acc value: %v", strVal) } - acc.RemEvent(ev2.TenantID()) + acc.RemEvent(ev2.ID) if strVal := acc.GetValue(); strVal != 3.4 { t.Errorf("wrong acc value: %v", strVal) } - acc.RemEvent(ev4.TenantID()) - acc.RemEvent(ev5.TenantID()) + acc.RemEvent(ev4.ID) + acc.RemEvent(ev5.ID) if strVal := acc.GetValue(); strVal != -1.0 { t.Errorf("wrong acc value: %v", strVal) } @@ -582,7 +582,7 @@ func TestTCCGetStringValue(t *testing.T) { if strVal := tcc.GetStringValue(""); strVal != "18" { t.Errorf("wrong tcc value: %s", strVal) } - tcc.RemEvent(ev3.TenantID()) + tcc.RemEvent(ev3.ID) if strVal := tcc.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong tcc value: %s", strVal) } @@ -596,16 +596,16 @@ func TestTCCGetStringValue(t *testing.T) { "Cost": 1.2}} tcc.AddEvent(ev4) tcc.AddEvent(ev5) - tcc.RemEvent(ev.TenantID()) + tcc.RemEvent(ev.ID) if strVal := tcc.GetStringValue(""); strVal != "6.8" { t.Errorf("wrong tcc value: %s", strVal) } - tcc.RemEvent(ev2.TenantID()) + tcc.RemEvent(ev2.ID) if strVal := tcc.GetStringValue(""); strVal != "6.8" { t.Errorf("wrong tcc value: %s", strVal) } - tcc.RemEvent(ev4.TenantID()) - tcc.RemEvent(ev5.TenantID()) + tcc.RemEvent(ev4.ID) + tcc.RemEvent(ev5.ID) if strVal := tcc.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong tcc value: %s", strVal) } @@ -634,7 +634,7 @@ func TestTCCGetValue(t *testing.T) { if strVal := tcc.GetValue(); strVal != 13.5 { t.Errorf("wrong tcc value: %v", strVal) } - tcc.RemEvent(ev3.TenantID()) + tcc.RemEvent(ev3.ID) if strVal := tcc.GetValue(); strVal != -1.0 { t.Errorf("wrong tcc value: %v", strVal) } @@ -648,16 +648,16 @@ func TestTCCGetValue(t *testing.T) { "Cost": "1.2"}} tcc.AddEvent(ev4) tcc.AddEvent(ev5) - tcc.RemEvent(ev.TenantID()) + tcc.RemEvent(ev.ID) if strVal := tcc.GetValue(); strVal != 6.8 { t.Errorf("wrong tcc value: %v", strVal) } - tcc.RemEvent(ev2.TenantID()) + tcc.RemEvent(ev2.ID) if strVal := tcc.GetValue(); strVal != 6.8 { t.Errorf("wrong tcc value: %v", strVal) } - tcc.RemEvent(ev4.TenantID()) - tcc.RemEvent(ev5.TenantID()) + tcc.RemEvent(ev4.ID) + tcc.RemEvent(ev5.ID) if strVal := tcc.GetValue(); strVal != -1.0 { t.Errorf("wrong tcc value: %v", strVal) } @@ -685,11 +685,11 @@ func TestPDDGetStringValue(t *testing.T) { if strVal := pdd.GetStringValue(""); strVal != "1.666666666s" { t.Errorf("wrong pdd value: %s", strVal) } - pdd.RemEvent(ev3.TenantID()) + pdd.RemEvent(ev3.ID) if strVal := pdd.GetStringValue(""); strVal != "2.5s" { t.Errorf("wrong pdd value: %s", strVal) } - pdd.RemEvent(ev.TenantID()) + pdd.RemEvent(ev.ID) if strVal := pdd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong pdd value: %s", strVal) } @@ -713,13 +713,13 @@ func TestPDDGetStringValue(t *testing.T) { if strVal := pdd.GetStringValue(""); strVal != "3.333333333s" { t.Errorf("wrong pdd value: %s", strVal) } - pdd.RemEvent(ev2.TenantID()) + pdd.RemEvent(ev2.ID) if strVal := pdd.GetStringValue(""); strVal != "5s" { t.Errorf("wrong pdd value: %s", strVal) } - pdd.RemEvent(ev5.TenantID()) - pdd.RemEvent(ev4.TenantID()) - pdd.RemEvent(ev5.TenantID()) + pdd.RemEvent(ev5.ID) + pdd.RemEvent(ev4.ID) + pdd.RemEvent(ev5.ID) if strVal := pdd.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong pdd value: %s", strVal) } @@ -762,19 +762,19 @@ func TestPDDGetFloat64Value(t *testing.T) { if strVal := pdd.GetFloat64Value(); strVal != 3.75 { t.Errorf("wrong pdd value: %v", strVal) } - pdd.RemEvent(ev2.TenantID()) + pdd.RemEvent(ev2.ID) if strVal := pdd.GetFloat64Value(); strVal != 5 { t.Errorf("wrong pdd value: %v", strVal) } - pdd.RemEvent(ev4.TenantID()) + pdd.RemEvent(ev4.ID) if strVal := pdd.GetFloat64Value(); strVal != 2.5 { t.Errorf("wrong pdd value: %v", strVal) } - pdd.RemEvent(ev.TenantID()) + pdd.RemEvent(ev.ID) if strVal := pdd.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong pdd value: %v", strVal) } - pdd.RemEvent(ev5.TenantID()) + pdd.RemEvent(ev5.ID) if strVal := pdd.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong pdd value: %v", strVal) } @@ -802,11 +802,11 @@ func TestPDDGetValue(t *testing.T) { if v := pdd.GetValue(); v != time.Duration(6333333333*time.Nanosecond) { t.Errorf("wrong pdd value: %+v", v) } - pdd.RemEvent(ev.TenantID()) + pdd.RemEvent(ev.ID) if v := pdd.GetValue(); v != time.Duration(5*time.Second) { t.Errorf("wrong pdd value: %+v", v) } - pdd.RemEvent(ev2.TenantID()) + pdd.RemEvent(ev2.ID) if v := pdd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { t.Errorf("wrong pdd value: %+v", v) } @@ -828,12 +828,12 @@ func TestPDDGetValue(t *testing.T) { if v := pdd.GetValue(); v != time.Duration(2666666666*time.Nanosecond) { t.Errorf("wrong pdd value: %+v", v) } - pdd.RemEvent(ev5.TenantID()) - pdd.RemEvent(ev4.TenantID()) + pdd.RemEvent(ev5.ID) + pdd.RemEvent(ev4.ID) if v := pdd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { t.Errorf("wrong pdd value: %+v", v) } - pdd.RemEvent(ev3.TenantID()) + pdd.RemEvent(ev3.ID) if v := pdd.GetValue(); v != time.Duration((-1)*time.Nanosecond) { t.Errorf("wrong pdd value: %+v", v) } @@ -867,15 +867,15 @@ func TestDDCGetStringValue(t *testing.T) { if strVal := ddc.GetStringValue(""); strVal != "2" { t.Errorf("wrong ddc value: %s", strVal) } - ddc.RemEvent(ev.TenantID()) + ddc.RemEvent(ev.ID) if strVal := ddc.GetStringValue(""); strVal != "2" { t.Errorf("wrong ddc value: %s", strVal) } - ddc.RemEvent(ev2.TenantID()) + ddc.RemEvent(ev2.ID) if strVal := ddc.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong ddc value: %s", strVal) } - ddc.RemEvent(ev3.TenantID()) + ddc.RemEvent(ev3.ID) if strVal := ddc.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong ddc value: %s", strVal) } @@ -921,19 +921,19 @@ func TestDDCGetFloat64Value(t *testing.T) { if strVal := ddc.GetFloat64Value(); strVal != 3 { t.Errorf("wrong ddc value: %v", strVal) } - ddc.RemEvent(ev2.TenantID()) + ddc.RemEvent(ev2.ID) if strVal := ddc.GetFloat64Value(); strVal != 3 { t.Errorf("wrong pdd value: %v", strVal) } - ddc.RemEvent(ev4.TenantID()) + ddc.RemEvent(ev4.ID) if strVal := ddc.GetFloat64Value(); strVal != 2 { t.Errorf("wrong ddc value: %v", strVal) } - ddc.RemEvent(ev.TenantID()) + ddc.RemEvent(ev.ID) if strVal := ddc.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong ddc value: %v", strVal) } - ddc.RemEvent(ev5.TenantID()) + ddc.RemEvent(ev5.ID) if strVal := ddc.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong ddc value: %v", strVal) } @@ -982,19 +982,19 @@ func TestStatSumGetFloat64Value(t *testing.T) { if strVal := statSum.GetFloat64Value(); strVal != 60 { t.Errorf("wrong statSum value: %v", strVal) } - statSum.RemEvent(ev2.TenantID()) + statSum.RemEvent(ev2.ID) if strVal := statSum.GetFloat64Value(); strVal != 60 { t.Errorf("wrong statSum value: %v", strVal) } - statSum.RemEvent(ev4.TenantID()) + statSum.RemEvent(ev4.ID) if strVal := statSum.GetFloat64Value(); strVal != 40 { t.Errorf("wrong statSum value: %v", strVal) } - statSum.RemEvent(ev.TenantID()) + statSum.RemEvent(ev.ID) if strVal := statSum.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong statSum value: %v", strVal) } - statSum.RemEvent(ev5.TenantID()) + statSum.RemEvent(ev5.ID) if strVal := statSum.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong statSum value: %v", strVal) } @@ -1031,15 +1031,15 @@ func TestStatSumGetStringValue(t *testing.T) { if strVal := statSum.GetStringValue(""); strVal != "60" { t.Errorf("wrong statSum value: %s", strVal) } - statSum.RemEvent(ev.TenantID()) + statSum.RemEvent(ev.ID) if strVal := statSum.GetStringValue(""); strVal != "40" { t.Errorf("wrong statSum value: %s", strVal) } - statSum.RemEvent(ev2.TenantID()) + statSum.RemEvent(ev2.ID) if strVal := statSum.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong statSum value: %s", strVal) } - statSum.RemEvent(ev3.TenantID()) + statSum.RemEvent(ev3.ID) if strVal := statSum.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong statSum value: %s", strVal) } @@ -1088,19 +1088,19 @@ func TestStatAverageGetFloat64Value(t *testing.T) { if strVal := statAvg.GetFloat64Value(); strVal != 23.33333 { t.Errorf("wrong statAvg value: %v", strVal) } - statAvg.RemEvent(ev2.TenantID()) + statAvg.RemEvent(ev2.ID) if strVal := statAvg.GetFloat64Value(); strVal != 23.33333 { t.Errorf("wrong statAvg value: %v", strVal) } - statAvg.RemEvent(ev4.TenantID()) + statAvg.RemEvent(ev4.ID) if strVal := statAvg.GetFloat64Value(); strVal != 20 { t.Errorf("wrong statAvg value: %v", strVal) } - statAvg.RemEvent(ev.TenantID()) + statAvg.RemEvent(ev.ID) if strVal := statAvg.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong statAvg value: %v", strVal) } - statAvg.RemEvent(ev5.TenantID()) + statAvg.RemEvent(ev5.ID) if strVal := statAvg.GetFloat64Value(); strVal != -1.0 { t.Errorf("wrong statAvg value: %v", strVal) } @@ -1137,15 +1137,15 @@ func TestStatAverageGetStringValue(t *testing.T) { if strVal := statAvg.GetStringValue(""); strVal != "20" { t.Errorf("wrong statAvg value: %s", strVal) } - statAvg.RemEvent(ev.TenantID()) + statAvg.RemEvent(ev.ID) if strVal := statAvg.GetStringValue(""); strVal != "20" { t.Errorf("wrong statAvg value: %s", strVal) } - statAvg.RemEvent(ev2.TenantID()) + statAvg.RemEvent(ev2.ID) if strVal := statAvg.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong statAvg value: %s", strVal) } - statAvg.RemEvent(ev3.TenantID()) + statAvg.RemEvent(ev3.ID) if strVal := statAvg.GetStringValue(""); strVal != utils.NOT_AVAILABLE { t.Errorf("wrong statAvg value: %s", strVal) }