mhjort / trombi

Load testing library for testing stateful apps with Clojure
Eclipse Public License 1.0
235 stars 19 forks source link

IndexOutOfBoundsException when splitting rate to weighted scenarios #84

Closed mhjort closed 1 year ago

mhjort commented 2 years ago

A rare corner case revealed by property based tests.

lein test clj-gatling.simulation-util-test                                                                                                                                                    {:type :clojure.test.check.clojure-test/shrunk, :clojure.test.check.clojure-test/property #clojure.test.check.generators.Generator{:gen #object[clojure.test.check.generators$gen_fmap$fn__15377 0x4355f7b6 "clojure.test.check.generators$gen_fmap$fn__15377@4355f7b6"]}, :clojure.test.check.clojure-test/params [10 10 [{:name "", :weight 1} {:name "", :weight 18} {:name "", :weight 1}]]}                                                                                                                                                                                                                                                                                                                                                                                        lein test :only clj-gatling.simulation-util-test/splits-rate-to-weighted-scenarios                                                                                                                                                                                                                                                                                                          FAIL in (splits-rate-to-weighted-scenarios) (simulation_util_test.clj:52)                                                                                                                     expected: {:result true}                                                                                                                                                                        actual: {:shrunk {:total-nodes-visited 214, :depth 41, :pass? false, :result #error {                                                                                                        :cause nil                                                                                                                                                                                    :via                                                                                                                                                                                          [{:type java.lang.IndexOutOfBoundsException                                                                                                                                                     :message nil                                                                                                                                                                                  :at [clojure.lang.RT subvec "RT.java" 1617]}]                                                                                                                                               :trace                                                                                                                                                                                        [[clojure.lang.RT subvec "RT.java" 1617]                                                                                                                                                       [clojure.core$subvec invokeStatic "core.clj" 3817]                                                                                                                                            [clojure.core$subvec invoke "core.clj" 3806]                                                                                                                                                  [clj_gatling.simulation_util$split_to_buckets invokeStatic "simulation_util.clj" 61]        
mhjort commented 2 years ago

This can be reproduced in repl with following call:

(weighted-scenarios (range 10) 10 [{:name "A" :weight 1} {:name "B" :weight 18} {:name "C" :weight 1}])

Which gives following error:

Execution error (IndexOutOfBoundsException) at clj-gatling.simulation-util/split-to-buckets (simulation_util.clj:61).