Open Closed

Error test enviroment Hangfire #6731


User avatar
0
inavarro.cp created
  • ABP Framework version: v6.0.1
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Auth Server Separated (Angular): Tired
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Hi, Anyone can help us with test modules? Right now when we run every test projecte, we get this error:

Mensaje: 
Volo.Abp.AbpInitializationException : An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Cincaporc.WebApp.WebAppTestBaseModule, Cincaporc.WebApp.TestBase, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating λ:Volo.Abp.Identity.EntityFrameworkCore.IIdentityDbContext -> λ:Volo.Abp.Identity.EntityFrameworkCore.IIdentityProDbContext -> Cincaporc.WebApp.EntityFrameworkCore.WebAppDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions`1[[Cincaporc.WebApp.EntityFrameworkCore.WebAppDbContext, Cincaporc.WebApp.EntityFrameworkCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].. See the inner exception for details.
---- Autofac.Core.DependencyResolutionException : An exception was thrown while activating λ:Volo.Abp.Identity.EntityFrameworkCore.IIdentityDbContext -> λ:Volo.Abp.Identity.EntityFrameworkCore.IIdentityProDbContext -> Cincaporc.WebApp.EntityFrameworkCore.WebAppDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions`1[[Cincaporc.WebApp.EntityFrameworkCore.WebAppDbContext, Cincaporc.WebApp.EntityFrameworkCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
-------- System.ArgumentNullException : Value cannot be null. (Parameter 'connectionString')
 
  Seguimiento de la pila: 
ModuleManager.InitializeModules(ApplicationInitializationContext context)
AbpApplicationBase.InitializeModules()
AbpApplicationWithExternalServiceProvider.Initialize(IServiceProvider serviceProvider)
AbpIntegratedTest`1.ctor()
WebAppTestBase`1.ctor()
WebAppEntityFrameworkCoreTestBase.ctor()
AdsRepositoryTests.ctor() línea 15
RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
----- Inner Stack Trace -----
ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
ResolvePipeline.Invoke(ResolveRequestContext ctxt)
RegistrationPipelineInvokeMiddleware.Execute(ResolveRequestContext context, Action`1 next)
<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
SharingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action`1 next)
<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
ResolvePipeline.Invoke(ResolveRequestContext ctxt)
ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
ResolveOperation.ExecuteOperation(ResolveRequest request)
ResolveOperation.Execute(ResolveRequest request)
LifetimeScope.ResolveComponent(ResolveRequest request)
ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
ResolutionExtensions.Resolve(IComponentContext context, Type serviceType)
AutofacServiceProvider.GetRequiredService(Type serviceType)
ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
UnitOfWorkDbContextProvider`1.CreateDbContextWithTransactionAsync(IUnitOfWork unitOfWork)
UnitOfWorkDbContextProvider`1.CreateDbContextAsync(IUnitOfWork unitOfWork)
UnitOfWorkDbContextProvider`1.CreateDbContextAsync(IUnitOfWork unitOfWork, String connectionStringName, String connectionString)
UnitOfWorkDbContextProvider`1.GetDbContextAsync()
EfCoreRepository`2.GetDbSetAsync()
EfCoreIdentityUserRepository.FindByNormalizedUserNameAsync(String normalizedUserName, Boolean includeDetails, CancellationToken cancellationToken)
AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
IdentityDataSeeder.SeedAsync(String adminEmail, String adminPassword, Nullable`1 tenantId)
AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
DataSeeder.SeedAsync(DataSeedContext context)
AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapter.ProceedAsync()
UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter`1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
&lt;&lt;SeedTestData&gt;b__0>d.MoveNext() línea 48
--- End of stack trace from previous location ---
TaskExtensions.WaitAndUnwrapException(Task task)
&lt;&gt;c__DisplayClass15_0.&lt;Run&gt;b__0(Task t)
ContinuationTaskFromTask.InnerInvoke()
&lt;.cctor&gt;b__272_0(Object obj)
ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
TaskExtensions.WaitAndUnwrapException(Task task)
AsyncContext.Run(Func`1 action)
AsyncHelper.RunSync(Func`1 action)
WebAppTestBaseModule.SeedTestData(ApplicationInitializationContext context) línea 44
WebAppTestBaseModule.OnApplicationInitialization(ApplicationInitializationContext context) línea 39
OnApplicationInitializationModuleLifecycleContributor.Initialize(ApplicationInitializationContext context, IAbpModule module)
ModuleManager.InitializeModules(ApplicationInitializationContext context)
----- Inner Stack Trace -----
Check.NotEmpty(String value, String parameterName)
NpgsqlDbContextOptionsBuilderExtensions.UseNpgsql(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 npgsqlOptionsAction)
NpgsqlDbContextOptionsBuilderExtensions.UseNpgsql[TContext](DbContextOptionsBuilder`1 optionsBuilder, String connectionString, Action`1 npgsqlOptionsAction)
<>c__DisplayClass1_0.<ConfigureServices>b__3(AbpDbContextConfigurationContext`1 dbContextOptions) línea 158
DbContextOptionsFactory.Configure[TDbContext](AbpDbContextOptions options, AbpDbContextConfigurationContext`1 context)
DbContextOptionsFactory.Create[TDbContext](IServiceProvider serviceProvider)
<>c__DisplayClass3_0.<Register>b__0(IComponentContext context, IEnumerable`1 parameters)
DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
DelegateActivator.<ConfigurePipeline>b__2_0(ResolveRequestContext ctxt, Action`1 next)
DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)

6 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share some code or a project to reproduce this?

    liming.ma@volosoft.com

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The project you shared can't run to reproduce the problem.

    Can you share a simple project?

    Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can fix System.ArgumentNullException : Value cannot be null. (Parameter 'connectionString') by follow code:

    Now the error is SQLite Error 19: 'NOT NULL constraint failed: AppArticleFamilies.Code'.

    You can fix this by change the seeder code.

    btw you don't need to get and set connectionString in WebAppEntityFrameworkCoreModule manually.

    https://docs.abp.io/en/abp/latest/Connection-Strings

  • User Avatar
    0
    inavarro.cp created

    We already solved the previous error, but now we get this new error, this happens when launching Application.Tests.

    Cincaporc.WebApp.Adss.AdssAppServiceTests.CreateAsync Origen: AdsApplicationTests.cs línea 46 Duración: 1 ms

    Mensaje:  Volo.Abp.AbpInitializationException : An error occurred during the initialize Volo.Abp.Modularity.OnPreApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.BackgroundWorkers.Hangfire.AbpBackgroundWorkersHangfireModule, Volo.Abp.BackgroundWorkers.Hangfire, Version=6.0.1.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating λ:Volo.Abp.Hangfire.AbpHangfireBackgroundJobServer -> λ:Hangfire.JobStorage.. See the inner exception for details. ---- Autofac.Core.DependencyResolutionException : An exception was thrown while activating λ:Volo.Abp.Hangfire.AbpHangfireBackgroundJobServer -> λ:Hangfire.JobStorage. -------- System.InvalidOperationException : JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API.

    Seguimiento de la pila:  ModuleManager.InitializeModules(ApplicationInitializationContext context) AbpApplicationBase.InitializeModules() AbpApplicationWithExternalServiceProvider.Initialize(IServiceProvider serviceProvider) AbpIntegratedTest1.ctor() WebAppTestBase1.ctor() WebAppApplicationTestBase.ctor() AdssAppServiceTests.ctor() línea 15 RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions) ----- Inner Stack Trace ----- ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) ResolvePipeline.Invoke(ResolveRequestContext ctxt) RegistrationPipelineInvokeMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) <>c__DisplayClass5_0.<Execute>b__0() LifetimeScope.CreateSharedInstance(Guid id, Func1 creator) LifetimeScope.CreateSharedInstance(Guid primaryId, Nullable1 qualifyingId, Func1 creator) SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) ResolvePipeline.Invoke(ResolveRequestContext ctxt) ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) ResolveOperation.ExecuteOperation(ResolveRequest request) ResolveOperation.Execute(ResolveRequest request) LifetimeScope.ResolveComponent(ResolveRequest request) ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable1 parameters) ResolutionExtensions.Resolve(IComponentContext context, Type serviceType) AutofacServiceProvider.GetRequiredService(Type serviceType) ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) HangfireBackgroundWorkerManager.StartAsync(CancellationToken cancellationToken) AbpBackgroundWorkersHangfireModule.OnPreApplicationInitializationAsync(ApplicationInitializationContext context) TaskExtensions.WaitAndUnwrapException(Task task) <>c__DisplayClass15_0.<Run>b__0(Task t) ContinuationTaskFromTask.InnerInvoke() <.cctor>b__272_0(Object obj) ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- TaskExtensions.WaitAndUnwrapException(Task task) AsyncContext.Run(Func1 action) AsyncHelper.RunSync(Func1 action) AbpBackgroundWorkersHangfireModule.OnPreApplicationInitialization(ApplicationInitializationContext context) OnPreApplicationInitializationModuleLifecycleContributor.Initialize(ApplicationInitializationContext context, IAbpModule module) ModuleManager.InitializeModules(ApplicationInitializationContext context) ----- Inner Stack Trace ----- JobStorage.get_Current() <>c.<AddHangfire>b__1_0(IServiceProvider _) <>c__DisplayClass13_01.<TryAddSingletonChecked>b__0(IServiceProvider serviceProvider) <>c__DisplayClass3_0.<Register>b__0(IComponentContext context, IEnumerable1 parameters) DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) DelegateActivator.<ConfigurePipeline>b__2_0(ResolveRequestContext ctxt, Action1 next) DelegateMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action1 next) <>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API.

    You can try to use MemoryStorage in unit test.

    var jobStorage = new MemoryStorage();
    var options = new BackgroundJobServerOptions();
    GlobalConfiguration.Configuration.UseStorage(jobStorage);
    

    https://github.com/HangfireIO/Hangfire.InMemory https://github.com/perrich/Hangfire.MemoryStorage

  • User Avatar
    0
    inavarro.cp created

    Perfect, this is already working for us. Thank you so much

Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19