Exemple #1
0
func init() {
	srv.SetMockServices()
	setMockExpressions()
	storage.New("internal")
	constraints := map[string]float64{
		"C1": 1.0,
		"C2": 2.0,
	}
	for _, service := range srv.List() {
		srv.SetServiceConstraints(service, constraints)
	}
}
Exemple #2
0
func TestComputeMetricAnalytics(t *testing.T) {
	metrics := map[string]float64{
		"M1": 0.2,
		"M2": 0.8,
	}
	constraints := map[string]float64{
		"C1": 1.0,
		"C2": 2.0,
	}

	expected1 := map[string]float64{
		"expr1": 0.5,
	}

	expected2 := map[string]float64{
		"expr2": 0.6,
	}

	expected3 := map[string]float64{
		"expr3": 0.0,
	}

	var result map[string]float64

	srv.SetServiceConstraints("service1", constraints)
	result = ComputeMetricAnalytics("service1", metrics)
	assert.Equal(t, expected1, result)

	srv.SetServiceConstraints("service2", constraints)
	result = ComputeMetricAnalytics("service2", metrics)
	assert.Equal(t, expected2, result)

	srv.SetServiceConstraints("service3", constraints)
	result = ComputeMetricAnalytics("service3", metrics)
	assert.Equal(t, expected3, result)

}