System.AggregateException thrown while starting the launch
saurabhsrivastava2009 opened this issue · 6 comments
Hi Team,
I'm getting the following error while starting the launch. This error is occurring occasionally, but still it will be great if anyone can help us fix this.
2023-10-11 16:32:46.833 | method="BaseOneTimeSetUpAsync" - Error in starting the launch or suite with exception:System.AggregateException: One or more errors occurred. (A task was canceled.)
2023-10-11 16:32:46.833 | ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
2023-10-11 16:32:46.834 | at System.Threading.Tasks.Task.GetExceptions(Boolean includeTaskCanceledExceptions)
2023-10-11 16:32:46.834 | at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
2023-10-11 16:32:46.834 | at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
2023-10-11 16:32:46.834 | at System.Threading.Tasks.Task`1.get_Result()
2023-10-11 16:32:46.834 | at Automation.Framework.Base.TestSetUp.BaseOneTimeSetUpAsync()
2023-10-11 16:32:46.834 | at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
2023-10-11 16:32:46.834 | at BlackLine.Automation.Framework.Base.TestSetUp.BaseOneTimeSetUpAsync()
2023-10-11 16:32:46.834 | at SetUpFixture.OneTimeSetUpAsync() in /Automation.Project.Test/SetUp/SetUpFixture.cs:line 16
2023-10-11 16:32:46.834 | at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
2023-10-11 16:32:46.834 | at SetUpFixture.OneTimeSetUpAsync()
2023-10-11 16:32:46.834 | at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
2023-10-11 16:32:46.834 | at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2023-10-11 16:32:46.834 | at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
2023-10-11 16:32:46.834 | at NUnit.Framework.Internal.Reflect.InvokeMethod(MethodInfo method, Object fixture, Object[] args)
2023-10-11 16:32:46.834 | at NUnit.Framework.Internal.MethodWrapper.Invoke(Object fixture, Object[] args)
2023-10-11 16:32:46.834 | at NUnit.Framework.Internal.Commands.SetUpTearDownItem.InvokeMethod(IMethodInfo method, TestExecutionContext context)
2023-10-11 16:32:46.834 | at NUnit.Framework.Internal.Commands.SetUpTearDownItem.<>c__DisplayClass9_0.<RunSetUpOrTearDownMethod>b__0()
2023-10-11 16:32:46.834 | at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
2023-10-11 16:32:46.835 | at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
2023-10-11 16:32:46.835 | at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
2023-10-11 16:32:46.835 | at NUnit.Framework.Internal.Commands.OneTimeSetUpCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
2023-10-11 16:32:46.835 | at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
2023-10-11 16:32:46.835 | at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
2023-10-11 16:32:46.835 | at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformOneTimeSetUp()
2023-10-11 16:32:46.835 | at NUnit.Framework.Internal.Execution.CompositeWorkItem.PerformWork()
2023-10-11 16:32:46.835 | at NUnit.Framework.Internal.Execution.WorkItem.RunOnCurrentThread()
2023-10-11 16:32:46.835 | at NUnit.Framework.Internal.Execution.WorkItem.Execute()
2023-10-11 16:32:46.835 | at NUnit.Framework.Internal.Execution.TestWorker.TestWorkerThreadProc()
2023-10-11 16:32:46.835 | at System.Threading.Thread.StartCallback()
2023-10-11 16:32:46.835 | --- End of stack trace from previous location ---
2023-10-11 16:32:46.835 |
2023-10-11 16:32:46.835 | --- End of inner exception stack trace ---
2023-10-11 16:32:46.835 | at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
2023-10-11 16:32:46.835 | at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
2023-10-11 16:32:46.835 | at System.Threading.Tasks.Task`1.get_Result()
2023-10-11 16:32:46.835 | at Automation.Framework.Base.TestSetUp.BaseOneTimeSetUpAsync()
The code used is
try
{
Logger.Log("Starting launch and Suite");
ReportPortalHelper.launchResponse = ReportPortalHelper.StartLaunch();
ReportPortalHelper.suiteResponse = ReportPortalHelper.AddSuite(ReportPortalHelper.launchResponse.Result);
}
catch (Exception e)
{
Logger.Log("Error in starting the launch or suite with exception:"+e);
}
public static async Task<LaunchCreatedResponse> StartLaunch()
{
if (!_currentProduct.Equals(_productPlatformName))
{
_currentProduct = _productPlatformName;
var launchResponse = await _service.Launch.StartAsync(new StartLaunchRequest
{
Name = _rpLaunchName,
Description = "Master Job Link:" + _masterJobLink + "\n" + "Product Job Link:" + _productJobLink,
Attributes = new List<ItemAttribute>()
{
new ItemAttribute { Key = "product", Value = _productPlatformName },
new ItemAttribute { Key = "buildNumber", Value = _productBuildNumber },
new ItemAttribute { Key = "environment", Value = _environment },
new ItemAttribute { Key = "jobName", Value = _jobName }
},
Mode = LaunchMode.Default,
});
_launchUuid = launchResponse;
}
return _launchUuid;
}
public static async Task<TestItemCreatedResponse> AddSuite(LaunchCreatedResponse launchCreatedResponse)
{
if (!isSuiteAdded)
{
var testItemSuite = await _service.TestItem.StartAsync(new StartTestItemRequest
{
LaunchUuid = launchCreatedResponse.Uuid,
Name = _productPlatformName,
Type = TestItemType.Suite,
Description = "This is the Suite for " + _productPlatformName
}
);
_testItemSuiteUuid = testItemSuite;
isSuiteAdded = true;
}
return _testItemSuiteUuid;
}
Just curious why https://github.com/reportportal/agent-net-nunit doesn't work for you?
Hi @nvborisenko
As per the docs that requires a json to maintain attributes https://github.com/reportportal/agent-net-nunit#configuration
We want to add dynamic attributes from the job. We have multiple projects which get triggered by a master job from which some of the dynamic values get passed on to the child jobs( project repos) and then the child job has its own set of dynamic value.
client-net makes more sense as we can post the result same way as we are posting it in Testrail.
You can set environment variables to add launch attributes like:
RP_Launch_Attributes=++os:win64
It will concatenate os:win64
attribute with predefined in json config.
Read more about about it.
Regarding original issue: usually TaskCanceledException
means timeout exception, you should check connectivity between client and server, or monitor why server couldn't respond in time.
But we will need to add these Json in all projects, and we have a lot of them. Also test methods needs to be updated for each project as I can see in this example https://github.com/reportportal/agent-net-nunit/blob/develop/test/ReportPortal.NUnitExtension.Tests/SimpleTests.cs
Ideally we do not want to touch any existing project repo and want to handle it through the base framework only.
Any suggestions here @nvborisenko ?
Please join https://slack.epmrpp.reportportal.io/ to have more comfortable discussion. There, everybody including me, will be glad to find the best solution in your case.