Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Produce Step from the child thread #48

Open
devAarno opened this issue Jul 3, 2020 · 1 comment
Open

Produce Step from the child thread #48

devAarno opened this issue Jul 3, 2020 · 1 comment
Assignees
Labels
bug Something isn't working nunit-allure

Comments

@devAarno
Copy link

devAarno commented Jul 3, 2020

Story
My test has a long-time item creation part, but I can speed-up it by parallelism. The item builder writes an Allure report. Also, I have noticed that the parallel item building may fail sometimes, but I can not get the report because of the inner exception in your library.

Example

namespace ...
{
    [TestFixture(Description = "Smoke tests")]
    public class GroupDeleteEntities : AllureReport
    {
        [Test]
        [Category(TestGroups.Smoke)]
        [Category(TestGroups.MSSQL)]
        [AllureTag(TestGroups.Smoke, TestGroups.MSSQL)]
        [AllureSeverity(SeverityLevel.Critical)]
        public void CreateAndDeleteManyItems()
        {
            Parallel.For(0, 1000, new ParallelOptions {MaxDegreeOfParallelism = 8, TaskScheduler = TaskScheduler.Default}, i =>
            {
                AllureLifecycle.Instance.RunStep("Step", () => { /* long Selenium / Rest-Api requests */ });
            });
        }
    }
}

produces

XXXXX.Tests.Tests.Smoke.GroupDelete.GroupDeleteEntities.CreateAndDeleteManyItems

System.AggregateException : One or more errors occurred. (Value cannot be null. (Parameter 'key')) (Value cannot be null. (Parameter 'key')) (Value ca...

System.AggregateException : One or more errors occurred. (Value cannot be null. (Parameter 'key')) (Value cannot be null. (Parameter 'key')) (Value cannot be null. (Parameter 'key')) (Value cannot be null. (Parameter 'key'))
  ----> System.ArgumentNullException : Value cannot be null. (Parameter 'key')
  ----> System.ArgumentNullException : Value cannot be null. (Parameter 'key')
  ----> System.ArgumentNullException : Value cannot be null. (Parameter 'key')
  ----> System.ArgumentNullException : Value cannot be null. (Parameter 'key')
   at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
   at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body)
   at XXXXX.Tests.Tests.Smoke.GroupDelete.GroupDeleteEntities.CreateAndDeleteManyItems() in ..\XXXXX.SeleniumTests\Tests\Tests\Smoke\GroupDelete\GroupDeleteEntities.cs:line 34
