func TestComputeServicesAnalytics(t *testing.T) { stats := data.CreateMockStats() expected := make(map[string]data.AnalyticData) expected["service1"] = data.AnalyticData{ BaseAnalytics: map[string]float64{ enum.METRIC_CPU_AVG.ToString(): 0.6, enum.METRIC_MEM_AVG.ToString(): 0.3, }, UserAnalytics: map[string]float64{ "expr1": 0.5, }, } expected["service2"] = data.AnalyticData{ BaseAnalytics: map[string]float64{ enum.METRIC_CPU_AVG.ToString(): 0.1, enum.METRIC_MEM_AVG.ToString(): 0.1, }, UserAnalytics: map[string]float64{ "expr2": 0.6, }, } expected["service3"] = data.AnalyticData{ BaseAnalytics: map[string]float64{ enum.METRIC_CPU_AVG.ToString(): 0.9, enum.METRIC_MEM_AVG.ToString(): 0.8, }, UserAnalytics: map[string]float64{ "expr3": 0.0, }, } analytics := computeServicesAnalytics(stats.Metrics.Service) assert.Equal(t, expected, analytics) }
func TestComputeSystemAnalytics(t *testing.T) { stats := data.CreateMockStats() expected := data.AnalyticData{ BaseAnalytics: map[string]float64{ enum.METRIC_CPU_AVG.ToString(): 0.5, enum.METRIC_MEM_AVG.ToString(): 0.4, }, } analytics := computeSystemAnalytics(stats.Metrics.System) assert.Equal(t, expected, analytics) }