mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tools/functional-tester/etcd-tester: report agent status
This commit is contained in:
parent
1f470fd1c6
commit
46ebb83b90
@ -16,6 +16,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
@ -37,6 +38,10 @@ type cluster struct {
|
|||||||
ClientURLs []string
|
ClientURLs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ClusterStatus struct {
|
||||||
|
AgentStatuses map[string]client.Status
|
||||||
|
}
|
||||||
|
|
||||||
// newCluster starts and returns a new cluster. The caller should call Terminate when finished, to shut it down.
|
// newCluster starts and returns a new cluster. The caller should call Terminate when finished, to shut it down.
|
||||||
func newCluster(agentEndpoints []string, datadir string) (*cluster, error) {
|
func newCluster(agentEndpoints []string, datadir string) (*cluster, error) {
|
||||||
c := &cluster{
|
c := &cluster{
|
||||||
@ -160,6 +165,24 @@ func (c *cluster) Terminate() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *cluster) Status() ClusterStatus {
|
||||||
|
cs := ClusterStatus{
|
||||||
|
AgentStatuses: make(map[string]client.Status),
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, a := range c.Agents {
|
||||||
|
s, err := a.Status()
|
||||||
|
// TODO: add a.Desc() as a key of the map
|
||||||
|
desc := c.agentEndpoints[i]
|
||||||
|
if err != nil {
|
||||||
|
cs.AgentStatuses[desc] = client.Status{State: "unknown"}
|
||||||
|
log.Printf("etcd-tester: failed to get the status of agent [%s]", desc)
|
||||||
|
}
|
||||||
|
cs.AgentStatuses[desc] = s
|
||||||
|
}
|
||||||
|
return cs
|
||||||
|
}
|
||||||
|
|
||||||
// setHealthKey sets health key on all given urls.
|
// setHealthKey sets health key on all given urls.
|
||||||
func setHealthKey(us []string) error {
|
func setHealthKey(us []string) error {
|
||||||
for _, u := range us {
|
for _, u := range us {
|
||||||
|
@ -31,6 +31,7 @@ type tester struct {
|
|||||||
func (tt *tester) runLoop() {
|
func (tt *tester) runLoop() {
|
||||||
tt.status.Since = time.Now()
|
tt.status.Since = time.Now()
|
||||||
tt.status.RoundLimit = tt.limit
|
tt.status.RoundLimit = tt.limit
|
||||||
|
tt.status.cluster = tt.cluster
|
||||||
for _, f := range tt.failures {
|
for _, f := range tt.failures {
|
||||||
tt.status.Failures = append(tt.status.Failures, f.Desc())
|
tt.status.Failures = append(tt.status.Failures, f.Desc())
|
||||||
}
|
}
|
||||||
@ -85,8 +86,10 @@ type Status struct {
|
|||||||
Failures []string
|
Failures []string
|
||||||
RoundLimit int
|
RoundLimit int
|
||||||
|
|
||||||
|
Cluster ClusterStatus
|
||||||
|
cluster *cluster
|
||||||
|
|
||||||
mu sync.Mutex // guards Round and Case
|
mu sync.Mutex // guards Round and Case
|
||||||
// TODO: add agent status
|
|
||||||
Round int
|
Round int
|
||||||
Case int
|
Case int
|
||||||
}
|
}
|
||||||
@ -94,8 +97,11 @@ type Status struct {
|
|||||||
// get gets a copy of status
|
// get gets a copy of status
|
||||||
func (s *Status) get() Status {
|
func (s *Status) get() Status {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
got := *s
|
||||||
return *s
|
cluster := s.cluster
|
||||||
|
s.mu.Unlock()
|
||||||
|
got.Cluster = cluster.Status()
|
||||||
|
return got
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Status) setRound(r int) {
|
func (s *Status) setRound(r int) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user