Open Closed

Error running ApplicationTests concurrently #579


User avatar
0
scott7106 created
  • ABP Framework version: v3.3.1
  • UI type: Angular
  • Tiered (MVC) or Identity Server Seperated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:

I can run all tests for a single application service and the tests work correctly. However, if I try running all application service tests, every single test fails with the error message below. This is preventing us from using the tests in our CI pipeline. The domain and repository tests are not having this issue. I can run all of them concurrently without an issue.

Message: Volo.Abp.AbpInitializationException : An error occurred during PostConfigureServices phase of the module Volo.Saas.Host.SaasHostApplicationContractsModule, Volo.Saas.Host.Application.Contracts, Version=3.3.1.0, Culture=neutral, PublicKeyToken=null. See the inner exception for details. ---- System.InvalidOperationException : Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct. Stack Trace: AbpApplicationBase.ConfigureServices() AbpApplicationBase.ctor(Type startupModuleType, IServiceCollection services, Action1 optionsAction) AbpApplicationWithExternalServiceProvider.ctor(Type startupModuleType, IServiceCollection services, Action1 optionsAction) AbpApplicationFactory.Create(Type startupModuleType, IServiceCollection services, Action1 optionsAction) AbpApplicationFactory.Create[TStartupModule](IServiceCollection services, Action1 optionsAction) ServiceCollectionApplicationExtensions.AddApplication[TStartupModule](IServiceCollection services, Action1 optionsAction) AbpIntegratedTest1.ctor() SynergyzTestBase1.ctor() SynergyzApplicationTestBase.ctor() CompiledDictionaryAppServiceTests.ctor() line 15 ----- Inner Stack Trace ----- Dictionary2.FindEntry(TKey key) Dictionary2.TryGetValue(TKey key, TValue& value) AbpDictionaryExtensions.GetOrAdd[TKey,TValue](IDictionary2 dictionary, TKey key, Func2 factory) AbpDictionaryExtensions.GetOrAdd[TKey,TValue](IDictionary2 dictionary, TKey key, Func1 factory) ObjectExtensionInfo.AddOrUpdateProperty(Type propertyType, String propertyName, Action1 configureAction) <>c__DisplayClass3_0.<AddOrUpdateProperty>b__0(ObjectExtensionInfo options) ObjectExtensionManager.AddOrUpdate(Type type, Action1 configureAction) ObjectExtensionManagerExtensions.AddOrUpdateProperty(ObjectExtensionManager objectExtensionManager, Type objectType, Type propertyType, String propertyName, Action1 configureAction) ObjectExtensionManagerExtensions.AddOrUpdateProperty(ObjectExtensionManager objectExtensionManager, Type[] objectTypes, Type propertyType, String propertyName, Action`1 configureAction) ModuleExtensionConfigurationHelper.ApplyPropertyConfigurationToTypes(ExtensionPropertyConfiguration propertyConfig, Type[] types) ModuleExtensionConfigurationHelper.ApplyEntityConfigurationToApi(String moduleName, String objectName, Type[] getApiTypes, Type[] createApiTypes, Type[] updateApiTypes) SaasHostApplicationContractsModule.PostConfigureServices(ServiceConfigurationContext context) AbpApplicationBase.ConfigureServices()


7 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Can you provide steps to reproduce? thanks.

  • User Avatar
    0
    paul.harriman created

    Run all tests at parent level

    Run tests at child level then run without issue

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Sorry, I can't get useful information, Can you use CLI to make a sample project to reproduce? thanks.

  • User Avatar
    0
    scott7106 created

    The project was created using ABP Suite version 3.1 and then upgraded to 3.3.1. Creating a sample project using the 3.3 framework does not seem to reproduce the problem.

  • User Avatar
    0
    alper created
    Support Team Director

    I created a clean 3.3.1 project and tried to reproduce it but it works when I click Run All Tests

    It looks like there is a thread unsafe singleton, which can result this exception. Is it possible for you to comment out your app service tests one by one to understand which service is breaking this thread safety.

  • User Avatar
    0
    scott7106 created

    Here is the list of packages from my Application project. Keep in mind, we are not using MongoDb.

      <ItemGroup>
        <PackageReference Include="Volo.Abp.Account.Pro.Shared.Application" Version="3.3.1" />
        <PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="3.3.1" />
        <PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="3.3.1" />
        <PackageReference Include="Volo.Saas.Host.Application" Version="3.3.1" />
        <PackageReference Include="Volo.Abp.AuditLogging.Application" Version="3.3.1" />
        <PackageReference Include="Volo.Abp.Identity.Pro.Application" Version="3.3.1" />
        <PackageReference Include="Volo.Abp.IdentityServer.Application" Version="3.3.1" />
        <PackageReference Include="Volo.Abp.Account.Pro.Public.Application" Version="3.3.1" />
        <PackageReference Include="Volo.Abp.Account.Pro.Admin.Application" Version="3.3.1" />
        <PackageReference Include="Volo.Abp.LanguageManagement.Application" Version="3.3.1" />
        <PackageReference Include="Volo.Abp.TextTemplateManagement.Application" Version="3.3.1" />
        <PackageReference Include="Volo.Abp.LeptonTheme.Management.Application" Version="3.3.1" />
      </ItemGroup>
    

    I commented out all tests and then started adding tests 1 at a time. The process works for 2 tests (any two), but the process starts showing errors when adding a 3rd test (any item). With 3 tests, it works sometimes and fails others. Very inconsistent, but it fails more than it succeeds. Adding a 4th test caused it to fail every time.

    An example test case is shown below

    public class ClassificationSubcategoryAppServiceTests : SynergyzApplicationTestBase
        {
            private readonly IClassificationSubcategoryAppService _classificationSubcategoryAppService;
            private readonly IRepository<ClassificationSubcategory, int> _classificationSubcategoryRepository;
    
            public ClassificationSubcategoryAppServiceTests()
            {
                _classificationSubcategoryAppService = GetRequiredService<IClassificationSubcategoryAppService>();
                _classificationSubcategoryRepository = GetRequiredService<IRepository<ClassificationSubcategory, int>>();
            }
    
            [Fact]
            public async Task GetListAsync()
            {
                // Act
                var result = await _classificationSubcategoryAppService.GetListAsync(new GetClassificationSubcategoriesInput());
    
                // Assert
                result.TotalCount.ShouldBe(2);
                result.Items.Count.ShouldBe(2);
                result.Items.Any(x => x.Id == 2069964284).ShouldBe(true);
                result.Items.Any(x => x.Id == 268848218).ShouldBe(true);
            }
    
            [Fact]
            public async Task GetAsync()
            {
                // Act
                var result = await _classificationSubcategoryAppService.GetAsync(2069964284);
    
                // Assert
                result.ShouldNotBeNull();
                result.Id.ShouldBe(2069964284);
            }
    
            [Fact]
            public async Task CreateAsync()
            {
                // Arrange
                var input = new ClassificationSubcategoryCreateDto
                {
                    Name = "b8aa10058749413fae20f5b21834f142e59c87e73ce8405d84ba798226f9eaed1a01fc330d1a4d91be561a465f9a47416045dfe08b7244ecbab46087feebdee2b5736e43a58846d78e1562a9ea5184caa69534d8d5174b0cb9ec4aede460d6f02d7f18040bd14bf8b69c8d2a6c8a68d575b65716869c4a0aa7e3a1683595dbd",
                    Definition = "989",
                    CedsFlag = true
                };
    
                // Act
                var serviceResult = await _classificationSubcategoryAppService.CreateAsync(input);
    
                // Assert
                var result = await _classificationSubcategoryRepository.FindAsync(c => c.Id == serviceResult.Id);
    
                result.ShouldNotBe(null);
                result.Name.ShouldBe("b8aa10058749413fae20f5b21834f142e59c87e73ce8405d84ba798226f9eaed1a01fc330d1a4d91be561a465f9a47416045dfe08b7244ecbab46087feebdee2b5736e43a58846d78e1562a9ea5184caa69534d8d5174b0cb9ec4aede460d6f02d7f18040bd14bf8b69c8d2a6c8a68d575b65716869c4a0aa7e3a1683595dbd");
                result.Definition.ShouldBe("989");
                result.CedsFlag.ShouldBe(true);
            }
    
            [Fact]
            public async Task UpdateAsync()
            {
                // Arrange
                var input = new ClassificationSubcategoryUpdateDto()
                {
                    Name = "9eb166489eb44c869edebebd65472cabd7abbdb868f44c22b6e2f236b6297a49366cab5647944c9a93bb7c892580f81310d6952b0a0d4b99a085f3e528eda76974d6586f55724aa6ac7545b0629885be4c5aeac1d89d46d190ae3e5ebf40d5b5ce5316e81da3466c931807bac703a899c9021cc6e867497191522bd8e0355d1",
                    Definition = "58f",
                    CedsFlag = true
                };
    
                // Act
                var serviceResult = await _classificationSubcategoryAppService.UpdateAsync(2069964284, input);
    
                // Assert
                var result = await _classificationSubcategoryRepository.FindAsync(c => c.Id == serviceResult.Id);
    
                result.ShouldNotBe(null);
                result.Name.ShouldBe("9eb166489eb44c869edebebd65472cabd7abbdb868f44c22b6e2f236b6297a49366cab5647944c9a93bb7c892580f81310d6952b0a0d4b99a085f3e528eda76974d6586f55724aa6ac7545b0629885be4c5aeac1d89d46d190ae3e5ebf40d5b5ce5316e81da3466c931807bac703a899c9021cc6e867497191522bd8e0355d1");
                result.Definition.ShouldBe("58f");
                result.CedsFlag.ShouldBe(true);
            }
    
            [Fact]
            public async Task DeleteAsync()
            {
                // Act
                await _classificationSubcategoryAppService.DeleteAsync(2069964284);
    
                // Assert
                var result = await _classificationSubcategoryRepository.FindAsync(c => c.Id == 2069964284);
    
                result.ShouldBeNull();
            }
        }
    
  • User Avatar
    0
    alper created
    Support Team Director

    thanks for the information. the issue has been addressed here https://github.com/abpframework/abp/issues/6334 will be fixed in the v4.0 release

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11