Add result summary support for IM tests
This commit is contained in:
@@ -20,13 +20,31 @@ func (h FacebookMessenger) Run(ctl *nettests.Controller) error {
|
||||
type FacebookMessengerSummary struct {
|
||||
DNSBlocking bool
|
||||
TCPBlocking bool
|
||||
Blocked bool
|
||||
}
|
||||
|
||||
// Summary generates a summary for a test run
|
||||
func (h FacebookMessenger) Summary(tk map[string]interface{}) interface{} {
|
||||
var (
|
||||
dnsBlocking bool
|
||||
tcpBlocking bool
|
||||
)
|
||||
if tk["facebook_dns_blocking"] == nil {
|
||||
dnsBlocking = false
|
||||
} else {
|
||||
dnsBlocking = tk["facebook_dns_blocking"].(bool)
|
||||
}
|
||||
|
||||
if tk["facebook_tcp_blocking"] == nil {
|
||||
tcpBlocking = false
|
||||
} else {
|
||||
tcpBlocking = tk["facebook_tcp_blocking"].(bool)
|
||||
}
|
||||
|
||||
return FacebookMessengerSummary{
|
||||
DNSBlocking: tk["facebook_dns_blocking"].(bool),
|
||||
TCPBlocking: tk["facebook_tcp_blocking"].(bool),
|
||||
DNSBlocking: dnsBlocking,
|
||||
TCPBlocking: tcpBlocking,
|
||||
Blocked: dnsBlocking || tcpBlocking,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+27
-3
@@ -21,14 +21,38 @@ type TelegramSummary struct {
|
||||
HTTPBlocking bool
|
||||
TCPBlocking bool
|
||||
WebBlocking bool
|
||||
Blocked bool
|
||||
}
|
||||
|
||||
// Summary generates a summary for a test run
|
||||
func (h Telegram) Summary(tk map[string]interface{}) interface{} {
|
||||
var (
|
||||
tcpBlocking bool
|
||||
httpBlocking bool
|
||||
webBlocking bool
|
||||
)
|
||||
|
||||
if tk["telegram_tcp_blocking"] == nil {
|
||||
tcpBlocking = false
|
||||
} else {
|
||||
tcpBlocking = tk["telegram_tcp_blocking"].(bool)
|
||||
}
|
||||
if tk["telegram_http_blocking"] == nil {
|
||||
httpBlocking = false
|
||||
} else {
|
||||
httpBlocking = tk["telegram_http_blocking"].(bool)
|
||||
}
|
||||
if tk["telegram_web_status"] == nil {
|
||||
webBlocking = false
|
||||
} else {
|
||||
webBlocking = tk["telegram_web_status"].(string) == "blocked"
|
||||
}
|
||||
|
||||
return TelegramSummary{
|
||||
TCPBlocking: tk["telegram_tcp_blocking"].(bool) == true,
|
||||
HTTPBlocking: tk["telegram_http_blocking"].(bool) == true,
|
||||
WebBlocking: tk["telegram_web_status"].(string) == "blocked",
|
||||
TCPBlocking: tcpBlocking,
|
||||
HTTPBlocking: httpBlocking,
|
||||
WebBlocking: webBlocking,
|
||||
Blocked: webBlocking || httpBlocking || tcpBlocking,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+24
-4
@@ -21,16 +21,36 @@ type WhatsAppSummary struct {
|
||||
RegistrationServerBlocking bool
|
||||
WebBlocking bool
|
||||
EndpointsBlocking bool
|
||||
Blocked bool
|
||||
}
|
||||
|
||||
// Summary generates a summary for a test run
|
||||
func (h WhatsApp) Summary(tk map[string]interface{}) interface{} {
|
||||
const blk = "blocked"
|
||||
var (
|
||||
webBlocking bool
|
||||
registrationBlocking bool
|
||||
endpointsBlocking bool
|
||||
)
|
||||
|
||||
var computeBlocking = func(key string) bool {
|
||||
const blk = "blocked"
|
||||
if tk[key] == nil {
|
||||
return false
|
||||
}
|
||||
if tk[key].(string) == blk {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
registrationBlocking = computeBlocking("registration_server_status")
|
||||
webBlocking = computeBlocking("whatsapp_web_status")
|
||||
endpointsBlocking = computeBlocking("whatsapp_endpoints_status")
|
||||
|
||||
return WhatsAppSummary{
|
||||
RegistrationServerBlocking: tk["registration_server_status"].(string) == blk,
|
||||
WebBlocking: tk["whatsapp_web_status"].(string) == blk,
|
||||
EndpointsBlocking: tk["whatsapp_endpoints_status"].(string) == blk,
|
||||
RegistrationServerBlocking: registrationBlocking,
|
||||
WebBlocking: webBlocking,
|
||||
EndpointsBlocking: endpointsBlocking,
|
||||
Blocked: registrationBlocking || webBlocking || endpointsBlocking,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user