Skip to content

Commit b49c5ff

Browse files
committed
[SYSTEMDS-3842] Improve test coverage of API components: ScriptExecutorUtils & JMLConnection
Closes #2253.
1 parent c6f6137 commit b49c5ff

File tree

3 files changed

+463
-13
lines changed

3 files changed

+463
-13
lines changed

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

-13
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

+45
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,24 @@
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.conf.ConfigurationManager;
2831
import org.apache.sysds.parser.LanguageException;
32+
import org.apache.sysds.runtime.controlprogram.context.ExecutionContext;
33+
import org.apache.sysds.runtime.controlprogram.context.ExecutionContextFactory;
2934
import org.apache.sysds.test.LoggingUtils;
3035
import org.junit.Assert;
3136
import org.junit.Test;
3237

3338
import java.io.ByteArrayOutputStream;
3439
import java.io.IOException;
3540
import java.io.PrintStream;
41+
import java.util.Arrays;
3642
import java.util.List;
3743
import java.util.concurrent.ExecutorService;
3844
import java.util.concurrent.Executors;
@@ -359,5 +365,44 @@ public void executeDMLWithScriptAndDebugTest() throws IOException {
359365
public void createDMLScriptInstance(){
360366
DMLScript script = new DMLScript();
361367
Assert.assertTrue(script != null);
368+
369+
}
370+
371+
@Test
372+
public void testLineageScriptExecutorUtilTestTest() throws IOException {
373+
// just for code coverage
374+
new ScriptExecutorUtils();
375+
376+
String cl = "systemds -lineage estimate -s \"print('hello')\"";
377+
String[] args = cl.split(" ");
378+
final PrintStream originalOut = System.out;
379+
try {
380+
final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
381+
System.setOut(new PrintStream(outputStreamCaptor));
382+
executeScript(args);
383+
System.setOut(originalOut);
384+
String[] lines = outputStreamCaptor.toString().split(System.lineSeparator());
385+
Assert.assertTrue(lines[0].startsWith("hello"));
386+
Assert.assertTrue(Arrays.stream(lines).anyMatch(s -> s.startsWith("Compute Time (Elapsed/Saved):")));
387+
Assert.assertTrue(Arrays.stream(lines).anyMatch(s -> s.startsWith("Space Used (C/R/L):")));
388+
Assert.assertTrue(Arrays.stream(lines).anyMatch(s -> s.startsWith("Cache Full Timestamp:")));
389+
} finally {
390+
System.setOut(originalOut);
391+
}
392+
}
393+
394+
@Test
395+
public void testScriptExecutorUtilTestTest() throws IOException, ParseException {
396+
boolean old = DMLScript.USE_ACCELERATOR;
397+
DMLScript.USE_ACCELERATOR = true;
398+
try {
399+
ExecutionContext ec = ExecutionContextFactory.createContext();
400+
ScriptExecutorUtils.executeRuntimeProgram(null, ec, ConfigurationManager.getDMLConfig(), 0, null);
401+
} catch (Error e){
402+
Assert.assertTrue("Expecting Message starting with \"Error while loading native library. Instead got:"
403+
+ e.getMessage(), e.getMessage().startsWith("Error while loading native library"));
404+
} finally {
405+
DMLScript.USE_ACCELERATOR = old;
406+
}
362407
}
363408
}

0 commit comments

Comments
 (0)