[ 
https://issues.apache.org/jira/browse/CASSANDRA-8289?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14212994#comment-14212994
 ] 

Robert Stupp commented on CASSANDRA-8289:
-----------------------------------------

Also added some functionality to ensure that a UDF
* is thread-safe (execute one UDF concurrently)
* is deterministic (execute one UDF several times)
As a side effect people can measure timings of UDF invocations (using metrics 
with {{System.nanoTime}} - not a micro benchmark).

Has anyone time and is in the mood to take a look at it? Would really 
appreciate any feedback about it. Code is on 
[github|https://github.com/snazy/cassandra/tree/8289-udftest] at 
{{tools/udftest}}.

In the end people should be able to build a JUnit/TestNG test that does this 
test automatically. (JUnit/TestNG is not required by the code - but can be used 
for assertions.) A unit test for this one is {{UDFTestTest}} with some code 
examples in it.

Technically the implementation takes C* as a dependency, uses the CQL parser 
code to produce a {{CreateFunctionStatement}} instance and lets it return an 
instance to {{UDFunction}}.

> Allow users to debug/test UDF
> -----------------------------
>
>                 Key: CASSANDRA-8289
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-8289
>             Project: Cassandra
>          Issue Type: New Feature
>            Reporter: Robert Stupp
>            Assignee: Robert Stupp
>              Labels: udf
>             Fix For: 3.0
>
>
> Currently it's not possible to execute unit tests against UDFs nor is it 
> possible to debug them.
> Idea is to provide some kind of minimalistic "framework" to execute at least 
> scalar UDFs from a unit test.
> Basically that UDF-executor would take the information that 'CREATE FUNCTION' 
> takes, compiles that UDF and allows the user to call it using plain java 
> calls.
> In case of the Java language it could also generate Java source files to 
> enable users to set breakpoints.
> It could also check for timeouts to identify e.g. "endless loop" scenarios or 
> do some byte code analysis to check for "evil" package usage.
> For example:
> {code}
> import org.apache.cassandra.udfexec.*
> public class MyUnitTest {
>   @Test
>   public void testIt() {
>     UDFExec sinExec = UDFExec.compile("sin", "java",
>       Double.class, // return type
>       Double.class  // argument type(s)
>     );
>     sinExec.call(2.0d);
>     sinExec.call(null);
>   }
> }
> {code}
> Note: this one is not intended to do some "magic" to start a debugger on a C* 
> node and debug it there.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to