tntim96 / JSCover

JSCover is a JavaScript Code Coverage Tool that measures line, branch and function coverage
GNU General Public License v2.0
399 stars 84 forks source link

Issue with instrumenting. #210

Closed saur5784 closed 9 years ago

saur5784 commented 9 years ago

I have no-instrument for "analytics.js" but even after that I am consistently getting this in logs...

20150829 11:09:17.690,11021,INFO,"Instrumenting /modules/about/AboutCtrl.js",jscover.instrument.InstrumenterService, 20150829 11:09:17.799,11048,INFO,"Instrumenting /modules/common/ntCompile/ntCompile.js",jscover.instrument.InstrumenterService, 20150829 11:09:25.372,10819,SEVERE,"/favicon.ico",jscover.server.ProxyService, java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at java.net.Socket.(Socket.java:434) at java.net.Socket.(Socket.java:211) at jscover.server.ProxyService.handleProxyRequest(ProxyService.java:379) at jscover.server.ProxyService.handleProxyGet(ProxyService.java:368) at jscover.server.InstrumentingRequestHandler.handleGet(InstrumentingRequestHandler.java:475) at jscover.server.HttpServer.run(HttpServer.java:416)

20150829 11:09:40.729,11089,SEVERE,"/analytics.js",jscover.server.ProxyService, java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at java.net.Socket.(Socket.java:434) at java.net.Socket.(Socket.java:211) at jscover.server.ProxyService.handleProxyRequest(ProxyService.java:379) at jscover.server.ProxyService.handleProxyGet(ProxyService.java:368) at jscover.server.InstrumentingRequestHandler.handleGet(InstrumentingRequestHandler.java:475) at jscover.server.HttpServer.run(HttpServer.java:416)

tntim96 commented 9 years ago

This means that the JSCover proxy cannot connect to the host where analytics.js is hosted.

If you don't want this file served by JSCover, add theanalytics.js file's host to the browsers proxy bypass list.

saur5784 commented 9 years ago

Thanks for the response. Analytics.js file is on same host as the other application files, so that will not help.

On Sun, Aug 30, 2015 at 4:20 PM, tntim96 notifications@github.com wrote:

This means that the JSCover proxy cannot connect to the host where {{analytics.js}} is hosted.

If you don't want this file served by JSCover, add the {{analytics.js}} file's host to the browsers proxy bypass list.

— Reply to this email directly or view it on GitHub https://github.com/tntim96/JSCover/issues/210#issuecomment-136216632.

tntim96 commented 9 years ago

Can you try again with this JAR and post the logs again?

saur5784 commented 9 years ago

Still the same...Funny thing, not sure why logs are getting printed twice...

20150903 13:18:23.192,241,INFO,"Instrumenting /modules/common/ntCompile/ntCompile.js",jscover.instrument.InstrumenterService, 20150903 13:18:23.339,215,INFO,"Instrumenting /modules/badgingDashboard/BadgingDashboardCtrl.js",jscover.instrument.InstrumenterService, 20150903 13:18:23.339,215,INFO,"Instrumenting /modules/badgingDashboard/BadgingDashboardCtrl.js",jscover.instrument.InstrumenterService, 20150903 13:18:23.356,212,INFO,"Instrumenting /modules/onboardedClients/OnboardedClientsCtrl.js",jscover.instrument.InstrumenterService, 20150903 13:18:23.356,212,INFO,"Instrumenting /modules/onboardedClients/OnboardedClientsCtrl.js",jscover.instrument.InstrumenterService, 20150903 13:18:46.777,282,SEVERE,"/analytics.js",jscover.server.ProxyService, java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at java.net.Socket.(Socket.java:434) at java.net.Socket.(Socket.java:211) at jscover.server.ProxyService.handleProxyRequest(ProxyService.java:379) at jscover.server.ProxyService.handleProxyGet(ProxyService.java:368) at jscover.server.InstrumentingRequestHandler.handleGet(InstrumentingRequestHandler.java:475) at jscover.server.HttpServer.run(HttpServer.java:416)

20150903 13:19:54.517,289,INFO,"Saving JSON",jscover.report.JSONDataSaver, 20150903 13:19:54.517,289,INFO,"Saving JSON",jscover.report.JSONDataSaver, 20150903 13:20:08.943,335,INFO,"Instrumenting /modules/common/ntAppIcon/ntApp

On Wed, Sep 2, 2015 at 4:02 PM, tntim96 notifications@github.com wrote:

Can you try again with this JAR http://jscover.sourceforge.net/JSCover-all.jar and post the logs again?

— Reply to this email directly or view it on GitHub https://github.com/tntim96/JSCover/issues/210#issuecomment-137268607.

tntim96 commented 9 years ago

Are you sure you're using the new JAR? I changed the logs to print more information and I don't see it.

saur5784 commented 9 years ago

using 21 actually...I am using jenkins and maven to run it on another machine...I dont see this issue when running locally but only when running via jenkins slave. Do you have 22-snap up that I can use from maven ?

On Thu, Sep 3, 2015 at 2:44 PM, tntim96 notifications@github.com wrote:

Are you sure you're using the new JAR? I changed the logs to print more information and I don't see it.

— Reply to this email directly or view it on GitHub https://github.com/tntim96/JSCover/issues/210#issuecomment-137582678.

tntim96 commented 9 years ago

Try with:

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
saur5784 commented 9 years ago

