perl-based tests against stock test data on running system

Bug #1206531 reported by Jason Etheridge
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Undecided
Unassigned

Bug Description

I think I want to add more examples before pullrequesting this, but here's what I have so far:

collab/phasefx/livetests @ working/Evergreen.git
http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/collab/phasefx/livetests

opensrf@dev141:~/git/Evergreen/Open-ILS/src/perlmods (livetests)$ make livecheck 2> /dev/null
perl Build.PL --destdir || make -s build-perl-fail
Creating new 'MYMETA.yml' with configuration results
Creating new 'Build' script for 'OpenILS' version '2.4'
./Build test --test_files live_t || make -s build-perl-fail
live_t/00-simple.t ....... ok
live_t/01-auth.t ......... ok
live_t/02-simple_circ.t .. ok
All tests successful.
Files=3, Tests=20, 4 wallclock secs ( 0.13 usr 0.07 sys + 1.88 cusr 0.31 csys = 2.39 CPU)
Result: PASS

and

opensrf@dev141:~/git/Evergreen/Open-ILS/src/perlmods/live_t (livetests)$ prove -v *.t
00-simple.t .......
1..2
ok 1 - open-ils.storage.direct.actor.user.retrieve returned object
ok 2 - User with id = 1 is admin user
ok
01-auth.t .........
1..4
# authtoken is 87a774500605a3405e1f2689bd5a40ab
# authtime is 7200
ok 1 - Have an authtoken
ok 2 - Default authtime for staff login is 7200 seconds
ok 3 - Can retrieve authtoken from memcached
ok 4 - Authtoken is removed from memcached after logout
ok
02-simple_circ.t ..
1..14
ok 1 - open-ils.storage.direct.actor.usr.retrieve returned object
ok 2 - User with id = 1 is admin
ok 3 - open-ils.storage.direct.asset.copy.retrieve returned object
ok 4 - Item with id = 310 has barcode CONC70000345
ok 5 - Item with id = 310 has status of Reshelving or Available
# authtoken is 903928330fadc401dbe1b3bfd51a9d00
# authtime is 7200
ok 6 - Have an authtoken
ok 7 - Registered a new workstation
# authtoken is db8af84d622e2e89e2f8fb19ce48e4ce
# authtime is 7200
ok 8 - Have an authtoken associated with the workstation
ok 9 - Checkout request returned an object
ok 10 - Checkout returned a SUCCESS event
ok 11 - Item with id = 310 has status of Checked Out after fresh Storage request
ok 12 - Checkin request returned an object
ok 13 - Checkin returned a SUCCESS event
ok 14 - Item with id = 310 has status of Reshelving or Available after fresh Storage request
ok
All tests successful.
Files=3, Tests=20, 4 wallclock secs ( 0.04 usr 0.03 sys + 1.73 cusr 0.30 csys = 2.10 CPU)
Result: PASS

Changed in evergreen:
assignee: nobody → Jason Etheridge (phasefx)
status: New → In Progress
Revision history for this message
Jason Etheridge (phasefx) wrote :

I'm going to go ahead and add a pullrequest to this. I have more tests coming, but I can push a new branch/ticket for them. There are also two tickets/branches that silence some warnings that these tests manage to trigger:

https://bugs.launchpad.net/evergreen/+bug/1207425

and

https://bugs.launchpad.net/opensrf/+bug/1207464

Revision history for this message
Jason Etheridge (phasefx) wrote :

Note that there are 5 commits at the tip of collab/phasefx/livetests

tags: added: pullrequest
Changed in evergreen:
assignee: Jason Etheridge (phasefx) → nobody
status: In Progress → New
Revision history for this message
Jason Etheridge (phasefx) wrote :

Sneaked in two more commits since no one has grabbed this yet. 7 commits at tip. Feel free to squash.

Revision history for this message
Jason Etheridge (phasefx) wrote :

I force-pushed a rebased and squashed branch to collab/phasefx/livetests. Just a single commit at the tip.

Revision history for this message
Jason Etheridge (phasefx) wrote :

Pushed another commit for 05-pay_bills.t

Changed in evergreen:
milestone: none → 2.5.0-alpha1
Remington Steed (rjs7)
Changed in evergreen:
milestone: 2.5.0-alpha1 → 2.5.0-alpha2
Revision history for this message
Dan Scott (denials) wrote :

First impression: the copy/paste code in the test cases (like osrf_connect(), etc) must be factored out into a common library. Heavy copy/paste is a bad code quality smell.

Ideally as much as possible of the common code should be in a common library that can be used by other actual production code, too, so that the tests can focus on specifics. Fortunately, there is such a library: OpenILS::Utils::Cronscript!

The remaining test-specific code could go into a OpenILS::Utils::TestHelper library, or something like that.

Revision history for this message
Jason Etheridge (phasefx) wrote :

Thanks Dan; I did try to make use of oils_header.pl for this purpose, but had trouble pulling it in so that it worked both with make check and when running the tests directly out of the live_t/ directory. Doing the latter is probably not strictly needed, though it helps to be able to do that when developing the tests. I'll give it another go, but if anyone has any ideas in that regard, I'd appreciate any help. I also got the impression that the testing community shies away from pulling in external libraries with tests when not needed, but if the library is kept simple, maybe that's not a big deal for us.

Revision history for this message
Jason Etheridge (phasefx) wrote :

I pushed two new commits to collab/phasefx/livetests (so 4 commits at the tip that aren't in master). Adds a method to Cronscript, adds a TestUtils module inheriting from Cronscript, and has the live_t/ tests making use of TestUtils for less code duplication. Let me know how it looks.

Dan Wells (dbw2)
Changed in evergreen:
milestone: 2.5.0-alpha2 → 2.5.0-beta1
Revision history for this message
Bill Erickson (berick) wrote :

Jason, I gave this a run through. My only concern is that the tests can only be run once per newly minted database, since the tests fail when a workstation already exists. One solution that worked for me was to call register workstation in override mode:

open-ils.actor.workstation.register.override

This will work regardless of whether the workstation exists. Alternatively, we could delete each workstation we create.

Or we could add a set of stock workstations to the seed data and use those instead of creating new ones for each test.

Revision history for this message
Jason Etheridge (phasefx) wrote :

Bill, either of those sound sane and I have no objection to them. But my concern with your concern is that in the long run, it may be difficult to keep these tests perfectly reversible, so I wonder if we should not have that expectation in order to make it easier to produce tests in the first place. The tactic I had in mind would be for an integration server to to use a pristine database (at minimum) for each test run. A bit onerous maybe for developers running these things by hand, but not for an automated system. What do you think?

Revision history for this message
Bill Erickson (berick) wrote :

Hmm, yeah, that may be an unreasonable expectation on my part. I'm not entirely sure why I think it's important. My first instinct was to run the tests multiple times, though. I guess I see it as another dimension to the tests. I.e. does running the test once break the system in some way? That may not be the right way to think about, though...

Erring on the side of *not* increasing the barrier to entry for testing, disregard my concerns.

Dan Wells (dbw2)
Changed in evergreen:
milestone: 2.5.0-beta1 → 2.5.0-rc
Revision history for this message
Bill Erickson (berick) wrote :

Ran through another round of testing. Squashed and added a few more words to top two commits. Pushed to master. Thanks, Jason.

Changed in evergreen:
status: New → Fix Committed
Dan Wells (dbw2)
Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.