[#8] Revisions and fixes to enable YDBTest imptp tests to run and pass
All YottaDB APIs must be tested using the imptp portion of the YDBTest test framework. This commit includes various revisions and fixes to enable imptp tests to run and pass within YDBTest.See the YDBTest!1299 merge request for those changes.
To allow correct redirection of output in impjob.py instances spawned during YDBTest imptp testing, it was necessary to implement a wrapper for the ydb_stdout_stderr_adjust Simple API function. This function is wrapped by the new adjust_stdout_stderr function, which was implemented in _yottadb.c and added to yottadb.py. It is not straightforward to test directly, so test coverage for this function is accomplished by the imptp tests in YDBTest.
To allow YDBPython to be used and tested with address sanitization, the following changes were made:
- Revised
setup.pyto automatically compile YDBPython with ASAN when YDB (in$ydb_dist) is compiled with ASAN - Fixed heap-buffer-overflow detected by ASAN settings by removing erroneous
+ 1for null terminator inmemcpy()call in_yottadb.c - Fixed heap-buffer-overflow bug detected by ASAN in
ci_wrapper()- Added
gparam_liststruct to_yottadb.hfor use in callers ofydb_call_variadic_plist_func() - Revised type of
arg_valuesfromuintptr_ttogparam_listin callers ofydb_call_variadic_plist_func()
- Removed
malloc()andfree()calls, asgparam_listis now stack allocated - Updated various type casts and array assignments to match
gparam_listmember types
- Added
- Added missing
free()calls in various places
Pipeline updates:
- Revised CentOS jobs to use Rocky instead of CentOS to match other YDB repos
- Broke
.testsubjob into two subjobs:.test_ubuntuand.test_rockyto allow different ASAN specifications per platform - Increased test verbosity in pipeline by adding
-vtopytestcall, allowing overview of tests passing/failing at a glance - Added redirect of pytest
stdoutto file and added to job artifacts to facilitate debugging- Added error file for
pytestoutput to allow review ofpytest'sstderroutput
- Added error file for
- Revised
test_wordfreqto output to file instead ofstdoutand added new output files to artifacts
Test fixes:
- Added
try/exceptblock to handleKeyErrorwhen environment variables are already unset intest_no_ydb_gbldir(). This resolves failures where the test tries to unsetydb_gbldirbut it wasn't set in the environment, causing aKeyErrorexception. So, an except block catching and ignoring this exception was added to handle that case. - Decreased sleep time to 0.1 seconds in lock timeout tests to prevent timing-related failures. This was necessary because
lock_valueis a function that acquires a lock and sleeps for 0.2 seconds before releasing it. Therefore if the affected lines sleep for 0.2 seconds, it is more likely that by the time the_yottadb.lock_incr()call in each is done, the initial process has released the lock. In that case no timeout error is raised and the test fails. Reducing the timeout to 0.1 seconds (half of the time that process sleeps with the lock held) eliminates this issue by almost guaranteeing process is still sleeping while holding the lock.- This prevents the test from waiting so long that the lock is released before an attempt is made to acquire it.
- Revised
test_unsigned_int_length_bytes_overflowto use2**32(i.e.UINT32_MAX + 1) instead of(2**32) + 1(i.e.UINT32_MAX + 2) to test the off-by-one case- Corrected type size check in
anystr_to_buffer()by replacingINT32_MAXwithUINT32_MAX - Updated comments in
test_unsigned_int_length_bytes_overflowandanystr_to_buffer()
- Corrected type size check in
README.md updates:
- Updated README with package instructions
- Added cleanup instructions to README
- Added ASAN setup to README
- Added comments explaining lock_timeout tests sleep duration
- Fixed tab/spaces issue and restructured instructions for clarity
- Fixed list numbering in various places that were out of order and made one item lists unordered instead of numbered lists
- Changed secondary headers to use
##(h2) instead of#(h1) for clearer organization and consistency with HTML best practice
Miscellaneous changes:
- Added
tmp*to.gitignoreto ignore auto-generatedtmp.mupipfile and test subdirectories used for test database creation - Replaced various return values of
FALSEwith!YDB_OKto make return value success/failure format consistent with YDB API calls, which returnYDB_OKon success - Renamed
YDB_INSTALL_DIRtoYDB_DIST - Added missing function information to docstring for
tp() - Revisions to fix failure due to erroneous counting of '^' as part of global variable name during buffer population in
_yottadb.c- Refactored
POPULATE_NEW_BUFFERandcast_pyssize_t_to_unsigned_intinto existinganystr_to_buffer - Removed a bunch of dead code and unused variables, simplified calls to
PyArg_ParseTupleAndKeywordsby reducing argument count - Added new
YDBPY_ERR_ARG_NOT_BYTES_LIKEfor use in genericTypeErrors during argument parsing
- Refactored
- Fixed bug in functions calling the
POPULATE_SUBS_USED_AND_SUBSARRAY()macro wherein the value ofreturn_nullwas not checked across macro calls, allowing failures in prior macros to go undetected. This is now fixed by the following changes:- Refactored
POPULATE_SUBS_USED_AND_SUBSARRAY()intopopulate_subs_used_and_subsarray()function - Replaced above macro with new function and relevant error handling throughout
_yottadb.c - Refactored affected functions to add explicit error checking, cleanup, and remove implicit fall-throughs via
return_nullvariable
- Refactored
- Corrected SIG-11 in
set()due to unallocated default value, by adding default value and conditionalfree()in the case where the default is NOT used - Added default Python parameter initialization to some functions
- Added
INT32_MAXoverflow check toanystr_to_buffer - Reduced duplication by moving buffer and subsarray population and cleanup into new
INVOKE_ANYSTR_TO_BUFFERandINVOKE_POPULATE_SUBS_USED_AND_SUBSARRAY_AND_CLEANUP_VARNAMEmacros - Fixed compiler warnings on freeing of string literals by converting these literals into heap allocated variables (the compiler did not respect/understand the logic that prevented this scenario and issued this warning anyway)
- Split
YDBTimeoutErrorintoYDBLockTimeoutErrorandYDBTpTimeoutErrorto distinguish timeouts issued bylock()andtp() - Revised
conftest.pyto store both stdout and stderr output inexecute()function for use in debugging - Removed newlines before returns in
_yottadb.c