Here...this is good logs..so I will try adding google-analytics to no proxy.

20150903 16:46:53.982,214,INFO,"Instrumenting 20150903 16:46:54.320,240,INFO,"Instrumenting /modules/common/ntCompile/ntCompile.js",jscover.instrument.InstrumenterService,

20150903 16:47:22.244,277,SEVERE,"http://www.google-analytics.com/analytics.js",jscover.server.ProxyService, java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) at

On Thu, Sep 3, 2015 at 2:58 PM, tntim96 notifications@github.com wrote:

Try with:

sonatype-nexus-snapshots Sonatype Nexus Snapshots https://oss.sonatype.org/content/repositories/snapshots true

— Reply to this email directly or view it on GitHub https://github.com/tntim96/JSCover/issues/210#issuecomment-137585593.

saur5784 commented 9 years ago

That seemed to have helped. Thank you so much. One last thing..I am getting this while running the report. Since its a seperate thread, the driver quits while other thread is still running the report. Is there a way I can halt or look for in order to prevent this ?

20150904 10:29:08.409,293,INFO,"Saving JSON",jscover.report.JSONDataSaver, <= Have a 5 sec sleep then driver.quit() 20150904 10:29:13.705,300,WARNING,"Error processing request string null",jscover.server.HttpServer, java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:209) at java.net.SocketInputStream.read(SocketInputStream.java:141) at java.io.FilterInputStream.read(FilterInputStream.java:133) at java.io.PushbackInputStream.read(PushbackInputStream.java:186) at java.io.FilterInputStream.read(FilterInputStream.java:107) at jscover.server.HttpServer.run(HttpServer.java:384)

20150904 10:29:13.987,1,WARNING,"Stopping JSCover",jscover.server.WebDaemon, 20150904 10:29:13.987,1,WARNING,"Stopping JSCover",jscover.server.WebDaemon,

On Fri, Sep 4, 2015 at 10:08 AM, Saurabh saurabh.thetrojan@gmail.com wrote:

Here...this is good logs..so I will try adding google-analytics to no proxy.

20150903 16:46:53.982,214,INFO,"Instrumenting 20150903 16:46:54.320,240,INFO,"Instrumenting /modules/common/ntCompile/ntCompile.js",jscover.instrument.InstrumenterService,

20150903 16:47:22.244,277,SEVERE,"http://www.google-analytics.com/analytics.js",jscover.server.ProxyService, java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) at

On Thu, Sep 3, 2015 at 2:58 PM, tntim96 notifications@github.com wrote:

Try with:

sonatype-nexus-snapshots Sonatype Nexus Snapshots https://oss.sonatype.org/content/repositories/snapshots true

— Reply to this email directly or view it on GitHub https://github.com/tntim96/JSCover/issues/210#issuecomment-137585593.

tntim96 commented 9 years ago

Here...this is good logs..so I will try adding google-analytics to no proxy

I've added the extra logging to the project.

I am getting this while running the report...Is there a way I can halt or look for

Reports are triggered by issuing a web request to JSCover, so you just have to wait for the response Coverage data stored at <file location>. If it's triggered via the UI, take a look at the manual.

Is this what you're after?

saur5784 commented 9 years ago

I am using webdriver like this : ((JavascriptExecutor) webClient).executeScript("jscoverage_report();"); So, what should I wait for complete report to be generated before I move on to destroy driver ? Maybe something similar to what you mentioned in 5.1.1Waiting for JavaScript

On Fri, Sep 4, 2015 at 5:16 PM, tntim96 notifications@github.com wrote:

Reports are triggered by issuing a web request to JSCover, so you just have to wait for the response Coverage data stored at . If it's triggered via the UI, take a look at the manual http://tntim96.github.io/JSCover/manual/manual.xml#automatingDomIdsWait.

Is this what you're after?

— Reply to this email directly or view it on GitHub https://github.com/tntim96/JSCover/issues/210#issuecomment-137886301.

tntim96 commented 9 years ago

I think that should block until the report is saved. Are you sure it's causing a problem.

saur5784 commented 9 years ago

well, since that is on a different thread than the main, the main thread kills the driver while jscover thread is still storing the reports. Thus getting this error : java.net.SocketException: Connection reset

On Tue, Sep 8, 2015 at 3:16 PM, tntim96 notifications@github.com wrote:

I think that should block until the report is saved. Are you sure it's causing a problem.

— Reply to this email directly or view it on GitHub https://github.com/tntim96/JSCover/issues/210#issuecomment-138719332.

tntim96 commented 9 years ago

the main thread kills the driver

Which thread and how? Can't the main thread wait for the thread executing the ((JavascriptExecutor) webClient).executeScript("jscoverage_report();"); to finish?

saur5784 commented 9 years ago

Its actually the way our internal tool handles driver lifecycle. Is there a way, you can change return for jscoverage_report and return done or success after its done ? I can just look for that string ?

On Tue, Sep 8, 2015 at 3:29 PM, tntim96 notifications@github.com wrote:

the main thread kills the driver

Which thread and how? Can't the main thread wait for the thread executing the ((JavascriptExecutor) webClient).executeScript("jscoverage_report();"); to finish?

— Reply to this email directly or view it on GitHub https://github.com/tntim96/JSCover/issues/210#issuecomment-138721947.

tntim96 commented 9 years ago

It returns the string Coverage data stored at <file location> which you can use, but any string returned means that it's done.