X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=testsrc%2Fcompbio%2Fengine%2FLoadBalancerTester.java;fp=testsrc%2Fcompbio%2Fengine%2FLoadBalancerTester.java;h=f3457208035ef1f246fa44fe4a508bf13ac7eba9;hb=babb6decd107f2769f1fbcce00afcda16bd07110;hp=0000000000000000000000000000000000000000;hpb=8bb35115758f447219bef40d3e7c1f1ac9ba3ed6;p=proteocache.git diff --git a/testsrc/compbio/engine/LoadBalancerTester.java b/testsrc/compbio/engine/LoadBalancerTester.java new file mode 100644 index 0000000..f345720 --- /dev/null +++ b/testsrc/compbio/engine/LoadBalancerTester.java @@ -0,0 +1,68 @@ +package compbio.engine; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.List; + +import org.testng.annotations.Test; + +import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.SequenceUtil; +import compbio.engine.client.ConfiguredExecutable; +import compbio.engine.client.Executable.ExecProvider; +import compbio.metadata.AllTestSuit; +import compbio.metadata.JobSubmissionException; +import compbio.metadata.Limit; +import compbio.metadata.PresetManager; +import compbio.runner.msa.ClustalW; + +public class LoadBalancerTester { + + @Test + public void testLoadBalance() { + /** + * This is 5 sequence x per 20000 length + */ + String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + + "testlimit.fasta"; + try { + FileInputStream fio = new FileInputStream(test_input); + List data = SequenceUtil.readFasta(fio); + fio.close(); + assertNotNull(data); + assertTrue(data.size() > 0); + + ClustalW clustal = new ClustalW(); + /** + * ClustalW local limit is 2 sequences per 500 letters + */ + ConfiguredExecutable confClust = Configurator + .configureExecutable(clustal); + ExecProvider aEngine = LoadBalancer.getEngine(confClust, data); + Limit locExec = new Limit(2, 500, PresetManager.LOCAL_ENGINE_LIMIT_PRESET); + // For testing of production configuration uncomment + //Limit locExec = confClust + // .getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET); + assertTrue(locExec.getSeqNumber() <= data.size() + || locExec.getAvgSeqLength() * locExec.getSeqNumber() <= Limit + .getAvgSequenceLength(data)); + // Engine will be local because LoadBalancer accessed the presets & limits + // directly + // For testing of production configuration uncomment + // assertEquals(aEngine, ExecProvider.Cluster); + + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + + } +}