浏览代码

Add renames to integration tests

Audrius Butkevicius 10 年之前
父节点
当前提交
e50a8917ec
共有 3 个文件被更改,包括 23 次插入8 次删除
  1. 3 3
      test/h2/config.xml
  2. 5 5
      test/sync_test.go
  3. 15 0
      test/util.go

+ 3 - 3
test/h2/config.xml

@@ -7,7 +7,7 @@
         <lenientMtimes>false</lenientMtimes>
         <lenientMtimes>false</lenientMtimes>
         <copiers>1</copiers>
         <copiers>1</copiers>
         <pullers>16</pullers>
         <pullers>16</pullers>
-        <finishers>1</finishers>
+        <hashers>0</hashers>
     </folder>
     </folder>
     <folder id="s12" path="s12-2" ro="false" rescanIntervalS="15" ignorePerms="false">
     <folder id="s12" path="s12-2" ro="false" rescanIntervalS="15" ignorePerms="false">
         <device id="I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU"></device>
         <device id="I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU"></device>
@@ -16,7 +16,7 @@
         <lenientMtimes>false</lenientMtimes>
         <lenientMtimes>false</lenientMtimes>
         <copiers>1</copiers>
         <copiers>1</copiers>
         <pullers>16</pullers>
         <pullers>16</pullers>
-        <finishers>1</finishers>
+        <hashers>0</hashers>
     </folder>
     </folder>
     <folder id="s23" path="s23-2" ro="false" rescanIntervalS="15" ignorePerms="false">
     <folder id="s23" path="s23-2" ro="false" rescanIntervalS="15" ignorePerms="false">
         <device id="JMFJCXB-GZDE4BN-OCJE3VF-65GYZNU-AIVJRET-3J6HMRQ-AUQIGJO-FKNHMQU"></device>
         <device id="JMFJCXB-GZDE4BN-OCJE3VF-65GYZNU-AIVJRET-3J6HMRQ-AUQIGJO-FKNHMQU"></device>
@@ -25,7 +25,7 @@
         <lenientMtimes>false</lenientMtimes>
         <lenientMtimes>false</lenientMtimes>
         <copiers>1</copiers>
         <copiers>1</copiers>
         <pullers>16</pullers>
         <pullers>16</pullers>
-        <finishers>1</finishers>
+        <hashers>0</hashers>
     </folder>
     </folder>
     <device id="I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU" name="s1" compression="true" introducer="false">
     <device id="I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU" name="s1" compression="true" introducer="false">
         <address>127.0.0.1:22001</address>
         <address>127.0.0.1:22001</address>

+ 5 - 5
test/sync_test.go

@@ -105,7 +105,7 @@ func testSyncCluster(t *testing.T) {
 	}
 	}
 
 
 	// We'll use this file for appending data without modifying the time stamp.
 	// We'll use this file for appending data without modifying the time stamp.
-	fd, err := os.Create("s1/appendfile")
+	fd, err := os.Create("s1/test-appendfile")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -207,12 +207,12 @@ func testSyncCluster(t *testing.T) {
 			break
 			break
 		}
 		}
 
 
-		// Alter the "appendfile" without changing it's modification time. Sneaky!
-		fi, err := os.Stat("s1/appendfile")
+		// Alter the "test-appendfile" without changing it's modification time. Sneaky!
+		fi, err := os.Stat("s1/test-appendfile")
 		if err != nil {
 		if err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
-		fd, err := os.OpenFile("s1/appendfile", os.O_APPEND|os.O_WRONLY, 0644)
+		fd, err := os.OpenFile("s1/test-appendfile", os.O_APPEND|os.O_WRONLY, 0644)
 		if err != nil {
 		if err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
@@ -228,7 +228,7 @@ func testSyncCluster(t *testing.T) {
 		if err != nil {
 		if err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
-		err = os.Chtimes("s1/appendfile", fi.ModTime(), fi.ModTime())
+		err = os.Chtimes("s1/test-appendfile", fi.ModTime(), fi.ModTime())
 		if err != nil {
 		if err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}

+ 15 - 0
test/util.go

@@ -116,6 +116,10 @@ func alterFiles(dir string) error {
 			return err
 			return err
 		}
 		}
 
 
+		if strings.HasPrefix(filepath.Base(path), "test-") {
+			return nil
+		}
+
 		switch filepath.Base(path) {
 		switch filepath.Base(path) {
 		case ".stfolder":
 		case ".stfolder":
 			return nil
 			return nil
@@ -161,6 +165,17 @@ func alterFiles(dir string) error {
 			if err != nil {
 			if err != nil {
 				return err
 				return err
 			}
 			}
+		case r < 0.3 && comps > 1 && (info.Mode().IsRegular() || rand.Float64() < 0.2):
+			rpath := filepath.Dir(path)
+			if rand.Float64() < 0.2 {
+				for move := rand.Intn(comps - 1); move > 0; move-- {
+					rpath = filepath.Join(rpath, "..")
+				}
+			}
+			err = os.Rename(path, filepath.Join(rpath, randomName()))
+			if err != nil {
+				return err
+			}
 		}
 		}
 		return nil
 		return nil
 	})
 	})