--ArgumentNullException
   at System.Collections.Concurrent.ConcurrentDictionary`2.ThrowKeyNullException()
   at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)
   at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
   at Allure.Commons.Storage.AllureStorage.Get[T](String uuid)
   at Allure.Commons.Storage.AllureStorage.AddStep(String parentUuid, String uuid, StepResult stepResult)
   at Allure.Commons.AllureLifecycle.StartStep(String parentUuid, String uuid, StepResult stepResult)
   at Allure.Commons.AllureLifecycle.StartStep(String uuid, StepResult result)
   at Allure.Commons.AllureLifecycle.StepRunner[TResult](String stepName, Delegate del, Boolean throwEx, Status stepStatusIfFailed, Object[] stepParams)
   at Allure.Commons.AllureLifecycle.RunStep(String stepName, Action stepBody, Object[] stepParams)
   at XXXXX.Tests.Tests.Smoke.GroupDelete.GroupDeleteEntities.<>c.<CreateAndDeleteManyItems>b__1_0(Int32 i) in ..\XXXXX.SeleniumTests\Tests\Tests\Smoke\GroupDelete\GroupDeleteEntities.cs:line 36
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica.Execute()
--ArgumentNullException
   at System.Collections.Concurrent.ConcurrentDictionary`2.ThrowKeyNullException()
   at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)
   at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
   at Allure.Commons.Storage.AllureStorage.Get[T](String uuid)
   at Allure.Commons.Storage.AllureStorage.AddStep(String parentUuid, String uuid, StepResult stepResult)
   at Allure.Commons.AllureLifecycle.StartStep(String parentUuid, String uuid, StepResult stepResult)
   at Allure.Commons.AllureLifecycle.StartStep(String uuid, StepResult result)
   at Allure.Commons.AllureLifecycle.StepRunner[TResult](String stepName, Delegate del, Boolean throwEx, Status stepStatusIfFailed, Object[] stepParams)
   at Allure.Commons.AllureLifecycle.RunStep(String stepName, Action stepBody, Object[] stepParams)
   at XXXXX.Tests.Tests.Smoke.GroupDelete.GroupDeleteEntities.<>c.<CreateAndDeleteManyItems>b__1_0(Int32 i) in ..\XXXXX.SeleniumTests\Tests\Tests\Smoke\GroupDelete\GroupDeleteEntities.cs:line 36
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica.Execute()
--ArgumentNullException
   at System.Collections.Concurrent.ConcurrentDictionary`2.ThrowKeyNullException()
   at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)
   at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
   at Allure.Commons.Storage.AllureStorage.Get[T](String uuid)
   at Allure.Commons.Storage.AllureStorage.AddStep(String parentUuid, String uuid, StepResult stepResult)
   at Allure.Commons.AllureLifecycle.StartStep(String parentUuid, String uuid, StepResult stepResult)
   at Allure.Commons.AllureLifecycle.StartStep(String uuid, StepResult result)
   at Allure.Commons.AllureLifecycle.StepRunner[TResult](String stepName, Delegate del, Boolean throwEx, Status stepStatusIfFailed, Object[] stepParams)
   at Allure.Commons.AllureLifecycle.RunStep(String stepName, Action stepBody, Object[] stepParams)
   at XXXXX.Tests.Tests.Smoke.GroupDelete.GroupDeleteEntities.<>c.<CreateAndDeleteManyItems>b__1_0(Int32 i) in ..\XXXXX.SeleniumTests\Tests\Tests\Smoke\GroupDelete\GroupDeleteEntities.cs:line 36
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica.Execute()
--ArgumentNullException
   at System.Collections.Concurrent.ConcurrentDictionary`2.ThrowKeyNullException()
   at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)
   at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
   at Allure.Commons.Storage.AllureStorage.Get[T](String uuid)
   at Allure.Commons.Storage.AllureStorage.AddStep(String parentUuid, String uuid, StepResult stepResult)
   at Allure.Commons.AllureLifecycle.StartStep(String parentUuid, String uuid, StepResult stepResult)
   at Allure.Commons.AllureLifecycle.StartStep(String uuid, StepResult result)
   at Allure.Commons.AllureLifecycle.StepRunner[TResult](String stepName, Delegate del, Boolean throwEx, Status stepStatusIfFailed, Object[] stepParams)
   at Allure.Commons.AllureLifecycle.RunStep(String stepName, Action stepBody, Object[] stepParams)
   at XXXXX.Tests.Tests.Smoke.GroupDelete.GroupDeleteEntities.<>c.<CreateAndDeleteManyItems>b__1_0(Int32 i) in ..\XXXXX.SeleniumTests\Tests\Tests\Smoke\GroupDelete\GroupDeleteEntities.cs:line 36
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica.Execute()

Expected
The separated unsorted steps in the Allure report on the one level have been expected.

Question
Am I do something wrong? If so, may you offer the workaround?
Or Is It bug?

Versions

  • NUnit: 3.12.0
  • Allure: 2.13.3
  • Noksa.NUnit.Allure: 3.1.1-beta (from NuGet repo)
  • .Net Core 3.0
@Noksa
Copy link
Owner

Noksa commented Jul 3, 2020

Hello.
This is the bug.

@Noksa Noksa self-assigned this Jul 6, 2020
@Noksa Noksa added bug Something isn't working nunit-allure labels Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working nunit-allure
Projects
None yet
Development

No branches or pull requests

2 participants