Giter Site home page Giter Site logo

client-net's Introduction

API client for Report Portal

Provides an ability to interact with Report Portal API in .NET/C#. Supports starting/finishing launches/tests, sending logs.

CI NuGet Badge Coverage

Setup

Install ReportPortal.Client NuGet package.

PS> Install-Package ReportPortal.Client

Usage

The main entry point to start interact with API is ReportPortal.Client.Service class. It requires uri, project name and uuid. Uuid value is specific for an user and it can be obtained on User Profile page.

var service = new ReportPortal.Client.Service(
new Uri("https://demo.reportportal.com"), "my_project", "my_uuid");

Starting new launch:

var launch = await service.Launch.StartAsync(new StartLaunchRequest
    {
        Name = "LaunchName",
        Description = "LaunchDescription"
    });

To start test item we need to use the LaunchUuid received from the previous step:

var test = await service.TestItem.StartAsync(new StartTestItemRequest
    {
        LaunchUuid = launch.Uuid,
        Name = "Test1",
        Type = TestItemType.Test
    });

To send log item the TestItemUuid is used which was received from the previous step:

var log = await service.LogItem.CreateAsync(new CreateLogItemRequest
    {
        TestItemUuid = test.Uuid,
        Text = "My log",
        Level = LogLevel.Debug
    }); 

Finishing the test:

await Service.TestItem.FinishAsync(test.Uuid, new FinishTestItemRequest
    {
        Status = Status.Passed
    });

Finishing the launch:

await Service.Launch.FinishAsync(launch.Uuid, new FinishLaunchRequest());

client-net's People

Contributors

aleh-yanushkevich avatar artpl avatar claudiospizzi avatar fasterfish avatar kzadorozhnaya avatar mnicula avatar nvborisenko avatar vitali-sonchyk-epam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

client-net's Issues

Introduce net5.0 as target framework

With

  • System.Text.Json as serializer

It allows:

  • Less memory allocation with better performance

To be carefully tested:

  • Shared package is not broken
  • Agents, which targets on older framework, can work in cooperation with client/shared targeted to net5.0

Benefits of new json serializer with code gen
image

Make it possible:

  • Find out all usages of Serializer in upstream projects
  • All upstream projects should use own implementation of serializer
    • NUnit 3
    • XUnit
    • VSTest
  • Hide serializer here at all

Unit tests should be independent on real hosted api

We started writing tests, which interact with real environment, just to make sure that http/serialization/whatever stuff is working somehow. And it would helpful.

We need isolate tests, and at the same time we would have ability to verify all stuff.

Remove "Newtonsoft.json" dependency

Client uses Newtonsoft.json library to serialize/deserialize objects to/from json format. It would be better if Client will use standard/native possibilities to do it without 3rd party libraries.

FilterOperation values are not the same in requests from Report Portal UI

In request from Report Portal UI we have !has filter:

Example:

/api/v1/{project}/launch?page.page=1&page.size=50&page.sort=startTime%2Cnumber%2CDESC&filter.%21has.compositeAttribute=Android%2CiOS

Report Portal UI version - 5.7.2

Inside of nuget ReportPortal.Client we have only has filter and there are no !has filter:

https://github.com/reportportal/client-net/blob/3.0.6/src/ReportPortal.Client/Abstractions/Filtering/Filter.cs#L34

public enum FilterOperation
{
[DataMember(Name = "eq")] Equals,
[DataMember(Name = "ne")] NotEquals,
[DataMember(Name = "cnt")] Contains,
[DataMember(Name = "!cnt")] NotContains,
[DataMember(Name = "ex")] Exists,
[DataMember(Name = "in")] In,
[DataMember(Name = "!in")] NotIn,
[DataMember(Name = "gt")] GreaterThan,
[DataMember(Name = "gte")] GreaterThanOrEquals,
[DataMember(Name = "lt")] LowerThan,
[DataMember(Name = "lte")] LowerThanOrEquals,
[DataMember(Name = "btw")] Between,
[DataMember(Name = "size")] Size,
[DataMember(Name = "has")] Has,
}

ReportPortal.Client version - 3.0.6.
Newer version(3.1.0) has the same FilterOperation enum values.

Make stacktrace of rp service exception shorter

image

We can easily remove these lines.

To make it just remove async keyword from methods and return Task object directly.

Benefits:

  • Short stacktrace without loosing useful info
  • Increased performance (ha :))

API does not have the ability to get the list of Debug Launches

As of now i see API does not have the ability to get the List of Debug Launches.
This is useful if we want to delete old debug launches.
Tried to implement in the following in Sevice.Launch.cs in my local and it does give the debug launch list

  public LaunchesContainer GetDebugLaunches(FilterOption filterOption = null)
        {
            var request = new RestRequest(Project + "/launch/mode");
            if (filterOption != null)
            {
                foreach (var p in filterOption.ConvertToDictionary())
                {
                    request.AddParameter(p.Key, p.Value);
                }
            }
            var response = _restClient.ExecuteWithErrorHandling(request);
            return JsonConvert.DeserializeObject<LaunchesContainer>(JObject.Parse(response.Content).ToString());
        }

Using FinishTestItemRequest.Issue.ExternalSystemIssues with Azure integration fails the report

STR:

  1. Perform azure integration
    image

  2. Add external issues using

https://github.com/reportportal/example-net-nunit/blob/master/src/Example/ReportPortalCustomization/Customization.cs

[Extension]
public class ReportPortalListener : ITestEventListener

BeforeTestFinished += BeforeTestFinishedHandler;    

//ExternalSystemIssues = new List<ExternalSystemIssue>

private void BeforeTestFinishedHandler(object sender, TestItemFinishedEventArgs e)
{
    e.FinishTestItemRequest.Issue = new()
    {
        Type = _reportParameters.KnownIssueResolutionId,
        Comment = value,
        ExternalSystemIssues = new List<ExternalSystemIssue>
        {
            new ExternalSystemIssue
            {
                TicketId = "47029",
                Url = "https://dev.azure.com/IN**********ve/azure-web/_workitems/edit/47029"
            }
        }
};
}

Actual result:
BeforeTestFinishedHandler executes without exception
But on the ReportPortal UI, the test and the tests run remain not finished
image
image

Extra:
When I do not set ExternalSystemIssues - it works.

Versions:

<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit.Engine" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageReference Include="ReportPortal.NUnit" Version="4.2.0" />
<PackageReference Include="ReportPortal.Shared" Version="3.1.3" />

ExternalSystemIssue.SubmitDate throws exception on debug
image

Linking the issue from the UI works as expected:
image

v5: Support 2 strong typed ids in client

To use api user needs 2 ids: id and uuid.

When starting new launch, client should provide 2 ids in model implicitly.

string - uuid   (guid)     (start launch)
long - id

RetryHandler doesn't work properly

HttpClient creates single instance of this handler to send requests. It means that inner counter is shared for all requests, that's definitely is unexpected behavior.

The remote certificate is invalid because of errors in the certificate

In case of self-signed certificate (using VsTest runner)

System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
 ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot

Make all Async methods cancellable

interface ILaunchResource
Task<MessageResponse> AnalyzeAsync(AnalyzeLaunchRequest request, CancellationToken cancellationToken = default);

CAUTION:
It's not a breaking change on compilation level, but a breaking change at binary level.

nested step status not correctly displayed on UI

I'm using net-client to log data into rp. When sending FinishAsync request for a NestedStep I expect that in RP the nested step will be marked as failed if it has a log of LogLevel.Fatal in it, but they are always passed unless I provide the Status in the FinishTestItemRequest. Am I doing something wrong?

Follow client-java and move away from GPL license?

Currently the license of this client library obligates any consumers of the library to also be released under the GPL license. This isn't acceptable for essentially any commercial company.

Could this client lib have it's license changed, or if not be dual licensed?

I'm hopeful this is possible as this year the java lib made exactly this change:
reportportal/client-java@ec8b7d1

Ability to update test item status

Please, add to the Report Portal client an ability to update test item status. It is possible to do it with Report Portal API.

test-item-controller (Test Item Controller)
/v1/{projectName}/item/{itemId}/update

{
"attributes": [
{
"key": "string",
"value": "string"
}
],
"description": "string",
"status": "string"
}

Improve ReportPortalException to be structured object

Now we have this error in output

InternalServerError (500) POST http://localhost:8080/api/v1/demo/item)
 ---> ReportPortal.Client.ReportPortalException: Response status code does not indicate success: InternalServerError (500) POST http://localhost:8080/api/v1/demo/item
 ---> System.Net.Http.HttpRequestException: Response message: {"errorCode":5000,"message":"Unclassified error [Ambiguous handler methods mapped for '/v1/demo/item': {public com.epam.ta.reportportal.demodata.model.DemoDataRs com.epam.ta.reportportal.demodata.DemoDataController.generate(java.lang.String,com.epam.ta.reportportal.demodata.model.DemoDataRq,com.epam.ta.reportportal.commons.ReportPortalUser), public com.epam.ta.reportportal.ws.model.EntryCreatedAsyncRS com.epam.ta.reportportal.ws.controller.TestItemController.startRootItem(java.lang.String,com.epam.ta.reportportal.commons.ReportPortalUser,com.epam.ta.reportportal.ws.model.StartTestItemRQ)}]"}

We see some structured information in http response (errorCode and message). To simplify output, we can try to deserialize response, and throw "good" exception which will keep all information inside appropriate object.

Main goal is simplifying output.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.