public async Task StartFinishDeleteLaunch() { var startLaunchRequest = new StartLaunchRequest { Name = "StartFinishDeleteLaunch", StartTime = DateTime.UtcNow }; var launch = await Service.Launch.StartAsync(startLaunchRequest); Assert.NotNull(launch.Uuid); Assert.NotEqual(0, launch.Number); var finishLaunchRequest = new FinishLaunchRequest { EndTime = DateTime.UtcNow.AddHours(1) }; var message = await Service.Launch.FinishAsync(launch.Uuid, finishLaunchRequest); Assert.Equal(launch.Uuid, message.Id); var gotLaunch = await Service.Launch.GetAsync(launch.Uuid); Assert.Equal("StartFinishDeleteLaunch", gotLaunch.Name); Assert.Equal(startLaunchRequest.StartTime, gotLaunch.StartTime); Assert.Equal(finishLaunchRequest.EndTime, gotLaunch.EndTime); var delMessage = await Service.Launch.DeleteAsync(gotLaunch.Id); Assert.Contains("successfully", delMessage.Info); }
public void Start(StartLaunchRequest request) { if (StartTask != null) { throw new InsufficientExecutionStackException("The launch is already scheduled for starting."); } if (!_isExternalLaunchId) { // start new launch item StartTask = Task.Run(async() => { var id = (await _service.StartLaunchAsync(request)).Id; LaunchInfo = new Launch { Id = id, Name = request.Name, StartTime = request.StartTime }; }); } else { // get launch info StartTask = Task.Run(async() => { LaunchInfo = await _service.GetLaunchAsync(LaunchInfo.Id); }); } }
private BeforeLaunchStartingEventArgs NotifyStarting(StartLaunchRequest request) { var args = new BeforeLaunchStartingEventArgs(_service, _configuration, request); Notify(() => ReportEventsSource.RaiseBeforeLaunchStarting(_reportEventsSource, this, args)); return(args); }
public async Task UpdateLaunchDescription() { var originalLaunchRequest = new StartLaunchRequest { Name = "UpdateLaunchDescription", StartTime = DateTime.UtcNow, Mode = LaunchMode.Default }; var launch = await Service.Launch.StartAsync(originalLaunchRequest); var tempLaunch = await Service.Launch.GetAsync(launch.Uuid); var updateMessage = await Service.Launch.UpdateAsync(tempLaunch.Id, new UpdateLaunchRequest() { Description = "New description" }); updateMessage.Info.Should().Contain("successfully updated"); await Service.Launch.FinishAsync(launch.Uuid, new FinishLaunchRequest { EndTime = DateTime.UtcNow }); var gotLaunch = await Service.Launch.GetAsync(launch.Uuid); gotLaunch.Name.Should().Be(originalLaunchRequest.Name); gotLaunch.Mode.Should().Be(originalLaunchRequest.Mode); gotLaunch.Description.Should().Be("New description"); await Service.Launch.DeleteAsync(gotLaunch.Id); }
private void Events_TestRunStart(object sender, TestRunStartEventArgs e) { var requestNewLaunch = new StartLaunchRequest { Name = _config.GetValue(ConfigurationPath.LaunchName, "VsTest Launch"), Description = _config.GetValue(ConfigurationPath.LaunchDescription, ""), StartTime = DateTime.UtcNow }; if (_config.GetValue(ConfigurationPath.LaunchDebugMode, false)) { requestNewLaunch.Mode = LaunchMode.Debug; } requestNewLaunch.Tags = _config.GetValues(ConfigurationPath.LaunchTags, new List <string>()).ToList(); // see wether we need use external launch var launchId = _config.GetValue <string>("Launch:Id", ""); if (string.IsNullOrEmpty(launchId)) { _launchReporter = new LaunchReporter(Bridge.Service); } else { _launchReporter = new LaunchReporter(Bridge.Service, launchId); } _launchReporter.Start(requestNewLaunch); }
/// <summary> /// Starting connect to report portal. Create launcher and start it. /// </summary> /// <param name="args"></param> protected virtual void TestAssemblyExecutionStarting(MessageHandlerArgs <ITestAssemblyStarting> args) { lock (Logger.LockObject) { try { LaunchMode launchMode = _config.GetValue(ConfigurationPath.LaunchDebugMode, false) ? LaunchMode.Debug : LaunchMode.Default; StartLaunchRequest startLaunchRequest = new StartLaunchRequest { Name = _config.GetValue(ConfigurationPath.LaunchName, "xUnit Demo Launch"), StartTime = DateTime.UtcNow, Mode = launchMode, Tags = _config.GetValues(ConfigurationPath.LaunchTags, new List <string>()).ToList(), Description = _config.GetValue(ConfigurationPath.LaunchDescription, "") }; Bridge.Context.LaunchReporter = new LaunchReporter(Bridge.Service, _config, null); Bridge.Context.LaunchReporter.Start(startLaunchRequest); } catch (Exception exp) { Logger.LogError(exp.ToString()); } } }
public void Start(StartLaunchRequest request) { TraceLogger.Verbose($"Scheduling request to start new '{request.Name}' launch in {GetHashCode()} proxy instance"); if (StartTask != null) { throw new InsufficientExecutionStackException("The launch is already scheduled for starting."); } if (!_isExternalLaunchId) { // start new launch item StartTask = Task.Run(async() => { var id = (await _service.StartLaunchAsync(request)).Id; LaunchInfo = new Launch { Id = id, Name = request.Name, StartTime = request.StartTime }; }); } else { // get launch info StartTask = Task.Run(async() => { LaunchInfo = await _service.GetLaunchAsync(LaunchInfo.Id); }); } }
public void RunStarted(string name, int testCount) { var requestNewLaunch = new StartLaunchRequest { Name = Configuration.ReportPortal.Launch.Name, StartTime = DateTime.UtcNow }; if (Configuration.ReportPortal.Launch.DebugMode) { requestNewLaunch.Mode = LaunchMode.Debug; } requestNewLaunch.Tags = new List <string>(Configuration.ReportPortal.Launch.Tags.Split(',')); var eventArg = new RunStartedEventArgs(Bridge.Service, requestNewLaunch); if (BeforeRunStarted != null) { BeforeRunStarted(this, eventArg); } if (!eventArg.Canceled) { Bridge.Context.LaunchId = Bridge.Service.StartLaunch(requestNewLaunch).Id; if (AfterRunStarted != null) { AfterRunStarted(this, new RunStartedEventArgs(Bridge.Service, requestNewLaunch, Bridge.Context.LaunchId)); } } }
/// <summary> /// Starting connect to report portal. Create launcher and start it. /// </summary> /// <param name="args"></param> protected virtual void TestAssemblyExecutionStarting(MessageHandlerArgs <ITestAssemblyStarting> args) { lock (Logger.LockObject) { try { LaunchMode launchMode = _config.GetValue(ConfigurationPath.LaunchDebugMode, false) ? LaunchMode.Debug : LaunchMode.Default; var startLaunchRequest = new StartLaunchRequest { Name = _config.GetValue(ConfigurationPath.LaunchName, args.Message.TestAssembly.Assembly.Name), StartTime = DateTime.UtcNow, Mode = launchMode, Attributes = _config.GetKeyValues("Launch:Attributes", new List <KeyValuePair <string, string> >()).Select(a => new ItemAttribute { Key = a.Key, Value = a.Value }).ToList(), Description = _config.GetValue(ConfigurationPath.LaunchDescription, "") }; Shared.Extensibility.Embedded.Analytics.AnalyticsReportEventsObserver.DefineConsumer("agent-dotnet-xunit"); _launchReporter = new LaunchReporter(_service, _config, null, Shared.Extensibility.ExtensionManager.Instance); _launchReporter.Start(startLaunchRequest); } catch (Exception exp) { Logger.LogError(exp.ToString()); } } }
public static void BeforeTestRun() { if (Configuration.ReportPortal.Enabled) { var request = new StartLaunchRequest { Name = Configuration.ReportPortal.Launch.Name, StartTime = DateTime.UtcNow }; if (Configuration.ReportPortal.Launch.DebugMode) { request.Mode = LaunchMode.Debug; } request.Tags = new List <string>(Configuration.ReportPortal.Launch.Tags.Split(',')); var eventArg = new RunStartedEventArgs(Bridge.Service, request); ReportPortalAddin.OnBeforeRunStarted(null, eventArg); if (!eventArg.Canceled) { Bridge.Context.LaunchReporter = new LaunchReporter(Bridge.Service); Bridge.Context.LaunchReporter.Start(request); Bridge.Context.LaunchReporter.StartTask.Wait(); ReportPortalAddin.OnAfterRunStarted(null, new RunStartedEventArgs(Bridge.Service, request, Bridge.Context.LaunchReporter)); } } }
private void StartRun(XmlDocument xmlDoc) { try { LaunchMode launchMode; if (Config.Launch.IsDebugMode) { launchMode = LaunchMode.Debug; } else { launchMode = LaunchMode.Default; } var startLaunchRequest = new StartLaunchRequest { Name = Config.Launch.Name, Description = Config.Launch.Description, StartTime = DateTime.UtcNow, Mode = launchMode, Tags = Config.Launch.Tags }; var eventArg = new RunStartedEventArgs(Bridge.Service, startLaunchRequest); try { if (BeforeRunStarted != null) { BeforeRunStarted(this, eventArg); } } catch (Exception exp) { Console.WriteLine("Exception was thrown in 'BeforeRunStarted' subscriber." + Environment.NewLine + exp); } if (!eventArg.Canceled) { Bridge.Context.LaunchReporter = new LaunchReporter(Bridge.Service); Bridge.Context.LaunchReporter.Start(eventArg.Launch); try { if (AfterRunStarted != null) { AfterRunStarted(this, new RunStartedEventArgs(Bridge.Service, startLaunchRequest, Bridge.Context.LaunchReporter)); } } catch (Exception exp) { Console.WriteLine("Exception was thrown in 'AfterRunStarted' subscriber." + Environment.NewLine + exp); } } } catch (Exception exception) { Console.WriteLine("ReportPortal exception was thrown." + Environment.NewLine + exception); } }
/// <summary> /// Creates a new launch. /// </summary> /// <param name="request">Information about representation of launch.</param> /// <returns>Representation of just created launch.</returns> public virtual async Task <LaunchCreatedResponse> StartAsync(StartLaunchRequest request) { var uri = BaseUri.Append($"{ProjectName}/launch"); var body = ModelSerializer.Serialize <StartLaunchRequest>(request); var response = await HttpClient.PostAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false); response.VerifySuccessStatusCode(); return(ModelSerializer.Deserialize <LaunchCreatedResponse>(await response.Content.ReadAsStringAsync().ConfigureAwait(false))); }
private void StartRun(XmlDocument xmlDoc) { try { LaunchMode launchMode; if (Config.GetValue(ConfigurationPath.LaunchDebugMode, false)) { launchMode = LaunchMode.Debug; } else { launchMode = LaunchMode.Default; } var startLaunchRequest = new StartLaunchRequest { Name = Config.GetValue(ConfigurationPath.LaunchName, "NUnit Launch"), Description = Config.GetValue(ConfigurationPath.LaunchDescription, ""), StartTime = DateTime.UtcNow, Mode = launchMode, Tags = Config.GetValues(ConfigurationPath.LaunchTags, new List <string>()).ToList() }; var eventArg = new RunStartedEventArgs(Bridge.Service, startLaunchRequest); try { BeforeRunStarted?.Invoke(this, eventArg); } catch (Exception exp) { Console.WriteLine("Exception was thrown in 'BeforeRunStarted' subscriber." + Environment.NewLine + exp); } if (!eventArg.Canceled) { Bridge.Context.LaunchReporter = Bridge.Context.LaunchReporter ?? new LaunchReporter(Bridge.Service, Config, null); Bridge.Context.LaunchReporter.Start(eventArg.StartLaunchRequest); try { AfterRunStarted?.Invoke(this, new RunStartedEventArgs(Bridge.Service, startLaunchRequest, Bridge.Context.LaunchReporter, xmlDoc.OuterXml)); } catch (Exception exp) { Console.WriteLine("Exception was thrown in 'AfterRunStarted' subscriber." + Environment.NewLine + exp); } } } catch (Exception exception) { Console.WriteLine("ReportPortal exception was thrown." + Environment.NewLine + exception); } }
public async Task RerunNonExistingLaunch() { var request = new StartLaunchRequest { Name = "Some unique " + Guid.NewGuid().ToString(), StartTime = DateTime.UtcNow, Mode = LaunchMode.Default, IsRerun = true }; await Assert.ThrowsAnyAsync <ReportPortalException>(() => Service.Launch.StartAsync(request)); }
public static void BeforeTestRun() { try { var config = Initialize(); var request = new StartLaunchRequest { Name = config.GetValue(ConfigurationPath.LaunchName, "SpecFlow Launch"), StartTime = DateTime.UtcNow }; if (config.GetValue(ConfigurationPath.LaunchDebugMode, false)) { request.Mode = LaunchMode.Debug; } request.Attributes = config.GetKeyValues("Launch:Attributes", new List <KeyValuePair <string, string> >()).Select(a => new ItemAttribute { Key = a.Key, Value = a.Value }).ToList(); request.Description = config.GetValue(ConfigurationPath.LaunchDescription, string.Empty); var eventArg = new RunStartedEventArgs(_service, request); ReportPortalAddin.OnBeforeRunStarted(null, eventArg); if (eventArg.LaunchReporter != null) { _launchReporter = eventArg.LaunchReporter; } if (!eventArg.Canceled) { Shared.Extensibility.Embedded.Analytics.AnalyticsReportEventsObserver.DefineConsumer("agent-dotnet-specflow"); _launchReporter = _launchReporter ?? new LaunchReporter(_service, config, null, Shared.Extensibility.ExtensionManager.Instance); _launchReporter.Start(request); ReportPortalAddin.OnAfterRunStarted(null, new RunStartedEventArgs(_service, request, _launchReporter)); } } catch (Exception exp) { _traceLogger.Error(exp.ToString()); } }
public void RunStarted(TestResult result) { var requestNewLaunch = new StartLaunchRequest { Name = Config.Launch.Name, Description = Config.Launch.Description, StartTime = result.StartTime.UtcDateTime }; if (Config.Launch.IsDebugMode) { requestNewLaunch.Mode = LaunchMode.Debug; } requestNewLaunch.Tags = Config.Launch.Tags; Bridge.Context.LaunchReporter = new LaunchReporter(Bridge.Service); Bridge.Context.LaunchReporter.Start(requestNewLaunch); }
private void Events_TestRunStart(object sender, TestRunStartEventArgs e) { var requestNewLaunch = new StartLaunchRequest { Name = _config.GetValue(ConfigurationPath.LaunchName, "VsTest Launch"), Description = _config.GetValue(ConfigurationPath.LaunchDescription, ""), StartTime = DateTime.UtcNow }; if (_config.GetValue(ConfigurationPath.LaunchDebugMode, false)) { requestNewLaunch.Mode = LaunchMode.Debug; } requestNewLaunch.Tags = _config.GetValues(ConfigurationPath.LaunchTags, new List <string>()).ToList(); _launchReporter = new LaunchReporter(Bridge.Service, _config, null); _launchReporter.Start(requestNewLaunch); }
public async Task UpdateLaunchAttributes() { var originalLaunchRequest = new StartLaunchRequest { Name = "UpdateLaunchAttributes", StartTime = DateTime.UtcNow, Mode = LaunchMode.Default }; var launch = await Service.Launch.StartAsync(originalLaunchRequest); var tempLaunch = await Service.Launch.GetAsync(launch.Uuid); var updateRequest = new UpdateLaunchRequest() { Attributes = new List <ItemAttribute> { new ItemAttribute { Key = "k1", Value = "v1" } } }; var updateMessage = await Service.Launch.UpdateAsync(tempLaunch.Id, updateRequest); updateMessage.Info.Should().Contain("successfully updated"); await Service.Launch.FinishAsync(launch.Uuid, new FinishLaunchRequest { EndTime = DateTime.UtcNow }); var gotLaunch = await Service.Launch.GetAsync(launch.Uuid); gotLaunch.Name.Should().Be(originalLaunchRequest.Name); gotLaunch.Mode.Should().Be(originalLaunchRequest.Mode); gotLaunch.Description.Should().BeNull(); gotLaunch.Attributes.Should().BeEquivalentTo(updateRequest.Attributes); await Service.Launch.DeleteAsync(gotLaunch.Id); }
public bool StartLaunch(string launchName, Mode mode, string tags) { try { var launchRequest = new StartLaunchRequest() { Name = launchName, StartTime = DateTime.UtcNow, Mode = (LaunchMode)mode, Tags = SplitOnTags(tags) }; _launchReporter.Start(launchRequest); ReportSuccess(nameof(StartLaunch)); return(true); } catch (Exception ex) { ReportError(nameof(StartLaunch), ex); return(false); } }
public void StartLaunch(ExecutionStartingRequest request) { lock (_lockObj) { if (_launch == null) { var suiteExecutionResult = request.SuiteResult; // deffer starting of launch _startLaunchRequest = new StartLaunchRequest { Name = _configuration.GetValue("Launch:Name", suiteExecutionResult.ProjectName), Description = _configuration.GetValue("Launch:Description", string.Empty), Attributes = _configuration.GetKeyValues("Launch:Attributes", new List <KeyValuePair <string, string> >()).Select(a => new Client.Abstractions.Models.ItemAttribute { Key = a.Key, Value = a.Value }).ToList(), StartTime = DateTime.UtcNow }; } _launchesCount++; } }
private void Events_TestRunStart(object sender, TestRunStartEventArgs e) { try { var apiUri = _config.GetValue <string>(ConfigurationPath.ServerUrl); var apiProject = _config.GetValue <string>(ConfigurationPath.ServerProject); var apiToken = _config.GetValue <string>(ConfigurationPath.ServerAuthenticationUuid); var apiService = new Service(new Uri(apiUri), apiProject, apiToken); var requestNewLaunch = new StartLaunchRequest { Name = _config.GetValue(ConfigurationPath.LaunchName, "VsTest Launch"), Description = _config.GetValue(ConfigurationPath.LaunchDescription, ""), StartTime = DateTime.UtcNow, RerunOfLaunchUuid = Environment.GetEnvironmentVariable("DTA.RerunIterationCount") != null ? this._config.Properties["RerunOfLaunchUuid"].ToString() : null, }; if (_config.GetValue(ConfigurationPath.LaunchDebugMode, false)) { requestNewLaunch.Mode = LaunchMode.Debug; } requestNewLaunch.Attributes = _config.GetKeyValues("Launch:Attributes", new List <KeyValuePair <string, string> >()).Select(a => new ItemAttribute { Key = a.Key, Value = a.Value }).ToList(); _launchReporter = new LaunchReporter(apiService, _config, null); _launchReporter.Start(requestNewLaunch); } catch (Exception exp) { var error = $"Unexpected exception in {nameof(Events_TestRunStart)}: {exp}"; TraceLogger.Error(error); Console.WriteLine(error); throw; } }
public BeforeLaunchStartingEventArgs(IClientService clientService, IConfiguration configuration, StartLaunchRequest startLaunchRequest) : base(clientService, configuration) { StartLaunchRequest = startLaunchRequest; }
public async Task <LaunchCreatedResponse> StartAsync(StartLaunchRequest request) { return(await Task.FromResult(new LaunchCreatedResponse { Uuid = Guid.NewGuid().ToString() })); }
public Task <LaunchCreatedResponse> StartAsync(StartLaunchRequest request) { return(PostAsJsonAsync <LaunchCreatedResponse, StartLaunchRequest>($"{ProjectName}/launch", request)); }
public void Start(StartLaunchRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } TraceLogger.Verbose($"Scheduling request to start new '{request.Name}' launch in {GetHashCode()} proxy instance"); if (StartTask != null) { var exp = new InsufficientExecutionStackException("The launch is already scheduled for starting."); TraceLogger.Error(exp.ToString()); throw exp; } if (_rerunOfUuid != null) { request.IsRerun = true; request.RerunOfLaunchUuid = _rerunOfUuid; // start rerun launch item StartTask = Task.Run(async() => { NotifyStarting(request); var launch = await _requestExecuter.ExecuteAsync(() => _service.Launch.StartAsync(request), null).ConfigureAwait(false); _launchInfo = new LaunchInfo { Uuid = launch.Uuid, Name = request.Name, StartTime = request.StartTime }; NotifyStarted(); }); } else if (!_isExternalLaunchId) { if (_isRerun) { request.IsRerun = true; } // start new launch item StartTask = Task.Run(async() => { NotifyStarting(request); var launch = await _requestExecuter.ExecuteAsync(() => _service.Launch.StartAsync(request), null).ConfigureAwait(false); _launchInfo = new LaunchInfo { Uuid = launch.Uuid, Name = request.Name, StartTime = request.StartTime }; NotifyStarted(); }); } else { // get launch info StartTask = Task.Run(async() => { var launch = await _requestExecuter.ExecuteAsync(() => _service.Launch.GetAsync(Info.Uuid), null).ConfigureAwait(false); _launchInfo = new LaunchInfo { Uuid = launch.Uuid, Name = launch.Name, StartTime = launch.StartTime }; }); } }
public RunStartedEventArgs(Service service, StartLaunchRequest request, string id) : this(service, request) { _id = id; }
public RunStartedEventArgs(Service service, StartLaunchRequest request) { _service = service; _request = request; }
public override async Task <Launch> StartLaunchAsync(StartLaunchRequest model) { return(await Task.FromResult(new Launch { Id = Guid.NewGuid().ToString() })); }
public RunStartedEventArgs(IClientService service, StartLaunchRequest request, ILaunchReporter launchReporter) : this(service, request) { LaunchReporter = launchReporter; }
public RunStartedEventArgs(IClientService service, StartLaunchRequest request) { Service = service; StartLaunchRequest = request; }