Trying to get a node js agent to dump execution data

52 views
Skip to first unread message

robin.s...@clearpoint.co.nz

unread,
May 10, 2016, 5:59:03 PM5/10/16
to JaCoCo and EclEmma Users
Hi,
I've got an e2e test suite that runs cucumber/protractor tests and I'm trying to hook that into server code coverage (mixed with client coverage). I've got part way there with the agent successfully responding to a node tcp socket connection:

const buf = new Buffer([0x01,0xc0,0xc0,0x10,0x07]);
// block header
this.write(buf);
// BLOCK_CMDDUMP 64 = 0x40
const buf2 = new Buffer(1);
buf2.writeInt8(64);
this.write(buf2);

//Dump flag and reset flag (both true)
buf3 = new Buffer([0x01,0x01]);
this.write(buf3);

agents[i].client.on('data', function(data) {
//only write execution data if there actually is data to write (avoid empty files)
if (data && data.toString().trim() != "" ) {
mkpath.sync('executionData', 0700);
fs.appendFileSync('executionData/'+ this.logFileId +'.exec', data.toString());
}
this.end();
});


The binary data written to the log file at a glance looks ok to me and similar to what the maven and ant tasks output. But upon trying to generate a report from the data the java code complains that it is invalid.

I'm hoping someone here is an expert on the format of the execution data and can see something I've done wrong... or might point me towards a spec on the exeecution data so I can validate it somehow.

Marc R. Hoffmann

unread,
May 10, 2016, 6:05:35 PM5/10/16
to jac...@googlegroups.com
Hi,

first of all I have to admit that I have no experience with the runtime
you're using. But the following line looks suspicious:

> fs.appendFileSync('executionData/'+ this.logFileId +'.exec',
data.toString());

Exec files are pure binary data. If this line does any byte/string
conversations this will probably corrupt the content. Make sure to
actually dump the binary content of the buffer.

For further analysis the fill error message and stack trace when reading
the exec file would be useful.

Regards,
-marc
--
Marc Hoffmann
hoff...@mountainminds.com
_______________________________________________
Mountainminds GmbH & Co. KG

Nussbaumstr. 4 * 80336 Muenchen * Germany
Phone/Fax +49-700-68664637 * 0700-MTNMINDS

Registergericht Muenchen * HRA 80201
Mountainminds Verwaltungs GmbH
Registergericht Muenchen * HRB 143183
Geschaeftsfuehrer Marc Hoffmann

robin.s...@clearpoint.co.nz

unread,
May 11, 2016, 4:45:22 AM5/11/16
to JaCoCo and EclEmma Users
The toString method will be doing string conversion and invalidating the format... not sure why I felt that necessary. I've updated it to

> fs.appendFileSync('executionData/'+ this.logFileId +'.exec', data);

and the and merge now gets through some of the files before complaining.

The stack trace is:
Unable to read /var/lib/go-agent/pipelines/Acceptance-Tests-With-Coverage/tests/executionData/1462927504650_6901.exec
at org.jacoco.ant.MergeTask.load(MergeTask.java:87)
at org.jacoco.ant.MergeTask.execute(MergeTask.java:67)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.io.IOException: Unknown block type 20.
at org.jacoco.core.data.ExecutionDataReader.readBlock(ExecutionDataReader.java:119)
at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.java:90)
at org.jacoco.core.tools.ExecFileLoader.load(ExecFileLoader.java:59)
at org.jacoco.ant.MergeTask.load(MergeTask.java:85)
... 17 more

I see old mentions of concurrency issues on google, but these files are written synchronously in a single thread, so that should not be the issue here.

Marc R. Hoffmann

unread,
May 11, 2016, 1:46:05 PM5/11/16
to jac...@googlegroups.com
I see. Block type 0x20 is BLOCK_CMDOK which is part of the remote
protocol only and must not be written to the exec file.

Looks like you need to dig a little bit deeper into the JaCoCo binary
protocols or maybe use our Java APIs.

Regards,
-marc
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages