Skip to content

Commit bd2964b

Browse files
committed
[SYSTEMDS-3842] Improve test coverage of API components: ScriptExecutorUtils & JMLConnection
1 parent 3ce16d0 commit bd2964b

File tree

4 files changed

+474
-48
lines changed

4 files changed

+474
-48
lines changed

.github/workflows/javaTests.yml

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -50,41 +50,7 @@ jobs:
5050
matrix:
5151
os: [ubuntu-22.04]
5252
tests: [
53-
"org.apache.sysds.test.applications.**",
54-
"**.test.usertest.**",
55-
"**.component.c**.** -Dtest-threadCount=1 -Dtest-forkCount=1",
56-
"**.component.e**.**,**.component.f**.**,**.component.m**.**",
57-
"**.component.p**.**,**.component.r**.**,**.component.s**.**,**.component.t**.**,**.component.u**.**",
58-
"**.functions.a**.**,**.functions.binary.matrix.**,**.functions.binary.scalar.**,**.functions.binary.tensor.**",
59-
"**.functions.blocks.**,**.functions.data.rand.**,",
60-
"**.functions.countDistinct.**,**.functions.countDistinctApprox.**",
61-
"**.functions.data.misc.**,**.functions.lineage.**",
62-
"**.functions.compress.**,**.functions.data.tensor.**,**.functions.codegenalg.parttwo.**,**.functions.codegen.**,**.functions.caching.**",
63-
"**.functions.binary.matrix_full_cellwise.**,**.functions.binary.matrix_full_other.**",
64-
"**.functions.federated.algorithms.**,**.functions.federated.io.**,**.functions.federated.paramserv.**",
65-
"**.functions.federated.transform.**,**.functions.federated.fedplanner.**",
66-
"**.functions.federated.primitives.part1.** -Dtest-threadCount=1 -Dtest-forkCount=1",
67-
"**.functions.federated.primitives.part2.** -Dtest-threadCount=1 -Dtest-forkCount=1",
68-
"**.functions.federated.primitives.part3.** -Dtest-threadCount=1 -Dtest-forkCount=1",
69-
"**.functions.federated.primitives.part4.** -Dtest-threadCount=1 -Dtest-forkCount=1",
70-
"**.functions.federated.primitives.part5.** -Dtest-threadCount=1 -Dtest-forkCount=1",
71-
"**.functions.federated.monitoring.**,**.functions.federated.multitenant.**",
72-
"**.functions.federated.codegen.**,**.functions.federated.FederatedTestObjectConstructor",
73-
"**.functions.codegenalg.partone.**",
74-
"**.functions.builtin.part1.**",
75-
"**.functions.builtin.part2.**",
76-
"**.functions.frame.**,**.functions.indexing.**,**.functions.io.**,**.functions.iogen.**",
77-
"**.functions.dnn.**",
78-
"**.functions.paramserv.**",
79-
"**.functions.recompile.**,**.functions.misc.**",
80-
"**.functions.mlcontext.**",
81-
"**.functions.nary.**,**.functions.quaternary.**",
82-
"**.functions.parfor.**,**.functions.pipelines.**",
83-
"**.functions.homomorphicEncryption.**",
84-
"**.functions.unary.scalar.**,**.functions.updateinplace.**,**.functions.vect.**",
85-
"**.functions.reorg.**,**.functions.rewrite.**,**.functions.ternary.**",
86-
"**.functions.transform.**","**.functions.unique.**",
87-
"**.functions.unary.matrix.**,**.functions.linearization.**,**.functions.jmlc.**"
53+
"**.functions.jmlc.**"
8854
]
8955
java: ['11']
9056
javadist: ['adopt']

src/main/java/org/apache/sysds/api/jmlc/Connection.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -827,19 +827,6 @@ public FrameBlock convertToFrame(InputStream input, int rows, int cols, String f
827827
// Read transform meta data
828828
////////////////////////////////////////////
829829

830-
/**
831-
* Reads transform meta data from an HDFS file path and converts it into an in-memory
832-
* FrameBlock object. The column names in the meta data file 'column.names' is processed
833-
* with default separator ','.
834-
*
835-
* @param metapath hdfs file path to meta data directory
836-
* @return FrameBlock object representing transform metadata
837-
* @throws IOException if IOException occurs
838-
*/
839-
public FrameBlock readTransformMetaDataFromFile(String metapath) throws IOException {
840-
return readTransformMetaDataFromFile(null, metapath, TfUtils.TXMTD_SEP);
841-
}
842-
843830
/**
844831
* Reads transform meta data from an HDFS file path and converts it into an in-memory
845832
* FrameBlock object. The column names in the meta data file 'column.names' is processed

src/test/java/org/apache/sysds/test/component/misc/DMLScriptTest.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,31 @@
2121
package org.apache.sysds.test.component.misc;
2222

2323

24+
import org.apache.commons.cli.ParseException;
2425
import org.apache.log4j.Level;
2526
import org.apache.log4j.Logger;
2627
import org.apache.log4j.spi.LoggingEvent;
2728
import org.apache.sysds.api.DMLScript;
29+
import org.apache.sysds.api.ScriptExecutorUtils;
30+
import org.apache.sysds.api.mlcontext.Script;
31+
import org.apache.sysds.conf.ConfigurationManager;
32+
import org.apache.sysds.parser.DMLProgram;
2833
import org.apache.sysds.parser.LanguageException;
34+
import org.apache.sysds.parser.ParserFactory;
35+
import org.apache.sysds.parser.ParserWrapper;
36+
import org.apache.sysds.runtime.controlprogram.Program;
37+
import org.apache.sysds.runtime.controlprogram.context.ExecutionContext;
38+
import org.apache.sysds.runtime.controlprogram.context.ExecutionContextFactory;
2939
import org.apache.sysds.test.LoggingUtils;
3040
import org.junit.Assert;
3141
import org.junit.Test;
3242

3343
import java.io.ByteArrayOutputStream;
3444
import java.io.IOException;
3545
import java.io.PrintStream;
46+
import java.util.Arrays;
3647
import java.util.List;
48+
import java.util.Map;
3749
import java.util.concurrent.ExecutorService;
3850
import java.util.concurrent.Executors;
3951
import java.util.concurrent.Future;
@@ -42,6 +54,8 @@
4254

4355
import static org.apache.sysds.api.DMLScript.executeScript;
4456
import static org.apache.sysds.api.DMLScript.readDMLScript;
57+
import static org.apache.sysds.api.mlcontext.ScriptFactory.dml;
58+
import static org.junit.Assert.assertTrue;
4559

4660
@net.jcip.annotations.NotThreadSafe
4761
public class DMLScriptTest {
@@ -359,5 +373,44 @@ public void executeDMLWithScriptAndDebugTest() throws IOException {
359373
public void createDMLScriptInstance(){
360374
DMLScript script = new DMLScript();
361375
Assert.assertTrue(script != null);
376+
377+
}
378+
379+
@Test
380+
public void testLineageScriptExecutorUtilTestTest() throws IOException {
381+
// just for code coverage
382+
new ScriptExecutorUtils();
383+
384+
String cl = "systemds -lineage estimate -s \"print('hello')\"";
385+
String[] args = cl.split(" ");
386+
final PrintStream originalOut = System.out;
387+
try {
388+
final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
389+
System.setOut(new PrintStream(outputStreamCaptor));
390+
executeScript(args);
391+
System.setOut(originalOut);
392+
String[] lines = outputStreamCaptor.toString().split(System.lineSeparator());
393+
Assert.assertTrue(lines[0].startsWith("hello"));
394+
Assert.assertTrue(Arrays.stream(lines).anyMatch(s -> s.startsWith("Compute Time (Elapsed/Saved):")));
395+
Assert.assertTrue(Arrays.stream(lines).anyMatch(s -> s.startsWith("Space Used (C/R/L):")));
396+
Assert.assertTrue(Arrays.stream(lines).anyMatch(s -> s.startsWith("Cache Full Timestamp:")));
397+
} finally {
398+
System.setOut(originalOut);
399+
}
400+
}
401+
402+
@Test
403+
public void testScriptExecutorUtilTestTest() throws IOException, ParseException {
404+
boolean old = DMLScript.USE_ACCELERATOR;
405+
DMLScript.USE_ACCELERATOR = true;
406+
try {
407+
ExecutionContext ec = ExecutionContextFactory.createContext();
408+
ScriptExecutorUtils.executeRuntimeProgram(null, ec, ConfigurationManager.getDMLConfig(), 0, null);
409+
} catch (Error e){
410+
Assert.assertTrue("Expecting Message starting with \"Error while loading native library. Instead got:"
411+
+ e.getMessage(), e.getMessage().startsWith("Error while loading native library"));
412+
} finally {
413+
DMLScript.USE_ACCELERATOR = old;
414+
}
362415
}
363416
}

0 commit comments

Comments
 (0)