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