Skip to content

[SYSTEMDS-3842] Improve test coverage of API components: ScriptExecutorUtils, jmlc.Connection #2253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions src/main/java/org/apache/sysds/api/jmlc/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -827,19 +827,6 @@ public FrameBlock convertToFrame(InputStream input, int rows, int cols, String f
// Read transform meta data
////////////////////////////////////////////

/**
* Reads transform meta data from an HDFS file path and converts it into an in-memory
* FrameBlock object. The column names in the meta data file 'column.names' is processed
* with default separator ','.
*
* @param metapath hdfs file path to meta data directory
* @return FrameBlock object representing transform metadata
* @throws IOException if IOException occurs
*/
public FrameBlock readTransformMetaDataFromFile(String metapath) throws IOException {
return readTransformMetaDataFromFile(null, metapath, TfUtils.TXMTD_SEP);
}

/**
* Reads transform meta data from an HDFS file path and converts it into an in-memory
* FrameBlock object. The column names in the meta data file 'column.names' is processed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,24 @@
package org.apache.sysds.test.component.misc;


import org.apache.commons.cli.ParseException;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.sysds.api.DMLScript;
import org.apache.sysds.api.ScriptExecutorUtils;
import org.apache.sysds.conf.ConfigurationManager;
import org.apache.sysds.parser.LanguageException;
import org.apache.sysds.runtime.controlprogram.context.ExecutionContext;
import org.apache.sysds.runtime.controlprogram.context.ExecutionContextFactory;
import org.apache.sysds.test.LoggingUtils;
import org.junit.Assert;
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -359,5 +365,44 @@ public void executeDMLWithScriptAndDebugTest() throws IOException {
public void createDMLScriptInstance(){
DMLScript script = new DMLScript();
Assert.assertTrue(script != null);

}

@Test
public void testLineageScriptExecutorUtilTestTest() throws IOException {
// just for code coverage
new ScriptExecutorUtils();

String cl = "systemds -lineage estimate -s \"print('hello')\"";
String[] args = cl.split(" ");
final PrintStream originalOut = System.out;
try {
final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
System.setOut(new PrintStream(outputStreamCaptor));
executeScript(args);
System.setOut(originalOut);
String[] lines = outputStreamCaptor.toString().split(System.lineSeparator());
Assert.assertTrue(lines[0].startsWith("hello"));
Assert.assertTrue(Arrays.stream(lines).anyMatch(s -> s.startsWith("Compute Time (Elapsed/Saved):")));
Assert.assertTrue(Arrays.stream(lines).anyMatch(s -> s.startsWith("Space Used (C/R/L):")));
Assert.assertTrue(Arrays.stream(lines).anyMatch(s -> s.startsWith("Cache Full Timestamp:")));
} finally {
System.setOut(originalOut);
}
}

@Test
public void testScriptExecutorUtilTestTest() throws IOException, ParseException {
boolean old = DMLScript.USE_ACCELERATOR;
DMLScript.USE_ACCELERATOR = true;
try {
ExecutionContext ec = ExecutionContextFactory.createContext();
ScriptExecutorUtils.executeRuntimeProgram(null, ec, ConfigurationManager.getDMLConfig(), 0, null);
} catch (Error e){
Assert.assertTrue("Expecting Message starting with \"Error while loading native library. Instead got:"
+ e.getMessage(), e.getMessage().startsWith("Error while loading native library"));
} finally {
DMLScript.USE_ACCELERATOR = old;
}
}
}
Loading
Loading