Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #460 from tpepper/master
Browse files Browse the repository at this point in the history
scheduler: more test code locking bugfixes
  • Loading branch information
markdryan authored Aug 16, 2016
2 parents c8ce4e8 + 1054f51 commit e8916ad
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ciao-scheduler/scheduler_ssntp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func TestSendAgentStatus(t *testing.T) {

server.cnMutex.Lock()
cn = server.cnMap[testutil.AgentUUID]
cn.mutex.Lock()
defer cn.mutex.Unlock()
if cn != nil && cn.status != tgtStatus {
t.Fatalf("agent node incorrect status: expected %s, got %s", tgtStatus.String(), cn.status.String())
}
Expand Down Expand Up @@ -90,6 +92,8 @@ func TestSendNetAgentStatus(t *testing.T) {

server.nnMutex.Lock()
nn = server.nnMap[testutil.NetAgentUUID]
nn.mutex.Lock()
defer nn.mutex.Unlock()
if nn != nil && nn.status != tgtStatus {
t.Fatalf("netagent node incorrect status: expected %s, got %s", tgtStatus.String(), nn.status.String())
}
Expand Down Expand Up @@ -505,6 +509,7 @@ func waitForAgent(uuid string, status *ssntp.Status) {
for {
server.cnMutex.Lock()
cn := server.cnMap[uuid]
cn.mutex.Lock()
server.cnMutex.Unlock()

if cn == nil {
Expand All @@ -514,14 +519,17 @@ func waitForAgent(uuid string, status *ssntp.Status) {
fmt.Printf("awaiting agent %s in state %s\n", uuid, status.String())
time.Sleep(50 * time.Millisecond)
} else {
cn.mutex.Unlock()
return
}
cn.mutex.Unlock()
}
}
func waitForNetAgent(uuid string, status *ssntp.Status) {
for {
server.nnMutex.Lock()
nn := server.nnMap[uuid]
nn.mutex.Lock()
server.nnMutex.Unlock()

if nn == nil {
Expand All @@ -531,8 +539,10 @@ func waitForNetAgent(uuid string, status *ssntp.Status) {
fmt.Printf("awaiting netagent %s in state %s\n", uuid, status.String())
time.Sleep(50 * time.Millisecond)
} else {
nn.mutex.Unlock()
return
}
nn.mutex.Unlock()
}
}

Expand Down Expand Up @@ -580,17 +590,17 @@ func ssntpTestsTeardown() {
wg.Add(3)

go func() {
controller.Ssntp.Close()
controller.Shutdown()
wg.Done()
}()

go func() {
netAgent.Ssntp.Close()
netAgent.Shutdown()
wg.Done()
}()

go func() {
agent.Ssntp.Close()
agent.Shutdown()
wg.Done()
}()

Expand Down

0 comments on commit e8916ad

Please sign in to comment.