-
Notifications
You must be signed in to change notification settings - Fork 934
NH-4026 - Upgrade Firebird driver and use server #639
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
Changes from 16 commits
7c8aa5a
4d36a19
fd84733
fe0e8ac
728ede7
704c122
96ac0d3
ab0410c
da88449
d75f7ef
8b832cf
e794efe
d04fafa
3a5395e
d71f510
b42cfb3
907b5cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
Installation steps for Firebird for NH TeamCity: | ||
|
||
1. Download Firebird (Firebird-3.0.2.32703_0_x64): https://www.firebirdsql.org/en/server-packages/; | ||
2. Run the installer AS ADMINISTRATOR... Use the default firebird password when prompted: masterkey. | ||
3. Leave other settings with their defaults. | ||
4. The setup should install Firebird on the machine; | ||
5. Go into Firebird folder (c:\program files\firebird\) and create a folder named Data; | ||
6. Go in Firebird installation directory and open databases.conf; | ||
7. Add in "Live Databases" section: | ||
nhibernate = D:\SqlData\Firebird\nhibernate.fdb | ||
8. Open firebird.conf; | ||
9. Ensure AuthClient, AuthServer and UserManager are set to Srp only: | ||
AuthServer = Srp | ||
AuthClient = Srp | ||
UserManager = Srp | ||
10. Ensure WireCrypt is set to Enabled. | ||
WireCrypt = Enabled | ||
11. Restart Firebird service. | ||
|
||
The TestDatabaseSetup will create the database on the Teamcity agent. It will create the folder | ||
D:\SqlData\Firebird if it is missing. Firebird is particularly sensitive to disk performances, | ||
and D: is supposed to be local to the host, thus this choice. | ||
For manual testing, take care of not creating it with inadequate acl on the file. This may happen | ||
if you use ISQL with a connection string causing it to create it in embedded mode, without actually | ||
using the server. Prefixing your path with "localhost:" should avoid that. | ||
|
||
For tests performances, and since it is just an expandable test database, better disable forced writes. | ||
Since those tests drop/create schema constantly, they are quite heavy on writes and this single setting | ||
can have a six fold impact on their duration. For changing it, do: | ||
a. Stop Firebird service. | ||
b. From Firebird installation folder, run: | ||
gfix -w async nhibernate -user SYSDBA | ||
c. Restart Firebird service. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using System.Linq; | ||
using NHibernate.Cfg.MappingSchema; | ||
using NHibernate.Linq; | ||
using NHibernate.Cfg.MappingSchema; | ||
using NHibernate.Mapping.ByCode; | ||
using NUnit.Framework; | ||
|
||
|
@@ -15,9 +13,11 @@ protected override HbmMapping GetMappings() | |
mapper.Class<Document>(rc => | ||
{ | ||
rc.Id(x => x.Id, idMapper => idMapper.Generator(Generators.Identity)); | ||
rc.ManyToOne(x => x.Blob, m => | ||
rc.ManyToOne(x => x.Blob, | ||
m => | ||
{ | ||
m.Cascade(Mapping.ByCode.Cascade.All); | ||
m.Column("`Blob`"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the correct way to do this is to mark "blob" as a keyword for Firebird dialect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe a lot more are missing... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And does not work anyway. Test failing again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those keywords are seldom used in the code base. Only the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why "date"? it's "blob" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is the current only registered word. For my local test I have added "blob". But that has no effect on column quoting. |
||
}); | ||
rc.Property(x => x.Name); | ||
}); | ||
|
@@ -30,21 +30,31 @@ protected override HbmMapping GetMappings() | |
y.Length(int.MaxValue); | ||
y.Lazy(true); | ||
}); | ||
map.Table("`Blob`"); | ||
}); | ||
|
||
return mapper.CompileMappingForAllExplicitlyAddedEntities(); | ||
} | ||
|
||
private int _blobId; | ||
private int _docId; | ||
|
||
protected override void OnSetUp() | ||
{ | ||
using (ISession session = OpenSession()) | ||
using (ITransaction transaction = session.BeginTransaction()) | ||
{ | ||
var e1 = new Document { Name = "Bob" }; | ||
e1.Blob = new Blob { Bytes = new byte[] { 1, 2, 3 } }; | ||
var e1 = new Document | ||
{ | ||
Name = "Bob", | ||
Blob = new Blob {Bytes = new byte[] {1, 2, 3}} | ||
}; | ||
|
||
session.Save(e1); | ||
|
||
session.Flush(); | ||
|
||
_blobId = e1.Blob.Id; | ||
_docId = e1.Id; | ||
transaction.Commit(); | ||
} | ||
} | ||
|
@@ -71,7 +81,7 @@ public void TestNoTargetException() | |
document.Blob = blob; | ||
|
||
using (ISession session = OpenSession()) | ||
using (ITransaction transaction = session.BeginTransaction()) | ||
using (session.BeginTransaction()) | ||
{ | ||
session.Merge(document); | ||
} | ||
|
@@ -82,7 +92,7 @@ private Blob LoadDetachedBlob() | |
using (ISession session = OpenSession()) | ||
using (session.BeginTransaction()) | ||
{ | ||
var blob = session.Get<Blob>(1); | ||
var blob = session.Get<Blob>(_blobId); | ||
NHibernateUtil.Initialize(blob.Bytes); | ||
return blob; | ||
} | ||
|
@@ -93,7 +103,7 @@ private Document LoadDetachedEntity() | |
using (ISession session = OpenSession()) | ||
using (session.BeginTransaction()) | ||
{ | ||
return session.Get<Document>(1); | ||
return session.Get<Document>(_docId); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,17 +102,17 @@ private static void SetupSqlServerOdbc(Cfg.Configuration cfg) | |
|
||
private static void SetupFirebird(Cfg.Configuration cfg) | ||
{ | ||
Directory.CreateDirectory(@"D:\SqlData\Firebird"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like references to a specific folder. I think we need to use a local (relative) folder. Building with VS and NAnt+MSBuild will produce different results. When building with NAnt the output folder would be /build/version/net40 (or something like this). Building with VS will produce tests assemblies in different folders (/src/NHibernate.Test/bin/Debug-2.0/, /src/NHibernate.TestDatabaseSetup/bin/Debug-2.0/, etc). We need to choose some common folder, probably I think we shall/should parse connection string to find where the file sits. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The connection string does currently only hold the alias When using a database server, it does not really make sens for me to locate the database relatively to the client, that is usually the server choice. Firebird allows to specify the database location from the connection string, which is a strange model for a server, not at all common. So we may do that anyway, by detecting where the test assemblies are then tweaking the connection string for telling the server where to put the file. But that would depart from what is and can be done for other actual servers like Oracle, Sql-Server, PostgreSql, which gives no option to the client about where to locate the database. Otherwise we should go back to testing Firebird in embedded mode, with all its additional binaries and apparently some new behaviors in v3 requiring a dedicated dialect. (There are seven hundred failing tests when running in embedded mode with Firebird v3, most solved by redefining the boolean type as have done Nathan. I have not yet investigated the other cases, since I do not consider we should test Firebird as an embedded server.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem, that people might not necessarily have a "D:" drive, and this would fail. I usually use TestDb to create a fresh copy of a database (including Firebird) myself. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I may just locate the file on d:\ root if that prove to be any better than putting it within Firebird installation folder. That would avoid that line. Actually I was seeing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It still be executed if you run from ShowBuildMenu (release option, for ex) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I have missed that, sorry. |
||
var connStr = cfg.Properties[Cfg.Environment.ConnectionString]; | ||
try | ||
{ | ||
if (File.Exists("NHibernate.fdb")) | ||
File.Delete("NHibernate.fdb"); | ||
FbConnection.DropDatabase(connStr); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e); | ||
} | ||
|
||
FbConnection.CreateDatabase("Database=NHibernate.fdb;ServerType=1"); | ||
FbConnection.CreateDatabase(connStr, forcedWrites:false); | ||
} | ||
|
||
private static void SetupSqlServerCe(Cfg.Configuration cfg) | ||
|
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.
Why not make it local?
Uh oh!
There was an error while loading. Please reload this page.
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.
Local to the database server? Would be on
C:
, which is not local to the host. Local to the NHibernate test client? The path seems not frozen, only embedded mode can do that, where the client is the server too. I think Firebird mainstream usage is as an actual server, not as embedded mode. So I would rather test it as an actual server. And as showcase by Nathan branch, Firebird v3 embedded mode seems to need a new dialect.When using a database server, does it really make sens to locate the database relatively to the client? That should be the server choice, not the client. Currently this is done with a configured alias in
FireBird_3_0\databases.conf
file, which decides where to put the file for the aliasnhibernate
.