I've adjusted a bunch of tests to use "using (ISession s =
sessions.OpenSession())" and the problem went away. Still no idea why it
suddenly appeared (the problematic tests have been around since forever).

/Oskar

2016-11-20 21:57 GMT+00:00 Oskar Berggren <[email protected]>:

> Thanks for checking. Running in Visual Studio or using the NUnit GUI
> runner started from ShowBuildMenu did not seem to hang, so it's strange.
> They complete in about 6 minutes, while "build release package" took about
> 40 minutes, most of it in tests.
>
>
> I've just found that there are multiple sql connections open, and the one
> trying to do something is blocked waiting for a lock held by another. Both
> (or all 10...) connections belong to the nunit-agent process.
>
> Consider:
>
>                       <test-case name="NHibernate.Test.CompositeId.
> ClassWithCompositeIdFixture.Hql" executed="True" result="Error"
> success="False" time="0.000" asserts="0">
>                         <failure>
>                           
> <message><![CDATA[NHibernate.Exceptions.GenericADOException
> : could not execute batch command.[SQL: SQL not available]
>   ----> System.Data.SqlClient.SqlException : Violation of PRIMARY KEY
> constraint 'PK__class_w___AC41A41DF0C23C51'. Cannot insert duplicate key
> in object 'dbo.class_w_com_id'. The duplicate key value is (stringKey, 3,
> Aug 16 2003 12:00AM).
>
> THEN:
>
>                     <test-case name="NHibernate.Test.CompositeId.
> ClassWithCompositeIdFixture.TestSimpleCRUD" executed="True"
> result="Error" success="False" time="409.776" asserts="0">
>                         <failure>
>                           
> <message><![CDATA[NHibernate.Exceptions.GenericADOException
> : could not execute batch command.[SQL: SQL not available]
>   ----> System.Data.SqlClient.SqlException : Violation of PRIMARY KEY
> constraint 'PK__class_w___AC41A41DF0C23C51'. Cannot insert duplicate key
> in object 'dbo.class_w_com_id'. The duplicate key value is (stringKey, 3,
> Aug 16 2003 12:00AM).
>
>
> But the Hql() test case looks like:
>
>         [Test]
>         public void Hql()
>         {
>             // insert the new objects
>             ISession s = OpenSession();
>             ITransaction t = s.BeginTransaction();
>
>             ClassWithCompositeId theClass = new ClassWithCompositeId(id);
>             theClass.OneProperty = 5;
>
>             ClassWithCompositeId theSecondClass = new
> ClassWithCompositeId(secondId);
>             theSecondClass.OneProperty = 10;
>
>             s.Save(theClass);
>             s.Save(theSecondClass);
>
>             // XXXXXXX
>
>             t.Commit();
>             s.Close();
>
>             ISession s2 = OpenSession();
>
>             IQuery hql = s2.CreateQuery("from ClassWithCompositeId as cwid
> where cwid.Id.KeyString = :keyString");
>
>             hql.SetString("keyString", id.KeyString);
>
>             IList results = hql.List();
>
>             Assert.AreEqual(1, results.Count);
>
>             s2.Close();
>         }
>
>
> So if there is a failure it may exit without closing transactions and
> session. Keeping the transaction open could certainly block the next test
> case. But of course, the base TestClass is supposed to detected and close
> any forgotten sessions, so it's still weird.
>
>
> However, if I insert the following two lines at XXXXX above, I can get the
> same hack when running the tests in VS:
>     s.Flush();
>     throw new Exception("BUH!");
>
>
> Was just about to post this when I found a cuprit. This will run and hang
> before the base TestCase class gets around to closing left-over sessions:
>
> ClassWithCompositeIdFixture.OnTearDown()
>         {
>             using (ISession s = sessions.OpenSession())
>             {
>                 s.Delete("from ClassWithCompositeId");
>                 s.Flush();
>             }
>         }
>
>
>
> Still don't know why it's suddenly noticeable now. This isn't the only
> test case that suffers from this it appears, yet it's not a problem for the
> build server apparently. Just luck?
>
> /Oskar
>
> 2016-11-20 21:18 GMT+00:00 Alexander Zaytsev <[email protected]>:
>
>> No
>> On Mon, 21 Nov 2016 at 9:15 AM, Oskar Berggren <[email protected]>
>> wrote:
>>
>>> Is ShowBuildMenu -> Build release package hanging for anyone else?
>>>
>>> /Oskar
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "nhibernate-development" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nhibernate-development" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to