本文整理匯總了Golang中github.com/Comcast/traffic_control/traffic_ops/client.Session.TrafficMonitorConfigMap方法的典型用法代碼示例。如果您正苦於以下問題:Golang Session.TrafficMonitorConfigMap方法的具體用法?Golang Session.TrafficMonitorConfigMap怎麽用?Golang Session.TrafficMonitorConfigMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Comcast/traffic_control/traffic_ops/client.Session
的用法示例。
在下文中一共展示了Session.TrafficMonitorConfigMap方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestTMConfig
func TestTMConfig(t *testing.T) {
resp := fixtures.TrafficMonitorConfig()
server := testHelper.ValidHTTPServer(resp)
defer server.Close()
var httpClient http.Client
to := client.Session{
URL: server.URL,
UserAgent: &httpClient,
}
testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TM Config")
tm, err := to.TrafficMonitorConfigMap("test-cdn")
if err != nil {
testHelper.Error(t, "Should be able to make a request to Traffic Ops")
} else {
testHelper.Success(t, "Should be able to make a request to Traffic Ops")
}
testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TM Config - Traffic Server")
ts := tm.TrafficServer
if len(ts) != 2 {
testHelper.Error(t, "Should get back \"2\" Traffic Servers, got: %d", len(ts))
} else {
testHelper.Success(t, "Should get back \"2\" Traffic Servers")
}
hashID := "tr-chi-05"
if val, ok := ts[hashID]; ok {
testHelper.Success(t, "Should get back map entry for \"%s\"", hashID)
if val.IP != "10.10.10.10" {
testHelper.Error(t, "Should get back \"10.10.10.10\" for \"IP\", got: %s", val.IP)
} else {
testHelper.Success(t, "Should get back \"10.10.10.10\" for \"IP\"")
}
} else {
testHelper.Error(t, "Should get back map entry for \"%s\"", hashID)
}
hashID = "edge-test-01"
if val, ok := ts[hashID]; ok {
testHelper.Success(t, "Should get back map entry for for \"%s\"", hashID)
if val.Type != "EDGE" {
testHelper.Error(t, "Should get back \"EDGE\" for \"%s\" \"Type\", got: %s", hashID, ts[hashID].Type)
} else {
testHelper.Success(t, "Should get back \"EDGE\" for \"%s\" \"Type\"", hashID)
}
} else {
testHelper.Error(t, "Should get back map entry for \"%s\"", hashID)
}
testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TR Config - Traffic Monitor")
m := tm.TrafficMonitor
if len(m) != 1 {
testHelper.Error(t, "Should get back \"1\" Traffic Servers, got: %d", len(m))
} else {
testHelper.Success(t, "Should get back \"1\" Traffic Servers")
}
hostName := "traffic-monitor-01"
if val, ok := m[hostName]; ok {
testHelper.Success(t, "Should get back map entry for \"%s\"", hostName)
if val.Status != "ONLINE" {
testHelper.Error(t, "Should get back \"ONLINE\" for \"Status\", got: %s", val.Status)
} else {
testHelper.Success(t, "Should get back \"ONLINE\" for \"Status\"")
}
} else {
testHelper.Error(t, "Should get back map entry for \"%s\"", hostName)
}
testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TM Config - CacheGroups")
c := tm.CacheGroup
if len(c) != 2 {
testHelper.Error(t, "Should get back \"2\" Traffic Servers, got: %d", len(c))
} else {
testHelper.Success(t, "Should get back \"2\" Traffic Servers")
}
name := "philadelphia"
if val, ok := c[name]; ok {
testHelper.Success(t, "Should get back map entry for \"%s\"", name)
if val.Coordinates.Latitude != 55 {
testHelper.Error(t, "Should get back \"55\" for \"Coordinates.Latitude\", got: %s", val.Coordinates.Latitude)
} else {
testHelper.Success(t, "Should get back \"55\" for \"Coordinates.Latitude\"")
}
} else {
//.........這裏部分代碼省略.........