Hello again!
I'm running into another issue, this time on a different application. This one in particular is using a MySQL database. Everything seems to be building OK, but my tests are failing on the remote server. To make sure there's nothing wonky going on with my code, I cloned my repo from the remote server and ran all my tests. Everything builds and all my tests pass on my cloned repo, executing against the remote database when I run them locally, but when I trigger a build on the remote server, all my tests that hit the database fail.
Here's an example of the stacktrace I'm getting on my test failures:
`JordanRift.Grassroots.Tests/JordanRift/Grassroots/Tests/IntegrationTests/Models/CampaignRepositoryTests/Add_Should_Add_Campaign_To_Database (show/hide output)
at System.Data.Common.DbProviderFactories.GetFactory(String
providerInvariantName) at
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String
name) at
System.Data.Entity.Internal.LazyInternalConnection.Initialize() at
System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()
at
System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
entityType) at
System.Data.Entity.Internal.Linq.InternalSet1.Initialize() at
System.Data.Entity.Internal.Linq.InternalSet1.get_InternalContext()
at
System.Data.Entity.Internal.Linq.InternalSet1.ActOnSet(Action
action, EntityState newState, Object entity, String methodName) at
System.Data.Entity.Internal.Linq.InternalSet1.Add(Object
entity) at System.Data.Entity.DbSet1.Add(TEntity entity) at
JordanRift.Grassroots.Framework.Data.OrganizationRepository.Add(Organization
organization) in
d:\temp\x5e2tnda.2cn\input\JordanRift.Grassroots.Framework\Data\OrganizationRepository.cs:line
51 at
JordanRift.Grassroots.Tests.IntegrationTests.Models.CampaignRepositoryTests.ArrangeCampaignTest()
in
d:\temp\x5e2tnda.2cn\input\JordanRift.Grassroots.Tests\IntegrationTests\Models\CampaignRepositoryTests.cs:line
179 at
JordanRift.Grassroots.Tests.IntegrationTests.Models.CampaignRepositoryTests.Add_Should_Add_Campaign_To_Database()
in
d:\temp\x5e2tnda.2cn\input\JordanRift.Grassroots.Tests\IntegrationTests\Models\CampaignRepositoryTests.cs:line
46
I've added support as a collaborator on my project (StagingMySQL). Thanks in advance. You guys rock!
#1 Posted by friism Support staff on 20 May, 2011 05:18 PM
You generally shouldn't interact with the production/release database during unit testing. Use an in-memory database (such as sqlite) or mock your database.
Having said that, there's no reason it shouldn't work. Can you see what the exception being thrown is (you post only gives the stacktrace)?
#2 Posted by JasonOffutt on 20 May, 2011 05:53 PM
That's the thing, though. These aren't unit tests, they're integration tests. I want them to hit the database to make sure all the plumbing is working correctly.
I have versions of a lot of these same tests that use a mocked data layer, but again, these are meant to do what they're doing. I'd wager that if these tests are failing, then my app would likely be throwing errors too.
The weird thing is that they fail on the remote server. I can clone my appharbor repository, do a build and run all my tests locally against the remote database, and they all pass. I'm stuck as to why the tests pass running on my local machine against the remote database, but fail on the remote server.
My best guess is that maybe my local machine has some assembly running that the remote server doesn't. I do have the MySQL .NET driver set up on my local box, so maybe that's it?
I wish I had more info right now on the exact error being thrown. I suppose could try commenting out my integration tests, push again and see if the server logs any errors after my unit tests pass, and the app runs for the first time.
#3 Posted by JasonOffutt on 20 May, 2011 06:12 PM
OK, I commented them out and pushed. First successful build, and here's the error that got logged:
Unable to find the requested .Net Framework Data Provider. It may not be installed. (show/hide output)
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name) at System.Data.Entity.Internal.LazyInternalConnection.Initialize() at System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel() at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet
1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet1.get_InternalContext() at System.Data.Entity.Infrastructure.DbQuery1.System.Linq.IQueryable.get_Provider() at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable1 source) at JordanRift.Grassroots.Framework.Data.OrganizationRepository.GetDefaultOrganization(Boolean readOnly) in d:\temp\f5fm2vpm.fo3\input\JordanRift.Grassroots.Framework\Data\OrganizationRepository.cs:line 46 at JordanRift.Grassroots.Web.Helpers.UI.GrassrootsWebViewPage1..ctor() in d:\temp\f5fm2vpm.fo3\input\JordanRift.Grassroots.Web\Helpers\UI\GrassrootsWebViewPage.cs:line 33 at ASP._Page_Views_Error_Error_cshtml..ctor() in d:\websites\98\5798\14d29b4\_aspnettemporaryfiles\root\d8c32616\b9e40c78\App_Web_lgtkxxi2.2.cs:line 0 at DynamicInjectorbe90d6b5619c443a804a3dba2f89db06(Object[] ) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:line 81 at Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Context.cs:line 157 at Ninject.KernelBase.<Resolve>b__7(IContext context) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\KernelBase.cs:line 375 at System.Linq.Enumerable.<>c__DisplayClass123.b11(TSource x) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source) at Ninject.ResolutionExtensions.TryGetT in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Syntax\ResolutionExtensions.cs:line 270 at JordanRift.Grassroots.Web.Helpers.NinjectDependencyResolver.GetService(Type serviceType) in d:\temp\f5fm2vpm.fo3\input\JordanRift.Grassroots.Web\Helpers\NinjectDependencyResolver.cs:line 28 at System.Web.Mvc.BuildManagerViewEngine.DefaultViewPageActivator.Create(ControllerContext controllerContext, Type type) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) at System.Web.Mvc.Controller.ExecuteCore() at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) at System.Web.Mvc.MvcHandler.<>cDisplayClass6.<>cDisplayClassb.b5() at System.Web.Mvc.Async.AsyncResultWrapper.<>cDisplayClass1.b0() at System.Web.Mvc.Async.AsyncResultWrapper.<>cDisplayClass81.<BeginSynchronous>b__7(IAsyncResult _) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.End() at System.Web.Mvc.MvcHandler.<>cDisplayClasse.bd() at System.Web.Mvc.SecurityUtil.b0(Action f) at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)#4 Posted by JasonOffutt on 21 May, 2011 12:16 AM
OK, I got it fixed. Turns out it was my version of the MySQL Connector for .NET. It looks like the latest version (6.3.6) registers MySql.Data.Entities and MySql.Web with the GAC and that's why it ran on my local box fine but puked on the remote server. I added references to those assemblies and added them in my web.config and the site ran fine. No exceptions.
Just now, I added those assemblies to my test project, uncommented my integration tests and the build passed.
I got the MySql.Data package from NuGet, but it doesn't include MySql.Data.Entities or MySql.Web. Pretty weird that it doesn't include those, or at least that they don't offer separate packages for each one. Weird.
Anyway, issue solved. Hopefully if anybody stumbles upon this, they find this helpful. Thanks guys.
#5 Posted by friism Support staff on 21 May, 2011 05:52 AM
Great, thanks for sharing!
On 20/05/2011, at 17.16, "jason.offutt"
<[email blocked]>
wrote: