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) } }
func TestMergeInfo(t *testing.T) { defer service.ClearMockServices() var err error service.SetMockServices() shared1 := CreateMockShared() shared2 := CreateMockShared() shared3 := CreateMockShared() peers := []Shared{shared1, shared2, shared3} merged, err := MergeShared(peers) assert.NoError(t, err) assert.Equal(t, shared1.Service["service1"].Data.BaseShared[enum.METRIC_CPU_AVG.ToString()], merged.Service["service1"].Data.BaseShared[enum.METRIC_CPU_AVG.ToString()]) assert.Equal(t, shared1.System.ActiveServices, merged.System.ActiveServices) empty := []Shared{} _, err = MergeShared(empty) assert.Error(t, err) one := []Shared{shared1} _, err = MergeShared(one) assert.NoError(t, err) }
func init() { srv.SetMockServices() setMockExpressions() }