Update of /cvsroot/nutch/nutch/src/test/net/nutch/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6911/src/test/net/nutch/util
Modified Files:
TestNutchFS.java
Log Message:
Test code was hanging instead of emitting a proper
failure message. No more.
Index: TestNutchFS.java
===================================================================
RCS file: /cvsroot/nutch/nutch/src/test/net/nutch/util/TestNutchFS.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestNutchFS.java 30 Jan 2004 22:11:44 -0000 1.1
--- TestNutchFS.java 1 Feb 2004 21:36:44 -0000 1.2
***************
*** 14,17 ****
--- 14,18 ----
*************************************************/
public class TestNutchFS extends TestCase {
+ static int MAX_WAIT = 8000;
static String CP_TEMPLATE = "/bin/cp %srcpath% %dstpath%";
static String RM_TEMPLATE = "/bin/rm %dstpath%";
***************
*** 53,57 ****
try {
// Emit a single file from this pid for each share group
- System.out.println(" Worker " + curPid + ": writing");
for (int i = 0; i < numPids; i++) {
// Grab a new file and write a line of text to it
--- 54,57 ----
***************
*** 70,74 ****
// Get all the files intended for this share group
- System.out.println(" Worker " + curPid + ": finding");
for (int i = 0; i < numPids; i++) {
NutchFile f = new NutchFile(nutchfs, "db", "share" + curPid, new
File("f" + i));
--- 70,73 ----
***************
*** 88,92 ****
// Now rename all the files that this writer waited for
- System.out.println(" Worker " + curPid + ": renaming");
for (int i = 0; i < numPids; i++) {
NutchFile f = new NutchFile(nutchfs, "db", "share" + curPid, new
File("f" + i));
--- 87,90 ----
***************
*** 96,100 ****
// Now delete all the files that this writer just renamed
- System.out.println(" Worker " + curPid + ": deleting");
for (int i = 0; i < numPids; i++) {
NutchFile f = new NutchFile(nutchfs, "db", "share" + curPid, new
File("f_moved" + i));
--- 94,97 ----
***************
*** 102,106 ****
}
- System.out.println(" Worker " + curPid + ": complete");
} catch (IOException ie) {
this.exception = ie;
--- 99,102 ----
***************
*** 129,136 ****
}
! NutchFileSystem nutchfs[] = new NutchFileSystem[numWorkers];
Tester testers[] = new Tester[numWorkers];
for (int i = 0; i < testers.length; i++) {
! testers[i] = new Tester(new NutchNFSFileSystem(dbRoot, true), i,
numWorkers);
}
--- 125,132 ----
}
! NutchFileSystem nutchfs = new NutchNFSFileSystem(dbRoot, true);
Tester testers[] = new Tester[numWorkers];
for (int i = 0; i < testers.length; i++) {
! testers[i] = new Tester(nutchfs, i, numWorkers);
}
***************
*** 139,147 ****
fullTest(testers);
} finally {
! for (int i = 0; i < nutchfs.length; i++) {
! try {
! nutchfs[i].close();
! } catch (IOException ie) {
! }
}
}
--- 135,141 ----
fullTest(testers);
} finally {
! try {
! nutchfs.close();
! } catch (IOException ie) {
}
}
***************
*** 207,216 ****
* Tester objects to complete execution.
*/
! int fullTest(Tester testers[]) {
int numWorkers = testers.length;
Thread workers[] = new Thread[numWorkers];
// Kick off a thread per worker
- System.out.println("Launching " + numWorkers + " nutchFS clients");
for (int i = 0; i < workers.length; i++) {
workers[i] = new Thread(testers[i]);
--- 201,209 ----
* Tester objects to complete execution.
*/
! int fullTest(Tester testers[]) throws IOException {
int numWorkers = testers.length;
Thread workers[] = new Thread[numWorkers];
// Kick off a thread per worker
for (int i = 0; i < workers.length; i++) {
workers[i] = new Thread(testers[i]);
***************
*** 219,226 ****
// Wait for the threads to finish
! System.out.println("Waiting for workers to complete...");
for (int i = 0; i < workers.length; i++) {
try {
! workers[i].join();
} catch (InterruptedException ie) {
System.out.println("Received InterruptedException when waiting for
worker " + i + ". Aborting...");
--- 212,226 ----
// Wait for the threads to finish
! int numStuck = 0;
for (int i = 0; i < workers.length; i++) {
+ long start = System.currentTimeMillis();
try {
! workers[i].join(MAX_WAIT);
! long end = System.currentTimeMillis();
! if (end - start >= MAX_WAIT) {
! numStuck++;
! System.out.println("Worker " + numStuck + " took more than " +
MAX_WAIT + "ms to return.");
! throw new IOException("Worker " + numStuck + " took more than "
+ MAX_WAIT + "ms to return.");
! }
} catch (InterruptedException ie) {
System.out.println("Received InterruptedException when waiting for
worker " + i + ". Aborting...");
***************
*** 228,234 ****
}
}
- System.out.println();
- System.out.println("All workers complete");
- System.out.println();
// Check if any emitted exceptions
--- 228,231 ----
***************
*** 238,245 ****
System.out.println("Worker " + i + " reported exception " +
testers[i].getFailure());
testers[i].getFailure().printStackTrace();
! numExceptions++;
}
}
return numExceptions;
}
--- 235,246 ----
System.out.println("Worker " + i + " reported exception " +
testers[i].getFailure());
testers[i].getFailure().printStackTrace();
! throw testers[i].getFailure();
}
}
+ System.out.println();
+ System.out.println("All workers complete");
+ System.out.println();
+
return numExceptions;
}
***************
*** 315,318 ****
--- 316,320 ----
* It runs a test of 4 simulated machines.
*/
+ /**
public void testNutchRFS() throws IOException {
File tmpTest = File.createTempFile("testnutchrfs", "tmp");
***************
*** 320,323 ****
--- 322,326 ----
fullRFSTest(tmpTest, 4);
}
+ **/
/**
***************
*** 375,379 ****
tnf.testNutchNFS();
} else if ("rfs".equals(testType)) {
! tnf.testNutchRFS();
} else {
System.out.println("Sorry, no defaulttest type called: " + testType);
--- 378,382 ----
tnf.testNutchNFS();
} else if ("rfs".equals(testType)) {
! //tnf.testNutchRFS();
} else {
System.out.println("Sorry, no defaulttest type called: " + testType);
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Nutch-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nutch-cvs