Open Closed

ABP Suite and MongoDB unit tests. #3175


User avatar
0
james@melvin.tech created
  • ABP Framework version: v5.2
  • UI type: Blazor
  • DB provider: MongoDB
  • Tiered (MVC) or Identity Server Separated (Angular): Yes
  • Exception message and stack trace: Create any project with a Mongo DB database and create a new object. Try to run a unit test. Am I expecting too much to expect a new project created with the suite to at least compile and run afterwards? It keeps feeling like MongoDB is an afterthought. Note I change the path and namespace in the code below for security.

Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor...

Volo.Abp.AbpInitializationException An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module SampleApp.ForecastTestBaseModule, SampleApp.TestBase, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating SampleApp.Levels.LevelsDataSeedContributor -> SampleApp.Levels.LevelsDataSeedContributor.. See the inner exception for details. at Volo.Abp.Modularity.ModuleManager.InitializeModules(ApplicationInitializationContext context) at Volo.Abp.AbpApplicationBase.InitializeModules() at Volo.Abp.AbpApplicationWithExternalServiceProvider.Initialize(IServiceProvider serviceProvider) at Volo.Abp.Testing.AbpIntegratedTest1..ctor() at SampleApp.ForecastTestBase1..ctor() at SampleApp.ForecastDomainTestBase..ctor() at SampleApp.Samples.SampleDomainTests..ctor() in C:\Users\devbox\Documents\Projects\SampleApps\aspnet-core\test\SampleApp.Domain.Tests\Samples\SampleDomainTests.cs:line 19 at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)

Autofac.Core.DependencyResolutionException An exception was thrown while activating SampleApp.Levels.LevelsDataSeedContributor -> SampleApp.Levels.LevelsDataSeedContributor. at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.RegistrationPipelineInvokeMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.SharingMiddleware.<>c__DisplayClass5_0.<Execute>b__0() at Autofac.Core.Lifetime.LifetimeScope.CreateSharedInstance(Guid id, Func1 creator) at Autofac.Core.Lifetime.LifetimeScope.CreateSharedInstance(Guid primaryId, Nullable1 qualifyingId, Func1 creator) at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext ctxt) at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.Execute(ResolveRequest request) at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable1 parameters) at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType) at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Volo.Abp.Data.DataSeeder.SeedAsync(DataSeedContext context) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at SampleApp.ForecastTestBaseModule.<>c__DisplayClass3_0.<<SeedTestData>b__0>d.MoveNext() in C:\Users\devbox\Documents\Projects\SampleApps\aspnet-core\test\SampleApp.TestBase\ForecastTestBaseModule.cs:line 55 --- End of stack trace from previous location --- at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.<>c__DisplayClass15_0.<Run>b__0(Task t) at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.Run(Func1 action) at Volo.Abp.Threading.AsyncHelper.RunSync(Func1 action) at SampleApp.ForecastTestBaseModule.SeedTestData(ApplicationInitializationContext context) in C:\Users\devbox\Documents\Projects\SampleApps\aspnet-core\test\SampleApp.TestBase\ForecastTestBaseModule.cs:line 51 at SampleApp.ForecastTestBaseModule.OnApplicationInitialization(ApplicationInitializationContext context) in C:\Users\devbox\Documents\Projects\SampleApps\aspnet-core\test\SampleApp.TestBase\ForecastTestBaseModule.cs:line 46 at Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor.Initialize(ApplicationInitializationContext context, IAbpModule module) at Volo.Abp.Modularity.ModuleManager.InitializeModules(ApplicationInitializationContext context)

Autofac.Core.DependencyResolutionException Circular component dependency detected: SampleApp.Levels.LevelsDataSeedContributor -> SampleApp.Levels.LevelsDataSeedContributor -> SampleApp.Levels.LevelsDataSeedContributor. at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext ctxt) at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) at Autofac.Core.Resolving.Pipeline.DefaultResolveRequestContext.ResolveComponent(ResolveRequest request) at Autofac.Core.Activators.Reflection.AutowiringParameter.<>c__DisplayClass0_0.<CanSupplyValue>b__0() at Autofac.Core.Activators.Reflection.BoundConstructor.Instantiate() at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Activators.Reflection.ReflectionActivator.<ConfigurePipeline>b__11_0(ResolveRequestContext ctxt, Action1 next) at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Builder.RegistrationBuilder3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action1 next) at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)


5 Answer(s)
  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    I created a project as you said, I generated an entity with Suite, but I could not reproduce the error.

    The Suite version should be the same as the version of your project, you probably had problems because of it.

    Can you try again after making the version of the Suite the same as the version of your project?

    abp suite remove

    abp suite install -v 5.2.2

  • User Avatar
    0
    james@melvin.tech created

    Uninstalled CLI and suite. Checked my tools folder. Deleted it. Deleted my cache. Created a new project. Added one simple entity. Run tests. Failed. Okay, so then in frustration, I think your template is broken. Let me try the one on the site. Its so bad, it includes the Entity Framework model in the MongoDb solution. Can someone send me 1 project with any namespace and 1 entity where the tests work maybe. Tests dont work on the public download either.

  • User Avatar
    0
    james@melvin.tech created

    The issue happens on seeding. If I skip seeding, it works. Well works until a test runs that expected that seeding to run. Its consistent. Mongo2Go may be the issue in my case. I simply cant seed it seems.

  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    You can access the sample application from this link.

    The application may not work for you because all keys and libs are deleted.

    However, you can search for Yourkey in the solution and write your own key.

    For libraries, just run the following command in *.IdentityServer and *.HttpApi.Host project.

    abp install-libs

  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    The question seems to have been closed by the bot, but if the related problem is still not fixed, please feel free to open it.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35