freeipa icon indicating copy to clipboard operation
freeipa copied to clipboard

ipatests: /test_integration/test_krbtpolicy.py failed due to wrong python datetime parameters

Open fdvorak256 opened this issue 2 years ago • 5 comments

test_integration/test_krbtpolicy.py started to failed because there is a problem with a wrong python3.9 datetime parameters (datetime.strptime) obtained from TGT ticket.

Fix: change %Y to %y

Related: https://pagure.io/freeipa/issue/9205

Signed-off-by: Filip Dvorak [email protected]

fdvorak256 avatar Jul 20 '22 12:07 fdvorak256

Can you provide more information in the ticket on where you're seeing a failure? Links to the log(s)? The latest nightly test (nightly_latest_testing) from last night is passing http://freeipa-org-pr-ci.s3-website.eu-central-1.amazonaws.com/jobs/97595174-0816-11ed-80a5-fa163ebe8939/report.html (PR https://github.com/freeipa-pr-ci2/freeipa/pull/1881)

rcritten avatar Jul 20 '22 14:07 rcritten

@rcritten Hello, I have added checking of date from krb5 kinit output and set datetime format for datetime.strptime (%Y or %y) according to the format 2022 or 22 (year). I have checked it on LTE and it works. Could you check it? Thanks.

fdvorak256 avatar Aug 02 '22 11:08 fdvorak256

Hi @fdvorak256 The issue appears on downstream tests with RHEL 9.1. I suspect it's related to the locale settings, because klist output follows the locale settings for the date format, for instance:

$ LANG=fr_FR.utf-8 klist | grep krbtgt
11/08/2022 16:45:47  12/08/2022 02:45:47  krbtgt/[email protected]
$ LANG=C klist | grep krbtgt
08/11/22 16:45:47  08/12/22 02:45:47  krbtgt/[email protected]
$ LANG=en_US.utf-8 klist | grep krbtgt
08/11/2022 16:45:47  08/12/2022 02:45:47  krbtgt/[email protected]

I think it would be more robust to force a LANG before calling klist and parse accordingly. Otherwise we risk breaking the test if executed on an env with a different locale.

flo-renaud avatar Aug 11 '22 15:08 flo-renaud

Hi @flo-renaud Yes, the problem is probably in the locale settings, but I don't want to create some robust and too stable test because some bug might slip through. (IMO the test should run on the edge and one small error should finish with failed test) If there is some unexpected or different data format, the test fails with "ValueError". IMO it would be better to run "klist" with the default settings without forcing LANG.

fdvorak256 avatar Aug 16 '22 07:08 fdvorak256

@fdvorak256 either you are expecting a specific output in the locale-aware environment or you are not. krb5 utilities we use in this test do produce locale-aware output so you have to adapt the checks to it. It is not possible to expect a stable output if you are willingly ignore locale-awareness.

abbra avatar Aug 16 '22 07:08 abbra

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 15 '22 19:10 stale[bot]

Removing the stale label, a fix is needed for the issue.

flo-renaud avatar Oct 19 '22 16:10 flo-renaud

Hi @fdvorak256 the failure for docs/readthedocs.org:freeipa has already been fixed on the master branch and will disappear if you rebase your changes on top of the master branch.

flo-renaud avatar Dec 06 '22 21:12 flo-renaud

Hello @flo-renaud Thanks for help. Now the tests passed. Please, could you check my changes which I made? I added force LANG for kinit command and add installation of "langpacks-en" if the pkg was not available (only for sure).

fdvorak256 avatar Dec 08 '22 09:12 fdvorak256

@fdvorak256 thanks for the fix, LGTM. Could you provide a bit more details in the commit message, to make it clear that the commit only modifies the test and explain the rationale? You can remove the temp commit and I will ack when prci completes.

flo-renaud avatar Dec 14 '22 11:12 flo-renaud

I marked for backport to ipa-4-10 so that it reaches RHEL 9.x but do you also need a backport to ipa-4-9 for RHEL 8.x?

flo-renaud avatar Dec 14 '22 11:12 flo-renaud

master:

  • 1611d545492ecfcd1f4d312d62402fe7d1fb3b07 ipa tests: Add LANG before kinit command to fix issue with locale settings

flo-renaud avatar Jan 19 '23 15:01 flo-renaud