-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-commit configuration support #385
Conversation
Do you think this could / should be an option rather than a new fixture? |
What about initialising this to false to minimise impact on existing users test suites? |
What we currently have via Maybe we can add such option which would affect connections which are opened after the option is set. Another alternative might be to |
I believe it's false by default - it's set in |
May be a change for another day but as DatabaseTest and DatabaseEnvironment extend SequenceFuxture I think it should be possible to add methods to AbstractDbEnvironmment and wrap the environment object as the system under test, instead of creating new Fixture classes. I think DbFit Java used to work this way until it hit a FitLibrary issue which might have been fixed since. |
Our of interest Fitsharp's version has Command Timeout option which is a similar consideration - affects session characteristics. I guess either works fine. |
Hmmmm. I guess the Fixture classes are only really needed for StandAlone mode when the user could set the default environment object in DbEnvironmentFactory and then use the fixtures without having to have first used a DatavaseEnvironment fixture. In flow mode the methods could live on the Environment and be exposed via DatabaseTest's SUT object. I think I get it now. Sorry for the rambling! |
I think adding new Commit and Rollback fixtures isn't necessarily the right thing to do. We already have these from DatabaseEnvironment in standalone mode. |
Right, but invoking commit/rollback was a bit different in standalone vs flow mode and the test page couldn't work in both modes. |
Because the fixturing is different between the modes I think there has to be separate test pages. |
In general, yes - there are some differences between flow and standalone mode. Often the different parts can be isolated into In the particular case - I kind of tried to unify syntax and now the page works in both standalone and flow mode. (Transaction control is not something typical for flow mode but some edge cases are emerging).
Hmm, DbFit test connections now are now initialized via |
It kind of feels like we're changing the application to suit the tests rather than build the appropriate tests. Transaction control is the awkward case for reusing test content even within FlowMode for a single adaptor. Eg in PR #371 I had to do something a bit hacky to cater for TransctionsTest. |
I'll try to see how would it look like if auto-commit support is for standalone mode only. |
Or what about allowing this to be set via a I think this is one of those cases where it's simpler to have two test pages (one for each mode). If we take the approach of new Commit and Rollback fixtures then we end up with duplicated ways of committing/rolling back and would we start directing people to using these instead of |
Yes, sounds possible.
Do you mean separate tests for autoCommit=false and for autoCommit=true? Or for standalone and flow mode (in case we add support flow mode at all)?
Good point. On the other hand - having different syntax is causing some inconvenience when converting or sharing a test between modes. But if we move auto-commit as method in |
I guess that could have been an oversight in the original code as there's no documentation to say otherwise. |
I meant separate test pages for Flow and StandAlone modes. |
Thinking about the new Commit and Rollback fixtues - I think it's a good enhancement. We just need to document the new alternative ways of committing and rolling back in StandAlone mode. May be we should push this even further some time by creating a standalone |
For the |
I'll rebase on top of master to pick the refactored Options class. I'll try to implement that the feature as an option |
Or I guess we can add thin methods to both DatabaseTest and DatabaseEnvironment and use SequenceFixture's feature of handling these like fixtures. Adding a new SetOption fixture would allow users to not require using a DatabaseEnvironment fixture at all in StandAlone mode (once they'd created the default environment in DbEnvironmentFactory's instance). I wonder if anyone actually uses DbFit like that though. |
More thoughts...If this was a new (passive) option (instead of modifying the connection immediately) then that would mean we'd really have to centralise all statement execution into AbstractDbEnvironment and set the auto commit before every execution. I guess that could be a larger change. |
Ok, so I think I've finally come around to your original idea. May be an active option isn't best for this. An external process, in stand alone mode, might modify the auto commit property anyway and the user might expect an option value to be in effect until they explicitly change it via another Set Option. Then again...may be that would just need to be documented. Then again....does anyone actually use standalone mode like this!? May be I'm over complicating this all. What are your current thoughts? |
daf5273
to
314e4f3
Compare
I just pushed ability to set this via But I'm facing an issue with autoCommit in Derby (rollback after insert in auto-commit mode somehow roll-backs what has been inserted). |
The problematic case (in standalone mode):
|
Does the data even get committed at all, ever? I mean if you remove the rollback does it get committed at the end of the connection. Can you run the DB as a server instead of embedded and does that give a different result? |
If there is an explicit |
Does moving the commit after the DDL to be after the insert change anything? Probably not but I was wondering if an explicit commit is setting auto commit to false. |
dd3dd2c
to
5638d9e
Compare
* Add SetOption fixture with support for setting auto-commit (both as configuration setting and on top of the current connection if open) * Add setAutoCommit to DBEnvironment
0c91e12
to
9556c78
Compare
* Explained how to configure autocommit mode * |Commit| example for standalone mode update since now it's not necessary to prefix with |DatabaseEnvironment| * Copyright year updated to 2015
If we replace
(I have lots of test that use this construct) or even
(I use this less). I suppose it's less likely that people do something like this in Flow Mode: -
(I think that should work although it looks strange). |
In Are there any potential impacts we've not considered yet? What about any DbFit fixture subtyping people might have done? I guess unlikely but some concerns were raised when opinion on deprecating the 2.0 .net code was canvassed. |
|
||
!|DatabaseEnvironment| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is no longer supported then I'll have lots of ETL tests to update! Can we support both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's still supported. I removed it to simplify the reference a bit. But maybe we can leave a note that the "old" syntax is still supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Perhaps 'alternate syntax'.
Right now things like the following are still working actually:
Well, that's a good point. Maybe we need to increase version number to 3.x.x? |
Good to know!
Yes but methods that return Fit Fixtures are treated as 'alien' objects to DoFixture/SequenceFixture so perhaps some, as yet unknown, unintended impact on any subtypes people might have created although unlikely I guess.
Or up to 4.0 even? |
Ah, that's what I meant :-)
We already have many such cases in |
Ok. Nothing else from me to discuss on this one. Looks good. |
…ode is still valid
One more query:
But what about:
Won't the new Commit fixture take over processing of the table and then ignore the 'Close'? That will break quite a few of my ETL tests. If so can we still support this (may be by pushing more into the Database Environment)? |
We should test that, if it's important to have it working - perhaps we should have it in our test suites. |
More info on the breakages: not closing connections (in Teradata) results in sessions staying around in the database (until some kind of periodic garbage collection mops them up) but the accumulation results in max sessions for the DB being breached and tests suites start to fail consistently. I'd have to update a large number of tests to move the 'Close' into a second 'Database Environment' table (often multiple times per test page). |
@MMatten, I'm just trying the following for Derby in the
Do you mean you tested that for Teradata and it fails? |
@javornikolov, that sounds good then. I haven't run any tests yet with this branch. My previous note was just to explain why I need this working (rather than leave it to the DBMS to close them down after the client had detached). My thought was that the new commit Fixture would take over the processing of the |
OK, good - to me it looks like that we're not breaking the existing behaviour. I'm going to merge this PR. |
Ok. I think the noted behaviour only relates to Fixtures that are in flow. So it's not relevant for our standalone mode. We'd need to be wary in flow mode |
Add support to control transaction commit/rollback
This intends to resolve #383
References to another issue related to auto-commit mode: #326, #330