chiquitinxx / grooscript

Converts your Groovy code to Javascript
https://www.grooscript.org
Other
221 stars 18 forks source link

Size limit of returned data for a PhantomJS test? #45

Closed crazy4groovy closed 9 years ago

crazy4groovy commented 9 years ago

Is there a limit on the size of data that can get returned from a test?

With this script, I sometimes get **Size: 41** and other times **Size: 39** when it finally finishes.

In other words, it seems like returning too many characters (??) will instead cause a null value to be returned. But that limit changes (?!?).

@GrabConfig(systemClassLoader=true)
@Grab('org.grooscript:grooscript:1.0.1')

import org.grooscript.asts.PhantomJsTest

@PhantomJsTest(url = 'http://nelleke.deviantart.com/gallery', waitSeconds = 1)
def test1(arraySize = 45) {
    println "start"
    assert $('img[data-src]').size() > 10
    List a = $('img[data-src]').toArray().collect({ it.src })
    println "total char count: " + a.join('').size()
    arraySize = arraySize - 1
    println "chunked array size: " + a[0..(arraySize)].size()
    println "chunked char count: " + a[0..(arraySize)].join('').size()
    println "end"
    return [a[0..(arraySize)]]
}

void testSuite() {
    def resp
    int sz = 43
    while (resp == null) {
        resp = test1(--sz)
        println "***resp array size: " + resp?.flatten()?.size()
        println "***resp char count: " + resp?.flatten()?.join('')?.size()
    }
    println "***Size: $sz***"
}

testSuite()
chiquitinxx commented 9 years ago

Amazing photos :)

I have executed test 10 times and always same result. In the js test, the result comes back to groovy as a JSON. There isn't limit defined, don't know if there is a machine, system or language limit. You can increase waitSeconds, maybe not all loaded. Will try at other times.

[PhantomJs Test] Starting Test in http://nelleke.deviantart.com/gallery
  [Console]  start
  [Console]  total char count: 6758
  [Console]  chunked array size: 42
  [Console]  chunked char count: 3916
  [Console]  end
[PhantomJs Test] Number of tests: 1
[PhantomJs Test] Result SUCCESS.
***resp array size: 42
***resp char count: 3916
***Size: 42***
crazy4groovy commented 9 years ago

Interesting.. I'm reproducing similar results on my home Windows 7 desktop, however ***Size: 41*** consistently. So weird!

[PhantomJs Test] Using js local files in C:\Users\solsen\.grooscript\1.0.1
[PhantomJs Test] Starting Test in http://nelleke.deviantart.com/gallery
  [Console]  start
  [Console]  total char count: 6758
  [Console]  chunked array size: 42
  [Console]  chunked char count: 3916
  [Console]  end
[PhantomJs Test] Number of tests: 1
[PhantomJs Test] Result SUCCESS.
***resp array size: null
***resp char count: null
[PhantomJs Test] Using js local files in C:\Users\solsen\.grooscript\1.0.1
[PhantomJs Test] Starting Test in http://nelleke.deviantart.com/gallery
  [Console]  start
  [Console]  total char count: 6758
  [Console]  chunked array size: 41
  [Console]  chunked char count: 3826
  [Console]  end
[PhantomJs Test] Number of tests: 1
[PhantomJs Test] Result SUCCESS.
***resp array size: 41
***resp char count: 3826
***Size: 41***
crazy4groovy commented 9 years ago

Just going to put this here for reference. It's likely a PhantomJS bug (on Windows?), however the evaluating 'u.bind' error is interesting..

@GrabConfig(systemClassLoader=true)
@Grab('org.grooscript:grooscript:1.0.1')

import org.grooscript.asts.PhantomJsTest

@PhantomJsTest(url = 'http://nelleke.deviantart.com/gallery', waitSeconds = 0)
def test1(size) {
    def a = "x" * size
    println (a.size())
    return a
}

void testSuite() {
    def resp
    int sz = 4072
    while (resp == null) {
        resp = test1(--sz)
        println "***resp char count for $sz: " + resp?.size()
    }
    println "***passed on Size: $sz***"
    while (resp != null) {
        resp = test1(++sz)
        println "***resp char count for $sz: " + resp?.size()
    }
    println "***broke on Size: $sz***"
}

Results:

[PhantomJs Test] Using js local files in C:\Users\solsen\.grooscript\1.0.1
[PhantomJs Test] Starting Test in http://nelleke.deviantart.com/gallery
[PhantomJs Test] ONERROR: TypeError: undefined is not an object (evaluating 'u.bind')
[PhantomJs Test]   phantomjs.js:9 in onError
  [Console]  4071
[PhantomJs Test] Number of tests: 0
[PhantomJs Test] Result SUCCESS.
***resp char count for 4071: null
[PhantomJs Test] Using js local files in C:\Users\solsen\.grooscript\1.0.1
[PhantomJs Test] Starting Test in http://nelleke.deviantart.com/gallery
[PhantomJs Test] ONERROR: TypeError: undefined is not an object (evaluating 'u.bind')
[PhantomJs Test]   phantomjs.js:9 in onError
  [Console]  4070
[PhantomJs Test] Number of tests: 0
[PhantomJs Test] Result SUCCESS.
***resp char count for 4070: null
[PhantomJs Test] Using js local files in C:\Users\solsen\.grooscript\1.0.1
[PhantomJs Test] Starting Test in http://nelleke.deviantart.com/gallery
  [Console]  4069
[PhantomJs Test] Number of tests: 0
[PhantomJs Test] Result SUCCESS.
***resp char count for 4069: 4069
***passed on Size: 4069***
[PhantomJs Test] Using js local files in C:\Users\solsen\.grooscript\1.0.1
[PhantomJs Test] Starting Test in http://nelleke.deviantart.com/gallery
[PhantomJs Test] ONERROR: TypeError: undefined is not an object (evaluating 'u.bind')
[PhantomJs Test]   phantomjs.js:9 in onError
  [Console]  4070
[PhantomJs Test] Number of tests: 0
[PhantomJs Test] Result SUCCESS.
***resp char count for 4070: null
***broke on Size: 4070***

4069 chars seems like it's almost always the magic number.... Obviously [not] :\

chiquitinxx commented 9 years ago

I think is a windows console issue, I don't get that fails on Mac, even with bigger arrays. When grooscript runs phantomjs test, the results are printed in console as json, and grooscript reads that json. Maybe windows console has a limit of memory, and maybe the buffer is full at some point. Also can be an issue with groovy execution, that it has limited output in windows environments.

Yes, there is a limit on the console / return data size, in windows environments. Not a grooscript issue, but maybe some windows user can take a look :)

chiquitinxx commented 9 years ago

I suppose window users can manage with this error, so I'll add this limitation to documentation and will close this issue soon.