[SERVER-66506] Create a new assert.eq helper that assigns meaning to its operands Created: 12/Apr/22  Updated: 06/Jan/23

Status: Open
Project: Core Server
Component/s: Internal Code, Shell, Testing Infrastructure
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Romans Kasperovics Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: backlog
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Sub-Tasks:
Key
Summary
Type
Status
Assignee
SERVER-69961 Assign expected / actual for assert.s... Sub-task Closed Romans Kasperovics  
SERVER-70042 Assign expected / actual for assert.d... Sub-task Closed Romans Kasperovics  
Assigned Teams:
Query Execution
Backwards Compatibility: Fully Compatible
Sprint: QE 2022-09-19, QE 2022-10-03, QE 2022-10-17, QE 2022-10-31, QE 2022-11-14, QE 2022-11-28, QE 2022-12-12, QE 2022-12-26, QE 2023-01-09, QE 2023-01-23
Participants:

 Description   

Create a new assert.eq() operator that assigns meanings to its operands – for example, explicitly making one argument expected and the other argument actual. This would allow for us to make better, more readable error messages when the assertions actually fail.

One way to migrate the code from the old assert.eq() to the new one:

  1. Rename the existing function assert.eq_deprecated(), and replace all existing usages via sed.
  2. Create a new assert.eq() with the desired semantics and start using it in new code.
  3. Create tickets to migrate older code to use the newer version
Original Description

Currently, the signature is just function (a, b, msg) and the message in case of failure is just "[1] != [0] are not equal" and you have to look into the test to understand if 1 is expected or if 0 is expected.

I suggest to change the signature to function(expected, actual, msg) and change the default message to "expected value [1] and actual value [0] are not equal". Of course, many tests still use those interchangeably, but we can write the new tests following this semantics and "fix" the existing tests over time.



 Comments   
Comment by Misha Tyulenev [ 17/May/22 ]

The same applies to assert.docEq assert.setEq etc.

Comment by Robert Guo (Inactive) [ 22/Apr/22 ]

Roman, feel free to update the function signature as you see fit or add new ones. The interface to the shell assertions are mostly self-service.

Generated at Thu Feb 08 06:05:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.