There is this unit test:
QUnit.test( 'streamInSample() - session sampling resets', function ( assert ) { var conf, tot = 0, i; conf = { sample: { rate: 0.5, unit: 'session' } }; for ( i = 0; i < 20; i++ ) { tot += mw.eventLog.streamInSample( conf ); mw.eventLog.id.resetSessionId(); } assert.notEqual( tot, 20 ); assert.notEqual( tot, 0 ); } );
If I understand correctly, this generates a random true/false value 20 times, and checks that it got at least one true and one false. This test will fail once in 2^19 attempts (about 0.0002% chance). Seems low, but it just failed in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/711505 (https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php73-noselenium-docker/48968/console), so I guess I'm pretty unlucky (or my math is wrong).
It was added in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/EventLogging/+/659060 about a year ago. There are also a few other tests that look similar, but I didn't try to figure out if they also have this issue.
Failure for reference:
23:40:11 FAILED TESTS: 23:40:11 ext.eventLogging/stream 23:40:11 ✖ streamInSample() - session sampling resets 23:40:11 Chrome Headless 90.0.4430.212 (Linux x86_64) 23:40:11 Expected: 20 23:40:11 Actual: 20 23:40:11 at Object.<anonymous> (http://localhost:9876/load.php?modules=oojs-ui-core.icons%2Cstyles%7Coojs-ui-toolbars%2Coojs-ui-widgets%2Coojs-ui-windows%2Cpapaparse%2Crangefix%2Csinonjs%2Cspark-md5%2CtreeDiffer%2Cunicodejs%7Coojs-ui-toolbars.icons%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-accessibility%2Cicons-alerts%2Cicons-content%2Cicons-editing-advanced%2Cicons-editing-citation%2Cicons-editing-core%2Cicons-editing-list%2Cicons-editing-styling%2Cicons-interactions%2Cicons-layout%2Cicons-media%2Cicons-moderation%2Cicons-movement%2Cicons-user%2Cicons-wikimedia%2Cindicators%7Cskins.minerva.messageBox.styles%7Csocket.io%7Ctest.CentralAuth%2CCite%2CDiscussionTools%2CEcho%2CEventLogging%2CGuidedTour%2CMediaWiki%2CMinervaNeue%2CTemplateData%2CVisualEditor%2CWikiEditor%2CWikimediaEvents&version=1q8ym:2672:216) 23:40:11 at runTest (node_modules/qunit/qunit/qunit.js:2496:35) 23:40:11 at Test.run (node_modules/qunit/qunit/qunit.js:2479:9) 23:40:11 at node_modules/qunit/qunit/qunit.js:2770:16 23:40:11 at processTaskQueue (node_modules/qunit/qunit/qunit.js:2051:26) 23:40:11 at node_modules/qunit/qunit/qunit.js:2055:13
(Also, the failure message states the opposite of what it should – the expected value is anything but 20. This looks like a QUnit issue though.)