Wednesday, 2025-10-29

sean-k-mooneyhi folks, not urgent but one topic that came up in the watcher seesion today was the intorduction of pytest-based selenium test and fixture to horizon in the context of addign similar watcher-dashbaord testing in the future. manila-ui has also just added it https://review.opendev.org/c/openstack/manila-ui/+/961503 the problem is that using pytest as anythign more then a test19:09
sean-k-mooneyrunner is explcity agaisnt the pti for python projects https://github.com/openstack/governance/blob/master/reference/pti/python.rst#python-test-running and changing this in the past has previously been rejected on the ground that we did nto want to split the comunity by using two diffent python testing framewrosk that work in a fundemaly diffent way. i.e. every thign shoudl be19:09
sean-k-mooneybased on the standard lib unittests module and its helpers like fixutre and test tools19:09
fungiit's worth approaching pragmatically... is there a specific reason why it's using pytest? is it doing something that ((o)s)testr can't?19:10
sean-k-mooneyone fo the thigns we are evaulateing in wathcer is how to test the ui and we were going to explore usign playwrite instead of selenium as well but we now have a problem in that we could build on the work the horizon team is doing19:11
sean-k-mooneybut i really dont want ot have to mix pytest with the rest of our test or have to ways of writing test for watcher19:11
sean-k-mooneyfungi: not that im aware of. they used it because there wre django fixtures for pytest19:11
fungifor some reason i thought testr could use the same fixtures as pytest19:12
sean-k-mooneybut django uses the standard unit test modules and you can build the exact same fixture effectivly without pytest19:12
gouthamryes, that's the answer i got when i asked a similar queston.. i actually don't know if there are equivalents in unittest itself19:12
sean-k-mooneythere is19:12
gouthamris that code we'd need to create/maintain in horizon though?19:12
fungiif it's just a matter of the people who contributed the tests didn't know how to port them to unittest, then that seems worthwhile to help them fix19:13
fungiis the code not in the horizon repo? if not, how is it being consumed in jobs?19:13
gouthamr+119:13
sean-k-mooneyso this was in teh manial-ui repo bug there is code in horizong too19:14
sean-k-mooneyhttps://github.com/openstack/horizon/blob/4b81bd78fc22b846c82b18fc70bec5b49163f514/openstack_dashboard/test/selenium/ui/conftest.py19:15
sean-k-mooneyhttps://github.com/openstack/horizon/blob/4b81bd78fc22b846c82b18fc70bec5b49163f514/openstack_dashboard/test/selenium/integration/test_credentials.py19:16
sean-k-mooneythe seleinima based integration test were rewrite to this approch recently19:16
sean-k-mooneywell not super recently 19:17
sean-k-mooneyit seams to have started in 2023 https://github.com/openstack/horizon/commit/36536272ff6e1f191cf150892af814a6d41ba0ae19:17
sean-k-mooneyso as of bobcat horizon has depened on ptytest in the defintion of the selenium tests not just as an optional test runner19:18
sean-k-mooneydjangos native test suite uses unitests by the way https://docs.djangoproject.com/en/5.2/topics/testing/overview/#module-django.test and there example code use it too https://docs.djangoproject.com/en/5.2/topics/testing/tools/#liveservertestcase19:20
sean-k-mooneypytest is also commonly used with django but it seam like the team was not ware of the pti requirements when this work began.19:21
fungigot it, so really it's just something that should have been fixed/cleared up during development but got missed19:23
sean-k-mooneyright, and now there is 2 years of familarity with how it works and its starte to be adopted by other teams19:24
sean-k-mooneyso beign pargmatic we coudl update the pti to allow it with all the implciation that has. we coudl accpat the fact that horizon has alwasy been a littel special and bless it in that one case (selenium testing)19:25
sean-k-mooneyor we need to have a wider dicussion19:25
gouthamryou got thoughts out of my brain ^19:25
gouthamrwhen running tests with manila-ui (or horizon, or any ui plugin), i see differences 19:25
sean-k-mooneyto be totally transparent i would prefer not to have to use selenium either i woudl perfer to explroe plywrite btu if we have a common integration based on selenium and it now stable that not beyond reaons19:26
* gouthamr #TIL about playwright19:28
sean-k-mooneyi did a bit of reasuch for the grian-ui plugin in to how to do django based applciation testing in 2025 and what was/is the current trends19:29
sean-k-mooneymainly i didnt want to end up wiht technial debt19:29
fungiit sounds like we already ended up with technical debt in this case, but have an opportunity to fill in the hole rather than digging it even deeper19:30
clarkbfungi: some parts of pytest are standard conforming and work broadly and other parts are not. This means that you can use pytest to run the tests if you want as long as we stick to the standard but if you are not careful and add pytest bits that are not standards based then you may need to use pytest to run the tests19:30
clarkbthis is the upside to using standards based runners in CI, it ensures everyone else can use whichever runner they like19:31
fungiaha, so maybe we could just run this with testr regardless of whethet it's pytest or unittest based19:31
gouthamrdon't think it'll work :P 19:31
gouthamrhttps://opendev.org/openstack/horizon/src/commit/83117a21845e8b94939ea89b33df9287bd9fc8cf/tox.ini#L104 this is the invocation19:31
sean-k-mooneypytest can run  the stdlibs unittest19:32
sean-k-mooneybut i dont think the revers works19:32
sean-k-mooneypytest is doign dependcy injection19:32
sean-k-mooneyso to enabel a fixture you defein a funciton that takes an argumetn with the same name as the fixture19:33
sean-k-mooneya standard test runner wont do that as far as im aware19:33
clarkbseparately I think pytest has effectively won so the idea of a standard for unittesting is less valuable these days. THat said I'm not sure what pytests parallel test running support is like these days (it was poor once upon a time but I know it has improved)19:34
clarkbit probably wouldn't be the end of the world to just use pytest given its popularity assuming the CI runtimes can be kept down19:35
clarkbbut ya the theory behind using a standard based test runner was in part that developer A could choose pytest and developer B could choose whatever their IDE supports and developer C could just run what CI runs and everything would interoperate19:35
sean-k-mooneyare of the issues in the past was lack fo subunit output and integration  our ci tooling as a result19:35
sean-k-mooneybut ya its very common outside the openstack comunity19:35
sean-k-mooneybut it entirly new to us19:36
clarkbas a non IDE user I'm not sure what that landscape looks like today19:36
clarkbbut that is probably the main reason to continue to commit to standards: if it makes IDE usage easier19:36
sean-k-mooneyits supproted in both19:36
sean-k-mooneyand i fiend it tends to run our test beter sometimes19:36
sean-k-mooneyeventlet makes thigns hard19:36
fungialso worth pointing out a second time, there is a standard in python that the openstack community adheres to, and pytest is not entirely standards-compliant in that regard19:37
sean-k-mooneythat and we break tings by havign top leve moduels called fixtures19:37
clarkbit == pytest or the standards based system?19:37
sean-k-mooneywhich alis the fixtures package19:37
sean-k-mooneyi.e. this https://github.com/openstack/nova/tree/master/nova/tests/fixtures breaks the ide integration because you ingetrate by addign the test path to your python path19:38
sean-k-mooneypytest sometime work better for me in vs code but not alwasy again nova having a fixtures module causes test loading problems but eventlet cause more19:38
sean-k-mooneywe shoudl really rename that modlue local_fixture to fix that but time19:39
clarkbthats a funny interaction since it really shouldn't be so magical that it breaks like that19:39
sean-k-mooneyso pytest is messing with the python path to supprot things like the src layout for packages19:39
sean-k-mooneyand because the ide integration put your test path first it cause issues19:40
sean-k-mooneythe workaround is to go one level depter say to https://github.com/openstack/nova/tree/master/nova/tests/functional/regressions19:40
sean-k-mooneybaiscly you update the test search path to avoid the aliasing issue. but that nova specific 19:41
gouthamrbesides horizon and plugins, i see pytest being used in testing swift, skyline, python-observabilityclient, rally, etc19:41
clarkbre subunit I don't know how critical the use of that is as long as there are other serialization formats that can be used to debug cross test interactions19:43
clarkbwith subunit and ostestr you can grab a subunit file from CI or someone else, load it into your local db then have the test tool try to auto discover cross test interactions that produced an observed failure19:43
fungii think swift never adopted unittest fully (they were the last holdouts for nosetest for ages)19:44
clarkbI have no idea if pytest can do that. And maybe no one debugs test cases like that anyway so it doesn't matter (I used it a lot back when we made the test cases run in parallel but once the initial set of problems were sorted out then it became a lot simpler to debug one offs)19:44
fungiskyline and rally are good examples of projects developed outside the openstack community and injected later after they'd made their own choices independently of community standards19:44
fungi(rally much longer ago than skyline but similar situations)19:45
fungii'm unsure where python-observabilityclient came from, but again seems likely to have been developed outside the usual circle19:46
clarkbanyway long story short its possible that through its popularity pytest is now supported everywhere it matters and that parallelized testing works well enough for us to not worry too much about being standards compliant to ensure IDEs etc work19:47
gouthamrtons of plugins to pytest, but don't know if they're all maintained well, pytest-subunit promises to provide subunit compatibility, but i don't see a reference to it in code.o.o .. we're probably just getting an HTML o/p with pytest-html 19:47
clarkb8 years ago or whenever pytest first showed up this wasn't the case but its been a long time19:48
gouthamr++19:49
sean-k-mooneyso on ide supprot in watcher i get https://paste.opendev.org/show/bvIAOgzbBFnv81fpQOld/ with unitests selected. i.e. eventlet makes it explode19:50
sean-k-mooneybut if i installed pytest in the tox env19:50
sean-k-mooneythen it works and dicusovers all the tests19:50
fungiwill it be an issue once eventlet is gone?19:51
sean-k-mooneyhonestly it worked in the past 19:51
sean-k-mooneyand i used to be able to work around this i just have not set the env var19:51
sean-k-mooneyi sent am mailing list post about this a while ago i think on how to make it work i just normlaly use the cli19:52
clarkbI'm the weirdo that just uses the cli for java development so I'm really the wrong person to dig into that19:52
clarkbbut I know that was one of the goals with being standard compliant (the other was parallel testing that worked in order to speed up round trip times in ci)19:52
sean-k-mooneyya so paralle testing is  athing that pytest does supprot19:53
clarkbyup and it actually supported it when it first showed up. It just didn't work well19:53
sean-k-mooneybut since almost all my ptyhon expericne is form openstack i cant really comment on how well19:53
clarkbbut I think it has improved a lot since19:53
fungii still do all my development in vim19:54
fungiwith ~no plugins19:54
sean-k-mooneyfungi: python-observaiblity client was orginally develop by redhat for a seprate downstream product call STF (service telemetry framework)19:55
fungigot it, so basically the same situation as skyline and rally: developed outside openstack and then added19:55
sean-k-mooneyeffectivly yes19:56
sean-k-mooneyit does 2 thigns provide an osc plugin and python binding for talkign to what used to be ceilometner then gnocchi and now promethous19:56
fungior at least enough initial development was done in each case that their test frameworks had already been chosen by that time19:56
sean-k-mooneyapprenlty thsi was a surpsie to a lot of folks. 3 or 4 peopel have told me they ere not aware we were not ment ot use pytest in test code19:58
sean-k-mooneyi have been around to remember the debates about this in the pti and the other converstaion that happend a few years ago19:59
sean-k-mooney*few bing like 8+ at this point20:00
sean-k-mooneyhttps://github.com/openstack/requirements/commit/41bc11e2807275755018e8f2ead4047788b897c620:01
sean-k-mooneyso that when we added it to the requiremetn repo20:02
fungii mean, lots of things apparently came as a surprise to the skyline devs too, such that it took them years to redo stuff to make it more consistent with existing projects. but i feel like that's going to happen no matter what larger project you try to add a program to20:02
clarkbya and I think the friction of a different test runner is low if it works with your IDE or you run tox and it runs20:03
sean-k-mooneyya i guess im one of the few peole that regually read the pti and runtimes docs each cycle20:03
clarkbthat is different than say "can't translate the repo at all bceause it doesn't use gettext" or "can't release the project because its packaging is bespoke"20:03
fungiwe could opt as a community to just let people add whatever they like with whatever frameworks and tools they want, but that could lead to an explosion of things we need to support and even more fragmentation between projects which people already complain is at an unsustainable level20:03
sean-k-mooneyclarkb: ya my conserin is not with having tox -e py3 call pytest20:03
sean-k-mooneyits with the fact the test framework works fundementally diffently 20:04
sean-k-mooneyi.e. there are now self.assertEqual() pattherns20:04
sean-k-mooneyyou do assert X == Y20:04
fungiyeah, a lot of our linting assumes unittest paradigms, for example20:04
clarkbsean-k-mooney: I think both should work with pytest, but yes the language is a bit different20:05
clarkb(the important thing is you raise an exception when you want to trigger failures)20:05
sean-k-mooneyyes and it dose som stack trace paring magic to give pretty good output20:05
sean-k-mooneybut its also magic20:06
clarkbya I am a fan of the "use the explicit assertion that explicitly knows how to handle x and y and report failures nicely if it goes wrong" over do bare assertions and hope for the best20:06
clarkbits a bit more upfront work but it helps ensure you're asserting the right thing imo20:06
clarkbside note I helped create the original horizon selenium testing and nothing about it required a special test runner. Just needed to have something bootstrap selenium20:07
sean-k-mooneyclarkb: ya so apprently thy have been rewriten ot use test fixture to stablise them20:08
sean-k-mooneyand speed them up20:08
sean-k-mooneyso now they are usign fixture to do thing like create a nova instance and clean it up after the test20:08
sean-k-mooneybut they coudl have done that with https://github.com/testing-cabal/fixtures20:09
sean-k-mooneyor the fixture supprot that is build into the django test testcases20:09
sean-k-mooneyhttps://docs.djangoproject.com/en/5.2/topics/db/fixtures/#fixtures-explanation20:10
sean-k-mooneyor you know just use self.addCleanup()20:11
sean-k-mooneyanyway we dont need to decied or propose anything now. 20:11
sean-k-mooneybut it just gave me pause when the suggetion was made we adopt this test setup for watcher-dashboard was made20:11
sean-k-mooneyon teh one hadn id dont want watcher-dashboard to be special for horizon plugins and use unittest + playwright on the other hand im not conviced we shoudl use selenitum or pytest either20:13
fungiit wouldn't strictly be "special" if it's conforming to standards that the rest of openstack is following20:14
sean-k-mooneywell sepical is more by using playwright instead of selenium. we had not actully made a desion to do that but we wanted to explore our options20:16
clarkbthe main issues I think we've run into with selenium are sorting out how to make it play nice with firefox snaps20:17
clarkbto the point where I think we switched jobs at one point to chromium because that was a normal package on ubuntu20:17
clarkbopendev uses selenium for our deployment testing and one nice feature is that it can be manipulated remotely20:17
sean-k-mooneyhttps://github.com/microsoft/playwright-python works with a number of backend including jsut webkit20:18
sean-k-mooneyso that helps but ya i dont have enough expirnce with either to be honest20:18
sean-k-mooneyi think we are still going to try and do a poc of both aprpoches20:19
fungibut yeah the pti doesn't mandate selenium20:20
sean-k-mooneystrictly speaking watcher already has selenium tests https://github.com/openstack/watcher-dashboard/blob/master/test-requirements.txt#L520:20
sean-k-mooneybut like 5 of them20:20
sean-k-mooneyand those tests https://github.com/openstack/watcher-dashboard/blob/master/watcher_dashboard/test/integration_tests/pages/admin/optimization/auditspage.py20:20
sean-k-mooneyinherit form the olos onse so they probly broke20:20
sean-k-mooneywhen the rewrite happend20:21
sean-k-mooneyfungi: ya i also check the javascript pti but its not specifed there either20:22
fungibasically, not enough of openstack is a webui to warrant standardizing things for that specific niche20:26
fungiwe have a lot of rest api services, python libraries, et cetera that trying to standardize patterns across those makes sense20:26

Generated by irclog2html.py 4.0.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!