Changeset 3659
- Timestamp:
- Aug 13, 2007, 12:55:26 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 10 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/test/net/sf/basedb/test/FileUtil.java
r2938 r3659 41 41 42 42 /** 43 Upload a file to the logged in user's home directory. 43 Upload a file to the logged in user's home directory, or into the root 44 directory if the user has no home directory. 44 45 */ 45 46 public static File uploadFile(DbControl dc, String filename, String fileTypeId) … … 56 57 file.setFileType(FileType.getById(dc, SystemItems.getId(fileTypeId))); 57 58 } 58 if (!file.isInDatabase()) dc.saveItem(file); 59 60 file.upload(TestUtil.class.getResourceAsStream(path), false); 59 if (!file.isInDatabase()) 60 { 61 dc.saveItem(file); 62 file.upload(TestUtil.class.getResourceAsStream(path), false); 63 } 61 64 return file; 62 65 } -
trunk/src/test/net/sf/basedb/test/PluginUtil.java
r2938 r3659 57 57 { 58 58 59 /** 60 Create a new or load the existing plug-in configuration with a given name. Note! 61 If the configuration already exists, the parameters are not updated. 62 */ 59 63 public static PluginConfiguration createPluginConfiguration(DbControl dc, String name, String className, Map<String, Object> parameters) 60 64 { 61 65 TestUtil.write("--Creating/loading plugin configuration: " + name + "\n"); 62 66 63 ItemQuery<PluginConfiguration> query = PluginConfiguration.getQuery(); 67 PluginDefinition definition = PluginDefinition.getByClassName(dc, className); 68 ItemQuery<PluginConfiguration> query = definition.getPluginConfigurations(); 64 69 query.restrict(Restrictions.eq(Hql.property("name"), Expressions.string(name))); 65 70 List<PluginConfiguration> result = query.list(dc); 66 71 if (result.size() > 0) return result.get(0); 67 72 68 PluginDefinition definition = PluginDefinition.getByClassName(dc, className);69 73 PluginConfiguration config = PluginConfiguration.getNew(dc, definition); 70 74 config.setName(name); … … 98 102 /** 99 103 Import reporters. 104 @param jobName The name of the job 100 105 */ 101 public static void importReporters(PluginConfiguration config, File file )106 public static void importReporters(PluginConfiguration config, File file, String jobName) 102 107 throws Exception 103 108 { … … 109 114 config = PluginConfiguration.getById(dc, config.getId()); 110 115 Job job = Job.getNew(dc, config.getPluginDefinition(), config); 111 job.setName( "Importing reporters for project A");116 job.setName(jobName); 112 117 job.setParameterValue("file", new FileParameterType(), file); 113 118 job.setParameterValue("updateExisting", new BooleanParameterType(), true); -
trunk/src/test/net/sf/basedb/test/performance/RawDataTest.java
r2938 r3659 24 24 package net.sf.basedb.test.performance; 25 25 26 27 import java.util.List;28 29 26 import net.sf.basedb.core.ArrayDesign; 30 27 import net.sf.basedb.core.DbControl; 28 import net.sf.basedb.core.Experiment; 31 29 import net.sf.basedb.core.File; 32 30 import net.sf.basedb.core.FileParameterType; 33 import net.sf.basedb.core.FileType;34 31 import net.sf.basedb.core.ItemParameterType; 35 import net.sf.basedb.core.ItemQuery;36 32 import net.sf.basedb.core.Job; 37 33 import net.sf.basedb.core.PluginConfiguration; … … 39 35 import net.sf.basedb.core.RawDataTypes; 40 36 import net.sf.basedb.core.StringParameterType; 41 import net.sf.basedb.core.query.Expressions;42 import net.sf.basedb.core.query.Hql;43 import net.sf.basedb.core.query.Restrictions;44 import net.sf.basedb.test.FileUtil;45 import net.sf.basedb.test.MouseData;46 37 import net.sf.basedb.test.PluginUtil; 47 38 import net.sf.basedb.test.TestUtil; 39 import net.sf.basedb.util.Values; 48 40 49 41 /** 50 42 Import raw data. 51 43 52 44 @author nicklas … … 70 62 TestUtil.login(user, password, false); 71 63 72 // Create importers73 dc = TestUtil.getDbControl();74 // Importer for reporters75 PluginConfiguration reporterImporter = PluginUtil.createPluginConfiguration(dc,76 "Reporters for performance test",77 "net.sf.basedb.plugins.ReporterFlatFileImporter", MouseData.getReporterParameters());78 79 // Importer for raw data80 PluginConfiguration rawDataImporter = PluginUtil.createPluginConfiguration(dc,81 "Raw data for performance test",82 "net.sf.basedb.plugins.RawDataFlatFileImporter", MouseData.getGenePixRawDataParameters(false));83 84 // Importer for features85 PluginConfiguration genePixFeatureImporter = PluginUtil.createPluginConfiguration(dc,86 "Features from GenePix file",87 "net.sf.basedb.plugins.ReporterMapFlatFileImporter", MouseData.getGenePixReporterMapParameters());88 dc.commit();89 90 // Upload files91 dc = TestUtil.getDbControl();92 File reporters = FileUtil.uploadFile(dc, "plates_and_reporters.mouse.v4.37k.txt", FileType.REPORTER);93 File rawData1 = FileUtil.uploadFile(dc, "genepix.mouse.v4.37k.00h.gpr", FileType.RAW_DATA);94 File rawData2 = FileUtil.uploadFile(dc, "genepix.mouse.v4.37k.24h.gpr", FileType.RAW_DATA);95 dc.commit();96 97 // Import reporters98 PluginUtil.importReporters(reporterImporter, reporters);99 100 // Create array design101 dc = TestUtil.getDbControl();102 ArrayDesign design = createArrayDesign(dc, "Array design for performance test");103 dc.commit();104 105 // Import features106 if (!design.hasFeatures())107 {108 importFeatures(genePixFeatureImporter, rawData1, design);109 }110 111 64 // Create raw bioassays 112 65 dc = TestUtil.getDbControl(); 66 67 // Load prepared items 68 ArrayDesign design = PrepareTest.getArrayDesign(dc); 69 Experiment experiment = PrepareTest.getExperiment(dc); 70 PluginConfiguration rawDataImporter = PrepareTest.getRawDataImporter(dc); 71 File rawData1 = PrepareTest.getRawDataFile1(dc); 72 File rawData2 = PrepareTest.getRawDataFile2(dc); 73 74 long startNum = experiment.getRawBioAssays().count(dc); 113 75 RawBioAssay[] rba = new RawBioAssay[numIterations]; 114 76 for (int i = 0; i < numIterations; ++i) 115 77 { 116 rba[i] = createRawBioAssay(dc, "Performance test #" + i, design);78 rba[i] = createRawBioAssay(dc, "PerformanceTest #" + (startNum + i), design); 117 79 } 118 80 dc.commit(); 119 81 120 82 // Import raw data 83 long minTime = Long.MAX_VALUE; 84 long maxTime = 0; 85 long totalTime = 0; 121 86 for (int i = 0; i < numIterations; i += 2) 122 87 { 123 88 TestUtil.gc(); 124 89 long time = importRawData(rawDataImporter, rawData1, rba[i]) / 1000; 125 TestUtil.write("Import #" + i + "\t" + time + " s\n"); 90 totalTime += time; 91 if (time < minTime) minTime = time; 92 if (time > maxTime) maxTime = time; 93 TestUtil.write("Import #" + i + "\t" + Values.formatTime(time) + "\n"); 94 126 95 time = importRawData(rawDataImporter, rawData2, rba[i+1]) / 1000; 127 TestUtil.write("Import #" + (i + 1) + "\t" + time + " s\n"); 96 totalTime += time; 97 if (time < minTime) minTime = time; 98 if (time > maxTime) maxTime = time; 99 TestUtil.write("Import #" + (i + 1) + "\t" + Values.formatTime(time) + " s\n"); 128 100 } 101 TestUtil.write("---------------------------------------------\n"); 102 TestUtil.write("Imported " + numIterations + " raw data sets\n"); 103 TestUtil.write("Max time: " + Values.formatTime(maxTime) + "\n"); 104 TestUtil.write("Min time: " + Values.formatTime(minTime) + "\n"); 105 TestUtil.write("Mean time: " + Values.formatTime(totalTime / numIterations) + "\n"); 106 TestUtil.write("---------------------------------------------\n"); 107 108 // Add raw bioassays to experiment 109 dc = TestUtil.getDbControl(); 110 dc.reattachItem(experiment); 111 for (int i = 0; i < numIterations; i++) 112 { 113 dc.refreshItem(rba[i]); 114 experiment.addRawBioAssay(rba[i]); 115 } 116 dc.commit(); 129 117 130 118 TestUtil.logout(); … … 141 129 TestUtil.write("++Leaving raw data test (" + (ok ? "OK" : "FAILED") + ")\n"); 142 130 return ok; 143 }144 145 /**146 Create an array design or load the existing one.147 */148 public static ArrayDesign createArrayDesign(DbControl dc, String name)149 {150 TestUtil.write("--Creating/loading array design: " + name + "\n");151 152 ItemQuery<ArrayDesign> query = ArrayDesign.getQuery();153 query.restrict(Restrictions.eq(Hql.property("name"), Expressions.string(name)));154 List<ArrayDesign> result = query.list(dc);155 if (result.size() > 0) return result.get(0);156 ArrayDesign design = ArrayDesign.getNew(dc, false);157 design.setName(name);158 dc.saveItem(design);159 return design;160 }161 162 /**163 Import features.164 */165 public static void importFeatures(PluginConfiguration plugin, File file, ArrayDesign design)166 throws Exception167 {168 TestUtil.write("--Importing features from file: " + file.getName() + "\n");169 DbControl dc = TestUtil.getDbControl();170 try171 {172 plugin = PluginConfiguration.getById(dc, plugin.getId());173 Job job = Job.getNew(dc, plugin.getPluginDefinition(), plugin);174 job.setName("Importing features to array design: " + design.getName());175 job.setParameterValue("file", new FileParameterType(), file);176 job.setParameterValue("arrayDesign",177 new ItemParameterType<ArrayDesign>(ArrayDesign.class, null), design);178 job.setParameterValue("missingReporterError", new StringParameterType(), "skip");179 dc.saveItem(job);180 dc.commit();181 PluginUtil.executeJob(job);182 }183 finally184 {185 if (dc != null) dc.close();186 }187 131 } 188 132 … … 212 156 config = PluginConfiguration.getById(dc, config.getId()); 213 157 Job job = Job.getNew(dc, config.getPluginDefinition(), config); 214 job.setName("Importing data to raw bioassay: " + rba.getName()); 158 job.setName("PerformanceTest: Import data to raw bioassay: " + rba.getName()); 159 job.setSendMessage(false); 160 job.setRemoveJobWhenFinished(true); 215 161 job.setParameterValue("file", new FileParameterType(), file); 216 162 job.setParameterValue("rawBioAssay", … … 222 168 long time = System.currentTimeMillis(); 223 169 PluginUtil.executeJob(job); 224 return System.currentTimeMillis() - time;170 return System.currentTimeMillis() - time; 225 171 } 226 172 finally -
trunk/src/test/net/sf/basedb/test/performance/Run.java
r2938 r3659 24 24 package net.sf.basedb.test.performance; 25 25 26 import java.util.Arrays; 27 import java.util.HashSet; 28 import java.util.Set; 29 26 30 import net.sf.basedb.test.CmdLine; 27 31 import net.sf.basedb.test.TestUtil; … … 42 46 CmdLine cmdLine = new CmdLine(args); 43 47 44 S tring cmd = cmdLine.getCmd();45 boolean all = "all".equals(cmd);48 Set<String> cmds = new HashSet<String>(Arrays.asList(args)); 49 boolean all = cmds.contains("all"); 46 50 47 51 String user = cmdLine.getOption("-u", "root"); 48 52 String password = cmdLine.getOption("-p", "root"); 49 int numIte rations = Values.getInt(cmdLine.getOption("-n"), 100);53 int numItems = Values.getInt(cmdLine.getOption("-n"), 4); 50 54 51 55 int tests = 0; 52 boolean ok = true; 53 if (ok && (all || "raw".equals(cmd))) 56 TestUtil.begin(false); 57 boolean ok = PrepareTest.run(user, password); 58 if (ok && (all || cmds.contains("raw"))) 54 59 { 55 TestUtil.begin(false); 56 ok = RawDataTest.run(user, password, numIterations); 60 ok = RawDataTest.run(user, password, numItems); 61 tests++; 62 } 63 if (ok && (all || cmds.contains("root"))) 64 { 65 ok = RootTest.run(user, password, numItems); 66 tests++; 67 } 68 if (ok && (all || cmds.contains("filter"))) 69 { 70 ok = FilterTest.run(user, password); 71 tests++; 72 } 73 if (ok && (all || cmds.contains("lowess"))) 74 { 75 ok = LowessTest.run(user, password); 76 tests++; 77 } 78 if (ok && cmds.contains("clean")) 79 { 80 ok = PrepareTest.cleanUp(user, password); 57 81 tests++; 58 82 } -
trunk/src/test/net/sf/basedb/test/roles/PowerUserTest.java
r2981 r3659 160 160 dc.commit(); 161 161 162 PluginUtil.importReporters(reporterImporter, reporters );162 PluginUtil.importReporters(reporterImporter, reporters, "Importing reporters for project A"); 163 163 importPlates(platesImporter, plates, "Plate A", plateType); 164 164 -
trunk/src/test/set_classpath.bat
r3510 r3659 27 27 SET CP=%CP%;../../config/local 28 28 SET CP=%CP%;../../config/dist 29 SET CP=%CP%;../../config/test 29 30 30 31 REM Testdata -
trunk/src/test/set_classpath.sh
r3510 r3659 27 27 CP=$CP:../../config/local 28 28 CP=$CP:../../config/dist 29 CP=$CP:../../config/test 29 30 30 31 # Testdata
Note: See TracChangeset
for help on using the changeset viewer.