Browse Source

Keep syncthing running during integration test

Jakob Borg 11 years ago
parent
commit
fbd5ddea72
4 changed files with 39 additions and 19 deletions
  1. 1 1
      integration/h1/config.xml
  2. 1 1
      integration/h2/config.xml
  3. 1 1
      integration/h3/config.xml
  4. 36 16
      integration/test.sh

+ 1 - 1
integration/h1/config.xml

@@ -30,7 +30,7 @@
         <localAnnounceEnabled>true</localAnnounceEnabled>
         <parallelRequests>16</parallelRequests>
         <maxSendKbps>0</maxSendKbps>
-        <rescanIntervalS>60</rescanIntervalS>
+        <rescanIntervalS>10</rescanIntervalS>
         <reconnectionIntervalS>5</reconnectionIntervalS>
         <maxChangeKbps>1000</maxChangeKbps>
         <startBrowser>false</startBrowser>

+ 1 - 1
integration/h2/config.xml

@@ -38,7 +38,7 @@
         <localAnnounceEnabled>true</localAnnounceEnabled>
         <parallelRequests>16</parallelRequests>
         <maxSendKbps>0</maxSendKbps>
-        <rescanIntervalS>60</rescanIntervalS>
+        <rescanIntervalS>15</rescanIntervalS>
         <reconnectionIntervalS>5</reconnectionIntervalS>
         <maxChangeKbps>1000</maxChangeKbps>
         <startBrowser>false</startBrowser>

+ 1 - 1
integration/h3/config.xml

@@ -30,7 +30,7 @@
         <localAnnounceEnabled>true</localAnnounceEnabled>
         <parallelRequests>16</parallelRequests>
         <maxSendKbps>0</maxSendKbps>
-        <rescanIntervalS>60</rescanIntervalS>
+        <rescanIntervalS>20</rescanIntervalS>
         <reconnectionIntervalS>5</reconnectionIntervalS>
         <maxChangeKbps>1000</maxChangeKbps>
         <startBrowser>false</startBrowser>

+ 36 - 16
integration/test.sh

@@ -2,7 +2,7 @@
 
 export STNORESTART=1
 
-iterations=5
+iterations=${1:-5}
 
 id1=I6KAH7666SLLL5PFXSOAUFJCDZYAOMLEKCP2GB3BV5RQST3PSROA
 id2=JMFJCXBGZDE4BOCJE3VF65GYZNAIVJRET3J6HMRAUQIGJOFKNHMQ
@@ -12,12 +12,14 @@ go build genfiles.go
 go build md5r.go
 go build json.go
 
-testConvergence() {
+start() {
 	echo "Starting..."
 	for i in 1 2 3 ; do
 		STPROFILER=":909$i" syncthing -home "h$i" &
 	done
+}
 
+testConvergence() {
 	while true ; do
 		sleep 5
 		s1comp=$(curl -s "http://localhost:8082/rest/connections" | ./json "$id1/Completion")
@@ -29,8 +31,6 @@ testConvergence() {
 		tot=$(($s1comp + $s2comp + $s3comp))
 		echo $tot / 300
 		if [[ $tot == 300 ]] ; then
-			echo "Stopping..."
-			pkill syncthing
 			break
 		fi
 	done
@@ -72,10 +72,36 @@ testConvergence() {
 		fi
 	done
 	if [[ $ok != 7 ]] ; then
+		pkill syncthing
 		exit 1
 	fi
 }
 
+alterFiles() {
+	pkill -STOP syncthing
+	for i in 1 2 3 12-1 12-2 23-2 23-3 ; do
+		pushd "s$i" >/dev/null
+
+		nfiles=$(find . -type f | wc -l)
+		if [[ $nfiles > 2000 ]] ; then
+			todelete=$(( $nfiles - 2000 ))
+			echo "Deleting $todelete files..."
+			find . -type f \
+				| sort -k 1.16 \
+				| head -n "$todelete" \
+				| xargs rm -f
+		fi
+
+		../genfiles -maxexp 22 -files 600
+		echo "  $i: append to large file"
+		dd if=/dev/urandom bs=1024k count=4 >> large-$i 2>/dev/null
+		../md5r -l > ../md5-tmp
+		(grep -v large ../md5-tmp ; grep "large-$i" ../md5-tmp) | grep -v '/.syncthing.' > ../md5-$i
+		popd >/dev/null
+	done
+	pkill -CONT syncthing
+}
+
 echo "Setting up files..."
 for i in 1 2 3 12-1 12-2 23-2 23-3; do
 	rm -f h$i/*.idx.gz
@@ -98,21 +124,15 @@ for i in 1 2 3 12-1 12-2 23-2 23-3 ; do
 	popd >/dev/null
 done
 
+start
 testConvergence
 
-for ((t = 0; t < $iterations; t++)) ; do
-	echo "Add and remove random files ($((t+1)) / $iterations)..."
-	for i in 1 2 3 12-1 12-2 23-2 23-3 ; do
-		pushd "s$i" >/dev/null
-		rm -rf */?[02468ace]
-		../genfiles -maxexp 22 -files 600
-		echo "  $i: append to large file"
-		dd if=/dev/urandom bs=1024k count=4 >> large-$i 2>/dev/null
-		../md5r -l > ../md5-tmp
-		(grep -v large ../md5-tmp ; grep "large-$i" ../md5-tmp) > ../md5-$i
-		popd >/dev/null
-	done
+for ((t = 1; t <= $iterations; t++)) ; do
+	echo "Add and remove random files ($t / $iterations)..."
+	alterFiles
 
+	echo "Waiting..."
+	sleep 30
 	testConvergence
 done