mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fix(internal_version_test.go) protect the checkedVersion by a lock
This commit is contained in:
parent
2817baf3f8
commit
fc84da29e8
@ -6,17 +6,23 @@ import (
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Ensure that etcd does not come up if the internal raft versions do not match.
|
||||
func TestInternalVersion(t *testing.T) {
|
||||
var mu sync.Mutex
|
||||
|
||||
checkedVersion := false
|
||||
testMux := http.NewServeMux()
|
||||
|
||||
testMux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintln(w, "This is not a version number")
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
checkedVersion = true
|
||||
})
|
||||
|
||||
@ -48,6 +54,8 @@ func TestInternalVersion(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if checkedVersion == false {
|
||||
t.Fatal("etcd did not check the version")
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user