func buildPoolMonitoringProfile(pool *pool.ResourcePool, hostIDs []string, client *master.Client) error { var totalMemory uint64 = 0 var totalCores int = 0 //calculate total memory and total cores for i := range hostIDs { host, err := client.GetHost(hostIDs[i]) if err != nil { glog.Errorf("Failed to get host for id=%s -> %s", hostIDs[i], err) return err } totalCores += host.Cores totalMemory += host.Memory } tags := map[string][]string{"controlplane_host_id": hostIDs} profile, err := hostPoolProfile.ReBuild("1h-ago", tags) if err != nil { glog.Error("Failed to create pool profile: %s", err) return err } //add graphs to profile profile.GraphConfigs = make([]domain.GraphConfig, 3) profile.GraphConfigs[0] = newCpuConfigGraph(tags, totalCores) profile.GraphConfigs[1] = newRSSConfigGraph(tags, totalMemory) profile.GraphConfigs[2] = newMajorPageFaultGraph(tags) pool.MonitoringProfile = *profile return nil }
func TestServicedCLI_CmdPoolList_one(t *testing.T) { poolID := "test-pool-id-1" expected, err := DefaultPoolAPITest.GetResourcePool(poolID) if err != nil { t.Fatal(err) } var actual pool.ResourcePool output := pipe(InitPoolAPITest, "serviced", "pool", "list", poolID) if err := json.Unmarshal(output, &actual); err != nil { t.Fatalf("error unmarshalling resource: %s", err) } // Did you remember to update ResourcePool.Equals? if !actual.Equals(expected) { t.Fatalf("\ngot:\n%+v\nwant:\n%+v", actual, expected) } }
func (ft *FacadeTest) Test_NewResourcePool(t *C) { poolID := "Test_NewResourcePool" defer ft.Facade.RemoveResourcePool(ft.CTX, poolID) rp := pool.ResourcePool{} err := ft.Facade.AddResourcePool(ft.CTX, &rp) if err == nil { t.Errorf("Expected failure to create resource pool %-v", rp) } rp.ID = poolID err = ft.Facade.AddResourcePool(ft.CTX, &rp) if err != nil { t.Errorf("Failure creating resource pool %-v with error: %s", rp, err) t.Fail() } err = ft.Facade.AddResourcePool(ft.CTX, &rp) if err == nil { t.Errorf("Expected error creating redundant resource pool %-v", rp) t.Fail() } }