github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/worker/raft/rafttest/helpers.go (about) 1 // Copyright 2018 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package rafttest 5 6 import ( 7 "reflect" 8 9 "github.com/hashicorp/raft" 10 jc "github.com/juju/testing/checkers" 11 gc "gopkg.in/check.v1" 12 13 coretesting "github.com/juju/juju/testing" 14 ) 15 16 // CheckConfiguration waits some time for the Raft 17 // to have the expected server configuration. 18 func CheckConfiguration(c *gc.C, r *raft.Raft, expectedServers []raft.Server) { 19 var configuration raft.Configuration 20 for a := coretesting.LongAttempt.Start(); a.Next(); { 21 f := r.GetConfiguration() 22 c.Assert(f.Error(), jc.ErrorIsNil) 23 configuration = f.Configuration() 24 if reflect.DeepEqual(configuration.Servers, expectedServers) { 25 return 26 } 27 } 28 c.Assert( 29 configuration.Servers, jc.SameContents, expectedServers, 30 gc.Commentf( 31 "waited %s and still did not see the expected configuration", 32 coretesting.LongAttempt.Total, 33 ), 34 ) 35 }