Currently, the checkSBEEnabled function first assumes SBE is on, and then checks if there is a property internalQueryForceClassicEngine and if it is true, and if so, returns that SBE is off. However, the internalQueryForceClassicEngine setParameter didn't exist prior to 5.1, so in multiversion testing, SBE is incorrectly returned as on when it shouldn't be.
In order to remedy this, we can flip the sense of the check. The checkResult flag should really be called isSBEEnabled for more clarity, be initialized to false, and then the check for each node can be:
isSbeEnabled = getParam.hasOwnProperty("internalQueryForceClassicEngine") && !getParam.internalQueryForceClassicEngine;
With this change, SBE will be off by default in the versions where the internalQueryForceClassicEngine flag doesn't exist, and will be checked as normal in versions where it does exist.
We may also want to consider adding a secondary check in the case that internalQueryForceClassicEngine doesn't exist:
isSbeEnabled = getParam.hasOwnProperty("internalQueryEnableSlotBasedExecutionEngine") && getParam.internalQueryEnableSlotBasedExecutionEngine;
This was the old flag before internalQueryForceClassicEngine was added, and this could help us still test SBE in versions before we changed the flag.