Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Attempts to address a flakey tribe test
Browse files Browse the repository at this point in the history
  • Loading branch information
jcooklin committed Jul 15, 2016
1 parent c787526 commit 0987d52
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions mgmt/tribe/tribe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,6 @@ func TestTribePluginAgreement(t *testing.T) {
}
}
}(tr)

}
log.Debugf("Waits for %d members of clan1 to have %d plugins\n", numOfTribes, numAddMessages)
wg.Wait()
Expand Down Expand Up @@ -894,25 +893,45 @@ func TestTribePluginAgreement(t *testing.T) {
after := len(t.agreements["clan1"].PluginAgreement.Plugins)
So(before, ShouldEqual, after)
So(len(t.intentBuffer), ShouldEqual, 1)

So(len(t.agreements["clan1"].PluginAgreement.Plugins), ShouldBeGreaterThan, numAddMessages)
t.handleRemovePlugin(&pluginMsg{
LTime: t.clock.Time(),
Plugin: agreement.Plugin{Name_: "pluginABC", Version_: 1},
AgreementName: "clan1",
Type: removePluginMsgType,
})
time.Sleep(50 * time.Millisecond)
So(len(t.agreements["clan1"].PluginAgreement.Plugins), ShouldBeGreaterThan, numAddMessages)
So(len(t.intentBuffer), ShouldEqual, 0)

// removes the plugin added to test duplicates
t.handleRemovePlugin(&pluginMsg{
LTime: t.clock.Time(),
Plugin: agreement.Plugin{Name_: "pluginABC", Version_: 1},
AgreementName: "clan1",
Type: removePluginMsgType,
})
time.Sleep(50 * time.Millisecond)
So(len(t.agreements["clan1"].PluginAgreement.Plugins), ShouldEqual, numAddMessages)
// wait for all members of the tribe to get back to 10 plugins
wg = sync.WaitGroup{}
for _, tr := range tribes {
wg.Add(1)
go func(tr *tribe) {
defer wg.Done()
for {
select {
case <-time.After(1500 * time.Millisecond):
c.So(len(t.agreements["clan1"].PluginAgreement.Plugins), ShouldEqual, numAddMessages)
default:
if clan, ok := tr.agreements["clan1"]; ok {
if len(clan.PluginAgreement.Plugins) == numAddMessages {
return
}
time.Sleep(50 * time.Millisecond)
}
}
}
}(tr)
}

Convey("Handles a 'remove plugin' messages broadcasted across the cluster", func(c C) {
for _, t := range tribes {
Expand Down

0 comments on commit 0987d52

Please sign in to comment.