Clean up Test Operation Result types and generated codes (#2209)

* Clean up TestOperationResult; and AnalyzerClient and TRC Client.
* Rename ClientTestResultOperation to TestResultOperationDto
* Update descriptions in swagger files.
This commit is contained in:
Philip Lin 2019-12-31 13:28:27 -08:00 коммит произвёл GitHub
Родитель 2c2b3fa810
Коммит 9f27a25406
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
29 изменённых файлов: 67 добавлений и 254 удалений

Просмотреть файл

@ -209,6 +209,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TemperatureFilter", "test\m
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestAnalyzer", "test\modules\TestAnalyzer\TestAnalyzer.csproj", "{6208102C-151C-45CE-B573-B9C15B551B4D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TwinTester", "test\modules\TwinTester\TwinTester.csproj", "{1447EC5D-DD23-4C51-8941-336A495A48EE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
CheckInBuild|Any CPU = CheckInBuild|Any CPU
@ -681,6 +683,14 @@ Global
{6208102C-151C-45CE-B573-B9C15B551B4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6208102C-151C-45CE-B573-B9C15B551B4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6208102C-151C-45CE-B573-B9C15B551B4D}.Release|Any CPU.Build.0 = Release|Any CPU
{1447EC5D-DD23-4C51-8941-336A495A48EE}.CheckInBuild|Any CPU.ActiveCfg = CheckInBuild|Any CPU
{1447EC5D-DD23-4C51-8941-336A495A48EE}.CheckInBuild|Any CPU.Build.0 = CheckInBuild|Any CPU
{1447EC5D-DD23-4C51-8941-336A495A48EE}.CodeCoverage|Any CPU.ActiveCfg = CheckInBuild|Any CPU
{1447EC5D-DD23-4C51-8941-336A495A48EE}.CodeCoverage|Any CPU.Build.0 = CheckInBuild|Any CPU
{1447EC5D-DD23-4C51-8941-336A495A48EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1447EC5D-DD23-4C51-8941-336A495A48EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1447EC5D-DD23-4C51-8941-336A495A48EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1447EC5D-DD23-4C51-8941-336A495A48EE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -763,6 +773,7 @@ Global
{5918F481-0BE6-4D3F-95EB-34D30C9412DC} = {F921339B-32F9-4BF3-B364-2DB01FA2F1A1}
{E6510C48-92B8-4995-A5C5-CBCB98029863} = {F921339B-32F9-4BF3-B364-2DB01FA2F1A1}
{6208102C-151C-45CE-B573-B9C15B551B4D} = {F921339B-32F9-4BF3-B364-2DB01FA2F1A1}
{1447EC5D-DD23-4C51-8941-336A495A48EE} = {F921339B-32F9-4BF3-B364-2DB01FA2F1A1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D71830F5-3AF5-46B4-8A9E-1DCE4F2253AC}

Просмотреть файл

@ -5,20 +5,19 @@ namespace NetworkController
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.ModuleUtil.NetworkControllerResult;
using Microsoft.Azure.Devices.Edge.ModuleUtil.TestResultCoordinatorClient;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Logging;
class NetworkStatusReporter : INetworkStatusReporter
{
static readonly ILogger Log = Logger.Factory.CreateLogger<NetworkStatusReporter>();
readonly TestResultCoordinatorClient trcClient;
readonly TestResultReportingClient testResultReportingClient;
readonly string moduleId;
readonly string trackingId;
public NetworkStatusReporter(Uri testResultCoordinatorEndpoint, string moduleId, string trackingId)
{
this.trcClient = new TestResultCoordinatorClient() { BaseUrl = testResultCoordinatorEndpoint.AbsoluteUri };
this.testResultReportingClient = new TestResultReportingClient() { BaseUrl = testResultCoordinatorEndpoint.AbsoluteUri };
this.moduleId = moduleId;
this.trackingId = trackingId;
}
@ -26,7 +25,7 @@ namespace NetworkController
public Task ReportNetworkStatus(NetworkControllerOperation operation, NetworkControllerStatus networkControllerStatus, NetworkControllerType networkControllerType, bool success = true)
{
var networkController = new NetworkControllerResult() { Operation = operation.ToString(), OperationStatus = success ? "Success" : "Failed", NetworkControllerType = networkControllerType, NetworkControllerStatus = networkControllerStatus, TrackingId = this.trackingId };
return ModuleUtil.ReportStatus(this.trcClient, Log, this.moduleId, networkController.ToString(), TestOperationResultType.Network.ToString());
return ModuleUtil.ReportStatus(this.testResultReportingClient, Log, this.moduleId, networkController.ToString(), TestOperationResultType.Network.ToString());
}
}
}

Просмотреть файл

@ -8,7 +8,6 @@ namespace DirectMethodSender
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.ModuleUtil.TestResultCoordinatorClient;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Logging;
using TestOperationResult = Microsoft.Azure.Devices.Edge.ModuleUtil.TestOperationResult;
@ -56,9 +55,9 @@ namespace DirectMethodSender
await testReportCoordinatorUrl.ForEachAsync(
async (Uri uri) =>
{
TestResultCoordinatorClient trcClient = new TestResultCoordinatorClient { BaseUrl = uri.AbsoluteUri };
var testResultReportingClient = new TestResultReportingClient { BaseUrl = uri.AbsoluteUri };
await ModuleUtil.ReportStatus(
trcClient,
testResultReportingClient,
Logger,
Settings.Current.ModuleId + ".send",
ModuleUtil.FormatDirectMethodTestResultValue(
@ -74,8 +73,8 @@ namespace DirectMethodSender
await analyzerUrl.ForEachAsync(
async (Uri uri) =>
{
AnalyzerClient analyzerClient = new AnalyzerClient { BaseUrl = uri.AbsoluteUri };
await ReportStatus(Settings.Current.TargetModuleId, result, analyzerClient);
var testResultReportingClient = new TestResultReportingClient { BaseUrl = uri.AbsoluteUri };
await ReportStatus(Settings.Current.TargetModuleId, result, testResultReportingClient);
},
async () =>
{
@ -139,11 +138,11 @@ namespace DirectMethodSender
return (Settings.Current.TestDuration == TimeSpan.Zero) || (DateTime.UtcNow - testStartAt < Settings.Current.TestDuration);
}
static async Task ReportStatus(string moduleId, HttpStatusCode result, AnalyzerClient analyzerClient)
static async Task ReportStatus(string moduleId, HttpStatusCode result, TestResultReportingClient apiClient)
{
try
{
await analyzerClient.ReportResultAsync(new TestOperationResult { Source = moduleId, Result = result.ToString(), CreatedAt = DateTime.UtcNow, Type = Enum.GetName(typeof(TestOperationResultType), TestOperationResultType.LegacyDirectMethod) });
await apiClient.ReportResultAsync(new TestOperationResultDto { Source = moduleId, Result = result.ToString(), CreatedAt = DateTime.UtcNow, Type = Enum.GetName(typeof(TestOperationResultType), TestOperationResultType.LegacyDirectMethod) });
}
catch (Exception e)
{

Просмотреть файл

@ -43,78 +43,6 @@ namespace Microsoft.Azure.Devices.Edge.ModuleUtil
partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder);
partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response);
/// <summary>Report test operation result</summary>
/// <param name="body">Test result details</param>
/// <returns>Ok</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public System.Threading.Tasks.Task ReportResultAsync(TestOperationResult body)
{
return ReportResultAsync(body, System.Threading.CancellationToken.None);
}
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <summary>Report test operation result</summary>
/// <param name="body">Test result details</param>
/// <returns>Ok</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public async System.Threading.Tasks.Task ReportResultAsync(TestOperationResult body, System.Threading.CancellationToken cancellationToken)
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/testoperationresult");
var client_ = new System.Net.Http.HttpClient();
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value));
content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "204")
{
return;
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
if (client_ != null)
client_.Dispose();
}
}
/// <summary>Get report</summary>
/// <returns>successful operation</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
@ -365,64 +293,6 @@ namespace Microsoft.Azure.Devices.Edge.ModuleUtil
}
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.0.28.0 (Newtonsoft.Json v11.0.0.0)")]
public partial class TestOperationResult
{
[Newtonsoft.Json.JsonProperty("source", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public string Source { get; set; }
[Newtonsoft.Json.JsonProperty("result", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public string Result { get; set; }
[Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public string Type { get; set; }
[Newtonsoft.Json.JsonProperty("createdAt", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public System.DateTimeOffset CreatedAt { get; set; }
}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.1.6.0 (NJsonSchema v10.0.28.0 (Newtonsoft.Json v11.0.0.0))")]
public partial class ApiException : System.Exception
{
public int StatusCode { get; private set; }
public string Response { get; private set; }
public System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> Headers { get; private set; }
public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.Exception innerException)
: base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException)
{
StatusCode = statusCode;
Response = response;
Headers = headers;
}
public override string ToString()
{
return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString());
}
}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.1.6.0 (NJsonSchema v10.0.28.0 (Newtonsoft.Json v11.0.0.0))")]
public partial class ApiException<TResult> : ApiException
{
public TResult Result { get; private set; }
public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, TResult result, System.Exception innerException)
: base(message, statusCode, response, headers, innerException)
{
Result = result;
}
}
}
#pragma warning restore 1591

Просмотреть файл

@ -65,11 +65,11 @@ namespace Microsoft.Azure.Devices.Edge.ModuleUtil
return $"{trackingId};{batchId};{sequenceNumber};{resultMessage}";
}
public static async Task ReportStatus(TestResultCoordinatorClient.TestResultCoordinatorClient trcClient, ILogger logger, string source, string result, string format)
public static async Task ReportStatus(TestResultReportingClient apiClient, ILogger logger, string source, string result, string format)
{
try
{
await trcClient.ReportResultAsync(new TestResultCoordinatorClient.TestOperationResult { Source = source, Result = result, CreatedAt = DateTime.UtcNow, Type = format });
await apiClient.ReportResultAsync(new TestOperationResultDto { Source = source, Result = result, CreatedAt = DateTime.UtcNow, Type = format });
}
catch (Exception e)
{

Просмотреть файл

@ -1,32 +1,11 @@
swagger: "2.0"
info:
description: "analyzer API"
description: "Get test result report API implemented by Test Analyzer"
version: "1.0.0"
title: "Analyzer API swagger"
title: "Test Analyzer API swagger"
schemes:
- "https"
paths:
/api/testoperationresult:
post:
tags:
- "twinStatus"
summary: "Report test operation result"
description: ""
operationId: "reportResult"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Test result details"
required: true
schema:
$ref: "#/definitions/TestOperationResult"
responses:
204:
description: "Ok"
/api/report:
get:
tags:
@ -106,21 +85,4 @@ definitions:
lastReceivedAt:
type: "string"
format: date-time
TestOperationResult:
type: "object"
required:
- "source"
- "result"
- "type"
- "createdAt"
properties:
source:
type: "string"
result:
type: "string"
type:
type: "string"
createdAt:
type: "string"
format: date-time

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
namespace TestResultCoordinator
namespace Microsoft.Azure.Devices.Edge.ModuleUtil
{
using System;
using Microsoft.Azure.Devices.Edge.Util;

Просмотреть файл

@ -1,4 +1,4 @@
//----------------------
//----------------------
// <auto-generated>
// Generated using the NSwag toolchain v13.1.6.0 (NJsonSchema v10.0.28.0 (Newtonsoft.Json v11.0.0.0)) (http://NSwag.org)
// </auto-generated>
@ -10,17 +10,17 @@
#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ...
#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..."
namespace Microsoft.Azure.Devices.Edge.ModuleUtil.TestResultCoordinatorClient
namespace Microsoft.Azure.Devices.Edge.ModuleUtil
{
using System = global::System;
[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.1.6.0 (NJsonSchema v10.0.28.0 (Newtonsoft.Json v11.0.0.0))")]
public partial class TestResultCoordinatorClient
public partial class TestResultReportingClient
{
private string _baseUrl = "https://";
private System.Lazy<Newtonsoft.Json.JsonSerializerSettings> _settings;
public TestResultCoordinatorClient()
public TestResultReportingClient()
{
_settings = new System.Lazy<Newtonsoft.Json.JsonSerializerSettings>(() =>
{
@ -44,20 +44,20 @@ namespace Microsoft.Azure.Devices.Edge.ModuleUtil.TestResultCoordinatorClient
partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response);
/// <summary>Report test operation result</summary>
/// <param name="body">Test result details</param>
/// <param name="body">Test operation result data transfer object (DTO)</param>
/// <returns>Ok</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public System.Threading.Tasks.Task ReportResultAsync(TestOperationResult body)
public System.Threading.Tasks.Task ReportResultAsync(TestOperationResultDto body)
{
return ReportResultAsync(body, System.Threading.CancellationToken.None);
}
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <summary>Report test operation result</summary>
/// <param name="body">Test result details</param>
/// <param name="body">Test operation result data transfer object (DTO)</param>
/// <returns>Ok</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public async System.Threading.Tasks.Task ReportResultAsync(TestOperationResult body, System.Threading.CancellationToken cancellationToken)
public async System.Threading.Tasks.Task ReportResultAsync(TestOperationResultDto body, System.Threading.CancellationToken cancellationToken)
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/testoperationresult");
@ -215,7 +215,7 @@ namespace Microsoft.Azure.Devices.Edge.ModuleUtil.TestResultCoordinatorClient
}
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.0.28.0 (Newtonsoft.Json v11.0.0.0)")]
public partial class TestOperationResult
public partial class TestOperationResultDto
{
[Newtonsoft.Json.JsonProperty("source", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
@ -277,4 +277,4 @@ namespace Microsoft.Azure.Devices.Edge.ModuleUtil.TestResultCoordinatorClient
#pragma warning restore 1573
#pragma warning restore 472
#pragma warning restore 114
#pragma warning restore 108
#pragma warning restore 108

Просмотреть файл

@ -1,8 +1,8 @@
swagger: "2.0"
info:
description: "analyzer API"
description: "Report test result API implemented by both TestAnalyzer and TestResultCoordinator."
version: "1.0.0"
title: "Analyzer API swagger"
title: "Test Result Repoting API swagger"
schemes:
- "https"
paths:
@ -20,17 +20,17 @@ paths:
parameters:
- in: "body"
name: "body"
description: "Test result details"
description: "Test operation result data transfer object (DTO)"
required: true
schema:
$ref: "#/definitions/TestOperationResult"
$ref: "#/definitions/TestOperationResultDto"
responses:
204:
description: "Ok"
400:
description: "Invalid status value"
definitions:
TestOperationResult:
TestOperationResultDto:
type: "object"
required:
- "source"

Просмотреть файл

@ -7,6 +7,7 @@ namespace Modules.Test.TestResultCoordinator
using System.Threading.Tasks;
using global::TestResultCoordinator;
using global::TestResultCoordinator.Report;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Storage;
using Moq;
using Xunit;

Просмотреть файл

@ -3,8 +3,8 @@ namespace Modules.Test.TestResultCoordinator
{
using System;
using System.Collections.Generic;
using global::TestResultCoordinator;
using global::TestResultCoordinator.Report;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Xunit;
public class CountingReportTest

Просмотреть файл

@ -3,8 +3,8 @@ namespace Modules.Test.TestResultCoordinator
{
using System;
using System.Collections.Generic;
using global::TestResultCoordinator;
using global::TestResultCoordinator.Report;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Xunit;
public class SimpleTestOperationResultComparerTest

Просмотреть файл

@ -6,6 +6,7 @@ namespace Modules.Test.TestResultCoordinator
using System.Linq;
using System.Threading.Tasks;
using global::TestResultCoordinator;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Storage;
using Moq;
using Xunit;

Просмотреть файл

@ -7,6 +7,7 @@ namespace Modules.Test.TestResultCoordinator
using System.Threading.Tasks;
using global::TestResultCoordinator;
using global::TestResultCoordinator.Report;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Storage;
using Moq;
using Xunit;
@ -269,7 +270,7 @@ namespace Modules.Test.TestResultCoordinator
tc[item] = "1";
}
var twinTestResult = new Microsoft.Azure.Devices.Edge.ModuleUtil.TwinTestResult() { Properties = tc };
var twinTestResult = new TwinTestResult() { Properties = tc };
storeData.Add((count, new TestOperationResult(source, resultType, twinTestResult.ToString(), DateTime.UtcNow)));
count++;
}

Просмотреть файл

@ -7,7 +7,6 @@ namespace Relayer
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.ModuleUtil.TestResultCoordinatorClient;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Logging;
@ -93,9 +92,9 @@ namespace Relayer
}
// Report receiving message successfully to Test Result Coordinator
TestResultCoordinatorClient trcClient = new TestResultCoordinatorClient { BaseUrl = testResultCoordinatorUrl.AbsoluteUri };
var testResultReportingClient = new TestResultReportingClient { BaseUrl = testResultCoordinatorUrl.AbsoluteUri };
await ModuleUtil.ReportStatus(
trcClient,
testResultReportingClient,
Logger,
Settings.Current.ModuleId + ".receive",
ModuleUtil.FormatMessagesTestResultValue(trackingId, batchId, sequenceNumber),
@ -109,7 +108,7 @@ namespace Relayer
// Report sending message successfully to Test Result Coordinator
await ModuleUtil.ReportStatus(
trcClient,
testResultReportingClient,
Logger,
Settings.Current.ModuleId + ".send",
ModuleUtil.FormatMessagesTestResultValue(trackingId, batchId, sequenceNumber),

Просмотреть файл

@ -4,6 +4,7 @@ namespace TestAnalyzer.Controllers
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
[Route("api/[controller]")]
[ApiController]

Просмотреть файл

@ -1,29 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
namespace TestAnalyzer
{
using System;
using Microsoft.Azure.Devices.Edge.Util;
public class TestOperationResult
{
public TestOperationResult(
string source,
string type,
string result,
DateTime createdAt)
{
this.Source = Preconditions.CheckNonWhiteSpace(source, nameof(source));
this.Type = Preconditions.CheckNonWhiteSpace(type, nameof(type));
this.Result = Preconditions.CheckNonWhiteSpace(result, nameof(result));
this.CreatedAt = createdAt;
}
public string Source { get; }
public string Type { get; }
public string Result { get; }
public DateTime CreatedAt { get; }
}
}

Просмотреть файл

@ -9,7 +9,6 @@ namespace TestResultCoordinator.Controllers
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Logging;
using TestResultCoordinator.Storage;
using TestOperationResult = TestResultCoordinator.TestOperationResult;
[Route("api/[controller]")]
[ApiController]

Просмотреть файл

@ -8,13 +8,13 @@ namespace TestResultCoordinator.Report
using Microsoft.Azure.Devices.Shared;
using Microsoft.Extensions.Logging;
class CloudTwinTestResultCollection : ITestResultCollection<TestResultCoordinator.TestOperationResult>
class CloudTwinTestResultCollection : ITestResultCollection<TestOperationResult>
{
static readonly ILogger Logger = ModuleUtil.CreateLogger(nameof(CloudTwinTestResultCollection));
readonly RegistryManager registryManager;
readonly string moduleId;
readonly string trackingId;
TestResultCoordinator.TestOperationResult current;
TestOperationResult current;
bool isLoaded;
public CloudTwinTestResultCollection(string source, string serviceClientConnectionString, string moduleId, string trackingId)
@ -28,7 +28,7 @@ namespace TestResultCoordinator.Report
public string Source { get; }
TestResultCoordinator.TestOperationResult ITestResultCollection<TestResultCoordinator.TestOperationResult>.Current => this.current;
TestOperationResult ITestResultCollection<TestOperationResult>.Current => this.current;
public void Dispose()
{
@ -56,7 +56,7 @@ namespace TestResultCoordinator.Report
this.current = null;
}
async Task<TestResultCoordinator.TestOperationResult> GetTwinAsync()
async Task<TestOperationResult> GetTwinAsync()
{
try
{
@ -68,7 +68,7 @@ namespace TestResultCoordinator.Report
}
var twinTestResult = new TwinTestResult() { TrackingId = this.trackingId, Properties = twin.Properties.Reported };
return new TestResultCoordinator.TestOperationResult(
return new TestOperationResult(
this.Source,
TestOperationResultType.Twin.ToString(),
twinTestResult.ToString(),

Просмотреть файл

@ -8,7 +8,6 @@ namespace TestResultCoordinator.Report
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Logging;
using TestOperationResult = TestResultCoordinator.TestOperationResult;
/// <summary>
/// This is used to create counting report based on 2 different sources/stores; it will use given test result comparer to determine whether it matches or not.

Просмотреть файл

@ -2,6 +2,7 @@
namespace TestResultCoordinator.Report
{
using System;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
/// <summary>
/// This test result comparer is used to determine if 2 TestOperationResult instances matches.

Просмотреть файл

@ -2,6 +2,7 @@
namespace TestResultCoordinator.Report
{
using System;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Util;
using TestResultCoordinator.Storage;

Просмотреть файл

@ -8,7 +8,6 @@ namespace TestResultCoordinator.Report
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using TestOperationResult = TestResultCoordinator.TestOperationResult;
class TwinCountingReportGenerator : ITestResultReportGenerator
{

Просмотреть файл

@ -9,7 +9,6 @@ namespace TestResultCoordinator.Service
using Microsoft.Azure.EventHubs;
using Microsoft.Extensions.Logging;
using TestResultCoordinator.Storage;
using TestOperationResult = TestResultCoordinator.TestOperationResult;
class PartitionReceiveHandler : IPartitionReceiveHandler
{

Просмотреть файл

@ -2,6 +2,7 @@
namespace TestResultCoordinator.Storage
{
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Storage;
public interface ITestOperationResultStorage

Просмотреть файл

@ -5,6 +5,7 @@ namespace TestResultCoordinator.Storage
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.Storage;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Logging;

Просмотреть файл

@ -11,13 +11,13 @@ namespace TwinTester
class TwinAllOperationsResultHandler : ITwinTestResultHandler
{
static readonly ILogger Logger = ModuleUtil.CreateLogger(nameof(TwinAllOperationsResultHandler));
readonly AnalyzerClient analyzerClient;
readonly TestResultReportingClient testResultReportingClient;
readonly string moduleId;
readonly TwinEventStorage storage;
public TwinAllOperationsResultHandler(Uri analyzerClientUri, TwinEventStorage storage, string moduleId)
{
this.analyzerClient = new AnalyzerClient() { BaseUrl = analyzerClientUri.AbsoluteUri };
this.testResultReportingClient = new TestResultReportingClient { BaseUrl = analyzerClientUri.AbsoluteUri };
this.moduleId = moduleId;
this.storage = storage;
}
@ -76,7 +76,7 @@ namespace TwinTester
{
try
{
await this.analyzerClient.ReportResultAsync(new TestOperationResult { Source = this.moduleId, Result = failureStatus, CreatedAt = DateTime.UtcNow, Type = "LegacyTwin" });
await this.testResultReportingClient.ReportResultAsync(new TestOperationResultDto { Source = this.moduleId, Result = failureStatus, CreatedAt = DateTime.UtcNow, Type = "LegacyTwin" });
}
catch (Exception e)
{

Просмотреть файл

@ -4,7 +4,6 @@ namespace TwinTester
using System;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.ModuleUtil.TestResultCoordinatorClient;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Azure.Devices.Shared;
using Microsoft.Extensions.Logging;
@ -12,13 +11,13 @@ namespace TwinTester
class TwinEdgeOperationsResultHandler : ITwinTestResultHandler
{
static readonly ILogger Logger = ModuleUtil.CreateLogger(nameof(TwinEdgeOperationsResultHandler));
readonly TestResultCoordinatorClient trcClient;
readonly TestResultReportingClient testResultReportingClient;
readonly string moduleId;
readonly string trackingId;
public TwinEdgeOperationsResultHandler(Uri reporterUri, string moduleId, Option<string> trackingId)
{
this.trcClient = new TestResultCoordinatorClient() { BaseUrl = reporterUri.AbsoluteUri };
this.testResultReportingClient = new TestResultReportingClient { BaseUrl = reporterUri.AbsoluteUri };
this.moduleId = moduleId;
this.trackingId = trackingId.Expect(() => new ArgumentNullException(nameof(trackingId)));
}
@ -62,7 +61,7 @@ namespace TwinTester
{
var result = new TwinTestResult() { Operation = statusCode.ToString(), Properties = details, ErrorMessage = exception, TrackingId = this.trackingId };
Logger.LogDebug($"Sending report {result.ToString()}");
await ModuleUtil.ReportStatus(this.trcClient, Logger, source, result.ToString(), TestOperationResultType.Twin.ToString());
await ModuleUtil.ReportStatus(this.testResultReportingClient, Logger, source, result.ToString(), TestOperationResultType.Twin.ToString());
}
}
}

Просмотреть файл

@ -7,7 +7,6 @@ namespace LoadGen
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Edge.ModuleUtil;
using Microsoft.Azure.Devices.Edge.ModuleUtil.TestResultCoordinatorClient;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
@ -54,10 +53,10 @@ namespace LoadGen
Uri testResultCoordinatorUrl = new Uri(
trcUrl,
UriKind.Absolute);
TestResultCoordinatorClient trcClient = new TestResultCoordinatorClient { BaseUrl = testResultCoordinatorUrl.AbsoluteUri };
var testResultReportingClient = new TestResultReportingClient { BaseUrl = testResultCoordinatorUrl.AbsoluteUri };
await ModuleUtil.ReportStatus(
trcClient,
testResultReportingClient,
Logger,
Settings.Current.ModuleId + ".send",
ModuleUtil.FormatMessagesTestResultValue(