Add renames to integration tests

This commit is contained in:
Audrius Butkevicius 2014-12-20 23:12:12 +00:00
parent 74d7c8e625
commit e50a8917ec
3 changed files with 23 additions and 8 deletions

View File

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

View File

@ -105,7 +105,7 @@ func testSyncCluster(t *testing.T) {
}
// 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 {
t.Fatal(err)
}
@ -207,12 +207,12 @@ func testSyncCluster(t *testing.T) {
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 {
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 {
t.Fatal(err)
}
@ -228,7 +228,7 @@ func testSyncCluster(t *testing.T) {
if err != nil {
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 {
t.Fatal(err)
}

View File

@ -116,6 +116,10 @@ func alterFiles(dir string) error {
return err
}
if strings.HasPrefix(filepath.Base(path), "test-") {
return nil
}
switch filepath.Base(path) {
case ".stfolder":
return nil
@ -161,6 +165,17 @@ func alterFiles(dir string) error {
if err != nil {
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
})