consul: Fixing FSM path tests

This commit is contained in:
Armon Dadgar 2014-10-15 15:03:58 -07:00
parent 0ea385579a
commit e571d532b2
2 changed files with 78 additions and 16 deletions

View File

@ -2,6 +2,7 @@ package consul
import (
"bytes"
"io/ioutil"
"os"
"testing"
@ -37,7 +38,11 @@ func makeLog(buf []byte) *raft.Log {
}
func TestFSM_RegisterNode(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -73,7 +78,11 @@ func TestFSM_RegisterNode(t *testing.T) {
}
func TestFSM_RegisterNode_Service(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -126,7 +135,11 @@ func TestFSM_RegisterNode_Service(t *testing.T) {
}
func TestFSM_DeregisterService(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -181,7 +194,11 @@ func TestFSM_DeregisterService(t *testing.T) {
}
func TestFSM_DeregisterCheck(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -236,7 +253,11 @@ func TestFSM_DeregisterCheck(t *testing.T) {
}
func TestFSM_DeregisterNode(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -303,7 +324,11 @@ func TestFSM_DeregisterNode(t *testing.T) {
}
func TestFSM_SnapshotRestore(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -347,7 +372,7 @@ func TestFSM_SnapshotRestore(t *testing.T) {
}
// Try to restore on a new FSM
fsm2, err := NewFSM(os.Stderr)
fsm2, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -409,7 +434,11 @@ func TestFSM_SnapshotRestore(t *testing.T) {
}
func TestFSM_KVSSet(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -444,7 +473,11 @@ func TestFSM_KVSSet(t *testing.T) {
}
func TestFSM_KVSDelete(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -490,7 +523,11 @@ func TestFSM_KVSDelete(t *testing.T) {
}
func TestFSM_KVSDeleteTree(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -537,7 +574,11 @@ func TestFSM_KVSDeleteTree(t *testing.T) {
}
func TestFSM_KVSCheckAndSet(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -594,7 +635,11 @@ func TestFSM_KVSCheckAndSet(t *testing.T) {
}
func TestFSM_SessionCreate_Destroy(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -674,7 +719,11 @@ func TestFSM_SessionCreate_Destroy(t *testing.T) {
}
func TestFSM_KVSLock(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -719,7 +768,11 @@ func TestFSM_KVSLock(t *testing.T) {
}
func TestFSM_KVSUnlock(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -782,7 +835,11 @@ func TestFSM_KVSUnlock(t *testing.T) {
}
func TestFSM_ACL_Set_Delete(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}

View File

@ -1,6 +1,7 @@
package consul
import (
"io/ioutil"
"os"
"reflect"
"testing"
@ -10,7 +11,11 @@ import (
// Testing for GH-300 and GH-279
func TestHealthCheckRace(t *testing.T) {
fsm, err := NewFSM(os.Stderr)
path, err := ioutil.TempDir("", "fsm")
if err != nil {
t.Fatalf("err: %v", err)
}
fsm, err := NewFSM(path, os.Stderr)
if err != nil {
t.Fatalf("err: %v", err)
}