Browse Source

Merge branch 'master' of https://github.com/coreos/etcd into clean-up-config

Conflicts:
	etcd.go
Ben Johnson 12 years ago
parent
commit
8952c1bd42
3 changed files with 14 additions and 3 deletions
  1. 11 0
      etcd.go
  2. 1 1
      tests/functional/simple_multi_node_test.go
  3. 2 2
      tests/functional/simple_snapshot_test.go

+ 11 - 0
etcd.go

@@ -47,6 +47,17 @@ func main() {
 		log.Verbose = true
 	}
 
+	// Setup a default directory based on the machine name
+	if config.DataDir == "" {
+		config.DataDir = config.Name + ".etcd"
+		log.Warnf("Using the directory %s as the etcd configuration directory because a directory was not specified. ", config.DataDir)
+	}
+
+	// Create data directory if it doesn't already exist.
+	if err := os.MkdirAll(config.DataDir, 0744); err != nil {
+		log.Fatalf("Unable to create path: %s", err)
+	}
+
 	// Load info object.
 	info, err := config.Info()
 	if err != nil {

+ 1 - 1
tests/functional/simple_multi_node_test.go

@@ -52,7 +52,7 @@ func templateTestSimpleMultiNode(t *testing.T, tls bool) {
 
 	result, err = c.Set("foo", "bar", 100)
 
-	if err != nil || result.Key != "/foo" || result.Value != "bar" || result.PrevValue != "bar" || result.TTL != 100 {
+	if err != nil || result.Key != "/foo" || result.Value != "bar" || result.PrevValue != "bar" || result.TTL < 95 {
 		if err != nil {
 			t.Fatal(err)
 		}

+ 2 - 2
tests/functional/simple_snapshot_test.go

@@ -55,7 +55,7 @@ func TestSimpleSnapshot(t *testing.T) {
 
 	index, _ := strconv.Atoi(snapshots[0].Name()[2:5])
 
-	if index < 507 || index > 510 {
+	if index <= 507 || index >= 510 {
 		t.Fatal("wrong name of snapshot :", snapshots[0].Name())
 	}
 
@@ -87,7 +87,7 @@ func TestSimpleSnapshot(t *testing.T) {
 
 	index, _ = strconv.Atoi(snapshots[0].Name()[2:6])
 
-	if index < 1015 || index > 1018 {
+	if index <= 1014 || index >= 1017 {
 		t.Fatal("wrong name of snapshot :", snapshots[0].Name())
 	}
 }