예제 #1
0
func TestTrapperShutdown(t *testing.T) {
	zabbix.SendBulk(
		"localhost",
		zabbix.TrapperRequest{Request: "shutdown"},
		timeout,
	)
	<-done
}
예제 #2
0
func TestTrapperSendTimeout(t *testing.T) {
	res, err := zabbix.SendBulk(
		"localhost",
		zabbix.TrapperRequest{
			Request: "timeout",
			Data: []zabbix.TrapperData{
				zabbix.TrapperData{Host: "localhost", Key: "foo", Value: "bar"},
			},
		},
		timeout,
	)
	if err == nil {
		t.Error("timeout must be timeouted.", err)
	}
	if _err := err.(*net.OpError); !_err.Timeout() {
		t.Error("err expected i/o timeout. got:", err)
	}
	log.Println("client timeout", res)
}
예제 #3
0
func TestTrapperSendBulk(t *testing.T) {
	res, err := zabbix.SendBulk(
		"localhost",
		zabbix.TrapperRequest{
			Data: []zabbix.TrapperData{
				zabbix.TrapperData{Host: "localhost", Key: "foo", Value: "bar"},
				zabbix.TrapperData{Host: "localhost", Key: "xxx", Value: "yyy"},
			},
		},
		timeout,
	)
	if err != nil {
		t.Errorf("send failed", err)
	}
	if res.Proceeded != 2 {
		t.Errorf("proceeded expected 2 got", res.Proceeded)
	}
	if res.Failed != 0 {
		t.Errorf("failed expected 0 got", res.Failed)
	}
	if res.Total != 2 {
		t.Errorf("total expected 2 got", res.Total)
	}
}