ibmdb / python-ibmdb

Automatically exported from code.google.com/p/ibm-db
Apache License 2.0
304 stars 193 forks source link

Update trusted-context testscripts for current cldriver messages and also allow running from remote #945

Open imavo opened 1 month ago

imavo commented 1 month ago

Steps to Reproduce:

  1. Run the existing testcases test_trusted_context_connect.py and test_trusted_context_pconnect.py against a Db2-LUW server, using a current version of clidriver (e.g. 11.5.9)
  2. Expect both testscripts to PASS but instead they FAIL for two reasons (a) the messages output for some SQLCODEs are changed in cldriver for example with SQL0551N meaning that the expected-output does not match the actual-output, and secondly (b) the testscripts only put the ADDRESS of the Db2-server into the trusted-context which in turn will cause failures if run on an hostname that is different from the Db2-server.

Narrative

Recent versions of clidriver changed the text of some messages and as a result the existing testscripts named test_trusted_context_connect.py and test_trusted_context_pconnect.py will always fail (when previously they would have passed).

The failures happen because the expected output messages from CLI differ slightly for actual messages for SQL0551N, so the regular expressions (comparing expected-output to actual-output) will not match.

In addition, both of these testscripts create the trusted-context with the assumption that the testscripts will run on the same hostname as the Db2-server (only a single ADDRESS is specified). As a consequence , when the trusted-context testscripts run on a different computer than the Db2-server, they will fail, because the trusted-context they create omits the local hostname, and only adds the hostname of the config.hostname (which must be the Db2-server in order to connect successfully).

Changing the testscript code so that the local hostname gets added as the ADDRESS when creating the trusted context will allow the testscripts to run remotely from the Db2-server, as well as locally on the Db2-server (where that is supported/workable).

I have made the code changes locally, and both testscripts now "PASS" when run from remote.

Should I create a PR for this?

Or should I just attach the modified test-scripts here? Or do you prefer to work out the testscript changes by yourselves? Note: no code changes are needed in ibm_db.c itself, only to the two testscripts.

Earammak commented 1 month ago

@imavo, Please raise a pull request. Thanks

imavo commented 1 month ago

@Earammak P.R created (ignore the update above re the Closed PR, and instead choose the PR from the main menu. I had to discard the first PR because the DCO was missing, and redo the PR but the second time around it did not put another comment for the new PR into this ticket for some reason).