[
https://issues.apache.org/jira/browse/OOZIE-1597?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Robert Kanter updated OOZIE-1597:
---------------------------------
Attachment: OOZIE-1597.patch
The patch makes {{XTestCase.setUp()}} call {{cleanUpDBTables()}} so that all
tests clean up the database. It also removes the direct call to
{{cleanUpDBTables()}} from any of the tests that were calling it in their
{{setUp()}} method. {{cleanUpDBTables()}} will now also start and end the
{{Services}} with the minimal set of required services needed for cleaning the
database, unless the {{Services}} is already started. There were a few tests,
notably, the ones under the tools dir, where I had to make a way to not clean
the database as it was interfering with those and causing surefire to get stuck.
The overhead of running {{cleanUpDBTables}} for every test shouldn't be too
expensive. It only takes about a second to run and we were already running it
for about half of the test classes already anyway.
> Cleanup database before every test
> ----------------------------------
>
> Key: OOZIE-1597
> URL: https://issues.apache.org/jira/browse/OOZIE-1597
> Project: Oozie
> Issue Type: Improvement
> Components: tests
> Affects Versions: trunk
> Reporter: Robert Kanter
> Assignee: Robert Kanter
> Attachments: OOZIE-1597.patch
>
>
> While investigating a flakey test
> ({{org.apache.oozie.sla.TestSLAJobEventListener.testOnJobEvent}}) I realized
> that some of the flakey SLA tests that I've seen lately are the same issue:
> The database has some leftover stuff from a previous test that its not
> expecting.
> Normally this is easy to fix because we can simply call
> {{cleanUpDBTables()}}. However, {{cleanUpDBTables}} requires some of the
> {{Services}} to be running, so you have to call it after starting
> {{Services}}; but, some of the failures were occurring during Services
> initialization (specifically when {{SLAService}} initializes the
> {{SLACalculatorMemory}}, which tries to load some data from the database,
> which may be incomplete (e.g. SLA registration for a job that doesn't
> exist)). So, in this case, we can't call {{cleanUpDBTables()}} before or
> after starting {{Services}}.
> This brings the larger issue that we should be cleaning up the database
> before every test anyway to make sure that the tests are truly independent
> and to prevent harmful leaking (just like we did a while back with the
> {{Services}}). I think we should have {{XTestCase.setup()}} call
> {{cleanUpDBTables()}} so that every test automatically it (and handle the
> {{Services}} dependency appropriately).
--
This message was sent by Atlassian JIRA
(v6.1#6144)